documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651
  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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. 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;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Represens a plane by the equation ax + by + cz + d = 0
  1909. */
  1910. export class Plane {
  1911. private static _TmpMatrix;
  1912. /**
  1913. * Normal of the plane (a,b,c)
  1914. */
  1915. normal: Vector3;
  1916. /**
  1917. * d component of the plane
  1918. */
  1919. d: number;
  1920. /**
  1921. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1922. * @param a a component of the plane
  1923. * @param b b component of the plane
  1924. * @param c c component of the plane
  1925. * @param d d component of the plane
  1926. */
  1927. constructor(a: number, b: number, c: number, d: number);
  1928. /**
  1929. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * @returns a new plane copied from the current Plane.
  1934. */
  1935. clone(): Plane;
  1936. /**
  1937. * @returns the string "Plane".
  1938. */
  1939. getClassName(): string;
  1940. /**
  1941. * @returns the Plane hash code.
  1942. */
  1943. getHashCode(): number;
  1944. /**
  1945. * Normalize the current Plane in place.
  1946. * @returns the updated Plane.
  1947. */
  1948. normalize(): Plane;
  1949. /**
  1950. * Applies a transformation the plane and returns the result
  1951. * @param transformation the transformation matrix to be applied to the plane
  1952. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1953. */
  1954. transform(transformation: DeepImmutable<Matrix>): Plane;
  1955. /**
  1956. * Compute the dot product between the point and the plane normal
  1957. * @param point point to calculate the dot product with
  1958. * @returns the dot product (float) of the point coordinates and the plane normal.
  1959. */
  1960. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1961. /**
  1962. * Updates the current Plane from the plane defined by the three given points.
  1963. * @param point1 one of the points used to contruct the plane
  1964. * @param point2 one of the points used to contruct the plane
  1965. * @param point3 one of the points used to contruct the plane
  1966. * @returns the updated Plane.
  1967. */
  1968. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1969. /**
  1970. * Checks if the plane is facing a given direction
  1971. * @param direction the direction to check if the plane is facing
  1972. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1973. * @returns True is the vector "direction" is the same side than the plane normal.
  1974. */
  1975. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1976. /**
  1977. * Calculates the distance to a point
  1978. * @param point point to calculate distance to
  1979. * @returns the signed distance (float) from the given point to the Plane.
  1980. */
  1981. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1982. /**
  1983. * Creates a plane from an array
  1984. * @param array the array to create a plane from
  1985. * @returns a new Plane from the given array.
  1986. */
  1987. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1988. /**
  1989. * Creates a plane from three points
  1990. * @param point1 point used to create the plane
  1991. * @param point2 point used to create the plane
  1992. * @param point3 point used to create the plane
  1993. * @returns a new Plane defined by the three given points.
  1994. */
  1995. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1996. /**
  1997. * Creates a plane from an origin point and a normal
  1998. * @param origin origin of the plane to be constructed
  1999. * @param normal normal of the plane to be constructed
  2000. * @returns a new Plane the normal vector to this plane at the given origin point.
  2001. * Note : the vector "normal" is updated because normalized.
  2002. */
  2003. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Calculates the distance from a plane and a point
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @param point point to calculate distance to
  2009. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2010. */
  2011. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2012. }
  2013. }
  2014. declare module BABYLON {
  2015. /**
  2016. * Class representing a vector containing 2 coordinates
  2017. */
  2018. export class Vector2 {
  2019. /** defines the first coordinate */
  2020. x: number;
  2021. /** defines the second coordinate */
  2022. y: number;
  2023. /**
  2024. * Creates a new Vector2 from the given x and y coordinates
  2025. * @param x defines the first coordinate
  2026. * @param y defines the second coordinate
  2027. */
  2028. constructor(
  2029. /** defines the first coordinate */
  2030. x?: number,
  2031. /** defines the second coordinate */
  2032. y?: number);
  2033. /**
  2034. * Gets a string with the Vector2 coordinates
  2035. * @returns a string with the Vector2 coordinates
  2036. */
  2037. toString(): string;
  2038. /**
  2039. * Gets class name
  2040. * @returns the string "Vector2"
  2041. */
  2042. getClassName(): string;
  2043. /**
  2044. * Gets current vector hash code
  2045. * @returns the Vector2 hash code as a number
  2046. */
  2047. getHashCode(): number;
  2048. /**
  2049. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2050. * @param array defines the source array
  2051. * @param index defines the offset in source array
  2052. * @returns the current Vector2
  2053. */
  2054. toArray(array: FloatArray, index?: number): Vector2;
  2055. /**
  2056. * Copy the current vector to an array
  2057. * @returns a new array with 2 elements: the Vector2 coordinates.
  2058. */
  2059. asArray(): number[];
  2060. /**
  2061. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2062. * @param source defines the source Vector2
  2063. * @returns the current updated Vector2
  2064. */
  2065. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2066. /**
  2067. * Sets the Vector2 coordinates with the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns the current updated Vector2
  2071. */
  2072. copyFromFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Sets the Vector2 coordinates with the given floats
  2075. * @param x defines the first coordinate
  2076. * @param y defines the second coordinate
  2077. * @returns the current updated Vector2
  2078. */
  2079. set(x: number, y: number): Vector2;
  2080. /**
  2081. * Add another vector with the current one
  2082. * @param otherVector defines the other vector
  2083. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2084. */
  2085. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2088. * @param otherVector defines the other vector
  2089. * @param result defines the target vector
  2090. * @returns the unmodified current Vector2
  2091. */
  2092. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2093. /**
  2094. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2095. * @param otherVector defines the other vector
  2096. * @returns the current updated Vector2
  2097. */
  2098. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2099. /**
  2100. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2101. * @param otherVector defines the other vector
  2102. * @returns a new Vector2
  2103. */
  2104. addVector3(otherVector: Vector3): Vector2;
  2105. /**
  2106. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2
  2109. */
  2110. subtract(otherVector: Vector2): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Multiplies in place the current Vector2 coordinates by the given ones
  2126. * @param otherVector defines the other vector
  2127. * @returns the current updated Vector2
  2128. */
  2129. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns a new Vector2
  2148. */
  2149. multiplyByFloats(x: number, y: number): Vector2;
  2150. /**
  2151. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. divide(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Divides the current Vector2 coordinates by the given ones
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 with current Vector2 negated coordinates
  2171. * @returns a new Vector2
  2172. */
  2173. negate(): Vector2;
  2174. /**
  2175. * Negate this vector in place
  2176. * @returns this
  2177. */
  2178. negateInPlace(): Vector2;
  2179. /**
  2180. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2181. * @param result defines the Vector3 object where to store the result
  2182. * @returns the current Vector2
  2183. */
  2184. negateToRef(result: Vector2): Vector2;
  2185. /**
  2186. * Multiply the Vector2 coordinates by scale
  2187. * @param scale defines the scaling factor
  2188. * @returns the current updated Vector2
  2189. */
  2190. scaleInPlace(scale: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2193. * @param scale defines the scaling factor
  2194. * @returns a new Vector2
  2195. */
  2196. scale(scale: number): Vector2;
  2197. /**
  2198. * Scale the current Vector2 values by a factor to a given Vector2
  2199. * @param scale defines the scale factor
  2200. * @param result defines the Vector2 object where to store the result
  2201. * @returns the unmodified current Vector2
  2202. */
  2203. scaleToRef(scale: number, result: Vector2): Vector2;
  2204. /**
  2205. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2206. * @param scale defines the scale factor
  2207. * @param result defines the Vector2 object where to store the result
  2208. * @returns the unmodified current Vector2
  2209. */
  2210. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2211. /**
  2212. * Gets a boolean if two vectors are equals
  2213. * @param otherVector defines the other vector
  2214. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2215. */
  2216. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2217. /**
  2218. * Gets a boolean if two vectors are equals (using an epsilon value)
  2219. * @param otherVector defines the other vector
  2220. * @param epsilon defines the minimal distance to consider equality
  2221. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2222. */
  2223. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2224. /**
  2225. * Gets a new Vector2 from current Vector2 floored values
  2226. * @returns a new Vector2
  2227. */
  2228. floor(): Vector2;
  2229. /**
  2230. * Gets a new Vector2 from current Vector2 floored values
  2231. * @returns a new Vector2
  2232. */
  2233. fract(): Vector2;
  2234. /**
  2235. * Gets the length of the vector
  2236. * @returns the vector length (float)
  2237. */
  2238. length(): number;
  2239. /**
  2240. * Gets the vector squared length
  2241. * @returns the vector squared length (float)
  2242. */
  2243. lengthSquared(): number;
  2244. /**
  2245. * Normalize the vector
  2246. * @returns the current updated Vector2
  2247. */
  2248. normalize(): Vector2;
  2249. /**
  2250. * Gets a new Vector2 copied from the Vector2
  2251. * @returns a new Vector2
  2252. */
  2253. clone(): Vector2;
  2254. /**
  2255. * Gets a new Vector2(0, 0)
  2256. * @returns a new Vector2
  2257. */
  2258. static Zero(): Vector2;
  2259. /**
  2260. * Gets a new Vector2(1, 1)
  2261. * @returns a new Vector2
  2262. */
  2263. static One(): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set from the given index element of the given array
  2266. * @param array defines the data source
  2267. * @param offset defines the offset in the data source
  2268. * @returns a new Vector2
  2269. */
  2270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2271. /**
  2272. * Sets "result" from the given index element of the given array
  2273. * @param array defines the data source
  2274. * @param offset defines the offset in the data source
  2275. * @param result defines the target vector
  2276. */
  2277. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2278. /**
  2279. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2280. * @param value1 defines 1st point of control
  2281. * @param value2 defines 2nd point of control
  2282. * @param value3 defines 3rd point of control
  2283. * @param value4 defines 4th point of control
  2284. * @param amount defines the interpolation factor
  2285. * @returns a new Vector2
  2286. */
  2287. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2288. /**
  2289. * 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".
  2290. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2291. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2292. * @param value defines the value to clamp
  2293. * @param min defines the lower limit
  2294. * @param max defines the upper limit
  2295. * @returns a new Vector2
  2296. */
  2297. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2298. /**
  2299. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2300. * @param value1 defines the 1st control point
  2301. * @param tangent1 defines the outgoing tangent
  2302. * @param value2 defines the 2nd control point
  2303. * @param tangent2 defines the incoming tangent
  2304. * @param amount defines the interpolation factor
  2305. * @returns a new Vector2
  2306. */
  2307. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2308. /**
  2309. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2310. * @param start defines the start vector
  2311. * @param end defines the end vector
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Gets the dot product of the vector "left" and the vector "right"
  2318. * @param left defines first vector
  2319. * @param right defines second vector
  2320. * @returns the dot product (float)
  2321. */
  2322. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2323. /**
  2324. * Returns a new Vector2 equal to the normalized given vector
  2325. * @param vector defines the vector to normalize
  2326. * @returns a new Vector2
  2327. */
  2328. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2329. /**
  2330. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2331. * @param left defines 1st vector
  2332. * @param right defines 2nd vector
  2333. * @returns a new Vector2
  2334. */
  2335. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2336. /**
  2337. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2338. * @param left defines 1st vector
  2339. * @param right defines 2nd vector
  2340. * @returns a new Vector2
  2341. */
  2342. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2345. * @param vector defines the vector to transform
  2346. * @param transformation defines the matrix to apply
  2347. * @returns a new Vector2
  2348. */
  2349. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2350. /**
  2351. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2352. * @param vector defines the vector to transform
  2353. * @param transformation defines the matrix to apply
  2354. * @param result defines the target vector
  2355. */
  2356. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2357. /**
  2358. * Determines if a given vector is included in a triangle
  2359. * @param p defines the vector to test
  2360. * @param p0 defines 1st triangle point
  2361. * @param p1 defines 2nd triangle point
  2362. * @param p2 defines 3rd triangle point
  2363. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2364. */
  2365. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2366. /**
  2367. * Gets the distance between the vectors "value1" and "value2"
  2368. * @param value1 defines first vector
  2369. * @param value2 defines second vector
  2370. * @returns the distance between vectors
  2371. */
  2372. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2373. /**
  2374. * Returns the squared distance between the vectors "value1" and "value2"
  2375. * @param value1 defines first vector
  2376. * @param value2 defines second vector
  2377. * @returns the squared distance between vectors
  2378. */
  2379. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2380. /**
  2381. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2382. * @param value1 defines first vector
  2383. * @param value2 defines second vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2389. * @param p defines the middle point
  2390. * @param segA defines one point of the segment
  2391. * @param segB defines the other point of the segment
  2392. * @returns the shortest distance
  2393. */
  2394. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2395. }
  2396. /**
  2397. * Class used to store (x,y,z) vector representation
  2398. * A Vector3 is the main object used in 3D geometry
  2399. * It can represent etiher the coordinates of a point the space, either a direction
  2400. * Reminder: js uses a left handed forward facing system
  2401. */
  2402. export class Vector3 {
  2403. /**
  2404. * Defines the first coordinates (on X axis)
  2405. */
  2406. x: number;
  2407. /**
  2408. * Defines the second coordinates (on Y axis)
  2409. */
  2410. y: number;
  2411. /**
  2412. * Defines the third coordinates (on Z axis)
  2413. */
  2414. z: number;
  2415. private static _UpReadOnly;
  2416. private static _ZeroReadOnly;
  2417. /**
  2418. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2419. * @param x defines the first coordinates (on X axis)
  2420. * @param y defines the second coordinates (on Y axis)
  2421. * @param z defines the third coordinates (on Z axis)
  2422. */
  2423. constructor(
  2424. /**
  2425. * Defines the first coordinates (on X axis)
  2426. */
  2427. x?: number,
  2428. /**
  2429. * Defines the second coordinates (on Y axis)
  2430. */
  2431. y?: number,
  2432. /**
  2433. * Defines the third coordinates (on Z axis)
  2434. */
  2435. z?: number);
  2436. /**
  2437. * Creates a string representation of the Vector3
  2438. * @returns a string with the Vector3 coordinates.
  2439. */
  2440. toString(): string;
  2441. /**
  2442. * Gets the class name
  2443. * @returns the string "Vector3"
  2444. */
  2445. getClassName(): string;
  2446. /**
  2447. * Creates the Vector3 hash code
  2448. * @returns a number which tends to be unique between Vector3 instances
  2449. */
  2450. getHashCode(): number;
  2451. /**
  2452. * Creates an array containing three elements : the coordinates of the Vector3
  2453. * @returns a new array of numbers
  2454. */
  2455. asArray(): number[];
  2456. /**
  2457. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2458. * @param array defines the destination array
  2459. * @param index defines the offset in the destination array
  2460. * @returns the current Vector3
  2461. */
  2462. toArray(array: FloatArray, index?: number): Vector3;
  2463. /**
  2464. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2465. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2466. */
  2467. toQuaternion(): Quaternion;
  2468. /**
  2469. * Adds the given vector to the current Vector3
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2474. /**
  2475. * Adds the given coordinates to the current Vector3
  2476. * @param x defines the x coordinate of the operand
  2477. * @param y defines the y coordinate of the operand
  2478. * @param z defines the z coordinate of the operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2482. /**
  2483. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2484. * @param otherVector defines the second operand
  2485. * @returns the resulting Vector3
  2486. */
  2487. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2490. * @param otherVector defines the second operand
  2491. * @param result defines the Vector3 object where to store the result
  2492. * @returns the current Vector3
  2493. */
  2494. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2495. /**
  2496. * Subtract the given vector from the current Vector3
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the resulting Vector3
  2505. */
  2506. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the resulting Vector3
  2520. */
  2521. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2531. /**
  2532. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2533. * @returns a new Vector3
  2534. */
  2535. negate(): Vector3;
  2536. /**
  2537. * Negate this vector in place
  2538. * @returns this
  2539. */
  2540. negateInPlace(): Vector3;
  2541. /**
  2542. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. negateToRef(result: Vector3): Vector3;
  2547. /**
  2548. * Multiplies the Vector3 coordinates by the float "scale"
  2549. * @param scale defines the multiplier factor
  2550. * @returns the current updated Vector3
  2551. */
  2552. scaleInPlace(scale: number): Vector3;
  2553. /**
  2554. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2555. * @param scale defines the multiplier factor
  2556. * @returns a new Vector3
  2557. */
  2558. scale(scale: number): Vector3;
  2559. /**
  2560. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2561. * @param scale defines the multiplier factor
  2562. * @param result defines the Vector3 object where to store the result
  2563. * @returns the current Vector3
  2564. */
  2565. scaleToRef(scale: number, result: Vector3): Vector3;
  2566. /**
  2567. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2568. * @param scale defines the scale factor
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the unmodified current Vector3
  2571. */
  2572. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2573. /**
  2574. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2575. * @param origin defines the origin of the projection ray
  2576. * @param plane defines the plane to project to
  2577. * @returns the projected vector3
  2578. */
  2579. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2580. /**
  2581. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2582. * @param origin defines the origin of the projection ray
  2583. * @param plane defines the plane to project to
  2584. * @param result defines the Vector3 where to store the result
  2585. */
  2586. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2587. /**
  2588. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2589. * @param otherVector defines the second operand
  2590. * @returns true if both vectors are equals
  2591. */
  2592. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2593. /**
  2594. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2595. * @param otherVector defines the second operand
  2596. * @param epsilon defines the minimal distance to define values as equals
  2597. * @returns true if both vectors are distant less than epsilon
  2598. */
  2599. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2600. /**
  2601. * Returns true if the current Vector3 coordinates equals the given floats
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @returns true if both vectors are equals
  2606. */
  2607. equalsToFloats(x: number, y: number, z: number): boolean;
  2608. /**
  2609. * Multiplies the current Vector3 coordinates by the given ones
  2610. * @param otherVector defines the second operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2616. * @param otherVector defines the second operand
  2617. * @returns the new Vector3
  2618. */
  2619. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2620. /**
  2621. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2622. * @param otherVector defines the second operand
  2623. * @param result defines the Vector3 object where to store the result
  2624. * @returns the current Vector3
  2625. */
  2626. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the new Vector3
  2633. */
  2634. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2637. * @param otherVector defines the second operand
  2638. * @returns the new Vector3
  2639. */
  2640. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2643. * @param otherVector defines the second operand
  2644. * @param result defines the Vector3 object where to store the result
  2645. * @returns the current Vector3
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2648. /**
  2649. * Divides the current Vector3 coordinates by the given ones.
  2650. * @param otherVector defines the second operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. divideInPlace(otherVector: Vector3): Vector3;
  2654. /**
  2655. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2656. * @param other defines the second operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2662. * @param other defines the second operand
  2663. * @returns the current updated Vector3
  2664. */
  2665. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2666. /**
  2667. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2684. * Check if is non uniform within a certain amount of decimal places to account for this
  2685. * @param epsilon the amount the values can differ
  2686. * @returns if the the vector is non uniform to a certain number of decimal places
  2687. */
  2688. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2689. /**
  2690. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2691. */
  2692. get isNonUniform(): boolean;
  2693. /**
  2694. * Gets a new Vector3 from current Vector3 floored values
  2695. * @returns a new Vector3
  2696. */
  2697. floor(): Vector3;
  2698. /**
  2699. * Gets a new Vector3 from current Vector3 floored values
  2700. * @returns a new Vector3
  2701. */
  2702. fract(): Vector3;
  2703. /**
  2704. * Gets the length of the Vector3
  2705. * @returns the length of the Vector3
  2706. */
  2707. length(): number;
  2708. /**
  2709. * Gets the squared length of the Vector3
  2710. * @returns squared length of the Vector3
  2711. */
  2712. lengthSquared(): number;
  2713. /**
  2714. * Normalize the current Vector3.
  2715. * Please note that this is an in place operation.
  2716. * @returns the current updated Vector3
  2717. */
  2718. normalize(): Vector3;
  2719. /**
  2720. * Reorders the x y z properties of the vector in place
  2721. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2722. * @returns the current updated vector
  2723. */
  2724. reorderInPlace(order: string): this;
  2725. /**
  2726. * Rotates the vector around 0,0,0 by a quaternion
  2727. * @param quaternion the rotation quaternion
  2728. * @param result vector to store the result
  2729. * @returns the resulting vector
  2730. */
  2731. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2732. /**
  2733. * Rotates a vector around a given point
  2734. * @param quaternion the rotation quaternion
  2735. * @param point the point to rotate around
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2740. /**
  2741. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2742. * The cross product is then orthogonal to both current and "other"
  2743. * @param other defines the right operand
  2744. * @returns the cross product
  2745. */
  2746. cross(other: Vector3): Vector3;
  2747. /**
  2748. * Normalize the current Vector3 with the given input length.
  2749. * Please note that this is an in place operation.
  2750. * @param len the length of the vector
  2751. * @returns the current updated Vector3
  2752. */
  2753. normalizeFromLength(len: number): Vector3;
  2754. /**
  2755. * Normalize the current Vector3 to a new vector
  2756. * @returns the new Vector3
  2757. */
  2758. normalizeToNew(): Vector3;
  2759. /**
  2760. * Normalize the current Vector3 to the reference
  2761. * @param reference define the Vector3 to update
  2762. * @returns the updated Vector3
  2763. */
  2764. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2765. /**
  2766. * Creates a new Vector3 copied from the current Vector3
  2767. * @returns the new Vector3
  2768. */
  2769. clone(): Vector3;
  2770. /**
  2771. * Copies the given vector coordinates to the current Vector3 ones
  2772. * @param source defines the source Vector3
  2773. * @returns the current updated Vector3
  2774. */
  2775. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Copies the given floats to the current Vector3 coordinates
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. set(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given float to the current Vector3 coordinates
  2794. * @param v defines the x, y and z coordinates of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. setAll(v: number): Vector3;
  2798. /**
  2799. * Get the clip factor between two vectors
  2800. * @param vector0 defines the first operand
  2801. * @param vector1 defines the second operand
  2802. * @param axis defines the axis to use
  2803. * @param size defines the size along the axis
  2804. * @returns the clip factor
  2805. */
  2806. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2807. /**
  2808. * Get angle between two vectors
  2809. * @param vector0 angle between vector0 and vector1
  2810. * @param vector1 angle between vector0 and vector1
  2811. * @param normal direction of the normal
  2812. * @return the angle between vector0 and vector1
  2813. */
  2814. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2815. /**
  2816. * Returns a new Vector3 set from the index "offset" of the given array
  2817. * @param array defines the source array
  2818. * @param offset defines the offset in the source array
  2819. * @returns the new Vector3
  2820. */
  2821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2824. * @param array defines the source array
  2825. * @param offset defines the offset in the source array
  2826. * @returns the new Vector3
  2827. * @deprecated Please use FromArray instead.
  2828. */
  2829. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @param result defines the Vector3 where to store the result
  2835. */
  2836. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2837. /**
  2838. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2839. * @param array defines the source array
  2840. * @param offset defines the offset in the source array
  2841. * @param result defines the Vector3 where to store the result
  2842. * @deprecated Please use FromArrayToRef instead.
  2843. */
  2844. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the given floats.
  2847. * @param x defines the x coordinate of the source
  2848. * @param y defines the y coordinate of the source
  2849. * @param z defines the z coordinate of the source
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2853. /**
  2854. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2855. * @returns a new empty Vector3
  2856. */
  2857. static Zero(): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2860. * @returns a new unit Vector3
  2861. */
  2862. static One(): Vector3;
  2863. /**
  2864. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2865. * @returns a new up Vector3
  2866. */
  2867. static Up(): Vector3;
  2868. /**
  2869. * Gets a up Vector3 that must not be updated
  2870. */
  2871. static get UpReadOnly(): DeepImmutable<Vector3>;
  2872. /**
  2873. * Gets a zero Vector3 that must not be updated
  2874. */
  2875. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2876. /**
  2877. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2878. * @returns a new down Vector3
  2879. */
  2880. static Down(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2883. * @param rightHandedSystem is the scene right-handed (negative z)
  2884. * @returns a new forward Vector3
  2885. */
  2886. static Forward(rightHandedSystem?: boolean): Vector3;
  2887. /**
  2888. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2889. * @param rightHandedSystem is the scene right-handed (negative-z)
  2890. * @returns a new forward Vector3
  2891. */
  2892. static Backward(rightHandedSystem?: boolean): Vector3;
  2893. /**
  2894. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2895. * @returns a new right Vector3
  2896. */
  2897. static Right(): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2900. * @returns a new left Vector3
  2901. */
  2902. static Left(): Vector3;
  2903. /**
  2904. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2905. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2906. * @param vector defines the Vector3 to transform
  2907. * @param transformation defines the transformation matrix
  2908. * @returns the transformed Vector3
  2909. */
  2910. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2921. * This method computes tranformed coordinates only, not transformed direction vectors
  2922. * @param x define the x coordinate of the source vector
  2923. * @param y define the y coordinate of the source vector
  2924. * @param z define the z coordinate of the source vector
  2925. * @param transformation defines the transformation matrix
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2931. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @returns the new Vector3
  2935. */
  2936. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param x define the x coordinate of the source vector
  2949. * @param y define the y coordinate of the source vector
  2950. * @param z define the z coordinate of the source vector
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2957. * @param value1 defines the first control point
  2958. * @param value2 defines the second control point
  2959. * @param value3 defines the third control point
  2960. * @param value4 defines the fourth control point
  2961. * @param amount defines the amount on the spline to use
  2962. * @returns the new Vector3
  2963. */
  2964. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2965. /**
  2966. * 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"
  2967. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2968. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2969. * @param value defines the current value
  2970. * @param min defines the lower range value
  2971. * @param max defines the upper range value
  2972. * @returns the new Vector3
  2973. */
  2974. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * 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"
  2977. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2978. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2979. * @param value defines the current value
  2980. * @param min defines the lower range value
  2981. * @param max defines the upper range value
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2985. /**
  2986. * Checks if a given vector is inside a specific range
  2987. * @param v defines the vector to test
  2988. * @param min defines the minimum range
  2989. * @param max defines the maximum range
  2990. */
  2991. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2994. * @param value1 defines the first control point
  2995. * @param tangent1 defines the first tangent vector
  2996. * @param value2 defines the second control point
  2997. * @param tangent2 defines the second tangent vector
  2998. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2999. * @returns the new Vector3
  3000. */
  3001. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3004. * @param start defines the start value
  3005. * @param end defines the end value
  3006. * @param amount max defines amount between both (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3018. /**
  3019. * Returns the dot product (float) between the vectors "left" and "right"
  3020. * @param left defines the left operand
  3021. * @param right defines the right operand
  3022. * @returns the dot product
  3023. */
  3024. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3025. /**
  3026. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3027. * The cross product is then orthogonal to both "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the cross product
  3031. */
  3032. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Sets the given vector "result" with the cross product of "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 as the normalization of the given vector
  3043. * @param vector defines the Vector3 to normalize
  3044. * @returns the new Vector3
  3045. */
  3046. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the normalization of the given first vector
  3049. * @param vector defines the Vector3 to normalize
  3050. * @param result defines the Vector3 where to store the result
  3051. */
  3052. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3053. /**
  3054. * Project a Vector3 onto screen space
  3055. * @param vector defines the Vector3 to project
  3056. * @param world defines the world matrix to use
  3057. * @param transform defines the transform (view x projection) matrix to use
  3058. * @param viewport defines the screen viewport to use
  3059. * @returns the new Vector3
  3060. */
  3061. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3062. /** @hidden */
  3063. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3064. /**
  3065. * Unproject from screen space to object space
  3066. * @param source defines the screen space Vector3 to use
  3067. * @param viewportWidth defines the current width of the viewport
  3068. * @param viewportHeight defines the current height of the viewport
  3069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3070. * @param transform defines the transform (view x projection) matrix to use
  3071. * @returns the new Vector3
  3072. */
  3073. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3074. /**
  3075. * Unproject from screen space to object space
  3076. * @param source defines the screen space Vector3 to use
  3077. * @param viewportWidth defines the current width of the viewport
  3078. * @param viewportHeight defines the current height of the viewport
  3079. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3080. * @param view defines the view matrix to use
  3081. * @param projection defines the projection matrix to use
  3082. * @returns the new Vector3
  3083. */
  3084. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3085. /**
  3086. * Unproject from screen space to object space
  3087. * @param source defines the screen space Vector3 to use
  3088. * @param viewportWidth defines the current width of the viewport
  3089. * @param viewportHeight defines the current height of the viewport
  3090. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3091. * @param view defines the view matrix to use
  3092. * @param projection defines the projection matrix to use
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3096. /**
  3097. * Unproject from screen space to object space
  3098. * @param sourceX defines the screen space x coordinate to use
  3099. * @param sourceY defines the screen space y coordinate to use
  3100. * @param sourceZ defines the screen space z coordinate to use
  3101. * @param viewportWidth defines the current width of the viewport
  3102. * @param viewportHeight defines the current height of the viewport
  3103. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3104. * @param view defines the view matrix to use
  3105. * @param projection defines the projection matrix to use
  3106. * @param result defines the Vector3 where to store the result
  3107. */
  3108. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3109. /**
  3110. * Gets the minimal coordinate values between two Vector3
  3111. * @param left defines the first operand
  3112. * @param right defines the second operand
  3113. * @returns the new Vector3
  3114. */
  3115. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Gets the maximal coordinate values between two Vector3
  3118. * @param left defines the first operand
  3119. * @param right defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Returns the distance between the vectors "value1" and "value2"
  3125. * @param value1 defines the first operand
  3126. * @param value2 defines the second operand
  3127. * @returns the distance
  3128. */
  3129. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3130. /**
  3131. * Returns the squared distance between the vectors "value1" and "value2"
  3132. * @param value1 defines the first operand
  3133. * @param value2 defines the second operand
  3134. * @returns the squared distance
  3135. */
  3136. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 located at the center between "value1" and "value2"
  3139. * @param value1 defines the first operand
  3140. * @param value2 defines the second operand
  3141. * @returns the new Vector3
  3142. */
  3143. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3144. /**
  3145. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3146. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3147. * to something in order to rotate it from its local system to the given target system
  3148. * Note: axis1, axis2 and axis3 are normalized during this operation
  3149. * @param axis1 defines the first axis
  3150. * @param axis2 defines the second axis
  3151. * @param axis3 defines the third axis
  3152. * @returns a new Vector3
  3153. */
  3154. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3155. /**
  3156. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @param ref defines the Vector3 where to store the result
  3161. */
  3162. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3163. }
  3164. /**
  3165. * Vector4 class created for EulerAngle class conversion to Quaternion
  3166. */
  3167. export class Vector4 {
  3168. /** x value of the vector */
  3169. x: number;
  3170. /** y value of the vector */
  3171. y: number;
  3172. /** z value of the vector */
  3173. z: number;
  3174. /** w value of the vector */
  3175. w: number;
  3176. /**
  3177. * Creates a Vector4 object from the given floats.
  3178. * @param x x value of the vector
  3179. * @param y y value of the vector
  3180. * @param z z value of the vector
  3181. * @param w w value of the vector
  3182. */
  3183. constructor(
  3184. /** x value of the vector */
  3185. x: number,
  3186. /** y value of the vector */
  3187. y: number,
  3188. /** z value of the vector */
  3189. z: number,
  3190. /** w value of the vector */
  3191. w: number);
  3192. /**
  3193. * Returns the string with the Vector4 coordinates.
  3194. * @returns a string containing all the vector values
  3195. */
  3196. toString(): string;
  3197. /**
  3198. * Returns the string "Vector4".
  3199. * @returns "Vector4"
  3200. */
  3201. getClassName(): string;
  3202. /**
  3203. * Returns the Vector4 hash code.
  3204. * @returns a unique hash code
  3205. */
  3206. getHashCode(): number;
  3207. /**
  3208. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3209. * @returns the resulting array
  3210. */
  3211. asArray(): number[];
  3212. /**
  3213. * Populates the given array from the given index with the Vector4 coordinates.
  3214. * @param array array to populate
  3215. * @param index index of the array to start at (default: 0)
  3216. * @returns the Vector4.
  3217. */
  3218. toArray(array: FloatArray, index?: number): Vector4;
  3219. /**
  3220. * Adds the given vector to the current Vector4.
  3221. * @param otherVector the vector to add
  3222. * @returns the updated Vector4.
  3223. */
  3224. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3227. * @param otherVector the vector to add
  3228. * @returns the resulting vector
  3229. */
  3230. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3233. * @param otherVector the vector to add
  3234. * @param result the vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Subtract in place the given vector from the current Vector4.
  3240. * @param otherVector the vector to subtract
  3241. * @returns the updated Vector4.
  3242. */
  3243. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3246. * @param otherVector the vector to add
  3247. * @returns the new vector with the result
  3248. */
  3249. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3252. * @param otherVector the vector to subtract
  3253. * @param result the vector to store the result
  3254. * @returns the current Vector4.
  3255. */
  3256. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3257. /**
  3258. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3259. */
  3260. /**
  3261. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3262. * @param x value to subtract
  3263. * @param y value to subtract
  3264. * @param z value to subtract
  3265. * @param w value to subtract
  3266. * @returns new vector containing the result
  3267. */
  3268. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3269. /**
  3270. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3271. * @param x value to subtract
  3272. * @param y value to subtract
  3273. * @param z value to subtract
  3274. * @param w value to subtract
  3275. * @param result the vector to store the result in
  3276. * @returns the current Vector4.
  3277. */
  3278. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3279. /**
  3280. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3281. * @returns a new vector with the negated values
  3282. */
  3283. negate(): Vector4;
  3284. /**
  3285. * Negate this vector in place
  3286. * @returns this
  3287. */
  3288. negateInPlace(): Vector4;
  3289. /**
  3290. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3291. * @param result defines the Vector3 object where to store the result
  3292. * @returns the current Vector4
  3293. */
  3294. negateToRef(result: Vector4): Vector4;
  3295. /**
  3296. * Multiplies the current Vector4 coordinates by scale (float).
  3297. * @param scale the number to scale with
  3298. * @returns the updated Vector4.
  3299. */
  3300. scaleInPlace(scale: number): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3303. * @param scale the number to scale with
  3304. * @returns a new vector with the result
  3305. */
  3306. scale(scale: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3309. * @param scale the number to scale with
  3310. * @param result a vector to store the result in
  3311. * @returns the current Vector4.
  3312. */
  3313. scaleToRef(scale: number, result: Vector4): Vector4;
  3314. /**
  3315. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3316. * @param scale defines the scale factor
  3317. * @param result defines the Vector4 object where to store the result
  3318. * @returns the unmodified current Vector4
  3319. */
  3320. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3321. /**
  3322. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3323. * @param otherVector the vector to compare against
  3324. * @returns true if they are equal
  3325. */
  3326. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3327. /**
  3328. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3329. * @param otherVector vector to compare against
  3330. * @param epsilon (Default: very small number)
  3331. * @returns true if they are equal
  3332. */
  3333. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3334. /**
  3335. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3336. * @param x x value to compare against
  3337. * @param y y value to compare against
  3338. * @param z z value to compare against
  3339. * @param w w value to compare against
  3340. * @returns true if equal
  3341. */
  3342. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3343. /**
  3344. * Multiplies in place the current Vector4 by the given one.
  3345. * @param otherVector vector to multiple with
  3346. * @returns the updated Vector4.
  3347. */
  3348. multiplyInPlace(otherVector: Vector4): Vector4;
  3349. /**
  3350. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3351. * @param otherVector vector to multiple with
  3352. * @returns resulting new vector
  3353. */
  3354. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3355. /**
  3356. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3357. * @param otherVector vector to multiple with
  3358. * @param result vector to store the result
  3359. * @returns the current Vector4.
  3360. */
  3361. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3364. * @param x x value multiply with
  3365. * @param y y value multiply with
  3366. * @param z z value multiply with
  3367. * @param w w value multiply with
  3368. * @returns resulting new vector
  3369. */
  3370. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3373. * @param otherVector vector to devide with
  3374. * @returns resulting new vector
  3375. */
  3376. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3379. * @param otherVector vector to devide with
  3380. * @param result vector to store the result
  3381. * @returns the current Vector4.
  3382. */
  3383. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3384. /**
  3385. * Divides the current Vector3 coordinates by the given ones.
  3386. * @param otherVector vector to devide with
  3387. * @returns the updated Vector3.
  3388. */
  3389. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3392. * @param other defines the second operand
  3393. * @returns the current updated Vector4
  3394. */
  3395. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3398. * @param other defines the second operand
  3399. * @returns the current updated Vector4
  3400. */
  3401. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Gets a new Vector4 from current Vector4 floored values
  3404. * @returns a new Vector4
  3405. */
  3406. floor(): Vector4;
  3407. /**
  3408. * Gets a new Vector4 from current Vector3 floored values
  3409. * @returns a new Vector4
  3410. */
  3411. fract(): Vector4;
  3412. /**
  3413. * Returns the Vector4 length (float).
  3414. * @returns the length
  3415. */
  3416. length(): number;
  3417. /**
  3418. * Returns the Vector4 squared length (float).
  3419. * @returns the length squared
  3420. */
  3421. lengthSquared(): number;
  3422. /**
  3423. * Normalizes in place the Vector4.
  3424. * @returns the updated Vector4.
  3425. */
  3426. normalize(): Vector4;
  3427. /**
  3428. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3429. * @returns this converted to a new vector3
  3430. */
  3431. toVector3(): Vector3;
  3432. /**
  3433. * Returns a new Vector4 copied from the current one.
  3434. * @returns the new cloned vector
  3435. */
  3436. clone(): Vector4;
  3437. /**
  3438. * Updates the current Vector4 with the given one coordinates.
  3439. * @param source the source vector to copy from
  3440. * @returns the updated Vector4.
  3441. */
  3442. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Updates the current Vector4 coordinates with the given floats.
  3445. * @param x float to copy from
  3446. * @param y float to copy from
  3447. * @param z float to copy from
  3448. * @param w float to copy from
  3449. * @returns the updated Vector4.
  3450. */
  3451. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3452. /**
  3453. * Updates the current Vector4 coordinates with the given floats.
  3454. * @param x float to set from
  3455. * @param y float to set from
  3456. * @param z float to set from
  3457. * @param w float to set from
  3458. * @returns the updated Vector4.
  3459. */
  3460. set(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Copies the given float to the current Vector3 coordinates
  3463. * @param v defines the x, y, z and w coordinates of the operand
  3464. * @returns the current updated Vector3
  3465. */
  3466. setAll(v: number): Vector4;
  3467. /**
  3468. * Returns a new Vector4 set from the starting index of the given array.
  3469. * @param array the array to pull values from
  3470. * @param offset the offset into the array to start at
  3471. * @returns the new vector
  3472. */
  3473. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3474. /**
  3475. * Updates the given vector "result" from the starting index of the given array.
  3476. * @param array the array to pull values from
  3477. * @param offset the offset into the array to start at
  3478. * @param result the vector to store the result in
  3479. */
  3480. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3481. /**
  3482. * Updates the given vector "result" from the starting index of the given Float32Array.
  3483. * @param array the array to pull values from
  3484. * @param offset the offset into the array to start at
  3485. * @param result the vector to store the result in
  3486. */
  3487. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3488. /**
  3489. * Updates the given vector "result" coordinates from the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @param result the vector to the floats in
  3495. */
  3496. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3497. /**
  3498. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3499. * @returns the new vector
  3500. */
  3501. static Zero(): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3504. * @returns the new vector
  3505. */
  3506. static One(): Vector4;
  3507. /**
  3508. * Returns a new normalized Vector4 from the given one.
  3509. * @param vector the vector to normalize
  3510. * @returns the vector
  3511. */
  3512. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3513. /**
  3514. * Updates the given vector "result" from the normalization of the given one.
  3515. * @param vector the vector to normalize
  3516. * @param result the vector to store the result in
  3517. */
  3518. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3519. /**
  3520. * Returns a vector with the minimum values from the left and right vectors
  3521. * @param left left vector to minimize
  3522. * @param right right vector to minimize
  3523. * @returns a new vector with the minimum of the left and right vector values
  3524. */
  3525. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Returns a vector with the maximum values from the left and right vectors
  3528. * @param left left vector to maximize
  3529. * @param right right vector to maximize
  3530. * @returns a new vector with the maximum of the left and right vector values
  3531. */
  3532. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Returns the distance (float) between the vectors "value1" and "value2".
  3535. * @param value1 value to calulate the distance between
  3536. * @param value2 value to calulate the distance between
  3537. * @return the distance between the two vectors
  3538. */
  3539. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3540. /**
  3541. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3542. * @param value1 value to calulate the distance between
  3543. * @param value2 value to calulate the distance between
  3544. * @return the distance between the two vectors squared
  3545. */
  3546. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3547. /**
  3548. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3549. * @param value1 value to calulate the center between
  3550. * @param value2 value to calulate the center between
  3551. * @return the center between the two vectors
  3552. */
  3553. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3554. /**
  3555. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3556. * This methods computes transformed normalized direction vectors only.
  3557. * @param vector the vector to transform
  3558. * @param transformation the transformation matrix to apply
  3559. * @returns the new vector
  3560. */
  3561. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3562. /**
  3563. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @param result the vector to store the result in
  3568. */
  3569. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param x value to transform
  3574. * @param y value to transform
  3575. * @param z value to transform
  3576. * @param w value to transform
  3577. * @param transformation the transformation matrix to apply
  3578. * @param result the vector to store the results in
  3579. */
  3580. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3581. /**
  3582. * Creates a new Vector4 from a Vector3
  3583. * @param source defines the source data
  3584. * @param w defines the 4th component (default is 0)
  3585. * @returns a new Vector4
  3586. */
  3587. static FromVector3(source: Vector3, w?: number): Vector4;
  3588. }
  3589. /**
  3590. * Class used to store quaternion data
  3591. * @see https://en.wikipedia.org/wiki/Quaternion
  3592. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3593. */
  3594. export class Quaternion {
  3595. /** defines the first component (0 by default) */
  3596. x: number;
  3597. /** defines the second component (0 by default) */
  3598. y: number;
  3599. /** defines the third component (0 by default) */
  3600. z: number;
  3601. /** defines the fourth component (1.0 by default) */
  3602. w: number;
  3603. /**
  3604. * Creates a new Quaternion from the given floats
  3605. * @param x defines the first component (0 by default)
  3606. * @param y defines the second component (0 by default)
  3607. * @param z defines the third component (0 by default)
  3608. * @param w defines the fourth component (1.0 by default)
  3609. */
  3610. constructor(
  3611. /** defines the first component (0 by default) */
  3612. x?: number,
  3613. /** defines the second component (0 by default) */
  3614. y?: number,
  3615. /** defines the third component (0 by default) */
  3616. z?: number,
  3617. /** defines the fourth component (1.0 by default) */
  3618. w?: number);
  3619. /**
  3620. * Gets a string representation for the current quaternion
  3621. * @returns a string with the Quaternion coordinates
  3622. */
  3623. toString(): string;
  3624. /**
  3625. * Gets the class name of the quaternion
  3626. * @returns the string "Quaternion"
  3627. */
  3628. getClassName(): string;
  3629. /**
  3630. * Gets a hash code for this quaternion
  3631. * @returns the quaternion hash code
  3632. */
  3633. getHashCode(): number;
  3634. /**
  3635. * Copy the quaternion to an array
  3636. * @returns a new array populated with 4 elements from the quaternion coordinates
  3637. */
  3638. asArray(): number[];
  3639. /**
  3640. * Check if two quaternions are equals
  3641. * @param otherQuaternion defines the second operand
  3642. * @return true if the current quaternion and the given one coordinates are strictly equals
  3643. */
  3644. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3645. /**
  3646. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3647. * @param otherQuaternion defines the other quaternion
  3648. * @param epsilon defines the minimal distance to consider equality
  3649. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3650. */
  3651. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3652. /**
  3653. * Clone the current quaternion
  3654. * @returns a new quaternion copied from the current one
  3655. */
  3656. clone(): Quaternion;
  3657. /**
  3658. * Copy a quaternion to the current one
  3659. * @param other defines the other quaternion
  3660. * @returns the updated current quaternion
  3661. */
  3662. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Updates the current quaternion with the given float coordinates
  3665. * @param x defines the x coordinate
  3666. * @param y defines the y coordinate
  3667. * @param z defines the z coordinate
  3668. * @param w defines the w coordinate
  3669. * @returns the updated current quaternion
  3670. */
  3671. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3672. /**
  3673. * Updates the current quaternion from the given float coordinates
  3674. * @param x defines the x coordinate
  3675. * @param y defines the y coordinate
  3676. * @param z defines the z coordinate
  3677. * @param w defines the w coordinate
  3678. * @returns the updated current quaternion
  3679. */
  3680. set(x: number, y: number, z: number, w: number): Quaternion;
  3681. /**
  3682. * Adds two quaternions
  3683. * @param other defines the second operand
  3684. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3685. */
  3686. add(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Add a quaternion to the current one
  3689. * @param other defines the quaternion to add
  3690. * @returns the current quaternion
  3691. */
  3692. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Subtract two quaternions
  3695. * @param other defines the second operand
  3696. * @returns a new quaternion as the subtraction result of the given one from the current one
  3697. */
  3698. subtract(other: Quaternion): Quaternion;
  3699. /**
  3700. * Multiplies the current quaternion by a scale factor
  3701. * @param value defines the scale factor
  3702. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3703. */
  3704. scale(value: number): Quaternion;
  3705. /**
  3706. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3707. * @param scale defines the scale factor
  3708. * @param result defines the Quaternion object where to store the result
  3709. * @returns the unmodified current quaternion
  3710. */
  3711. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3712. /**
  3713. * Multiplies in place the current quaternion by a scale factor
  3714. * @param value defines the scale factor
  3715. * @returns the current modified quaternion
  3716. */
  3717. scaleInPlace(value: number): Quaternion;
  3718. /**
  3719. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3720. * @param scale defines the scale factor
  3721. * @param result defines the Quaternion object where to store the result
  3722. * @returns the unmodified current quaternion
  3723. */
  3724. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Multiplies two quaternions
  3727. * @param q1 defines the second operand
  3728. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3729. */
  3730. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3733. * @param q1 defines the second operand
  3734. * @param result defines the target quaternion
  3735. * @returns the current quaternion
  3736. */
  3737. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @returns the currentupdated quaternion
  3742. */
  3743. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3744. /**
  3745. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3746. * @param ref defines the target quaternion
  3747. * @returns the current quaternion
  3748. */
  3749. conjugateToRef(ref: Quaternion): Quaternion;
  3750. /**
  3751. * Conjugates in place (1-q) the current quaternion
  3752. * @returns the current updated quaternion
  3753. */
  3754. conjugateInPlace(): Quaternion;
  3755. /**
  3756. * Conjugates in place (1-q) the current quaternion
  3757. * @returns a new quaternion
  3758. */
  3759. conjugate(): Quaternion;
  3760. /**
  3761. * Gets length of current quaternion
  3762. * @returns the quaternion length (float)
  3763. */
  3764. length(): number;
  3765. /**
  3766. * Normalize in place the current quaternion
  3767. * @returns the current updated quaternion
  3768. */
  3769. normalize(): Quaternion;
  3770. /**
  3771. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3772. * @param order is a reserved parameter and is ignore for now
  3773. * @returns a new Vector3 containing the Euler angles
  3774. */
  3775. toEulerAngles(order?: string): Vector3;
  3776. /**
  3777. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3778. * @param result defines the vector which will be filled with the Euler angles
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns the current unchanged quaternion
  3781. */
  3782. toEulerAnglesToRef(result: Vector3): Quaternion;
  3783. /**
  3784. * Updates the given rotation matrix with the current quaternion values
  3785. * @param result defines the target matrix
  3786. * @returns the current unchanged quaternion
  3787. */
  3788. toRotationMatrix(result: Matrix): Quaternion;
  3789. /**
  3790. * Updates the current quaternion from the given rotation matrix values
  3791. * @param matrix defines the source matrix
  3792. * @returns the current updated quaternion
  3793. */
  3794. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from a rotation matrix
  3797. * @param matrix defines the source matrix
  3798. * @returns a new quaternion created from the given rotation matrix values
  3799. */
  3800. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3801. /**
  3802. * Updates the given quaternion with the given rotation matrix values
  3803. * @param matrix defines the source matrix
  3804. * @param result defines the target quaternion
  3805. */
  3806. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3807. /**
  3808. * Returns the dot product (float) between the quaternions "left" and "right"
  3809. * @param left defines the left operand
  3810. * @param right defines the right operand
  3811. * @returns the dot product
  3812. */
  3813. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3814. /**
  3815. * Checks if the two quaternions are close to each other
  3816. * @param quat0 defines the first quaternion to check
  3817. * @param quat1 defines the second quaternion to check
  3818. * @returns true if the two quaternions are close to each other
  3819. */
  3820. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3821. /**
  3822. * Creates an empty quaternion
  3823. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3824. */
  3825. static Zero(): Quaternion;
  3826. /**
  3827. * Inverse a given quaternion
  3828. * @param q defines the source quaternion
  3829. * @returns a new quaternion as the inverted current quaternion
  3830. */
  3831. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Inverse a given quaternion
  3834. * @param q defines the source quaternion
  3835. * @param result the quaternion the result will be stored in
  3836. * @returns the result quaternion
  3837. */
  3838. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3839. /**
  3840. * Creates an identity quaternion
  3841. * @returns the identity quaternion
  3842. */
  3843. static Identity(): Quaternion;
  3844. /**
  3845. * Gets a boolean indicating if the given quaternion is identity
  3846. * @param quaternion defines the quaternion to check
  3847. * @returns true if the quaternion is identity
  3848. */
  3849. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3850. /**
  3851. * Creates a quaternion from a rotation around an axis
  3852. * @param axis defines the axis to use
  3853. * @param angle defines the angle to use
  3854. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3855. */
  3856. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3857. /**
  3858. * Creates a rotation around an axis and stores it into the given quaternion
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @param result defines the target quaternion
  3862. * @returns the target quaternion
  3863. */
  3864. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3865. /**
  3866. * Creates a new quaternion from data stored into an array
  3867. * @param array defines the data source
  3868. * @param offset defines the offset in the source array where the data starts
  3869. * @returns a new quaternion
  3870. */
  3871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3872. /**
  3873. * Updates the given quaternion "result" from the starting index of the given array.
  3874. * @param array the array to pull values from
  3875. * @param offset the offset into the array to start at
  3876. * @param result the quaternion to store the result in
  3877. */
  3878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3879. /**
  3880. * Create a quaternion from Euler rotation angles
  3881. * @param x Pitch
  3882. * @param y Yaw
  3883. * @param z Roll
  3884. * @returns the new Quaternion
  3885. */
  3886. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3887. /**
  3888. * Updates a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @param result the quaternion to store the result
  3893. * @returns the updated quaternion
  3894. */
  3895. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3896. /**
  3897. * Create a quaternion from Euler rotation vector
  3898. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3899. * @returns the new Quaternion
  3900. */
  3901. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3902. /**
  3903. * Updates a quaternion from Euler rotation vector
  3904. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3905. * @param result the quaternion to store the result
  3906. * @returns the updated quaternion
  3907. */
  3908. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3911. * @param yaw defines the rotation around Y axis
  3912. * @param pitch defines the rotation around X axis
  3913. * @param roll defines the rotation around Z axis
  3914. * @returns the new quaternion
  3915. */
  3916. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3917. /**
  3918. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @param result defines the target quaternion
  3923. */
  3924. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3925. /**
  3926. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3927. * @param alpha defines the rotation around first axis
  3928. * @param beta defines the rotation around second axis
  3929. * @param gamma defines the rotation around third axis
  3930. * @returns the new quaternion
  3931. */
  3932. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @param result defines the target quaternion
  3939. */
  3940. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3941. /**
  3942. * 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)
  3943. * @param axis1 defines the first axis
  3944. * @param axis2 defines the second axis
  3945. * @param axis3 defines the third axis
  3946. * @returns the new quaternion
  3947. */
  3948. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3949. /**
  3950. * 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
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @param ref defines the target quaternion
  3955. */
  3956. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3957. /**
  3958. * Interpolates between two quaternions
  3959. * @param left defines first quaternion
  3960. * @param right defines second quaternion
  3961. * @param amount defines the gradient to use
  3962. * @returns the new interpolated quaternion
  3963. */
  3964. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3965. /**
  3966. * Interpolates between two quaternions and stores it into a target quaternion
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @param result defines the target quaternion
  3971. */
  3972. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3973. /**
  3974. * Interpolate between two quaternions using Hermite interpolation
  3975. * @param value1 defines first quaternion
  3976. * @param tangent1 defines the incoming tangent
  3977. * @param value2 defines second quaternion
  3978. * @param tangent2 defines the outgoing tangent
  3979. * @param amount defines the target quaternion
  3980. * @returns the new interpolated quaternion
  3981. */
  3982. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3983. }
  3984. /**
  3985. * Class used to store matrix data (4x4)
  3986. */
  3987. export class Matrix {
  3988. private static _updateFlagSeed;
  3989. private static _identityReadOnly;
  3990. private _isIdentity;
  3991. private _isIdentityDirty;
  3992. private _isIdentity3x2;
  3993. private _isIdentity3x2Dirty;
  3994. /**
  3995. * Gets the update flag of the matrix which is an unique number for the matrix.
  3996. * It will be incremented every time the matrix data change.
  3997. * You can use it to speed the comparison between two versions of the same matrix.
  3998. */
  3999. updateFlag: number;
  4000. private readonly _m;
  4001. /**
  4002. * Gets the internal data of the matrix
  4003. */
  4004. get m(): DeepImmutable<Float32Array>;
  4005. /** @hidden */
  4006. _markAsUpdated(): void;
  4007. /** @hidden */
  4008. private _updateIdentityStatus;
  4009. /**
  4010. * Creates an empty matrix (filled with zeros)
  4011. */
  4012. constructor();
  4013. /**
  4014. * Check if the current matrix is identity
  4015. * @returns true is the matrix is the identity matrix
  4016. */
  4017. isIdentity(): boolean;
  4018. /**
  4019. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4020. * @returns true is the matrix is the identity matrix
  4021. */
  4022. isIdentityAs3x2(): boolean;
  4023. /**
  4024. * Gets the determinant of the matrix
  4025. * @returns the matrix determinant
  4026. */
  4027. determinant(): number;
  4028. /**
  4029. * Returns the matrix as a Float32Array
  4030. * @returns the matrix underlying array
  4031. */
  4032. toArray(): DeepImmutable<Float32Array>;
  4033. /**
  4034. * Returns the matrix as a Float32Array
  4035. * @returns the matrix underlying array.
  4036. */
  4037. asArray(): DeepImmutable<Float32Array>;
  4038. /**
  4039. * Inverts the current matrix in place
  4040. * @returns the current inverted matrix
  4041. */
  4042. invert(): Matrix;
  4043. /**
  4044. * Sets all the matrix elements to zero
  4045. * @returns the current matrix
  4046. */
  4047. reset(): Matrix;
  4048. /**
  4049. * Adds the current matrix with a second one
  4050. * @param other defines the matrix to add
  4051. * @returns a new matrix as the addition of the current matrix and the given one
  4052. */
  4053. add(other: DeepImmutable<Matrix>): Matrix;
  4054. /**
  4055. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4056. * @param other defines the matrix to add
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4061. /**
  4062. * Adds in place the given matrix to the current matrix
  4063. * @param other defines the second operand
  4064. * @returns the current updated matrix
  4065. */
  4066. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4067. /**
  4068. * Sets the given matrix to the current inverted Matrix
  4069. * @param other defines the target matrix
  4070. * @returns the unmodified current matrix
  4071. */
  4072. invertToRef(other: Matrix): Matrix;
  4073. /**
  4074. * add a value at the specified position in the current Matrix
  4075. * @param index the index of the value within the matrix. between 0 and 15.
  4076. * @param value the value to be added
  4077. * @returns the current updated matrix
  4078. */
  4079. addAtIndex(index: number, value: number): Matrix;
  4080. /**
  4081. * mutiply the specified position in the current Matrix by a value
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. multiplyAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * Inserts the translation vector (using 3 floats) in the current matrix
  4089. * @param x defines the 1st component of the translation
  4090. * @param y defines the 2nd component of the translation
  4091. * @param z defines the 3rd component of the translation
  4092. * @returns the current updated matrix
  4093. */
  4094. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4095. /**
  4096. * Adds the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Inserts the translation vector in the current matrix
  4105. * @param vector3 defines the translation to insert
  4106. * @returns the current updated matrix
  4107. */
  4108. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4109. /**
  4110. * Gets the translation value of the current matrix
  4111. * @returns a new Vector3 as the extracted translation from the matrix
  4112. */
  4113. getTranslation(): Vector3;
  4114. /**
  4115. * Fill a Vector3 with the extracted translation from the matrix
  4116. * @param result defines the Vector3 where to store the translation
  4117. * @returns the current matrix
  4118. */
  4119. getTranslationToRef(result: Vector3): Matrix;
  4120. /**
  4121. * Remove rotation and scaling part from the matrix
  4122. * @returns the updated matrix
  4123. */
  4124. removeRotationAndScaling(): Matrix;
  4125. /**
  4126. * Multiply two matrices
  4127. * @param other defines the second operand
  4128. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4129. */
  4130. multiply(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Copy the current matrix from the given one
  4133. * @param other defines the source matrix
  4134. * @returns the current updated matrix
  4135. */
  4136. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4137. /**
  4138. * Populates the given array from the starting index with the current matrix values
  4139. * @param array defines the target array
  4140. * @param offset defines the offset in the target array where to start storing values
  4141. * @returns the current matrix
  4142. */
  4143. copyToArray(array: Float32Array, offset?: number): Matrix;
  4144. /**
  4145. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4146. * @param other defines the second operand
  4147. * @param result defines the matrix where to store the multiplication
  4148. * @returns the current matrix
  4149. */
  4150. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4151. /**
  4152. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the array where to store the multiplication
  4155. * @param offset defines the offset in the target array where to start storing values
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4159. /**
  4160. * Check equality between this matrix and a second one
  4161. * @param value defines the second matrix to compare
  4162. * @returns true is the current matrix and the given one values are strictly equal
  4163. */
  4164. equals(value: DeepImmutable<Matrix>): boolean;
  4165. /**
  4166. * Clone the current matrix
  4167. * @returns a new matrix from the current matrix
  4168. */
  4169. clone(): Matrix;
  4170. /**
  4171. * Returns the name of the current matrix class
  4172. * @returns the string "Matrix"
  4173. */
  4174. getClassName(): string;
  4175. /**
  4176. * Gets the hash code of the current matrix
  4177. * @returns the hash code
  4178. */
  4179. getHashCode(): number;
  4180. /**
  4181. * Decomposes the current Matrix into a translation, rotation and scaling components
  4182. * @param scale defines the scale vector3 given as a reference to update
  4183. * @param rotation defines the rotation quaternion given as a reference to update
  4184. * @param translation defines the translation vector3 given as a reference to update
  4185. * @returns true if operation was successful
  4186. */
  4187. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4188. /**
  4189. * Gets specific row of the matrix
  4190. * @param index defines the number of the row to get
  4191. * @returns the index-th row of the current matrix as a new Vector4
  4192. */
  4193. getRow(index: number): Nullable<Vector4>;
  4194. /**
  4195. * Sets the index-th row of the current matrix to the vector4 values
  4196. * @param index defines the number of the row to set
  4197. * @param row defines the target vector4
  4198. * @returns the updated current matrix
  4199. */
  4200. setRow(index: number, row: Vector4): Matrix;
  4201. /**
  4202. * Compute the transpose of the matrix
  4203. * @returns the new transposed matrix
  4204. */
  4205. transpose(): Matrix;
  4206. /**
  4207. * Compute the transpose of the matrix and store it in a given matrix
  4208. * @param result defines the target matrix
  4209. * @returns the current matrix
  4210. */
  4211. transposeToRef(result: Matrix): Matrix;
  4212. /**
  4213. * Sets the index-th row of the current matrix with the given 4 x float values
  4214. * @param index defines the row index
  4215. * @param x defines the x component to set
  4216. * @param y defines the y component to set
  4217. * @param z defines the z component to set
  4218. * @param w defines the w component to set
  4219. * @returns the updated current matrix
  4220. */
  4221. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4222. /**
  4223. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4224. * @param scale defines the scale factor
  4225. * @returns a new matrix
  4226. */
  4227. scale(scale: number): Matrix;
  4228. /**
  4229. * Scale the current matrix values by a factor to a given result matrix
  4230. * @param scale defines the scale factor
  4231. * @param result defines the matrix to store the result
  4232. * @returns the current matrix
  4233. */
  4234. scaleToRef(scale: number, result: Matrix): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor and add the result to a given matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the Matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4244. * @param ref matrix to store the result
  4245. */
  4246. toNormalMatrix(ref: Matrix): void;
  4247. /**
  4248. * Gets only rotation part of the current matrix
  4249. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4250. */
  4251. getRotationMatrix(): Matrix;
  4252. /**
  4253. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4254. * @param result defines the target matrix to store data to
  4255. * @returns the current matrix
  4256. */
  4257. getRotationMatrixToRef(result: Matrix): Matrix;
  4258. /**
  4259. * Toggles model matrix from being right handed to left handed in place and vice versa
  4260. */
  4261. toggleModelMatrixHandInPlace(): void;
  4262. /**
  4263. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4264. */
  4265. toggleProjectionMatrixHandInPlace(): void;
  4266. /**
  4267. * Creates a matrix from an array
  4268. * @param array defines the source array
  4269. * @param offset defines an offset in the source array
  4270. * @returns a new Matrix set from the starting index of the given array
  4271. */
  4272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4273. /**
  4274. * Copy the content of an array into a given matrix
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @param result defines the target matrix
  4278. */
  4279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4280. /**
  4281. * Stores an array into a matrix after having multiplied each component by a given factor
  4282. * @param array defines the source array
  4283. * @param offset defines the offset in the source array
  4284. * @param scale defines the scaling factor
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4288. /**
  4289. * Gets an identity matrix that must not be updated
  4290. */
  4291. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4292. /**
  4293. * Stores a list of values (16) inside a given matrix
  4294. * @param initialM11 defines 1st value of 1st row
  4295. * @param initialM12 defines 2nd value of 1st row
  4296. * @param initialM13 defines 3rd value of 1st row
  4297. * @param initialM14 defines 4th value of 1st row
  4298. * @param initialM21 defines 1st value of 2nd row
  4299. * @param initialM22 defines 2nd value of 2nd row
  4300. * @param initialM23 defines 3rd value of 2nd row
  4301. * @param initialM24 defines 4th value of 2nd row
  4302. * @param initialM31 defines 1st value of 3rd row
  4303. * @param initialM32 defines 2nd value of 3rd row
  4304. * @param initialM33 defines 3rd value of 3rd row
  4305. * @param initialM34 defines 4th value of 3rd row
  4306. * @param initialM41 defines 1st value of 4th row
  4307. * @param initialM42 defines 2nd value of 4th row
  4308. * @param initialM43 defines 3rd value of 4th row
  4309. * @param initialM44 defines 4th value of 4th row
  4310. * @param result defines the target matrix
  4311. */
  4312. 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;
  4313. /**
  4314. * Creates new matrix from a list of values (16)
  4315. * @param initialM11 defines 1st value of 1st row
  4316. * @param initialM12 defines 2nd value of 1st row
  4317. * @param initialM13 defines 3rd value of 1st row
  4318. * @param initialM14 defines 4th value of 1st row
  4319. * @param initialM21 defines 1st value of 2nd row
  4320. * @param initialM22 defines 2nd value of 2nd row
  4321. * @param initialM23 defines 3rd value of 2nd row
  4322. * @param initialM24 defines 4th value of 2nd row
  4323. * @param initialM31 defines 1st value of 3rd row
  4324. * @param initialM32 defines 2nd value of 3rd row
  4325. * @param initialM33 defines 3rd value of 3rd row
  4326. * @param initialM34 defines 4th value of 3rd row
  4327. * @param initialM41 defines 1st value of 4th row
  4328. * @param initialM42 defines 2nd value of 4th row
  4329. * @param initialM43 defines 3rd value of 4th row
  4330. * @param initialM44 defines 4th value of 4th row
  4331. * @returns the new matrix
  4332. */
  4333. 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;
  4334. /**
  4335. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4336. * @param scale defines the scale vector3
  4337. * @param rotation defines the rotation quaternion
  4338. * @param translation defines the translation vector3
  4339. * @returns a new matrix
  4340. */
  4341. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4342. /**
  4343. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @param result defines the target matrix
  4348. */
  4349. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4350. /**
  4351. * Creates a new identity matrix
  4352. * @returns a new identity matrix
  4353. */
  4354. static Identity(): Matrix;
  4355. /**
  4356. * Creates a new identity matrix and stores the result in a given matrix
  4357. * @param result defines the target matrix
  4358. */
  4359. static IdentityToRef(result: Matrix): void;
  4360. /**
  4361. * Creates a new zero matrix
  4362. * @returns a new zero matrix
  4363. */
  4364. static Zero(): Matrix;
  4365. /**
  4366. * Creates a new rotation matrix for "angle" radians around the X axis
  4367. * @param angle defines the angle (in radians) to use
  4368. * @return the new matrix
  4369. */
  4370. static RotationX(angle: number): Matrix;
  4371. /**
  4372. * Creates a new matrix as the invert of a given matrix
  4373. * @param source defines the source matrix
  4374. * @returns the new matrix
  4375. */
  4376. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4377. /**
  4378. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4379. * @param angle defines the angle (in radians) to use
  4380. * @param result defines the target matrix
  4381. */
  4382. static RotationXToRef(angle: number, result: Matrix): void;
  4383. /**
  4384. * Creates a new rotation matrix for "angle" radians around the Y axis
  4385. * @param angle defines the angle (in radians) to use
  4386. * @return the new matrix
  4387. */
  4388. static RotationY(angle: number): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4391. * @param angle defines the angle (in radians) to use
  4392. * @param result defines the target matrix
  4393. */
  4394. static RotationYToRef(angle: number, result: Matrix): void;
  4395. /**
  4396. * Creates a new rotation matrix for "angle" radians around the Z axis
  4397. * @param angle defines the angle (in radians) to use
  4398. * @return the new matrix
  4399. */
  4400. static RotationZ(angle: number): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationZToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the given axis
  4409. * @param axis defines the axis to use
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @param result defines the target matrix
  4419. */
  4420. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4421. /**
  4422. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4423. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4424. * @param from defines the vector to align
  4425. * @param to defines the vector to align to
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a rotation matrix
  4431. * @param yaw defines the yaw angle in radians (Y axis)
  4432. * @param pitch defines the pitch angle in radians (X axis)
  4433. * @param roll defines the roll angle in radians (X axis)
  4434. * @returns the new rotation matrix
  4435. */
  4436. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4437. /**
  4438. * Creates a rotation matrix and stores it in a given matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4445. /**
  4446. * Creates a scaling matrix
  4447. * @param x defines the scale factor on X axis
  4448. * @param y defines the scale factor on Y axis
  4449. * @param z defines the scale factor on Z axis
  4450. * @returns the new matrix
  4451. */
  4452. static Scaling(x: number, y: number, z: number): Matrix;
  4453. /**
  4454. * Creates a scaling matrix and stores it in a given matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @param result defines the target matrix
  4459. */
  4460. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4461. /**
  4462. * Creates a translation matrix
  4463. * @param x defines the translation on X axis
  4464. * @param y defines the translation on Y axis
  4465. * @param z defines the translationon Z axis
  4466. * @returns the new matrix
  4467. */
  4468. static Translation(x: number, y: number, z: number): Matrix;
  4469. /**
  4470. * Creates a translation matrix and stores it in a given matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @param result defines the target matrix
  4475. */
  4476. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4477. /**
  4478. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4479. * @param startValue defines the start value
  4480. * @param endValue defines the end value
  4481. * @param gradient defines the gradient factor
  4482. * @returns the new matrix
  4483. */
  4484. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4485. /**
  4486. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @param result defines the Matrix object where to store data
  4491. */
  4492. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4493. /**
  4494. * Builds a new matrix whose values are computed by:
  4495. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4496. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4497. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4498. * @param startValue defines the first matrix
  4499. * @param endValue defines the second matrix
  4500. * @param gradient defines the gradient between the two matrices
  4501. * @returns the new matrix
  4502. */
  4503. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4504. /**
  4505. * Update a matrix to values which are computed by:
  4506. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4507. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4508. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4509. * @param startValue defines the first matrix
  4510. * @param endValue defines the second matrix
  4511. * @param gradient defines the gradient between the two matrices
  4512. * @param result defines the target matrix
  4513. */
  4514. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4515. /**
  4516. * 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"
  4517. * This function works in left handed mode
  4518. * @param eye defines the final position of the entity
  4519. * @param target defines where the entity should look at
  4520. * @param up defines the up vector for the entity
  4521. * @returns the new matrix
  4522. */
  4523. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4524. /**
  4525. * 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".
  4526. * This function works in left handed mode
  4527. * @param eye defines the final position of the entity
  4528. * @param target defines where the entity should look at
  4529. * @param up defines the up vector for the entity
  4530. * @param result defines the target matrix
  4531. */
  4532. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * 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"
  4535. * This function works in right handed mode
  4536. * @param eye defines the final position of the entity
  4537. * @param target defines where the entity should look at
  4538. * @param up defines the up vector for the entity
  4539. * @returns the new matrix
  4540. */
  4541. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4542. /**
  4543. * 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".
  4544. * This function works in right handed mode
  4545. * @param eye defines the final position of the entity
  4546. * @param target defines where the entity should look at
  4547. * @param up defines the up vector for the entity
  4548. * @param result defines the target matrix
  4549. */
  4550. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Create a left-handed orthographic projection matrix
  4553. * @param width defines the viewport width
  4554. * @param height defines the viewport height
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a left-handed orthographic projection matrix
  4558. */
  4559. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Store a left-handed orthographic projection to a given matrix
  4562. * @param width defines the viewport width
  4563. * @param height defines the viewport height
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. */
  4568. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4569. /**
  4570. * Create a left-handed orthographic projection matrix
  4571. * @param left defines the viewport left coordinate
  4572. * @param right defines the viewport right coordinate
  4573. * @param bottom defines the viewport bottom coordinate
  4574. * @param top defines the viewport top coordinate
  4575. * @param znear defines the near clip plane
  4576. * @param zfar defines the far clip plane
  4577. * @returns a new matrix as a left-handed orthographic projection matrix
  4578. */
  4579. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4580. /**
  4581. * Stores a left-handed orthographic projection into a given matrix
  4582. * @param left defines the viewport left coordinate
  4583. * @param right defines the viewport right coordinate
  4584. * @param bottom defines the viewport bottom coordinate
  4585. * @param top defines the viewport top coordinate
  4586. * @param znear defines the near clip plane
  4587. * @param zfar defines the far clip plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4591. /**
  4592. * Creates a right-handed orthographic projection matrix
  4593. * @param left defines the viewport left coordinate
  4594. * @param right defines the viewport right coordinate
  4595. * @param bottom defines the viewport bottom coordinate
  4596. * @param top defines the viewport top coordinate
  4597. * @param znear defines the near clip plane
  4598. * @param zfar defines the far clip plane
  4599. * @returns a new matrix as a right-handed orthographic projection matrix
  4600. */
  4601. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4602. /**
  4603. * Stores a right-handed orthographic projection into a given matrix
  4604. * @param left defines the viewport left coordinate
  4605. * @param right defines the viewport right coordinate
  4606. * @param bottom defines the viewport bottom coordinate
  4607. * @param top defines the viewport top coordinate
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Creates a left-handed perspective projection matrix
  4615. * @param width defines the viewport width
  4616. * @param height defines the viewport height
  4617. * @param znear defines the near clip plane
  4618. * @param zfar defines the far clip plane
  4619. * @returns a new matrix as a left-handed perspective projection matrix
  4620. */
  4621. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4622. /**
  4623. * Creates a left-handed perspective projection matrix
  4624. * @param fov defines the horizontal field of view
  4625. * @param aspect defines the aspect ratio
  4626. * @param znear defines the near clip plane
  4627. * @param zfar defines the far clip plane
  4628. * @returns a new matrix as a left-handed perspective projection matrix
  4629. */
  4630. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4631. /**
  4632. * Stores a left-handed perspective projection into a given matrix
  4633. * @param fov defines the horizontal field of view
  4634. * @param aspect defines the aspect ratio
  4635. * @param znear defines the near clip plane
  4636. * @param zfar defines the far clip plane
  4637. * @param result defines the target matrix
  4638. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4639. */
  4640. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4641. /**
  4642. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4643. * @param fov defines the horizontal field of view
  4644. * @param aspect defines the aspect ratio
  4645. * @param znear defines the near clip plane
  4646. * @param zfar not used as infinity is used as far clip
  4647. * @param result defines the target matrix
  4648. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4649. */
  4650. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4651. /**
  4652. * Creates a right-handed perspective projection matrix
  4653. * @param fov defines the horizontal field of view
  4654. * @param aspect defines the aspect ratio
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a right-handed perspective projection matrix
  4658. */
  4659. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Stores a right-handed perspective projection into a given matrix
  4662. * @param fov defines the horizontal field of view
  4663. * @param aspect defines the aspect ratio
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4668. */
  4669. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4670. /**
  4671. * Stores a right-handed perspective projection into a given matrix
  4672. * @param fov defines the horizontal field of view
  4673. * @param aspect defines the aspect ratio
  4674. * @param znear defines the near clip plane
  4675. * @param zfar not used as infinity is used as far clip
  4676. * @param result defines the target matrix
  4677. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4678. */
  4679. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4680. /**
  4681. * Stores a perspective projection for WebVR info a given matrix
  4682. * @param fov defines the field of view
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4687. */
  4688. static PerspectiveFovWebVRToRef(fov: {
  4689. upDegrees: number;
  4690. downDegrees: number;
  4691. leftDegrees: number;
  4692. rightDegrees: number;
  4693. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4694. /**
  4695. * Computes a complete transformation matrix
  4696. * @param viewport defines the viewport to use
  4697. * @param world defines the world matrix
  4698. * @param view defines the view matrix
  4699. * @param projection defines the projection matrix
  4700. * @param zmin defines the near clip plane
  4701. * @param zmax defines the far clip plane
  4702. * @returns the transformation matrix
  4703. */
  4704. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4705. /**
  4706. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4707. * @param matrix defines the matrix to use
  4708. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4709. */
  4710. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4711. /**
  4712. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4713. * @param matrix defines the matrix to use
  4714. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4715. */
  4716. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4717. /**
  4718. * Compute the transpose of a given matrix
  4719. * @param matrix defines the matrix to transpose
  4720. * @returns the new matrix
  4721. */
  4722. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4723. /**
  4724. * Compute the transpose of a matrix and store it in a target matrix
  4725. * @param matrix defines the matrix to transpose
  4726. * @param result defines the target matrix
  4727. */
  4728. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4729. /**
  4730. * Computes a reflection matrix from a plane
  4731. * @param plane defines the reflection plane
  4732. * @returns a new matrix
  4733. */
  4734. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4735. /**
  4736. * Computes a reflection matrix from a plane
  4737. * @param plane defines the reflection plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4741. /**
  4742. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4743. * @param xaxis defines the value of the 1st axis
  4744. * @param yaxis defines the value of the 2nd axis
  4745. * @param zaxis defines the value of the 3rd axis
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4749. /**
  4750. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4751. * @param quat defines the quaternion to use
  4752. * @param result defines the target matrix
  4753. */
  4754. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4755. }
  4756. /**
  4757. * @hidden
  4758. */
  4759. export class TmpVectors {
  4760. static Vector2: Vector2[];
  4761. static Vector3: Vector3[];
  4762. static Vector4: Vector4[];
  4763. static Quaternion: Quaternion[];
  4764. static Matrix: Matrix[];
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /**
  4769. * Defines potential orientation for back face culling
  4770. */
  4771. export enum Orientation {
  4772. /**
  4773. * Clockwise
  4774. */
  4775. CW = 0,
  4776. /** Counter clockwise */
  4777. CCW = 1
  4778. }
  4779. /** Class used to represent a Bezier curve */
  4780. export class BezierCurve {
  4781. /**
  4782. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4783. * @param t defines the time
  4784. * @param x1 defines the left coordinate on X axis
  4785. * @param y1 defines the left coordinate on Y axis
  4786. * @param x2 defines the right coordinate on X axis
  4787. * @param y2 defines the right coordinate on Y axis
  4788. * @returns the interpolated value
  4789. */
  4790. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4791. }
  4792. /**
  4793. * Defines angle representation
  4794. */
  4795. export class Angle {
  4796. private _radians;
  4797. /**
  4798. * Creates an Angle object of "radians" radians (float).
  4799. * @param radians the angle in radians
  4800. */
  4801. constructor(radians: number);
  4802. /**
  4803. * Get value in degrees
  4804. * @returns the Angle value in degrees (float)
  4805. */
  4806. degrees(): number;
  4807. /**
  4808. * Get value in radians
  4809. * @returns the Angle value in radians (float)
  4810. */
  4811. radians(): number;
  4812. /**
  4813. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4814. * @param a defines first vector
  4815. * @param b defines second vector
  4816. * @returns a new Angle
  4817. */
  4818. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4819. /**
  4820. * Gets a new Angle object from the given float in radians
  4821. * @param radians defines the angle value in radians
  4822. * @returns a new Angle
  4823. */
  4824. static FromRadians(radians: number): Angle;
  4825. /**
  4826. * Gets a new Angle object from the given float in degrees
  4827. * @param degrees defines the angle value in degrees
  4828. * @returns a new Angle
  4829. */
  4830. static FromDegrees(degrees: number): Angle;
  4831. }
  4832. /**
  4833. * This represents an arc in a 2d space.
  4834. */
  4835. export class Arc2 {
  4836. /** Defines the start point of the arc */
  4837. startPoint: Vector2;
  4838. /** Defines the mid point of the arc */
  4839. midPoint: Vector2;
  4840. /** Defines the end point of the arc */
  4841. endPoint: Vector2;
  4842. /**
  4843. * Defines the center point of the arc.
  4844. */
  4845. centerPoint: Vector2;
  4846. /**
  4847. * Defines the radius of the arc.
  4848. */
  4849. radius: number;
  4850. /**
  4851. * Defines the angle of the arc (from mid point to end point).
  4852. */
  4853. angle: Angle;
  4854. /**
  4855. * Defines the start angle of the arc (from start point to middle point).
  4856. */
  4857. startAngle: Angle;
  4858. /**
  4859. * Defines the orientation of the arc (clock wise/counter clock wise).
  4860. */
  4861. orientation: Orientation;
  4862. /**
  4863. * Creates an Arc object from the three given points : start, middle and end.
  4864. * @param startPoint Defines the start point of the arc
  4865. * @param midPoint Defines the midlle point of the arc
  4866. * @param endPoint Defines the end point of the arc
  4867. */
  4868. constructor(
  4869. /** Defines the start point of the arc */
  4870. startPoint: Vector2,
  4871. /** Defines the mid point of the arc */
  4872. midPoint: Vector2,
  4873. /** Defines the end point of the arc */
  4874. endPoint: Vector2);
  4875. }
  4876. /**
  4877. * Represents a 2D path made up of multiple 2D points
  4878. */
  4879. export class Path2 {
  4880. private _points;
  4881. private _length;
  4882. /**
  4883. * If the path start and end point are the same
  4884. */
  4885. closed: boolean;
  4886. /**
  4887. * Creates a Path2 object from the starting 2D coordinates x and y.
  4888. * @param x the starting points x value
  4889. * @param y the starting points y value
  4890. */
  4891. constructor(x: number, y: number);
  4892. /**
  4893. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4894. * @param x the added points x value
  4895. * @param y the added points y value
  4896. * @returns the updated Path2.
  4897. */
  4898. addLineTo(x: number, y: number): Path2;
  4899. /**
  4900. * 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.
  4901. * @param midX middle point x value
  4902. * @param midY middle point y value
  4903. * @param endX end point x value
  4904. * @param endY end point y value
  4905. * @param numberOfSegments (default: 36)
  4906. * @returns the updated Path2.
  4907. */
  4908. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4909. /**
  4910. * Closes the Path2.
  4911. * @returns the Path2.
  4912. */
  4913. close(): Path2;
  4914. /**
  4915. * Gets the sum of the distance between each sequential point in the path
  4916. * @returns the Path2 total length (float).
  4917. */
  4918. length(): number;
  4919. /**
  4920. * Gets the points which construct the path
  4921. * @returns the Path2 internal array of points.
  4922. */
  4923. getPoints(): Vector2[];
  4924. /**
  4925. * Retreives the point at the distance aways from the starting point
  4926. * @param normalizedLengthPosition the length along the path to retreive the point from
  4927. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4928. */
  4929. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4930. /**
  4931. * Creates a new path starting from an x and y position
  4932. * @param x starting x value
  4933. * @param y starting y value
  4934. * @returns a new Path2 starting at the coordinates (x, y).
  4935. */
  4936. static StartingAt(x: number, y: number): Path2;
  4937. }
  4938. /**
  4939. * Represents a 3D path made up of multiple 3D points
  4940. */
  4941. export class Path3D {
  4942. /**
  4943. * an array of Vector3, the curve axis of the Path3D
  4944. */
  4945. path: Vector3[];
  4946. private _curve;
  4947. private _distances;
  4948. private _tangents;
  4949. private _normals;
  4950. private _binormals;
  4951. private _raw;
  4952. private _alignTangentsWithPath;
  4953. private readonly _pointAtData;
  4954. /**
  4955. * new Path3D(path, normal, raw)
  4956. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4957. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4958. * @param path an array of Vector3, the curve axis of the Path3D
  4959. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4960. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4961. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4962. */
  4963. constructor(
  4964. /**
  4965. * an array of Vector3, the curve axis of the Path3D
  4966. */
  4967. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4968. /**
  4969. * Returns the Path3D array of successive Vector3 designing its curve.
  4970. * @returns the Path3D array of successive Vector3 designing its curve.
  4971. */
  4972. getCurve(): Vector3[];
  4973. /**
  4974. * Returns the Path3D array of successive Vector3 designing its curve.
  4975. * @returns the Path3D array of successive Vector3 designing its curve.
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the path.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns an array populated with tangent vectors on each Path3D curve point.
  4984. * @returns an array populated with tangent vectors on each Path3D curve point.
  4985. */
  4986. getTangents(): Vector3[];
  4987. /**
  4988. * Returns an array populated with normal vectors on each Path3D curve point.
  4989. * @returns an array populated with normal vectors on each Path3D curve point.
  4990. */
  4991. getNormals(): Vector3[];
  4992. /**
  4993. * Returns an array populated with binormal vectors on each Path3D curve point.
  4994. * @returns an array populated with binormal vectors on each Path3D curve point.
  4995. */
  4996. getBinormals(): Vector3[];
  4997. /**
  4998. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4999. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5000. */
  5001. getDistances(): number[];
  5002. /**
  5003. * Returns an interpolated point along this path
  5004. * @param position the position of the point along this path, from 0.0 to 1.0
  5005. * @returns a new Vector3 as the point
  5006. */
  5007. getPointAt(position: number): Vector3;
  5008. /**
  5009. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5010. * @param position the position of the point along this path, from 0.0 to 1.0
  5011. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5012. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5013. */
  5014. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5019. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5020. */
  5021. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5026. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5027. */
  5028. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5033. */
  5034. getDistanceAt(position: number): number;
  5035. /**
  5036. * Returns the array index of the previous point of an interpolated point along this path
  5037. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5038. * @returns the array index
  5039. */
  5040. getPreviousPointIndexAt(position: number): number;
  5041. /**
  5042. * 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)
  5043. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5044. * @returns the sub position
  5045. */
  5046. getSubPositionAt(position: number): number;
  5047. /**
  5048. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5049. * @param target the vector of which to get the closest position to
  5050. * @returns the position of the closest virtual point on this path to the target vector
  5051. */
  5052. getClosestPositionTo(target: Vector3): number;
  5053. /**
  5054. * Returns a sub path (slice) of this path
  5055. * @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
  5056. * @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
  5057. * @returns a sub path (slice) of this path
  5058. */
  5059. slice(start?: number, end?: number): Path3D;
  5060. /**
  5061. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5062. * @param path path which all values are copied into the curves points
  5063. * @param firstNormal which should be projected onto the curve
  5064. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5065. * @returns the same object updated.
  5066. */
  5067. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5068. private _compute;
  5069. private _getFirstNonNullVector;
  5070. private _getLastNonNullVector;
  5071. private _normalVector;
  5072. /**
  5073. * Updates the point at data for an interpolated point along this curve
  5074. * @param position the position of the point along this curve, from 0.0 to 1.0
  5075. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5076. * @returns the (updated) point at data
  5077. */
  5078. private _updatePointAtData;
  5079. /**
  5080. * Updates the point at data from the specified parameters
  5081. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5082. * @param point the interpolated point
  5083. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5084. */
  5085. private _setPointAtData;
  5086. /**
  5087. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5088. */
  5089. private _updateInterpolationMatrix;
  5090. }
  5091. /**
  5092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5093. * A Curve3 is designed from a series of successive Vector3.
  5094. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5095. */
  5096. export class Curve3 {
  5097. private _points;
  5098. private _length;
  5099. /**
  5100. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5101. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5102. * @param v1 (Vector3) the control point
  5103. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5104. * @param nbPoints (integer) the wanted number of points in the curve
  5105. * @returns the created Curve3
  5106. */
  5107. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5108. /**
  5109. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5110. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5111. * @param v1 (Vector3) the first control point
  5112. * @param v2 (Vector3) the second control point
  5113. * @param v3 (Vector3) the end point of the Cubic Bezier
  5114. * @param nbPoints (integer) the wanted number of points in the curve
  5115. * @returns the created Curve3
  5116. */
  5117. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5118. /**
  5119. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5120. * @param p1 (Vector3) the origin point of the Hermite Spline
  5121. * @param t1 (Vector3) the tangent vector at the origin point
  5122. * @param p2 (Vector3) the end point of the Hermite Spline
  5123. * @param t2 (Vector3) the tangent vector at the end point
  5124. * @param nbPoints (integer) the wanted number of points in the curve
  5125. * @returns the created Curve3
  5126. */
  5127. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5128. /**
  5129. * Returns a Curve3 object along a CatmullRom Spline curve :
  5130. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5131. * @param nbPoints (integer) the wanted number of points between each curve control points
  5132. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5140. * @param points points which make up the curve
  5141. */
  5142. constructor(points: Vector3[]);
  5143. /**
  5144. * @returns the Curve3 stored array of successive Vector3
  5145. */
  5146. getPoints(): Vector3[];
  5147. /**
  5148. * @returns the computed length (float) of the curve.
  5149. */
  5150. length(): number;
  5151. /**
  5152. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5153. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5154. * curveA and curveB keep unchanged.
  5155. * @param curve the curve to continue from this curve
  5156. * @returns the newly constructed curve
  5157. */
  5158. continue(curve: DeepImmutable<Curve3>): Curve3;
  5159. private _computeLength;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * This represents the main contract an easing function should follow.
  5165. * Easing functions are used throughout the animation system.
  5166. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5167. */
  5168. export interface IEasingFunction {
  5169. /**
  5170. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5171. * of the easing function.
  5172. * The link below provides some of the most common examples of easing functions.
  5173. * @see https://easings.net/
  5174. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5175. * @returns the corresponding value on the curve defined by the easing function
  5176. */
  5177. ease(gradient: number): number;
  5178. }
  5179. /**
  5180. * Base class used for every default easing function.
  5181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5182. */
  5183. export class EasingFunction implements IEasingFunction {
  5184. /**
  5185. * Interpolation follows the mathematical formula associated with the easing function.
  5186. */
  5187. static readonly EASINGMODE_EASEIN: number;
  5188. /**
  5189. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5190. */
  5191. static readonly EASINGMODE_EASEOUT: number;
  5192. /**
  5193. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5194. */
  5195. static readonly EASINGMODE_EASEINOUT: number;
  5196. private _easingMode;
  5197. /**
  5198. * Sets the easing mode of the current function.
  5199. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5200. */
  5201. setEasingMode(easingMode: number): void;
  5202. /**
  5203. * Gets the current easing mode.
  5204. * @returns the easing mode
  5205. */
  5206. getEasingMode(): number;
  5207. /**
  5208. * @hidden
  5209. */
  5210. easeInCore(gradient: number): number;
  5211. /**
  5212. * Given an input gradient between 0 and 1, this returns the corresponding value
  5213. * of the easing function.
  5214. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5215. * @returns the corresponding value on the curve defined by the easing function
  5216. */
  5217. ease(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a circle shape (see link below).
  5221. * @see https://easings.net/#easeInCirc
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class CircleEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a ease back shape (see link below).
  5230. * @see https://easings.net/#easeInBack
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BackEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the amplitude of the function */
  5235. amplitude: number;
  5236. /**
  5237. * Instantiates a back ease easing
  5238. * @see https://easings.net/#easeInBack
  5239. * @param amplitude Defines the amplitude of the function
  5240. */
  5241. constructor(
  5242. /** Defines the amplitude of the function */
  5243. amplitude?: number);
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a bouncing shape (see link below).
  5249. * @see https://easings.net/#easeInBounce
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class BounceEase extends EasingFunction implements IEasingFunction {
  5253. /** Defines the number of bounces */
  5254. bounces: number;
  5255. /** Defines the amplitude of the bounce */
  5256. bounciness: number;
  5257. /**
  5258. * Instantiates a bounce easing
  5259. * @see https://easings.net/#easeInBounce
  5260. * @param bounces Defines the number of bounces
  5261. * @param bounciness Defines the amplitude of the bounce
  5262. */
  5263. constructor(
  5264. /** Defines the number of bounces */
  5265. bounces?: number,
  5266. /** Defines the amplitude of the bounce */
  5267. bounciness?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 3 shape (see link below).
  5273. * @see https://easings.net/#easeInCubic
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class CubicEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with an elastic shape (see link below).
  5282. * @see https://easings.net/#easeInElastic
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the number of oscillations*/
  5287. oscillations: number;
  5288. /** Defines the amplitude of the oscillations*/
  5289. springiness: number;
  5290. /**
  5291. * Instantiates an elastic easing function
  5292. * @see https://easings.net/#easeInElastic
  5293. * @param oscillations Defines the number of oscillations
  5294. * @param springiness Defines the amplitude of the oscillations
  5295. */
  5296. constructor(
  5297. /** Defines the number of oscillations*/
  5298. oscillations?: number,
  5299. /** Defines the amplitude of the oscillations*/
  5300. springiness?: number);
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an exponential shape (see link below).
  5306. * @see https://easings.net/#easeInExpo
  5307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the exponent of the function */
  5311. exponent: number;
  5312. /**
  5313. * Instantiates an exponential easing function
  5314. * @see https://easings.net/#easeInExpo
  5315. * @param exponent Defines the exponent of the function
  5316. */
  5317. constructor(
  5318. /** Defines the exponent of the function */
  5319. exponent?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a power shape (see link below).
  5325. * @see https://easings.net/#easeInQuad
  5326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class PowerEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the power of the function */
  5330. power: number;
  5331. /**
  5332. * Instantiates an power base easing function
  5333. * @see https://easings.net/#easeInQuad
  5334. * @param power Defines the power of the function
  5335. */
  5336. constructor(
  5337. /** Defines the power of the function */
  5338. power?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with a power of 2 shape (see link below).
  5344. * @see https://easings.net/#easeInQuad
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a power of 4 shape (see link below).
  5353. * @see https://easings.net/#easeInQuart
  5354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5357. /** @hidden */
  5358. easeInCore(gradient: number): number;
  5359. }
  5360. /**
  5361. * Easing function with a power of 5 shape (see link below).
  5362. * @see https://easings.net/#easeInQuint
  5363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5364. */
  5365. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a sin shape (see link below).
  5371. * @see https://easings.net/#easeInSine
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class SineEase extends EasingFunction implements IEasingFunction {
  5375. /** @hidden */
  5376. easeInCore(gradient: number): number;
  5377. }
  5378. /**
  5379. * Easing function with a bezier shape (see link below).
  5380. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5382. */
  5383. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5384. /** Defines the x component of the start tangent in the bezier curve */
  5385. x1: number;
  5386. /** Defines the y component of the start tangent in the bezier curve */
  5387. y1: number;
  5388. /** Defines the x component of the end tangent in the bezier curve */
  5389. x2: number;
  5390. /** Defines the y component of the end tangent in the bezier curve */
  5391. y2: number;
  5392. /**
  5393. * Instantiates a bezier function
  5394. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5395. * @param x1 Defines the x component of the start tangent in the bezier curve
  5396. * @param y1 Defines the y component of the start tangent in the bezier curve
  5397. * @param x2 Defines the x component of the end tangent in the bezier curve
  5398. * @param y2 Defines the y component of the end tangent in the bezier curve
  5399. */
  5400. constructor(
  5401. /** Defines the x component of the start tangent in the bezier curve */
  5402. x1?: number,
  5403. /** Defines the y component of the start tangent in the bezier curve */
  5404. y1?: number,
  5405. /** Defines the x component of the end tangent in the bezier curve */
  5406. x2?: number,
  5407. /** Defines the y component of the end tangent in the bezier curve */
  5408. y2?: number);
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. /**
  5415. * Class used to hold a RBG color
  5416. */
  5417. export class Color3 {
  5418. /**
  5419. * Defines the red component (between 0 and 1, default is 0)
  5420. */
  5421. r: number;
  5422. /**
  5423. * Defines the green component (between 0 and 1, default is 0)
  5424. */
  5425. g: number;
  5426. /**
  5427. * Defines the blue component (between 0 and 1, default is 0)
  5428. */
  5429. b: number;
  5430. /**
  5431. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5432. * @param r defines the red component (between 0 and 1, default is 0)
  5433. * @param g defines the green component (between 0 and 1, default is 0)
  5434. * @param b defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. constructor(
  5437. /**
  5438. * Defines the red component (between 0 and 1, default is 0)
  5439. */
  5440. r?: number,
  5441. /**
  5442. * Defines the green component (between 0 and 1, default is 0)
  5443. */
  5444. g?: number,
  5445. /**
  5446. * Defines the blue component (between 0 and 1, default is 0)
  5447. */
  5448. b?: number);
  5449. /**
  5450. * Creates a string with the Color3 current values
  5451. * @returns the string representation of the Color3 object
  5452. */
  5453. toString(): string;
  5454. /**
  5455. * Returns the string "Color3"
  5456. * @returns "Color3"
  5457. */
  5458. getClassName(): string;
  5459. /**
  5460. * Compute the Color3 hash code
  5461. * @returns an unique number that can be used to hash Color3 objects
  5462. */
  5463. getHashCode(): number;
  5464. /**
  5465. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5466. * @param array defines the array where to store the r,g,b components
  5467. * @param index defines an optional index in the target array to define where to start storing values
  5468. * @returns the current Color3 object
  5469. */
  5470. toArray(array: FloatArray, index?: number): Color3;
  5471. /**
  5472. * Returns a new Color4 object from the current Color3 and the given alpha
  5473. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5474. * @returns a new Color4 object
  5475. */
  5476. toColor4(alpha?: number): Color4;
  5477. /**
  5478. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Returns the luminance value
  5484. * @returns a float value
  5485. */
  5486. toLuminance(): number;
  5487. /**
  5488. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5489. * @param otherColor defines the second operand
  5490. * @returns the new Color3 object
  5491. */
  5492. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5493. /**
  5494. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5495. * @param otherColor defines the second operand
  5496. * @param result defines the Color3 object where to store the result
  5497. * @returns the current Color3
  5498. */
  5499. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5500. /**
  5501. * Determines equality between Color3 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgb values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color3>): boolean;
  5506. /**
  5507. * Determines equality between the current Color3 object and a set of r,b,g values
  5508. * @param r defines the red component to check
  5509. * @param g defines the green component to check
  5510. * @param b defines the blue component to check
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equalsFloats(r: number, g: number, b: number): boolean;
  5514. /**
  5515. * Multiplies in place each rgb value by scale
  5516. * @param scale defines the scaling factor
  5517. * @returns the updated Color3
  5518. */
  5519. scale(scale: number): Color3;
  5520. /**
  5521. * Multiplies the rgb values by scale and stores the result into "result"
  5522. * @param scale defines the scaling factor
  5523. * @param result defines the Color3 object where to store the result
  5524. * @returns the unmodified current Color3
  5525. */
  5526. scaleToRef(scale: number, result: Color3): Color3;
  5527. /**
  5528. * Scale the current Color3 values by a factor and add the result to a given Color3
  5529. * @param scale defines the scale factor
  5530. * @param result defines color to store the result into
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into
  5539. * @returns the original Color3
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5542. /**
  5543. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5544. * @param otherColor defines the second operand
  5545. * @returns the new Color3
  5546. */
  5547. add(otherColor: DeepImmutable<Color3>): Color3;
  5548. /**
  5549. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5550. * @param otherColor defines the second operand
  5551. * @param result defines Color3 object to store the result into
  5552. * @returns the unmodified current Color3
  5553. */
  5554. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5555. /**
  5556. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5557. * @param otherColor defines the second operand
  5558. * @returns the new Color3
  5559. */
  5560. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5561. /**
  5562. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5563. * @param otherColor defines the second operand
  5564. * @param result defines Color3 object to store the result into
  5565. * @returns the unmodified current Color3
  5566. */
  5567. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5568. /**
  5569. * Copy the current object
  5570. * @returns a new Color3 copied the current one
  5571. */
  5572. clone(): Color3;
  5573. /**
  5574. * Copies the rgb values from the source in the current Color3
  5575. * @param source defines the source Color3 object
  5576. * @returns the updated Color3 object
  5577. */
  5578. copyFrom(source: DeepImmutable<Color3>): Color3;
  5579. /**
  5580. * Updates the Color3 rgb values from the given floats
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @returns the current Color3 object
  5585. */
  5586. copyFromFloats(r: number, g: number, b: number): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. set(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Compute the Color3 hexadecimal code as a string
  5597. * @returns a string containing the hexadecimal representation of the Color3 object
  5598. */
  5599. toHexString(): string;
  5600. /**
  5601. * Computes a new Color3 converted from the current one to linear space
  5602. * @returns a new Color3 object
  5603. */
  5604. toLinearSpace(): Color3;
  5605. /**
  5606. * Converts current color in rgb space to HSV values
  5607. * @returns a new color3 representing the HSV values
  5608. */
  5609. toHSV(): Color3;
  5610. /**
  5611. * Converts current color in rgb space to HSV values
  5612. * @param result defines the Color3 where to store the HSV values
  5613. */
  5614. toHSVToRef(result: Color3): void;
  5615. /**
  5616. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5617. * @param convertedColor defines the Color3 object where to store the linear space version
  5618. * @returns the unmodified Color3
  5619. */
  5620. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5621. /**
  5622. * Computes a new Color3 converted from the current one to gamma space
  5623. * @returns a new Color3 object
  5624. */
  5625. toGammaSpace(): Color3;
  5626. /**
  5627. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5628. * @param convertedColor defines the Color3 object where to store the gamma space version
  5629. * @returns the unmodified Color3
  5630. */
  5631. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5632. private static _BlackReadOnly;
  5633. /**
  5634. * Convert Hue, saturation and value to a Color3 (RGB)
  5635. * @param hue defines the hue
  5636. * @param saturation defines the saturation
  5637. * @param value defines the value
  5638. * @param result defines the Color3 where to store the RGB values
  5639. */
  5640. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5641. /**
  5642. * Creates a new Color3 from the string containing valid hexadecimal values
  5643. * @param hex defines a string containing valid hexadecimal values
  5644. * @returns a new Color3 object
  5645. */
  5646. static FromHexString(hex: string): Color3;
  5647. /**
  5648. * Creates a new Color3 from the starting index of the given array
  5649. * @param array defines the source array
  5650. * @param offset defines an offset in the source array
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5654. /**
  5655. * Creates a new Color3 from integer values (< 256)
  5656. * @param r defines the red component to read from (value between 0 and 255)
  5657. * @param g defines the green component to read from (value between 0 and 255)
  5658. * @param b defines the blue component to read from (value between 0 and 255)
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromInts(r: number, g: number, b: number): Color3;
  5662. /**
  5663. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5664. * @param start defines the start Color3 value
  5665. * @param end defines the end Color3 value
  5666. * @param amount defines the gradient value between start and end
  5667. * @returns a new Color3 object
  5668. */
  5669. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param left defines the start value
  5673. * @param right defines the end value
  5674. * @param amount defines the gradient factor
  5675. * @param result defines the Color3 object where to store the result
  5676. */
  5677. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5678. /**
  5679. * Returns a Color3 value containing a red color
  5680. * @returns a new Color3 object
  5681. */
  5682. static Red(): Color3;
  5683. /**
  5684. * Returns a Color3 value containing a green color
  5685. * @returns a new Color3 object
  5686. */
  5687. static Green(): Color3;
  5688. /**
  5689. * Returns a Color3 value containing a blue color
  5690. * @returns a new Color3 object
  5691. */
  5692. static Blue(): Color3;
  5693. /**
  5694. * Returns a Color3 value containing a black color
  5695. * @returns a new Color3 object
  5696. */
  5697. static Black(): Color3;
  5698. /**
  5699. * Gets a Color3 value containing a black color that must not be updated
  5700. */
  5701. static get BlackReadOnly(): DeepImmutable<Color3>;
  5702. /**
  5703. * Returns a Color3 value containing a white color
  5704. * @returns a new Color3 object
  5705. */
  5706. static White(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a purple color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Purple(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a magenta color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Magenta(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a yellow color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Yellow(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a gray color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Gray(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a teal color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Teal(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a random color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Random(): Color3;
  5737. }
  5738. /**
  5739. * Class used to hold a RBGA color
  5740. */
  5741. export class Color4 {
  5742. /**
  5743. * Defines the red component (between 0 and 1, default is 0)
  5744. */
  5745. r: number;
  5746. /**
  5747. * Defines the green component (between 0 and 1, default is 0)
  5748. */
  5749. g: number;
  5750. /**
  5751. * Defines the blue component (between 0 and 1, default is 0)
  5752. */
  5753. b: number;
  5754. /**
  5755. * Defines the alpha component (between 0 and 1, default is 1)
  5756. */
  5757. a: number;
  5758. /**
  5759. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5760. * @param r defines the red component (between 0 and 1, default is 0)
  5761. * @param g defines the green component (between 0 and 1, default is 0)
  5762. * @param b defines the blue component (between 0 and 1, default is 0)
  5763. * @param a defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. constructor(
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r?: number,
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g?: number,
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b?: number,
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a?: number);
  5782. /**
  5783. * Adds in place the given Color4 values to the current Color4 object
  5784. * @param right defines the second operand
  5785. * @returns the current updated Color4 object
  5786. */
  5787. addInPlace(right: DeepImmutable<Color4>): Color4;
  5788. /**
  5789. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5790. * @returns the new array
  5791. */
  5792. asArray(): number[];
  5793. /**
  5794. * Stores from the starting index in the given array the Color4 successive values
  5795. * @param array defines the array where to store the r,g,b components
  5796. * @param index defines an optional index in the target array to define where to start storing values
  5797. * @returns the current Color4 object
  5798. */
  5799. toArray(array: number[], index?: number): Color4;
  5800. /**
  5801. * Determines equality between Color4 objects
  5802. * @param otherColor defines the second operand
  5803. * @returns true if the rgba values are equal to the given ones
  5804. */
  5805. equals(otherColor: DeepImmutable<Color4>): boolean;
  5806. /**
  5807. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5808. * @param right defines the second operand
  5809. * @returns a new Color4 object
  5810. */
  5811. add(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5814. * @param right defines the second operand
  5815. * @returns a new Color4 object
  5816. */
  5817. subtract(right: DeepImmutable<Color4>): Color4;
  5818. /**
  5819. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5820. * @param right defines the second operand
  5821. * @param result defines the Color4 object where to store the result
  5822. * @returns the current Color4 object
  5823. */
  5824. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5825. /**
  5826. * Creates a new Color4 with the current Color4 values multiplied by scale
  5827. * @param scale defines the scaling factor to apply
  5828. * @returns a new Color4 object
  5829. */
  5830. scale(scale: number): Color4;
  5831. /**
  5832. * Multiplies the current Color4 values by scale and stores the result in "result"
  5833. * @param scale defines the scaling factor to apply
  5834. * @param result defines the Color4 object where to store the result
  5835. * @returns the current unmodified Color4
  5836. */
  5837. scaleToRef(scale: number, result: Color4): Color4;
  5838. /**
  5839. * Scale the current Color4 values by a factor and add the result to a given Color4
  5840. * @param scale defines the scale factor
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the unmodified current Color4
  5843. */
  5844. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Clamps the rgb values by the min and max values and stores the result into "result"
  5847. * @param min defines minimum clamping value (default is 0)
  5848. * @param max defines maximum clamping value (default is 1)
  5849. * @param result defines color to store the result into.
  5850. * @returns the cuurent Color4
  5851. */
  5852. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5853. /**
  5854. * Multipy an Color4 value by another and return a new Color4 object
  5855. * @param color defines the Color4 value to multiply by
  5856. * @returns a new Color4 object
  5857. */
  5858. multiply(color: Color4): Color4;
  5859. /**
  5860. * Multipy a Color4 value by another and push the result in a reference value
  5861. * @param color defines the Color4 value to multiply by
  5862. * @param result defines the Color4 to fill the result in
  5863. * @returns the result Color4
  5864. */
  5865. multiplyToRef(color: Color4, result: Color4): Color4;
  5866. /**
  5867. * Creates a string with the Color4 current values
  5868. * @returns the string representation of the Color4 object
  5869. */
  5870. toString(): string;
  5871. /**
  5872. * Returns the string "Color4"
  5873. * @returns "Color4"
  5874. */
  5875. getClassName(): string;
  5876. /**
  5877. * Compute the Color4 hash code
  5878. * @returns an unique number that can be used to hash Color4 objects
  5879. */
  5880. getHashCode(): number;
  5881. /**
  5882. * Creates a new Color4 copied from the current one
  5883. * @returns a new Color4 object
  5884. */
  5885. clone(): Color4;
  5886. /**
  5887. * Copies the given Color4 values into the current one
  5888. * @param source defines the source Color4 object
  5889. * @returns the current updated Color4 object
  5890. */
  5891. copyFrom(source: Color4): Color4;
  5892. /**
  5893. * Copies the given float values into the current one
  5894. * @param r defines the red component to read from
  5895. * @param g defines the green component to read from
  5896. * @param b defines the blue component to read from
  5897. * @param a defines the alpha component to read from
  5898. * @returns the current updated Color4 object
  5899. */
  5900. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5901. /**
  5902. * Copies the given float values into the current one
  5903. * @param r defines the red component to read from
  5904. * @param g defines the green component to read from
  5905. * @param b defines the blue component to read from
  5906. * @param a defines the alpha component to read from
  5907. * @returns the current updated Color4 object
  5908. */
  5909. set(r: number, g: number, b: number, a: number): Color4;
  5910. /**
  5911. * Compute the Color4 hexadecimal code as a string
  5912. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5913. * @returns a string containing the hexadecimal representation of the Color4 object
  5914. */
  5915. toHexString(returnAsColor3?: boolean): string;
  5916. /**
  5917. * Computes a new Color4 converted from the current one to linear space
  5918. * @returns a new Color4 object
  5919. */
  5920. toLinearSpace(): Color4;
  5921. /**
  5922. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5923. * @param convertedColor defines the Color4 object where to store the linear space version
  5924. * @returns the unmodified Color4
  5925. */
  5926. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5927. /**
  5928. * Computes a new Color4 converted from the current one to gamma space
  5929. * @returns a new Color4 object
  5930. */
  5931. toGammaSpace(): Color4;
  5932. /**
  5933. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5934. * @param convertedColor defines the Color4 object where to store the gamma space version
  5935. * @returns the unmodified Color4
  5936. */
  5937. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 from the string containing valid hexadecimal values
  5940. * @param hex defines a string containing valid hexadecimal values
  5941. * @returns a new Color4 object
  5942. */
  5943. static FromHexString(hex: string): Color4;
  5944. /**
  5945. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5946. * @param left defines the start value
  5947. * @param right defines the end value
  5948. * @param amount defines the gradient factor
  5949. * @returns a new Color4 object
  5950. */
  5951. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5952. /**
  5953. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @param result defines the Color4 object where to store data
  5958. */
  5959. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5960. /**
  5961. * Creates a new Color4 from a Color3 and an alpha value
  5962. * @param color3 defines the source Color3 to read from
  5963. * @param alpha defines the alpha component (1.0 by default)
  5964. * @returns a new Color4 object
  5965. */
  5966. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5967. /**
  5968. * Creates a new Color4 from the starting index element of the given array
  5969. * @param array defines the source array to read from
  5970. * @param offset defines the offset in the source array
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5974. /**
  5975. * Creates a new Color3 from integer values (< 256)
  5976. * @param r defines the red component to read from (value between 0 and 255)
  5977. * @param g defines the green component to read from (value between 0 and 255)
  5978. * @param b defines the blue component to read from (value between 0 and 255)
  5979. * @param a defines the alpha component to read from (value between 0 and 255)
  5980. * @returns a new Color3 object
  5981. */
  5982. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Check the content of a given array and convert it to an array containing RGBA data
  5985. * If the original array was already containing count * 4 values then it is returned directly
  5986. * @param colors defines the array to check
  5987. * @param count defines the number of RGBA data to expect
  5988. * @returns an array containing count * 4 values (RGBA)
  5989. */
  5990. static CheckColors4(colors: number[], count: number): number[];
  5991. }
  5992. /**
  5993. * @hidden
  5994. */
  5995. export class TmpColors {
  5996. static Color3: Color3[];
  5997. static Color4: Color4[];
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * Defines an interface which represents an animation key frame
  6003. */
  6004. export interface IAnimationKey {
  6005. /**
  6006. * Frame of the key frame
  6007. */
  6008. frame: number;
  6009. /**
  6010. * Value at the specifies key frame
  6011. */
  6012. value: any;
  6013. /**
  6014. * The input tangent for the cubic hermite spline
  6015. */
  6016. inTangent?: any;
  6017. /**
  6018. * The output tangent for the cubic hermite spline
  6019. */
  6020. outTangent?: any;
  6021. /**
  6022. * The animation interpolation type
  6023. */
  6024. interpolation?: AnimationKeyInterpolation;
  6025. }
  6026. /**
  6027. * Enum for the animation key frame interpolation type
  6028. */
  6029. export enum AnimationKeyInterpolation {
  6030. /**
  6031. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6032. */
  6033. STEP = 1
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Represents the range of an animation
  6039. */
  6040. export class AnimationRange {
  6041. /**The name of the animation range**/
  6042. name: string;
  6043. /**The starting frame of the animation */
  6044. from: number;
  6045. /**The ending frame of the animation*/
  6046. to: number;
  6047. /**
  6048. * Initializes the range of an animation
  6049. * @param name The name of the animation range
  6050. * @param from The starting frame of the animation
  6051. * @param to The ending frame of the animation
  6052. */
  6053. constructor(
  6054. /**The name of the animation range**/
  6055. name: string,
  6056. /**The starting frame of the animation */
  6057. from: number,
  6058. /**The ending frame of the animation*/
  6059. to: number);
  6060. /**
  6061. * Makes a copy of the animation range
  6062. * @returns A copy of the animation range
  6063. */
  6064. clone(): AnimationRange;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * Composed of a frame, and an action function
  6070. */
  6071. export class AnimationEvent {
  6072. /** The frame for which the event is triggered **/
  6073. frame: number;
  6074. /** The event to perform when triggered **/
  6075. action: (currentFrame: number) => void;
  6076. /** Specifies if the event should be triggered only once**/
  6077. onlyOnce?: boolean | undefined;
  6078. /**
  6079. * Specifies if the animation event is done
  6080. */
  6081. isDone: boolean;
  6082. /**
  6083. * Initializes the animation event
  6084. * @param frame The frame for which the event is triggered
  6085. * @param action The event to perform when triggered
  6086. * @param onlyOnce Specifies if the event should be triggered only once
  6087. */
  6088. constructor(
  6089. /** The frame for which the event is triggered **/
  6090. frame: number,
  6091. /** The event to perform when triggered **/
  6092. action: (currentFrame: number) => void,
  6093. /** Specifies if the event should be triggered only once**/
  6094. onlyOnce?: boolean | undefined);
  6095. /** @hidden */
  6096. _clone(): AnimationEvent;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Interface used to define a behavior
  6102. */
  6103. export interface Behavior<T> {
  6104. /** gets or sets behavior's name */
  6105. name: string;
  6106. /**
  6107. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6108. */
  6109. init(): void;
  6110. /**
  6111. * Called when the behavior is attached to a target
  6112. * @param target defines the target where the behavior is attached to
  6113. */
  6114. attach(target: T): void;
  6115. /**
  6116. * Called when the behavior is detached from its target
  6117. */
  6118. detach(): void;
  6119. }
  6120. /**
  6121. * Interface implemented by classes supporting behaviors
  6122. */
  6123. export interface IBehaviorAware<T> {
  6124. /**
  6125. * Attach a behavior
  6126. * @param behavior defines the behavior to attach
  6127. * @returns the current host
  6128. */
  6129. addBehavior(behavior: Behavior<T>): T;
  6130. /**
  6131. * Remove a behavior from the current object
  6132. * @param behavior defines the behavior to detach
  6133. * @returns the current host
  6134. */
  6135. removeBehavior(behavior: Behavior<T>): T;
  6136. /**
  6137. * Gets a behavior using its name to search
  6138. * @param name defines the name to search
  6139. * @returns the behavior or null if not found
  6140. */
  6141. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * Defines an array and its length.
  6147. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6148. */
  6149. export interface ISmartArrayLike<T> {
  6150. /**
  6151. * The data of the array.
  6152. */
  6153. data: Array<T>;
  6154. /**
  6155. * The active length of the array.
  6156. */
  6157. length: number;
  6158. }
  6159. /**
  6160. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6161. */
  6162. export class SmartArray<T> implements ISmartArrayLike<T> {
  6163. /**
  6164. * The full set of data from the array.
  6165. */
  6166. data: Array<T>;
  6167. /**
  6168. * The active length of the array.
  6169. */
  6170. length: number;
  6171. protected _id: number;
  6172. /**
  6173. * Instantiates a Smart Array.
  6174. * @param capacity defines the default capacity of the array.
  6175. */
  6176. constructor(capacity: number);
  6177. /**
  6178. * Pushes a value at the end of the active data.
  6179. * @param value defines the object to push in the array.
  6180. */
  6181. push(value: T): void;
  6182. /**
  6183. * Iterates over the active data and apply the lambda to them.
  6184. * @param func defines the action to apply on each value.
  6185. */
  6186. forEach(func: (content: T) => void): void;
  6187. /**
  6188. * Sorts the full sets of data.
  6189. * @param compareFn defines the comparison function to apply.
  6190. */
  6191. sort(compareFn: (a: T, b: T) => number): void;
  6192. /**
  6193. * Resets the active data to an empty array.
  6194. */
  6195. reset(): void;
  6196. /**
  6197. * Releases all the data from the array as well as the array.
  6198. */
  6199. dispose(): void;
  6200. /**
  6201. * Concats the active data with a given array.
  6202. * @param array defines the data to concatenate with.
  6203. */
  6204. concat(array: any): void;
  6205. /**
  6206. * Returns the position of a value in the active data.
  6207. * @param value defines the value to find the index for
  6208. * @returns the index if found in the active data otherwise -1
  6209. */
  6210. indexOf(value: T): number;
  6211. /**
  6212. * Returns whether an element is part of the active data.
  6213. * @param value defines the value to look for
  6214. * @returns true if found in the active data otherwise false
  6215. */
  6216. contains(value: T): boolean;
  6217. private static _GlobalId;
  6218. }
  6219. /**
  6220. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6221. * The data in this array can only be present once
  6222. */
  6223. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6224. private _duplicateId;
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6228. * @param value defines the object to push in the array.
  6229. */
  6230. push(value: T): void;
  6231. /**
  6232. * Pushes a value at the end of the active data.
  6233. * If the data is already present, it won t be added again
  6234. * @param value defines the object to push in the array.
  6235. * @returns true if added false if it was already present
  6236. */
  6237. pushNoDuplicate(value: T): boolean;
  6238. /**
  6239. * Resets the active data to an empty array.
  6240. */
  6241. reset(): void;
  6242. /**
  6243. * Concats the active data with a given array.
  6244. * This ensures no dupplicate will be present in the result.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concatWithNoDuplicate(array: any): void;
  6248. }
  6249. }
  6250. declare module BABYLON {
  6251. /**
  6252. * @ignore
  6253. * This is a list of all the different input types that are available in the application.
  6254. * Fo instance: ArcRotateCameraGamepadInput...
  6255. */
  6256. export var CameraInputTypes: {};
  6257. /**
  6258. * This is the contract to implement in order to create a new input class.
  6259. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6260. */
  6261. export interface ICameraInput<TCamera extends Camera> {
  6262. /**
  6263. * Defines the camera the input is attached to.
  6264. */
  6265. camera: Nullable<TCamera>;
  6266. /**
  6267. * Gets the class name of the current intput.
  6268. * @returns the class name
  6269. */
  6270. getClassName(): string;
  6271. /**
  6272. * Get the friendly name associated with the input class.
  6273. * @returns the input friendly name
  6274. */
  6275. getSimpleName(): string;
  6276. /**
  6277. * Attach the input controls to a specific dom element to get the input from.
  6278. * @param element Defines the element the controls should be listened from
  6279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6280. */
  6281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6282. /**
  6283. * Detach the current controls from the specified dom element.
  6284. * @param element Defines the element to stop listening the inputs from
  6285. */
  6286. detachControl(element: Nullable<HTMLElement>): void;
  6287. /**
  6288. * Update the current camera state depending on the inputs that have been used this frame.
  6289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6290. */
  6291. checkInputs?: () => void;
  6292. }
  6293. /**
  6294. * Represents a map of input types to input instance or input index to input instance.
  6295. */
  6296. export interface CameraInputsMap<TCamera extends Camera> {
  6297. /**
  6298. * Accessor to the input by input type.
  6299. */
  6300. [name: string]: ICameraInput<TCamera>;
  6301. /**
  6302. * Accessor to the input by input index.
  6303. */
  6304. [idx: number]: ICameraInput<TCamera>;
  6305. }
  6306. /**
  6307. * This represents the input manager used within a camera.
  6308. * It helps dealing with all the different kind of input attached to a camera.
  6309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6310. */
  6311. export class CameraInputsManager<TCamera extends Camera> {
  6312. /**
  6313. * Defines the list of inputs attahed to the camera.
  6314. */
  6315. attached: CameraInputsMap<TCamera>;
  6316. /**
  6317. * Defines the dom element the camera is collecting inputs from.
  6318. * This is null if the controls have not been attached.
  6319. */
  6320. attachedElement: Nullable<HTMLElement>;
  6321. /**
  6322. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. noPreventDefault: boolean;
  6325. /**
  6326. * Defined the camera the input manager belongs to.
  6327. */
  6328. camera: TCamera;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs: () => void;
  6334. /**
  6335. * Instantiate a new Camera Input Manager.
  6336. * @param camera Defines the camera the input manager blongs to
  6337. */
  6338. constructor(camera: TCamera);
  6339. /**
  6340. * Add an input method to a camera
  6341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6342. * @param input camera input method
  6343. */
  6344. add(input: ICameraInput<TCamera>): void;
  6345. /**
  6346. * Remove a specific input method from a camera
  6347. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6348. * @param inputToRemove camera input method
  6349. */
  6350. remove(inputToRemove: ICameraInput<TCamera>): void;
  6351. /**
  6352. * Remove a specific input type from a camera
  6353. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6354. * @param inputType the type of the input to remove
  6355. */
  6356. removeByType(inputType: string): void;
  6357. private _addCheckInputs;
  6358. /**
  6359. * Attach the input controls to the currently attached dom element to listen the events from.
  6360. * @param input Defines the input to attach
  6361. */
  6362. attachInput(input: ICameraInput<TCamera>): void;
  6363. /**
  6364. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6365. * @param element Defines the dom element to collect the events from
  6366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6367. */
  6368. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6369. /**
  6370. * Detach the current manager inputs controls from a specific dom element.
  6371. * @param element Defines the dom element to collect the events from
  6372. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6373. */
  6374. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6375. /**
  6376. * Rebuild the dynamic inputCheck function from the current list of
  6377. * defined inputs in the manager.
  6378. */
  6379. rebuildInputCheck(): void;
  6380. /**
  6381. * Remove all attached input methods from a camera
  6382. */
  6383. clear(): void;
  6384. /**
  6385. * Serialize the current input manager attached to a camera.
  6386. * This ensures than once parsed,
  6387. * the input associated to the camera will be identical to the current ones
  6388. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6389. */
  6390. serialize(serializedCamera: any): void;
  6391. /**
  6392. * Parses an input manager serialized JSON to restore the previous list of inputs
  6393. * and states associated to a camera.
  6394. * @param parsedCamera Defines the JSON to parse
  6395. */
  6396. parse(parsedCamera: any): void;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. /**
  6401. * Class used to store data that will be store in GPU memory
  6402. */
  6403. export class Buffer {
  6404. private _engine;
  6405. private _buffer;
  6406. /** @hidden */
  6407. _data: Nullable<DataArray>;
  6408. private _updatable;
  6409. private _instanced;
  6410. private _divisor;
  6411. /**
  6412. * Gets the byte stride.
  6413. */
  6414. readonly byteStride: number;
  6415. /**
  6416. * Constructor
  6417. * @param engine the engine
  6418. * @param data the data to use for this buffer
  6419. * @param updatable whether the data is updatable
  6420. * @param stride the stride (optional)
  6421. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6422. * @param instanced whether the buffer is instanced (optional)
  6423. * @param useBytes set to true if the stride in in bytes (optional)
  6424. * @param divisor sets an optional divisor for instances (1 by default)
  6425. */
  6426. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6427. /**
  6428. * Create a new VertexBuffer based on the current buffer
  6429. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6430. * @param offset defines offset in the buffer (0 by default)
  6431. * @param size defines the size in floats of attributes (position is 3 for instance)
  6432. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6433. * @param instanced defines if the vertex buffer contains indexed data
  6434. * @param useBytes defines if the offset and stride are in bytes *
  6435. * @param divisor sets an optional divisor for instances (1 by default)
  6436. * @returns the new vertex buffer
  6437. */
  6438. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6439. /**
  6440. * Gets a boolean indicating if the Buffer is updatable?
  6441. * @returns true if the buffer is updatable
  6442. */
  6443. isUpdatable(): boolean;
  6444. /**
  6445. * Gets current buffer's data
  6446. * @returns a DataArray or null
  6447. */
  6448. getData(): Nullable<DataArray>;
  6449. /**
  6450. * Gets underlying native buffer
  6451. * @returns underlying native buffer
  6452. */
  6453. getBuffer(): Nullable<DataBuffer>;
  6454. /**
  6455. * Gets the stride in float32 units (i.e. byte stride / 4).
  6456. * May not be an integer if the byte stride is not divisible by 4.
  6457. * @returns the stride in float32 units
  6458. * @deprecated Please use byteStride instead.
  6459. */
  6460. getStrideSize(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: Nullable<DataArray>): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /**
  6469. * Update current buffer data
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates the data directly.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param vertexCount the vertex count (optional)
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6481. /**
  6482. * Release all resources
  6483. */
  6484. dispose(): void;
  6485. }
  6486. /**
  6487. * Specialized buffer used to store vertex data
  6488. */
  6489. export class VertexBuffer {
  6490. /** @hidden */
  6491. _buffer: Buffer;
  6492. private _kind;
  6493. private _size;
  6494. private _ownsBuffer;
  6495. private _instanced;
  6496. private _instanceDivisor;
  6497. /**
  6498. * The byte type.
  6499. */
  6500. static readonly BYTE: number;
  6501. /**
  6502. * The unsigned byte type.
  6503. */
  6504. static readonly UNSIGNED_BYTE: number;
  6505. /**
  6506. * The short type.
  6507. */
  6508. static readonly SHORT: number;
  6509. /**
  6510. * The unsigned short type.
  6511. */
  6512. static readonly UNSIGNED_SHORT: number;
  6513. /**
  6514. * The integer type.
  6515. */
  6516. static readonly INT: number;
  6517. /**
  6518. * The unsigned integer type.
  6519. */
  6520. static readonly UNSIGNED_INT: number;
  6521. /**
  6522. * The float type.
  6523. */
  6524. static readonly FLOAT: number;
  6525. /**
  6526. * Gets or sets the instance divisor when in instanced mode
  6527. */
  6528. get instanceDivisor(): number;
  6529. set instanceDivisor(value: number);
  6530. /**
  6531. * Gets the byte stride.
  6532. */
  6533. readonly byteStride: number;
  6534. /**
  6535. * Gets the byte offset.
  6536. */
  6537. readonly byteOffset: number;
  6538. /**
  6539. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6540. */
  6541. readonly normalized: boolean;
  6542. /**
  6543. * Gets the data type of each component in the array.
  6544. */
  6545. readonly type: number;
  6546. /**
  6547. * Constructor
  6548. * @param engine the engine
  6549. * @param data the data to use for this vertex buffer
  6550. * @param kind the vertex buffer kind
  6551. * @param updatable whether the data is updatable
  6552. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6553. * @param stride the stride (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param offset the offset of the data (optional)
  6556. * @param size the number of components (optional)
  6557. * @param type the type of the component (optional)
  6558. * @param normalized whether the data contains normalized data (optional)
  6559. * @param useBytes set to true if stride and offset are in bytes (optional)
  6560. * @param divisor defines the instance divisor to use (1 by default)
  6561. */
  6562. 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);
  6563. /** @hidden */
  6564. _rebuild(): void;
  6565. /**
  6566. * Returns the kind of the VertexBuffer (string)
  6567. * @returns a string
  6568. */
  6569. getKind(): string;
  6570. /**
  6571. * Gets a boolean indicating if the VertexBuffer is updatable?
  6572. * @returns true if the buffer is updatable
  6573. */
  6574. isUpdatable(): boolean;
  6575. /**
  6576. * Gets current buffer's data
  6577. * @returns a DataArray or null
  6578. */
  6579. getData(): Nullable<DataArray>;
  6580. /**
  6581. * Gets underlying native buffer
  6582. * @returns underlying native buffer
  6583. */
  6584. getBuffer(): Nullable<DataBuffer>;
  6585. /**
  6586. * Gets the stride in float32 units (i.e. byte stride / 4).
  6587. * May not be an integer if the byte stride is not divisible by 4.
  6588. * @returns the stride in float32 units
  6589. * @deprecated Please use byteStride instead.
  6590. */
  6591. getStrideSize(): number;
  6592. /**
  6593. * Returns the offset as a multiple of the type byte length.
  6594. * @returns the offset in bytes
  6595. * @deprecated Please use byteOffset instead.
  6596. */
  6597. getOffset(): number;
  6598. /**
  6599. * Returns the number of components per vertex attribute (integer)
  6600. * @returns the size in float
  6601. */
  6602. getSize(): number;
  6603. /**
  6604. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6605. * @returns true if this buffer is instanced
  6606. */
  6607. getIsInstanced(): boolean;
  6608. /**
  6609. * Returns the instancing divisor, zero for non-instanced (integer).
  6610. * @returns a number
  6611. */
  6612. getInstanceDivisor(): number;
  6613. /**
  6614. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6615. * @param data defines the data to store
  6616. */
  6617. create(data?: DataArray): void;
  6618. /**
  6619. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6620. * This function will create a new buffer if the current one is not updatable
  6621. * @param data defines the data to store
  6622. */
  6623. update(data: DataArray): void;
  6624. /**
  6625. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6626. * Returns the directly updated WebGLBuffer.
  6627. * @param data the new data
  6628. * @param offset the new offset
  6629. * @param useBytes set to true if the offset is in bytes
  6630. */
  6631. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6632. /**
  6633. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6634. */
  6635. dispose(): void;
  6636. /**
  6637. * Enumerates each value of this vertex buffer as numbers.
  6638. * @param count the number of values to enumerate
  6639. * @param callback the callback function called for each value
  6640. */
  6641. forEach(count: number, callback: (value: number, index: number) => void): void;
  6642. /**
  6643. * Positions
  6644. */
  6645. static readonly PositionKind: string;
  6646. /**
  6647. * Normals
  6648. */
  6649. static readonly NormalKind: string;
  6650. /**
  6651. * Tangents
  6652. */
  6653. static readonly TangentKind: string;
  6654. /**
  6655. * Texture coordinates
  6656. */
  6657. static readonly UVKind: string;
  6658. /**
  6659. * Texture coordinates 2
  6660. */
  6661. static readonly UV2Kind: string;
  6662. /**
  6663. * Texture coordinates 3
  6664. */
  6665. static readonly UV3Kind: string;
  6666. /**
  6667. * Texture coordinates 4
  6668. */
  6669. static readonly UV4Kind: string;
  6670. /**
  6671. * Texture coordinates 5
  6672. */
  6673. static readonly UV5Kind: string;
  6674. /**
  6675. * Texture coordinates 6
  6676. */
  6677. static readonly UV6Kind: string;
  6678. /**
  6679. * Colors
  6680. */
  6681. static readonly ColorKind: string;
  6682. /**
  6683. * Matrix indices (for bones)
  6684. */
  6685. static readonly MatricesIndicesKind: string;
  6686. /**
  6687. * Matrix weights (for bones)
  6688. */
  6689. static readonly MatricesWeightsKind: string;
  6690. /**
  6691. * Additional matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesExtraKind: string;
  6694. /**
  6695. * Additional matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsExtraKind: string;
  6698. /**
  6699. * Deduces the stride given a kind.
  6700. * @param kind The kind string to deduce
  6701. * @returns The deduced stride
  6702. */
  6703. static DeduceStride(kind: string): number;
  6704. /**
  6705. * Gets the byte length of the given type.
  6706. * @param type the type
  6707. * @returns the number of bytes
  6708. */
  6709. static GetTypeByteLength(type: number): number;
  6710. /**
  6711. * Enumerates each value of the given parameters as numbers.
  6712. * @param data the data to enumerate
  6713. * @param byteOffset the byte offset of the data
  6714. * @param byteStride the byte stride of the data
  6715. * @param componentCount the number of components per element
  6716. * @param componentType the type of the component
  6717. * @param count the number of values to enumerate
  6718. * @param normalized whether the data is normalized
  6719. * @param callback the callback function called for each value
  6720. */
  6721. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6722. private static _GetFloatValue;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. /**
  6727. * @hidden
  6728. */
  6729. export class IntersectionInfo {
  6730. bu: Nullable<number>;
  6731. bv: Nullable<number>;
  6732. distance: number;
  6733. faceId: number;
  6734. subMeshId: number;
  6735. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6736. }
  6737. }
  6738. declare module BABYLON {
  6739. /**
  6740. * Class used to store bounding sphere information
  6741. */
  6742. export class BoundingSphere {
  6743. /**
  6744. * Gets the center of the bounding sphere in local space
  6745. */
  6746. readonly center: Vector3;
  6747. /**
  6748. * Radius of the bounding sphere in local space
  6749. */
  6750. radius: number;
  6751. /**
  6752. * Gets the center of the bounding sphere in world space
  6753. */
  6754. readonly centerWorld: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in world space
  6757. */
  6758. radiusWorld: number;
  6759. /**
  6760. * Gets the minimum vector in local space
  6761. */
  6762. readonly minimum: Vector3;
  6763. /**
  6764. * Gets the maximum vector in local space
  6765. */
  6766. readonly maximum: Vector3;
  6767. private _worldMatrix;
  6768. private static readonly TmpVector3;
  6769. /**
  6770. * Creates a new bounding sphere
  6771. * @param min defines the minimum vector (in local space)
  6772. * @param max defines the maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6776. /**
  6777. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6778. * @param min defines the new minimum vector (in local space)
  6779. * @param max defines the new maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6783. /**
  6784. * Scale the current bounding sphere by applying a scale factor
  6785. * @param factor defines the scale factor to apply
  6786. * @returns the current bounding box
  6787. */
  6788. scale(factor: number): BoundingSphere;
  6789. /**
  6790. * Gets the world matrix of the bounding box
  6791. * @returns a matrix
  6792. */
  6793. getWorldMatrix(): DeepImmutable<Matrix>;
  6794. /** @hidden */
  6795. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6796. /**
  6797. * Tests if the bounding sphere is intersecting the frustum planes
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if there is an intersection
  6800. */
  6801. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if the bounding sphere center is in between the frustum planes.
  6804. * Used for optimistic fast inclusion.
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if the sphere center is in between the frustum planes
  6807. */
  6808. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if a point is inside the bounding sphere
  6811. * @param point defines the point to test
  6812. * @returns true if the point is inside the bounding sphere
  6813. */
  6814. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6815. /**
  6816. * Checks if two sphere intersct
  6817. * @param sphere0 sphere 0
  6818. * @param sphere1 sphere 1
  6819. * @returns true if the speres intersect
  6820. */
  6821. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6822. }
  6823. }
  6824. declare module BABYLON {
  6825. /**
  6826. * Class used to store bounding box information
  6827. */
  6828. export class BoundingBox implements ICullable {
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in local space
  6831. */
  6832. readonly vectors: Vector3[];
  6833. /**
  6834. * Gets the center of the bounding box in local space
  6835. */
  6836. readonly center: Vector3;
  6837. /**
  6838. * Gets the center of the bounding box in world space
  6839. */
  6840. readonly centerWorld: Vector3;
  6841. /**
  6842. * Gets the extend size in local space
  6843. */
  6844. readonly extendSize: Vector3;
  6845. /**
  6846. * Gets the extend size in world space
  6847. */
  6848. readonly extendSizeWorld: Vector3;
  6849. /**
  6850. * Gets the OBB (object bounding box) directions
  6851. */
  6852. readonly directions: Vector3[];
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in world space
  6855. */
  6856. readonly vectorsWorld: Vector3[];
  6857. /**
  6858. * Gets the minimum vector in world space
  6859. */
  6860. readonly minimumWorld: Vector3;
  6861. /**
  6862. * Gets the maximum vector in world space
  6863. */
  6864. readonly maximumWorld: Vector3;
  6865. /**
  6866. * Gets the minimum vector in local space
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * Gets the maximum vector in local space
  6871. */
  6872. readonly maximum: Vector3;
  6873. private _worldMatrix;
  6874. private static readonly TmpVector3;
  6875. /**
  6876. * @hidden
  6877. */
  6878. _tag: number;
  6879. /**
  6880. * Creates a new bounding box
  6881. * @param min defines the minimum vector (in local space)
  6882. * @param max defines the maximum vector (in local space)
  6883. * @param worldMatrix defines the new world matrix
  6884. */
  6885. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6886. /**
  6887. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6888. * @param min defines the new minimum vector (in local space)
  6889. * @param max defines the new maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6893. /**
  6894. * Scale the current bounding box by applying a scale factor
  6895. * @param factor defines the scale factor to apply
  6896. * @returns the current bounding box
  6897. */
  6898. scale(factor: number): BoundingBox;
  6899. /**
  6900. * Gets the world matrix of the bounding box
  6901. * @returns a matrix
  6902. */
  6903. getWorldMatrix(): DeepImmutable<Matrix>;
  6904. /** @hidden */
  6905. _update(world: DeepImmutable<Matrix>): void;
  6906. /**
  6907. * Tests if the bounding box is intersecting the frustum planes
  6908. * @param frustumPlanes defines the frustum planes to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6912. /**
  6913. * Tests if the bounding box is entirely inside the frustum planes
  6914. * @param frustumPlanes defines the frustum planes to test
  6915. * @returns true if there is an inclusion
  6916. */
  6917. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6918. /**
  6919. * Tests if a point is inside the bounding box
  6920. * @param point defines the point to test
  6921. * @returns true if the point is inside the bounding box
  6922. */
  6923. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6924. /**
  6925. * Tests if the bounding box intersects with a bounding sphere
  6926. * @param sphere defines the sphere to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6930. /**
  6931. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6932. * @param min defines the min vector to use
  6933. * @param max defines the max vector to use
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6937. /**
  6938. * Tests if two bounding boxes are intersections
  6939. * @param box0 defines the first box to test
  6940. * @param box1 defines the second box to test
  6941. * @returns true if there is an intersection
  6942. */
  6943. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6944. /**
  6945. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6946. * @param minPoint defines the minimum vector of the bounding box
  6947. * @param maxPoint defines the maximum vector of the bounding box
  6948. * @param sphereCenter defines the sphere center
  6949. * @param sphereRadius defines the sphere radius
  6950. * @returns true if there is an intersection
  6951. */
  6952. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6953. /**
  6954. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6956. * @param frustumPlanes defines the frustum planes to test
  6957. * @return true if there is an inclusion
  6958. */
  6959. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an intersection
  6965. */
  6966. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /** @hidden */
  6971. export class Collider {
  6972. /** Define if a collision was found */
  6973. collisionFound: boolean;
  6974. /**
  6975. * Define last intersection point in local space
  6976. */
  6977. intersectionPoint: Vector3;
  6978. /**
  6979. * Define last collided mesh
  6980. */
  6981. collidedMesh: Nullable<AbstractMesh>;
  6982. private _collisionPoint;
  6983. private _planeIntersectionPoint;
  6984. private _tempVector;
  6985. private _tempVector2;
  6986. private _tempVector3;
  6987. private _tempVector4;
  6988. private _edge;
  6989. private _baseToVertex;
  6990. private _destinationPoint;
  6991. private _slidePlaneNormal;
  6992. private _displacementVector;
  6993. /** @hidden */
  6994. _radius: Vector3;
  6995. /** @hidden */
  6996. _retry: number;
  6997. private _velocity;
  6998. private _basePoint;
  6999. private _epsilon;
  7000. /** @hidden */
  7001. _velocityWorldLength: number;
  7002. /** @hidden */
  7003. _basePointWorld: Vector3;
  7004. private _velocityWorld;
  7005. private _normalizedVelocity;
  7006. /** @hidden */
  7007. _initialVelocity: Vector3;
  7008. /** @hidden */
  7009. _initialPosition: Vector3;
  7010. private _nearestDistance;
  7011. private _collisionMask;
  7012. get collisionMask(): number;
  7013. set collisionMask(mask: number);
  7014. /**
  7015. * Gets the plane normal used to compute the sliding response (in local space)
  7016. */
  7017. get slidePlaneNormal(): Vector3;
  7018. /** @hidden */
  7019. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7020. /** @hidden */
  7021. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7022. /** @hidden */
  7023. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7024. /** @hidden */
  7025. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7026. /** @hidden */
  7027. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7028. /** @hidden */
  7029. _getResponse(pos: Vector3, vel: Vector3): void;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. /**
  7034. * Interface for cullable objects
  7035. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7036. */
  7037. export interface ICullable {
  7038. /**
  7039. * Checks if the object or part of the object is in the frustum
  7040. * @param frustumPlanes Camera near/planes
  7041. * @returns true if the object is in frustum otherwise false
  7042. */
  7043. isInFrustum(frustumPlanes: Plane[]): boolean;
  7044. /**
  7045. * Checks if a cullable object (mesh...) is in the camera frustum
  7046. * Unlike isInFrustum this cheks the full bounding box
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7051. }
  7052. /**
  7053. * Info for a bounding data of a mesh
  7054. */
  7055. export class BoundingInfo implements ICullable {
  7056. /**
  7057. * Bounding box for the mesh
  7058. */
  7059. readonly boundingBox: BoundingBox;
  7060. /**
  7061. * Bounding sphere for the mesh
  7062. */
  7063. readonly boundingSphere: BoundingSphere;
  7064. private _isLocked;
  7065. private static readonly TmpVector3;
  7066. /**
  7067. * Constructs bounding info
  7068. * @param minimum min vector of the bounding box/sphere
  7069. * @param maximum max vector of the bounding box/sphere
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * min vector of the bounding box/sphere
  7082. */
  7083. get minimum(): Vector3;
  7084. /**
  7085. * max vector of the bounding box/sphere
  7086. */
  7087. get maximum(): Vector3;
  7088. /**
  7089. * If the info is locked and won't be updated to avoid perf overhead
  7090. */
  7091. get isLocked(): boolean;
  7092. set isLocked(value: boolean);
  7093. /**
  7094. * Updates the bounding sphere and box
  7095. * @param world world matrix to be used to update
  7096. */
  7097. update(world: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7100. * @param center New center of the bounding info
  7101. * @param extend New extend of the bounding info
  7102. * @returns the current bounding info
  7103. */
  7104. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7105. /**
  7106. * Scale the current bounding info by applying a scale factor
  7107. * @param factor defines the scale factor to apply
  7108. * @returns the current bounding info
  7109. */
  7110. scale(factor: number): BoundingInfo;
  7111. /**
  7112. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7113. * @param frustumPlanes defines the frustum to test
  7114. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7115. * @returns true if the bounding info is in the frustum planes
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7118. /**
  7119. * Gets the world distance between the min and max points of the bounding box
  7120. */
  7121. get diagonalLength(): number;
  7122. /**
  7123. * Checks if a cullable object (mesh...) is in the camera frustum
  7124. * Unlike isInFrustum this cheks the full bounding box
  7125. * @param frustumPlanes Camera near/planes
  7126. * @returns true if the object is in frustum otherwise false
  7127. */
  7128. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7129. /** @hidden */
  7130. _checkCollision(collider: Collider): boolean;
  7131. /**
  7132. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7133. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7134. * @param point the point to check intersection with
  7135. * @returns if the point intersects
  7136. */
  7137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7138. /**
  7139. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param boundingInfo the bounding info to check intersection with
  7142. * @param precise if the intersection should be done using OBB
  7143. * @returns if the bounding info intersects
  7144. */
  7145. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Extracts minimum and maximum values from a list of indexed positions
  7151. * @param positions defines the positions to use
  7152. * @param indices defines the indices to the positions
  7153. * @param indexStart defines the start index
  7154. * @param indexCount defines the end index
  7155. * @param bias defines bias value to add to the result
  7156. * @return minimum and maximum values
  7157. */
  7158. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7159. minimum: Vector3;
  7160. maximum: Vector3;
  7161. };
  7162. /**
  7163. * Extracts minimum and maximum values from a list of positions
  7164. * @param positions defines the positions to use
  7165. * @param start defines the start index in the positions array
  7166. * @param count defines the number of positions to handle
  7167. * @param bias defines bias value to add to the result
  7168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7169. * @return minimum and maximum values
  7170. */
  7171. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7172. minimum: Vector3;
  7173. maximum: Vector3;
  7174. };
  7175. }
  7176. declare module BABYLON {
  7177. /** @hidden */
  7178. export class WebGLDataBuffer extends DataBuffer {
  7179. private _buffer;
  7180. constructor(resource: WebGLBuffer);
  7181. get underlyingResource(): any;
  7182. }
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLPipelineContext implements IPipelineContext {
  7187. engine: ThinEngine;
  7188. program: Nullable<WebGLProgram>;
  7189. context?: WebGLRenderingContext;
  7190. vertexShader?: WebGLShader;
  7191. fragmentShader?: WebGLShader;
  7192. isParallelCompiled: boolean;
  7193. onCompiled?: () => void;
  7194. transformFeedback?: WebGLTransformFeedback | null;
  7195. vertexCompilationError: Nullable<string>;
  7196. fragmentCompilationError: Nullable<string>;
  7197. programLinkError: Nullable<string>;
  7198. programValidationError: Nullable<string>;
  7199. get isAsync(): boolean;
  7200. get isReady(): boolean;
  7201. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7202. _getVertexShaderCode(): string | null;
  7203. _getFragmentShaderCode(): string | null;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. declare module BABYLON {
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. get useUbo(): boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. get isSync(): boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: 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 x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module BABYLON {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module BABYLON {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module BABYLON {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module BABYLON {
  7626. interface ThinEngine {
  7627. /**
  7628. * Creates a depth stencil cube texture.
  7629. * This is only available in WebGL 2.
  7630. * @param size The size of face edge in the cube texture.
  7631. * @param options The options defining the cube texture.
  7632. * @returns The cube texture
  7633. */
  7634. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7635. /**
  7636. * Creates a cube texture
  7637. * @param rootUrl defines the url where the files to load is located
  7638. * @param scene defines the current scene
  7639. * @param files defines the list of files to load (1 per face)
  7640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7641. * @param onLoad defines an optional callback raised when the texture is loaded
  7642. * @param onError defines an optional callback raised if there is an issue to load the texture
  7643. * @param format defines the format of the data
  7644. * @param forcedExtension defines the extension to use to pick the right loader
  7645. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7648. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7649. * @returns the cube texture as an InternalTexture
  7650. */
  7651. 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;
  7652. /**
  7653. * Creates a cube texture
  7654. * @param rootUrl defines the url where the files to load is located
  7655. * @param scene defines the current scene
  7656. * @param files defines the list of files to load (1 per face)
  7657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7658. * @param onLoad defines an optional callback raised when the texture is loaded
  7659. * @param onError defines an optional callback raised if there is an issue to load the texture
  7660. * @param format defines the format of the data
  7661. * @param forcedExtension defines the extension to use to pick the right loader
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /**
  7666. * Creates a cube texture
  7667. * @param rootUrl defines the url where the files to load is located
  7668. * @param scene defines the current scene
  7669. * @param files defines the list of files to load (1 per face)
  7670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7671. * @param onLoad defines an optional callback raised when the texture is loaded
  7672. * @param onError defines an optional callback raised if there is an issue to load the texture
  7673. * @param format defines the format of the data
  7674. * @param forcedExtension defines the extension to use to pick the right loader
  7675. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /** @hidden */
  7682. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7683. /** @hidden */
  7684. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7687. /** @hidden */
  7688. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /**
  7690. * @hidden
  7691. */
  7692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Class for creating a cube texture
  7698. */
  7699. export class CubeTexture extends BaseTexture {
  7700. private _delayedOnLoad;
  7701. /**
  7702. * Observable triggered once the texture has been loaded.
  7703. */
  7704. onLoadObservable: Observable<CubeTexture>;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. set boundingBoxSize(value: Vector3);
  7723. /**
  7724. * Returns the bounding box size
  7725. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7726. */
  7727. get boundingBoxSize(): Vector3;
  7728. protected _rotationY: number;
  7729. /**
  7730. * Sets texture matrix rotation angle around Y axis in radians.
  7731. */
  7732. set rotationY(value: number);
  7733. /**
  7734. * Gets texture matrix rotation angle around Y axis radians.
  7735. */
  7736. get rotationY(): number;
  7737. /**
  7738. * Are mip maps generated for this texture or not.
  7739. */
  7740. get noMipmap(): boolean;
  7741. private _noMipmap;
  7742. private _files;
  7743. protected _forcedExtension: Nullable<string>;
  7744. private _extensions;
  7745. private _textureMatrix;
  7746. private _format;
  7747. private _createPolynomials;
  7748. /** @hidden */
  7749. _prefiltered: boolean;
  7750. /**
  7751. * Creates a cube texture from an array of image urls
  7752. * @param files defines an array of image urls
  7753. * @param scene defines the hosting scene
  7754. * @param noMipmap specifies if mip maps are not used
  7755. * @returns a cube texture
  7756. */
  7757. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7758. /**
  7759. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7760. * @param url defines the url of the prefiltered texture
  7761. * @param scene defines the scene the texture is attached to
  7762. * @param forcedExtension defines the extension of the file if different from the url
  7763. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7764. * @return the prefiltered texture
  7765. */
  7766. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7767. /**
  7768. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7769. * as prefiltered data.
  7770. * @param rootUrl defines the url of the texture or the root name of the six images
  7771. * @param scene defines the scene the texture is attached to
  7772. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7773. * @param noMipmap defines if mipmaps should be created or not
  7774. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7775. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7776. * @param onError defines a callback triggered in case of error during load
  7777. * @param format defines the internal format to use for the texture once loaded
  7778. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7779. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7780. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7783. * @return the cube texture
  7784. */
  7785. 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);
  7786. /**
  7787. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7788. */
  7789. get isPrefiltered(): boolean;
  7790. /**
  7791. * Get the current class name of the texture useful for serialization or dynamic coding.
  7792. * @returns "CubeTexture"
  7793. */
  7794. getClassName(): string;
  7795. /**
  7796. * Update the url (and optional buffer) of this texture if url was null during construction.
  7797. * @param url the url of the texture
  7798. * @param forcedExtension defines the extension to use
  7799. * @param onLoad callback called when the texture is loaded (defaults to null)
  7800. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7801. */
  7802. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7803. /**
  7804. * Delays loading of the cube texture
  7805. * @param forcedExtension defines the extension to use
  7806. */
  7807. delayLoad(forcedExtension?: string): void;
  7808. /**
  7809. * Returns the reflection texture matrix
  7810. * @returns the reflection texture matrix
  7811. */
  7812. getReflectionTextureMatrix(): Matrix;
  7813. /**
  7814. * Sets the reflection texture matrix
  7815. * @param value Reflection texture matrix
  7816. */
  7817. setReflectionTextureMatrix(value: Matrix): void;
  7818. /**
  7819. * Parses text to create a cube texture
  7820. * @param parsedTexture define the serialized text to read from
  7821. * @param scene defines the hosting scene
  7822. * @param rootUrl defines the root url of the cube texture
  7823. * @returns a cube texture
  7824. */
  7825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7826. /**
  7827. * Makes a clone, or deep copy, of the cube texture
  7828. * @returns a new cube texture
  7829. */
  7830. clone(): CubeTexture;
  7831. }
  7832. }
  7833. declare module BABYLON {
  7834. /**
  7835. * Manages the defines for the Material
  7836. */
  7837. export class MaterialDefines {
  7838. /** @hidden */
  7839. protected _keys: string[];
  7840. private _isDirty;
  7841. /** @hidden */
  7842. _renderId: number;
  7843. /** @hidden */
  7844. _areLightsDirty: boolean;
  7845. /** @hidden */
  7846. _areLightsDisposed: boolean;
  7847. /** @hidden */
  7848. _areAttributesDirty: boolean;
  7849. /** @hidden */
  7850. _areTexturesDirty: boolean;
  7851. /** @hidden */
  7852. _areFresnelDirty: boolean;
  7853. /** @hidden */
  7854. _areMiscDirty: boolean;
  7855. /** @hidden */
  7856. _areImageProcessingDirty: boolean;
  7857. /** @hidden */
  7858. _normals: boolean;
  7859. /** @hidden */
  7860. _uvs: boolean;
  7861. /** @hidden */
  7862. _needNormals: boolean;
  7863. /** @hidden */
  7864. _needUVs: boolean;
  7865. [id: string]: any;
  7866. /**
  7867. * Specifies if the material needs to be re-calculated
  7868. */
  7869. get isDirty(): boolean;
  7870. /**
  7871. * Marks the material to indicate that it has been re-calculated
  7872. */
  7873. markAsProcessed(): void;
  7874. /**
  7875. * Marks the material to indicate that it needs to be re-calculated
  7876. */
  7877. markAsUnprocessed(): void;
  7878. /**
  7879. * Marks the material to indicate all of its defines need to be re-calculated
  7880. */
  7881. markAllAsDirty(): void;
  7882. /**
  7883. * Marks the material to indicate that image processing needs to be re-calculated
  7884. */
  7885. markAsImageProcessingDirty(): void;
  7886. /**
  7887. * Marks the material to indicate the lights need to be re-calculated
  7888. * @param disposed Defines whether the light is dirty due to dispose or not
  7889. */
  7890. markAsLightDirty(disposed?: boolean): void;
  7891. /**
  7892. * Marks the attribute state as changed
  7893. */
  7894. markAsAttributesDirty(): void;
  7895. /**
  7896. * Marks the texture state as changed
  7897. */
  7898. markAsTexturesDirty(): void;
  7899. /**
  7900. * Marks the fresnel state as changed
  7901. */
  7902. markAsFresnelDirty(): void;
  7903. /**
  7904. * Marks the misc state as changed
  7905. */
  7906. markAsMiscDirty(): void;
  7907. /**
  7908. * Rebuilds the material defines
  7909. */
  7910. rebuild(): void;
  7911. /**
  7912. * Specifies if two material defines are equal
  7913. * @param other - A material define instance to compare to
  7914. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7915. */
  7916. isEqual(other: MaterialDefines): boolean;
  7917. /**
  7918. * Clones this instance's defines to another instance
  7919. * @param other - material defines to clone values to
  7920. */
  7921. cloneTo(other: MaterialDefines): void;
  7922. /**
  7923. * Resets the material define values
  7924. */
  7925. reset(): void;
  7926. /**
  7927. * Converts the material define values to a string
  7928. * @returns - String of material define information
  7929. */
  7930. toString(): string;
  7931. }
  7932. }
  7933. declare module BABYLON {
  7934. /**
  7935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7937. * 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;
  7938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7939. */
  7940. export class ColorCurves {
  7941. private _dirty;
  7942. private _tempColor;
  7943. private _globalCurve;
  7944. private _highlightsCurve;
  7945. private _midtonesCurve;
  7946. private _shadowsCurve;
  7947. private _positiveCurve;
  7948. private _negativeCurve;
  7949. private _globalHue;
  7950. private _globalDensity;
  7951. private _globalSaturation;
  7952. private _globalExposure;
  7953. /**
  7954. * Gets the global Hue value.
  7955. * 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).
  7956. */
  7957. get globalHue(): number;
  7958. /**
  7959. * Sets the global Hue value.
  7960. * 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).
  7961. */
  7962. set globalHue(value: number);
  7963. /**
  7964. * Gets the global Density value.
  7965. * 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.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get globalDensity(): number;
  7969. /**
  7970. * Sets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set globalDensity(value: number);
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. get globalSaturation(): number;
  7980. /**
  7981. * Sets the global Saturation value.
  7982. * 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.
  7983. */
  7984. set globalSaturation(value: number);
  7985. /**
  7986. * Gets the global Exposure value.
  7987. * 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.
  7988. */
  7989. get globalExposure(): number;
  7990. /**
  7991. * Sets the global Exposure value.
  7992. * 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.
  7993. */
  7994. set globalExposure(value: number);
  7995. private _highlightsHue;
  7996. private _highlightsDensity;
  7997. private _highlightsSaturation;
  7998. private _highlightsExposure;
  7999. /**
  8000. * Gets the highlights Hue value.
  8001. * 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).
  8002. */
  8003. get highlightsHue(): number;
  8004. /**
  8005. * Sets the highlights Hue value.
  8006. * 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).
  8007. */
  8008. set highlightsHue(value: number);
  8009. /**
  8010. * Gets the highlights Density value.
  8011. * 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.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get highlightsDensity(): number;
  8015. /**
  8016. * Sets the highlights Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set highlightsDensity(value: number);
  8021. /**
  8022. * Gets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. get highlightsSaturation(): number;
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * 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.
  8029. */
  8030. set highlightsSaturation(value: number);
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * 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.
  8034. */
  8035. get highlightsExposure(): number;
  8036. /**
  8037. * Sets the highlights Exposure value.
  8038. * 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.
  8039. */
  8040. set highlightsExposure(value: number);
  8041. private _midtonesHue;
  8042. private _midtonesDensity;
  8043. private _midtonesSaturation;
  8044. private _midtonesExposure;
  8045. /**
  8046. * Gets the midtones Hue value.
  8047. * 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).
  8048. */
  8049. get midtonesHue(): number;
  8050. /**
  8051. * Sets the midtones Hue value.
  8052. * 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).
  8053. */
  8054. set midtonesHue(value: number);
  8055. /**
  8056. * Gets the midtones Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get midtonesDensity(): number;
  8061. /**
  8062. * Sets the midtones Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set midtonesDensity(value: number);
  8067. /**
  8068. * Gets the midtones Saturation value.
  8069. * 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.
  8070. */
  8071. get midtonesSaturation(): number;
  8072. /**
  8073. * Sets the midtones Saturation value.
  8074. * 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.
  8075. */
  8076. set midtonesSaturation(value: number);
  8077. /**
  8078. * Gets the midtones Exposure value.
  8079. * 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.
  8080. */
  8081. get midtonesExposure(): number;
  8082. /**
  8083. * Sets the midtones Exposure value.
  8084. * 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.
  8085. */
  8086. set midtonesExposure(value: number);
  8087. private _shadowsHue;
  8088. private _shadowsDensity;
  8089. private _shadowsSaturation;
  8090. private _shadowsExposure;
  8091. /**
  8092. * Gets the shadows Hue value.
  8093. * 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).
  8094. */
  8095. get shadowsHue(): number;
  8096. /**
  8097. * Sets the shadows Hue value.
  8098. * 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).
  8099. */
  8100. set shadowsHue(value: number);
  8101. /**
  8102. * Gets the shadows Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. get shadowsDensity(): number;
  8107. /**
  8108. * Sets the shadows Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. set shadowsDensity(value: number);
  8113. /**
  8114. * Gets the shadows Saturation value.
  8115. * 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.
  8116. */
  8117. get shadowsSaturation(): number;
  8118. /**
  8119. * Sets the shadows Saturation value.
  8120. * 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.
  8121. */
  8122. set shadowsSaturation(value: number);
  8123. /**
  8124. * Gets the shadows Exposure value.
  8125. * 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.
  8126. */
  8127. get shadowsExposure(): number;
  8128. /**
  8129. * Sets the shadows Exposure value.
  8130. * 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.
  8131. */
  8132. set shadowsExposure(value: number);
  8133. /**
  8134. * Returns the class name
  8135. * @returns The class name
  8136. */
  8137. getClassName(): string;
  8138. /**
  8139. * Binds the color curves to the shader.
  8140. * @param colorCurves The color curve to bind
  8141. * @param effect The effect to bind to
  8142. * @param positiveUniform The positive uniform shader parameter
  8143. * @param neutralUniform The neutral uniform shader parameter
  8144. * @param negativeUniform The negative uniform shader parameter
  8145. */
  8146. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8147. /**
  8148. * Prepare the list of uniforms associated with the ColorCurves effects.
  8149. * @param uniformsList The list of uniforms used in the effect
  8150. */
  8151. static PrepareUniforms(uniformsList: string[]): void;
  8152. /**
  8153. * Returns color grading data based on a hue, density, saturation and exposure value.
  8154. * @param filterHue The hue of the color filter.
  8155. * @param filterDensity The density of the color filter.
  8156. * @param saturation The saturation.
  8157. * @param exposure The exposure.
  8158. * @param result The result data container.
  8159. */
  8160. private getColorGradingDataToRef;
  8161. /**
  8162. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8163. * @param value The input slider value in range [-100,100].
  8164. * @returns Adjusted value.
  8165. */
  8166. private static applyColorGradingSliderNonlinear;
  8167. /**
  8168. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8169. * @param hue The hue (H) input.
  8170. * @param saturation The saturation (S) input.
  8171. * @param brightness The brightness (B) input.
  8172. * @result An RGBA color represented as Vector4.
  8173. */
  8174. private static fromHSBToRef;
  8175. /**
  8176. * Returns a value clamped between min and max
  8177. * @param value The value to clamp
  8178. * @param min The minimum of value
  8179. * @param max The maximum of value
  8180. * @returns The clamped value.
  8181. */
  8182. private static clamp;
  8183. /**
  8184. * Clones the current color curve instance.
  8185. * @return The cloned curves
  8186. */
  8187. clone(): ColorCurves;
  8188. /**
  8189. * Serializes the current color curve instance to a json representation.
  8190. * @return a JSON representation
  8191. */
  8192. serialize(): any;
  8193. /**
  8194. * Parses the color curve from a json representation.
  8195. * @param source the JSON source to parse
  8196. * @return The parsed curves
  8197. */
  8198. static Parse(source: any): ColorCurves;
  8199. }
  8200. }
  8201. declare module BABYLON {
  8202. /**
  8203. * Interface to follow in your material defines to integrate easily the
  8204. * Image proccessing functions.
  8205. * @hidden
  8206. */
  8207. export interface IImageProcessingConfigurationDefines {
  8208. IMAGEPROCESSING: boolean;
  8209. VIGNETTE: boolean;
  8210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8211. VIGNETTEBLENDMODEOPAQUE: boolean;
  8212. TONEMAPPING: boolean;
  8213. TONEMAPPING_ACES: boolean;
  8214. CONTRAST: boolean;
  8215. EXPOSURE: boolean;
  8216. COLORCURVES: boolean;
  8217. COLORGRADING: boolean;
  8218. COLORGRADING3D: boolean;
  8219. SAMPLER3DGREENDEPTH: boolean;
  8220. SAMPLER3DBGRMAP: boolean;
  8221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8222. }
  8223. /**
  8224. * @hidden
  8225. */
  8226. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8227. IMAGEPROCESSING: boolean;
  8228. VIGNETTE: boolean;
  8229. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8230. VIGNETTEBLENDMODEOPAQUE: boolean;
  8231. TONEMAPPING: boolean;
  8232. TONEMAPPING_ACES: boolean;
  8233. CONTRAST: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. EXPOSURE: boolean;
  8241. constructor();
  8242. }
  8243. /**
  8244. * This groups together the common properties used for image processing either in direct forward pass
  8245. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8246. * or not.
  8247. */
  8248. export class ImageProcessingConfiguration {
  8249. /**
  8250. * Default tone mapping applied in BabylonJS.
  8251. */
  8252. static readonly TONEMAPPING_STANDARD: number;
  8253. /**
  8254. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8255. * to other engines rendering to increase portability.
  8256. */
  8257. static readonly TONEMAPPING_ACES: number;
  8258. /**
  8259. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8260. */
  8261. colorCurves: Nullable<ColorCurves>;
  8262. private _colorCurvesEnabled;
  8263. /**
  8264. * Gets wether the color curves effect is enabled.
  8265. */
  8266. get colorCurvesEnabled(): boolean;
  8267. /**
  8268. * Sets wether the color curves effect is enabled.
  8269. */
  8270. set colorCurvesEnabled(value: boolean);
  8271. private _colorGradingTexture;
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. get colorGradingTexture(): Nullable<BaseTexture>;
  8276. /**
  8277. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8278. */
  8279. set colorGradingTexture(value: Nullable<BaseTexture>);
  8280. private _colorGradingEnabled;
  8281. /**
  8282. * Gets wether the color grading effect is enabled.
  8283. */
  8284. get colorGradingEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color grading effect is enabled.
  8287. */
  8288. set colorGradingEnabled(value: boolean);
  8289. private _colorGradingWithGreenDepth;
  8290. /**
  8291. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8292. */
  8293. get colorGradingWithGreenDepth(): boolean;
  8294. /**
  8295. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8296. */
  8297. set colorGradingWithGreenDepth(value: boolean);
  8298. private _colorGradingBGR;
  8299. /**
  8300. * Gets wether the color grading texture contains BGR values.
  8301. */
  8302. get colorGradingBGR(): boolean;
  8303. /**
  8304. * Sets wether the color grading texture contains BGR values.
  8305. */
  8306. set colorGradingBGR(value: boolean);
  8307. /** @hidden */
  8308. _exposure: number;
  8309. /**
  8310. * Gets the Exposure used in the effect.
  8311. */
  8312. get exposure(): number;
  8313. /**
  8314. * Sets the Exposure used in the effect.
  8315. */
  8316. set exposure(value: number);
  8317. private _toneMappingEnabled;
  8318. /**
  8319. * Gets wether the tone mapping effect is enabled.
  8320. */
  8321. get toneMappingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the tone mapping effect is enabled.
  8324. */
  8325. set toneMappingEnabled(value: boolean);
  8326. private _toneMappingType;
  8327. /**
  8328. * Gets the type of tone mapping effect.
  8329. */
  8330. get toneMappingType(): number;
  8331. /**
  8332. * Sets the type of tone mapping effect used in BabylonJS.
  8333. */
  8334. set toneMappingType(value: number);
  8335. protected _contrast: number;
  8336. /**
  8337. * Gets the contrast used in the effect.
  8338. */
  8339. get contrast(): number;
  8340. /**
  8341. * Sets the contrast used in the effect.
  8342. */
  8343. set contrast(value: number);
  8344. /**
  8345. * Vignette stretch size.
  8346. */
  8347. vignetteStretch: number;
  8348. /**
  8349. * Vignette centre X Offset.
  8350. */
  8351. vignetteCentreX: number;
  8352. /**
  8353. * Vignette centre Y Offset.
  8354. */
  8355. vignetteCentreY: number;
  8356. /**
  8357. * Vignette weight or intensity of the vignette effect.
  8358. */
  8359. vignetteWeight: number;
  8360. /**
  8361. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8362. * if vignetteEnabled is set to true.
  8363. */
  8364. vignetteColor: Color4;
  8365. /**
  8366. * Camera field of view used by the Vignette effect.
  8367. */
  8368. vignetteCameraFov: number;
  8369. private _vignetteBlendMode;
  8370. /**
  8371. * Gets the vignette blend mode allowing different kind of effect.
  8372. */
  8373. get vignetteBlendMode(): number;
  8374. /**
  8375. * Sets the vignette blend mode allowing different kind of effect.
  8376. */
  8377. set vignetteBlendMode(value: number);
  8378. private _vignetteEnabled;
  8379. /**
  8380. * Gets wether the vignette effect is enabled.
  8381. */
  8382. get vignetteEnabled(): boolean;
  8383. /**
  8384. * Sets wether the vignette effect is enabled.
  8385. */
  8386. set vignetteEnabled(value: boolean);
  8387. private _applyByPostProcess;
  8388. /**
  8389. * Gets wether the image processing is applied through a post process or not.
  8390. */
  8391. get applyByPostProcess(): boolean;
  8392. /**
  8393. * Sets wether the image processing is applied through a post process or not.
  8394. */
  8395. set applyByPostProcess(value: boolean);
  8396. private _isEnabled;
  8397. /**
  8398. * Gets wether the image processing is enabled or not.
  8399. */
  8400. get isEnabled(): boolean;
  8401. /**
  8402. * Sets wether the image processing is enabled or not.
  8403. */
  8404. set isEnabled(value: boolean);
  8405. /**
  8406. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8407. */
  8408. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8409. /**
  8410. * Method called each time the image processing information changes requires to recompile the effect.
  8411. */
  8412. protected _updateParameters(): void;
  8413. /**
  8414. * Gets the current class name.
  8415. * @return "ImageProcessingConfiguration"
  8416. */
  8417. getClassName(): string;
  8418. /**
  8419. * Prepare the list of uniforms associated with the Image Processing effects.
  8420. * @param uniforms The list of uniforms used in the effect
  8421. * @param defines the list of defines currently in use
  8422. */
  8423. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8424. /**
  8425. * Prepare the list of samplers associated with the Image Processing effects.
  8426. * @param samplersList The list of uniforms used in the effect
  8427. * @param defines the list of defines currently in use
  8428. */
  8429. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8430. /**
  8431. * Prepare the list of defines associated to the shader.
  8432. * @param defines the list of defines to complete
  8433. * @param forPostProcess Define if we are currently in post process mode or not
  8434. */
  8435. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8436. /**
  8437. * Returns true if all the image processing information are ready.
  8438. * @returns True if ready, otherwise, false
  8439. */
  8440. isReady(): boolean;
  8441. /**
  8442. * Binds the image processing to the shader.
  8443. * @param effect The effect to bind to
  8444. * @param overrideAspectRatio Override the aspect ratio of the effect
  8445. */
  8446. bind(effect: Effect, overrideAspectRatio?: number): void;
  8447. /**
  8448. * Clones the current image processing instance.
  8449. * @return The cloned image processing
  8450. */
  8451. clone(): ImageProcessingConfiguration;
  8452. /**
  8453. * Serializes the current image processing instance to a json representation.
  8454. * @return a JSON representation
  8455. */
  8456. serialize(): any;
  8457. /**
  8458. * Parses the image processing from a json representation.
  8459. * @param source the JSON source to parse
  8460. * @return The parsed image processing
  8461. */
  8462. static Parse(source: any): ImageProcessingConfiguration;
  8463. private static _VIGNETTEMODE_MULTIPLY;
  8464. private static _VIGNETTEMODE_OPAQUE;
  8465. /**
  8466. * Used to apply the vignette as a mix with the pixel color.
  8467. */
  8468. static get VIGNETTEMODE_MULTIPLY(): number;
  8469. /**
  8470. * Used to apply the vignette as a replacement of the pixel color.
  8471. */
  8472. static get VIGNETTEMODE_OPAQUE(): number;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** @hidden */
  8477. export var postprocessVertexShader: {
  8478. name: string;
  8479. shader: string;
  8480. };
  8481. }
  8482. declare module BABYLON {
  8483. interface ThinEngine {
  8484. /**
  8485. * Creates a new render target texture
  8486. * @param size defines the size of the texture
  8487. * @param options defines the options used to create the texture
  8488. * @returns a new render target texture stored in an InternalTexture
  8489. */
  8490. createRenderTargetTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. layers?: number;
  8494. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8495. /**
  8496. * Creates a depth stencil texture.
  8497. * This is only available in WebGL 2 or with the depth texture extension available.
  8498. * @param size The size of face edge in the texture.
  8499. * @param options The options defining the texture.
  8500. * @returns The texture
  8501. */
  8502. createDepthStencilTexture(size: number | {
  8503. width: number;
  8504. height: number;
  8505. layers?: number;
  8506. }, options: DepthTextureCreationOptions): InternalTexture;
  8507. /** @hidden */
  8508. _createDepthStencilTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: DepthTextureCreationOptions): InternalTexture;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /** Defines supported spaces */
  8517. export enum Space {
  8518. /** Local (object) space */
  8519. LOCAL = 0,
  8520. /** World space */
  8521. WORLD = 1,
  8522. /** Bone space */
  8523. BONE = 2
  8524. }
  8525. /** Defines the 3 main axes */
  8526. export class Axis {
  8527. /** X axis */
  8528. static X: Vector3;
  8529. /** Y axis */
  8530. static Y: Vector3;
  8531. /** Z axis */
  8532. static Z: Vector3;
  8533. }
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add constraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8577. * panning
  8578. */
  8579. invertRotation: boolean;
  8580. /**
  8581. * Speed multiplier for inverse camera panning
  8582. */
  8583. inverseRotationSpeed: number;
  8584. /**
  8585. * Define the current target of the camera as an object or a position.
  8586. */
  8587. lockedTarget: any;
  8588. /** @hidden */
  8589. _currentTarget: Vector3;
  8590. /** @hidden */
  8591. _initialFocalDistance: number;
  8592. /** @hidden */
  8593. _viewMatrix: Matrix;
  8594. /** @hidden */
  8595. _camMatrix: Matrix;
  8596. /** @hidden */
  8597. _cameraTransformMatrix: Matrix;
  8598. /** @hidden */
  8599. _cameraRotationMatrix: Matrix;
  8600. /** @hidden */
  8601. _referencePoint: Vector3;
  8602. /** @hidden */
  8603. _transformedReferencePoint: Vector3;
  8604. protected _globalCurrentTarget: Vector3;
  8605. protected _globalCurrentUpVector: Vector3;
  8606. /** @hidden */
  8607. _reset: () => void;
  8608. private _defaultUp;
  8609. /**
  8610. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8611. * This is the base of the follow, arc rotate cameras and Free camera
  8612. * @see http://doc.babylonjs.com/features/cameras
  8613. * @param name Defines the name of the camera in the scene
  8614. * @param position Defines the start position of the camera in the scene
  8615. * @param scene Defines the scene the camera belongs to
  8616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8617. */
  8618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8619. /**
  8620. * Gets the position in front of the camera at a given distance.
  8621. * @param distance The distance from the camera we want the position to be
  8622. * @returns the position
  8623. */
  8624. getFrontPosition(distance: number): Vector3;
  8625. /** @hidden */
  8626. _getLockedTargetPosition(): Nullable<Vector3>;
  8627. private _storedPosition;
  8628. private _storedRotation;
  8629. private _storedRotationQuaternion;
  8630. /**
  8631. * Store current camera state of the camera (fov, position, rotation, etc..)
  8632. * @returns the camera
  8633. */
  8634. storeState(): Camera;
  8635. /**
  8636. * Restored camera state. You must call storeState() first
  8637. * @returns whether it was successful or not
  8638. * @hidden
  8639. */
  8640. _restoreStateValues(): boolean;
  8641. /** @hidden */
  8642. _initCache(): void;
  8643. /** @hidden */
  8644. _updateCache(ignoreParentClass?: boolean): void;
  8645. /** @hidden */
  8646. _isSynchronizedViewMatrix(): boolean;
  8647. /** @hidden */
  8648. _computeLocalCameraSpeed(): number;
  8649. /**
  8650. * Defines the target the camera should look at.
  8651. * @param target Defines the new target as a Vector or a mesh
  8652. */
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. * @returns the target position
  8657. */
  8658. getTarget(): Vector3;
  8659. /** @hidden */
  8660. _decideIfNeedsToMove(): boolean;
  8661. /** @hidden */
  8662. _updatePosition(): void;
  8663. /** @hidden */
  8664. _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */
  8674. _getViewMatrix(): Matrix;
  8675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8676. /**
  8677. * @hidden
  8678. */
  8679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8680. /**
  8681. * @hidden
  8682. */
  8683. _updateRigCameras(): void;
  8684. private _getRigCamPositionAndTarget;
  8685. /**
  8686. * Gets the current object class name.
  8687. * @return the class name
  8688. */
  8689. getClassName(): string;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Gather the list of keyboard event types as constants.
  8695. */
  8696. export class KeyboardEventTypes {
  8697. /**
  8698. * The keydown event is fired when a key becomes active (pressed).
  8699. */
  8700. static readonly KEYDOWN: number;
  8701. /**
  8702. * The keyup event is fired when a key has been released.
  8703. */
  8704. static readonly KEYUP: number;
  8705. }
  8706. /**
  8707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8708. */
  8709. export class KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Instantiates a new keyboard info.
  8720. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8721. * @param type Defines the type of event (KeyboardEventTypes)
  8722. * @param event Defines the related dom event
  8723. */
  8724. constructor(
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number,
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent);
  8733. }
  8734. /**
  8735. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8736. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8737. */
  8738. export class KeyboardInfoPre extends KeyboardInfo {
  8739. /**
  8740. * Defines the type of event (KeyboardEventTypes)
  8741. */
  8742. type: number;
  8743. /**
  8744. * Defines the related dom event
  8745. */
  8746. event: KeyboardEvent;
  8747. /**
  8748. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8749. */
  8750. skipOnPointerObservable: boolean;
  8751. /**
  8752. * Instantiates a new keyboard pre info.
  8753. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8754. * @param type Defines the type of event (KeyboardEventTypes)
  8755. * @param event Defines the related dom event
  8756. */
  8757. constructor(
  8758. /**
  8759. * Defines the type of event (KeyboardEventTypes)
  8760. */
  8761. type: number,
  8762. /**
  8763. * Defines the related dom event
  8764. */
  8765. event: KeyboardEvent);
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /**
  8770. * Manage the keyboard inputs to control the movement of a free camera.
  8771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8772. */
  8773. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8774. /**
  8775. * Defines the camera the input is attached to.
  8776. */
  8777. camera: FreeCamera;
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8780. */
  8781. keysUp: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8784. */
  8785. keysUpward: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8788. */
  8789. keysDown: number[];
  8790. /**
  8791. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8792. */
  8793. keysDownward: number[];
  8794. /**
  8795. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8796. */
  8797. keysLeft: number[];
  8798. /**
  8799. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8800. */
  8801. keysRight: number[];
  8802. private _keys;
  8803. private _onCanvasBlurObserver;
  8804. private _onKeyboardObserver;
  8805. private _engine;
  8806. private _scene;
  8807. /**
  8808. * Attach the input controls to a specific dom element to get the input from.
  8809. * @param element Defines the element the controls should be listened from
  8810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8811. */
  8812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8813. /**
  8814. * Detach the current controls from the specified dom element.
  8815. * @param element Defines the element to stop listening the inputs from
  8816. */
  8817. detachControl(element: Nullable<HTMLElement>): void;
  8818. /**
  8819. * Update the current camera state depending on the inputs that have been used this frame.
  8820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8821. */
  8822. checkInputs(): void;
  8823. /**
  8824. * Gets the class name of the current intput.
  8825. * @returns the class name
  8826. */
  8827. getClassName(): string;
  8828. /** @hidden */
  8829. _onLostFocus(): void;
  8830. /**
  8831. * Get the friendly name associated with the input class.
  8832. * @returns the input friendly name
  8833. */
  8834. getSimpleName(): string;
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Interface describing all the common properties and methods a shadow light needs to implement.
  8840. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8841. * as well as binding the different shadow properties to the effects.
  8842. */
  8843. export interface IShadowLight extends Light {
  8844. /**
  8845. * The light id in the scene (used in scene.findLighById for instance)
  8846. */
  8847. id: string;
  8848. /**
  8849. * The position the shdow will be casted from.
  8850. */
  8851. position: Vector3;
  8852. /**
  8853. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8854. */
  8855. direction: Vector3;
  8856. /**
  8857. * The transformed position. Position of the light in world space taking parenting in account.
  8858. */
  8859. transformedPosition: Vector3;
  8860. /**
  8861. * The transformed direction. Direction of the light in world space taking parenting in account.
  8862. */
  8863. transformedDirection: Vector3;
  8864. /**
  8865. * The friendly name of the light in the scene.
  8866. */
  8867. name: string;
  8868. /**
  8869. * Defines the shadow projection clipping minimum z value.
  8870. */
  8871. shadowMinZ: number;
  8872. /**
  8873. * Defines the shadow projection clipping maximum z value.
  8874. */
  8875. shadowMaxZ: number;
  8876. /**
  8877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8879. */
  8880. computeTransformedInformation(): boolean;
  8881. /**
  8882. * Gets the scene the light belongs to.
  8883. * @returns The scene
  8884. */
  8885. getScene(): Scene;
  8886. /**
  8887. * Callback defining a custom Projection Matrix Builder.
  8888. * This can be used to override the default projection matrix computation.
  8889. */
  8890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8891. /**
  8892. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8893. * @param matrix The materix to updated with the projection information
  8894. * @param viewMatrix The transform matrix of the light
  8895. * @param renderList The list of mesh to render in the map
  8896. * @returns The current light
  8897. */
  8898. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8899. /**
  8900. * Gets the current depth scale used in ESM.
  8901. * @returns The scale
  8902. */
  8903. getDepthScale(): number;
  8904. /**
  8905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8906. * @returns true if a cube texture needs to be use
  8907. */
  8908. needCube(): boolean;
  8909. /**
  8910. * Detects if the projection matrix requires to be recomputed this frame.
  8911. * @returns true if it requires to be recomputed otherwise, false.
  8912. */
  8913. needProjectionMatrixCompute(): boolean;
  8914. /**
  8915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8916. */
  8917. forceProjectionMatrixCompute(): void;
  8918. /**
  8919. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8922. */
  8923. getShadowDirection(faceIndex?: number): Vector3;
  8924. /**
  8925. * Gets the minZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the min for
  8927. * @returns the depth min z
  8928. */
  8929. getDepthMinZ(activeCamera: Camera): number;
  8930. /**
  8931. * Gets the maxZ used for shadow according to both the scene and the light.
  8932. * @param activeCamera The camera we are returning the max for
  8933. * @returns the depth max z
  8934. */
  8935. getDepthMaxZ(activeCamera: Camera): number;
  8936. }
  8937. /**
  8938. * Base implementation IShadowLight
  8939. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8940. */
  8941. export abstract class ShadowLight extends Light implements IShadowLight {
  8942. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8943. protected _position: Vector3;
  8944. protected _setPosition(value: Vector3): void;
  8945. /**
  8946. * Sets the position the shadow will be casted from. Also use as the light position for both
  8947. * point and spot lights.
  8948. */
  8949. get position(): Vector3;
  8950. /**
  8951. * Sets the position the shadow will be casted from. Also use as the light position for both
  8952. * point and spot lights.
  8953. */
  8954. set position(value: Vector3);
  8955. protected _direction: Vector3;
  8956. protected _setDirection(value: Vector3): void;
  8957. /**
  8958. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8959. * Also use as the light direction on spot and directional lights.
  8960. */
  8961. get direction(): Vector3;
  8962. /**
  8963. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8964. * Also use as the light direction on spot and directional lights.
  8965. */
  8966. set direction(value: Vector3);
  8967. protected _shadowMinZ: number;
  8968. /**
  8969. * Gets the shadow projection clipping minimum z value.
  8970. */
  8971. get shadowMinZ(): number;
  8972. /**
  8973. * Sets the shadow projection clipping minimum z value.
  8974. */
  8975. set shadowMinZ(value: number);
  8976. protected _shadowMaxZ: number;
  8977. /**
  8978. * Sets the shadow projection clipping maximum z value.
  8979. */
  8980. get shadowMaxZ(): number;
  8981. /**
  8982. * Gets the shadow projection clipping maximum z value.
  8983. */
  8984. set shadowMaxZ(value: number);
  8985. /**
  8986. * Callback defining a custom Projection Matrix Builder.
  8987. * This can be used to override the default projection matrix computation.
  8988. */
  8989. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. private _needProjectionMatrixCompute;
  8999. /**
  9000. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9001. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9002. */
  9003. computeTransformedInformation(): boolean;
  9004. /**
  9005. * Return the depth scale used for the shadow map.
  9006. * @returns the depth scale.
  9007. */
  9008. getDepthScale(): number;
  9009. /**
  9010. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9011. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9012. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9013. */
  9014. getShadowDirection(faceIndex?: number): Vector3;
  9015. /**
  9016. * Returns the ShadowLight absolute position in the World.
  9017. * @returns the position vector in world space
  9018. */
  9019. getAbsolutePosition(): Vector3;
  9020. /**
  9021. * Sets the ShadowLight direction toward the passed target.
  9022. * @param target The point to target in local space
  9023. * @returns the updated ShadowLight direction
  9024. */
  9025. setDirectionToTarget(target: Vector3): Vector3;
  9026. /**
  9027. * Returns the light rotation in euler definition.
  9028. * @returns the x y z rotation in local space.
  9029. */
  9030. getRotation(): Vector3;
  9031. /**
  9032. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9033. * @returns true if a cube texture needs to be use
  9034. */
  9035. needCube(): boolean;
  9036. /**
  9037. * Detects if the projection matrix requires to be recomputed this frame.
  9038. * @returns true if it requires to be recomputed otherwise, false.
  9039. */
  9040. needProjectionMatrixCompute(): boolean;
  9041. /**
  9042. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9043. */
  9044. forceProjectionMatrixCompute(): void;
  9045. /** @hidden */
  9046. _initCache(): void;
  9047. /** @hidden */
  9048. _isSynchronized(): boolean;
  9049. /**
  9050. * Computes the world matrix of the node
  9051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9052. * @returns the world matrix
  9053. */
  9054. computeWorldMatrix(force?: boolean): Matrix;
  9055. /**
  9056. * Gets the minZ used for shadow according to both the scene and the light.
  9057. * @param activeCamera The camera we are returning the min for
  9058. * @returns the depth min z
  9059. */
  9060. getDepthMinZ(activeCamera: Camera): number;
  9061. /**
  9062. * Gets the maxZ used for shadow according to both the scene and the light.
  9063. * @param activeCamera The camera we are returning the max for
  9064. * @returns the depth max z
  9065. */
  9066. getDepthMaxZ(activeCamera: Camera): number;
  9067. /**
  9068. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9069. * @param matrix The materix to updated with the projection information
  9070. * @param viewMatrix The transform matrix of the light
  9071. * @param renderList The list of mesh to render in the map
  9072. * @returns The current light
  9073. */
  9074. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9075. }
  9076. }
  9077. declare module BABYLON {
  9078. /**
  9079. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9080. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9081. */
  9082. export class EffectFallbacks implements IEffectFallbacks {
  9083. private _defines;
  9084. private _currentRank;
  9085. private _maxRank;
  9086. private _mesh;
  9087. /**
  9088. * Removes the fallback from the bound mesh.
  9089. */
  9090. unBindMesh(): void;
  9091. /**
  9092. * Adds a fallback on the specified property.
  9093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9094. * @param define The name of the define in the shader
  9095. */
  9096. addFallback(rank: number, define: string): void;
  9097. /**
  9098. * Sets the mesh to use CPU skinning when needing to fallback.
  9099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9100. * @param mesh The mesh to use the fallbacks.
  9101. */
  9102. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9103. /**
  9104. * Checks to see if more fallbacks are still availible.
  9105. */
  9106. get hasMoreFallbacks(): boolean;
  9107. /**
  9108. * Removes the defines that should be removed when falling back.
  9109. * @param currentDefines defines the current define statements for the shader.
  9110. * @param effect defines the current effect we try to compile
  9111. * @returns The resulting defines with defines of the current rank removed.
  9112. */
  9113. reduce(currentDefines: string, effect: Effect): string;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. /**
  9118. * "Static Class" containing the most commonly used helper while dealing with material for
  9119. * rendering purpose.
  9120. *
  9121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9122. *
  9123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9124. */
  9125. export class MaterialHelper {
  9126. /**
  9127. * Bind the current view position to an effect.
  9128. * @param effect The effect to be bound
  9129. * @param scene The scene the eyes position is used from
  9130. * @param variableName name of the shader variable that will hold the eye position
  9131. */
  9132. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9133. /**
  9134. * Helps preparing the defines values about the UVs in used in the effect.
  9135. * UVs are shared as much as we can accross channels in the shaders.
  9136. * @param texture The texture we are preparing the UVs for
  9137. * @param defines The defines to update
  9138. * @param key The channel key "diffuse", "specular"... used in the shader
  9139. */
  9140. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9141. /**
  9142. * Binds a texture matrix value to its corrsponding uniform
  9143. * @param texture The texture to bind the matrix for
  9144. * @param uniformBuffer The uniform buffer receivin the data
  9145. * @param key The channel key "diffuse", "specular"... used in the shader
  9146. */
  9147. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9148. /**
  9149. * Gets the current status of the fog (should it be enabled?)
  9150. * @param mesh defines the mesh to evaluate for fog support
  9151. * @param scene defines the hosting scene
  9152. * @returns true if fog must be enabled
  9153. */
  9154. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9155. /**
  9156. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9157. * @param mesh defines the current mesh
  9158. * @param scene defines the current scene
  9159. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9160. * @param pointsCloud defines if point cloud rendering has to be turned on
  9161. * @param fogEnabled defines if fog has to be turned on
  9162. * @param alphaTest defines if alpha testing has to be turned on
  9163. * @param defines defines the current list of defines
  9164. */
  9165. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9166. /**
  9167. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9168. * @param scene defines the current scene
  9169. * @param engine defines the current engine
  9170. * @param defines specifies the list of active defines
  9171. * @param useInstances defines if instances have to be turned on
  9172. * @param useClipPlane defines if clip plane have to be turned on
  9173. */
  9174. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9175. /**
  9176. * Prepares the defines for bones
  9177. * @param mesh The mesh containing the geometry data we will draw
  9178. * @param defines The defines to update
  9179. */
  9180. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9181. /**
  9182. * Prepares the defines for morph targets
  9183. * @param mesh The mesh containing the geometry data we will draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9187. /**
  9188. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9189. * @param mesh The mesh containing the geometry data we will draw
  9190. * @param defines The defines to update
  9191. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9192. * @param useBones Precise whether bones should be used or not (override mesh info)
  9193. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9194. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9195. * @returns false if defines are considered not dirty and have not been checked
  9196. */
  9197. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9198. /**
  9199. * Prepares the defines related to multiview
  9200. * @param scene The scene we are intending to draw
  9201. * @param defines The defines to update
  9202. */
  9203. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param light The light the effect is compiling for
  9209. * @param lightIndex The index of the light
  9210. * @param defines The defines to update
  9211. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9212. * @param state Defines the current state regarding what is needed (normals, etc...)
  9213. */
  9214. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9215. needNormals: boolean;
  9216. needRebuild: boolean;
  9217. shadowEnabled: boolean;
  9218. specularEnabled: boolean;
  9219. lightmapMode: boolean;
  9220. }): void;
  9221. /**
  9222. * Prepares the defines related to the light information passed in parameter
  9223. * @param scene The scene we are intending to draw
  9224. * @param mesh The mesh the effect is compiling for
  9225. * @param defines The defines to update
  9226. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9227. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9228. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9229. * @returns true if normals will be required for the rest of the effect
  9230. */
  9231. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9232. /**
  9233. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9234. * @param lightIndex defines the light index
  9235. * @param uniformsList The uniform list
  9236. * @param samplersList The sampler list
  9237. * @param projectedLightTexture defines if projected texture must be used
  9238. * @param uniformBuffersList defines an optional list of uniform buffers
  9239. */
  9240. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9241. /**
  9242. * Prepares the uniforms and samplers list to be used in the effect
  9243. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9244. * @param samplersList The sampler list
  9245. * @param defines The defines helping in the list generation
  9246. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9247. */
  9248. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9249. /**
  9250. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9251. * @param defines The defines to update while falling back
  9252. * @param fallbacks The authorized effect fallbacks
  9253. * @param maxSimultaneousLights The maximum number of lights allowed
  9254. * @param rank the current rank of the Effect
  9255. * @returns The newly affected rank
  9256. */
  9257. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9258. private static _TmpMorphInfluencers;
  9259. /**
  9260. * Prepares the list of attributes required for morph targets according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the morph targets attributes for
  9263. * @param influencers The number of influencers
  9264. */
  9265. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9266. /**
  9267. * Prepares the list of attributes required for morph targets according to the effect defines.
  9268. * @param attribs The current list of supported attribs
  9269. * @param mesh The mesh to prepare the morph targets attributes for
  9270. * @param defines The current Defines of the effect
  9271. */
  9272. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9273. /**
  9274. * Prepares the list of attributes required for bones according to the effect defines.
  9275. * @param attribs The current list of supported attribs
  9276. * @param mesh The mesh to prepare the bones attributes for
  9277. * @param defines The current Defines of the effect
  9278. * @param fallbacks The current efffect fallback strategy
  9279. */
  9280. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9281. /**
  9282. * Check and prepare the list of attributes required for instances according to the effect defines.
  9283. * @param attribs The current list of supported attribs
  9284. * @param defines The current MaterialDefines of the effect
  9285. */
  9286. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9287. /**
  9288. * Add the list of attributes required for instances to the attribs array.
  9289. * @param attribs The current list of supported attribs
  9290. */
  9291. static PushAttributesForInstances(attribs: string[]): void;
  9292. /**
  9293. * Binds the light information to the effect.
  9294. * @param light The light containing the generator
  9295. * @param effect The effect we are binding the data to
  9296. * @param lightIndex The light index in the effect used to render
  9297. */
  9298. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9299. /**
  9300. * Binds the lights information from the scene to the effect for the given mesh.
  9301. * @param light Light to bind
  9302. * @param lightIndex Light index
  9303. * @param scene The scene where the light belongs to
  9304. * @param effect The effect we are binding the data to
  9305. * @param useSpecular Defines if specular is supported
  9306. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9307. */
  9308. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9309. /**
  9310. * Binds the lights information from the scene to the effect for the given mesh.
  9311. * @param scene The scene the lights belongs to
  9312. * @param mesh The mesh we are binding the information to render
  9313. * @param effect The effect we are binding the data to
  9314. * @param defines The generated defines for the effect
  9315. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9317. */
  9318. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9319. private static _tempFogColor;
  9320. /**
  9321. * Binds the fog information from the scene to the effect for the given mesh.
  9322. * @param scene The scene the lights belongs to
  9323. * @param mesh The mesh we are binding the information to render
  9324. * @param effect The effect we are binding the data to
  9325. * @param linearSpace Defines if the fog effect is applied in linear space
  9326. */
  9327. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9328. /**
  9329. * Binds the bones information from the mesh to the effect.
  9330. * @param mesh The mesh we are binding the information to render
  9331. * @param effect The effect we are binding the data to
  9332. */
  9333. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9334. /**
  9335. * Binds the morph targets information from the mesh to the effect.
  9336. * @param abstractMesh The mesh we are binding the information to render
  9337. * @param effect The effect we are binding the data to
  9338. */
  9339. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9340. /**
  9341. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9342. * @param defines The generated defines used in the effect
  9343. * @param effect The effect we are binding the data to
  9344. * @param scene The scene we are willing to render with logarithmic scale for
  9345. */
  9346. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9347. /**
  9348. * Binds the clip plane information from the scene to the effect.
  9349. * @param scene The scene the clip plane information are extracted from
  9350. * @param effect The effect we are binding the data to
  9351. */
  9352. static BindClipPlane(effect: Effect, scene: Scene): void;
  9353. }
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var packingFunctions: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var shadowMapFragmentDeclaration: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var clipPlaneFragmentDeclaration: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var clipPlaneFragment: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var shadowMapFragment: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var shadowMapPixelShader: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var bonesDeclaration: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /** @hidden */
  9406. export var morphTargetsVertexGlobalDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module BABYLON {
  9412. /** @hidden */
  9413. export var morphTargetsVertexDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module BABYLON {
  9419. /** @hidden */
  9420. export var instancesDeclaration: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module BABYLON {
  9426. /** @hidden */
  9427. export var helperFunctions: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module BABYLON {
  9433. /** @hidden */
  9434. export var shadowMapVertexDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module BABYLON {
  9440. /** @hidden */
  9441. export var clipPlaneVertexDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module BABYLON {
  9447. /** @hidden */
  9448. export var morphTargetsVertex: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module BABYLON {
  9454. /** @hidden */
  9455. export var instancesVertex: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module BABYLON {
  9461. /** @hidden */
  9462. export var bonesVertex: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module BABYLON {
  9468. /** @hidden */
  9469. export var shadowMapVertexNormalBias: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module BABYLON {
  9475. /** @hidden */
  9476. export var shadowMapVertexMetric: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module BABYLON {
  9482. /** @hidden */
  9483. export var clipPlaneVertex: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var shadowMapVertexShader: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var depthBoxBlurPixelShader: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /**
  9504. * Class representing a ray with position and direction
  9505. */
  9506. export class Ray {
  9507. /** origin point */
  9508. origin: Vector3;
  9509. /** direction */
  9510. direction: Vector3;
  9511. /** length of the ray */
  9512. length: number;
  9513. private static readonly TmpVector3;
  9514. private _tmpRay;
  9515. /**
  9516. * Creates a new ray
  9517. * @param origin origin point
  9518. * @param direction direction
  9519. * @param length length of the ray
  9520. */
  9521. constructor(
  9522. /** origin point */
  9523. origin: Vector3,
  9524. /** direction */
  9525. direction: Vector3,
  9526. /** length of the ray */
  9527. length?: number);
  9528. /**
  9529. * Checks if the ray intersects a box
  9530. * This does not account for the ray lenght by design to improve perfs.
  9531. * @param minimum bound of the box
  9532. * @param maximum bound of the box
  9533. * @param intersectionTreshold extra extend to be added to the box in all direction
  9534. * @returns if the box was hit
  9535. */
  9536. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9537. /**
  9538. * Checks if the ray intersects a box
  9539. * This does not account for the ray lenght by design to improve perfs.
  9540. * @param box the bounding box to check
  9541. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9542. * @returns if the box was hit
  9543. */
  9544. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9545. /**
  9546. * If the ray hits a sphere
  9547. * @param sphere the bounding sphere to check
  9548. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9549. * @returns true if it hits the sphere
  9550. */
  9551. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9552. /**
  9553. * If the ray hits a triange
  9554. * @param vertex0 triangle vertex
  9555. * @param vertex1 triangle vertex
  9556. * @param vertex2 triangle vertex
  9557. * @returns intersection information if hit
  9558. */
  9559. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9560. /**
  9561. * Checks if ray intersects a plane
  9562. * @param plane the plane to check
  9563. * @returns the distance away it was hit
  9564. */
  9565. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9566. /**
  9567. * Calculate the intercept of a ray on a given axis
  9568. * @param axis to check 'x' | 'y' | 'z'
  9569. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9570. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9571. */
  9572. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9573. /**
  9574. * Checks if ray intersects a mesh
  9575. * @param mesh the mesh to check
  9576. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9577. * @returns picking info of the intersecton
  9578. */
  9579. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9580. /**
  9581. * Checks if ray intersects a mesh
  9582. * @param meshes the meshes to check
  9583. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9584. * @param results array to store result in
  9585. * @returns Array of picking infos
  9586. */
  9587. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9588. private _comparePickingInfo;
  9589. private static smallnum;
  9590. private static rayl;
  9591. /**
  9592. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9593. * @param sega the first point of the segment to test the intersection against
  9594. * @param segb the second point of the segment to test the intersection against
  9595. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9596. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9597. */
  9598. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9599. /**
  9600. * Update the ray from viewport position
  9601. * @param x position
  9602. * @param y y position
  9603. * @param viewportWidth viewport width
  9604. * @param viewportHeight viewport height
  9605. * @param world world matrix
  9606. * @param view view matrix
  9607. * @param projection projection matrix
  9608. * @returns this ray updated
  9609. */
  9610. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9611. /**
  9612. * Creates a ray with origin and direction of 0,0,0
  9613. * @returns the new ray
  9614. */
  9615. static Zero(): Ray;
  9616. /**
  9617. * Creates a new ray from screen space and viewport
  9618. * @param x position
  9619. * @param y y position
  9620. * @param viewportWidth viewport width
  9621. * @param viewportHeight viewport height
  9622. * @param world world matrix
  9623. * @param view view matrix
  9624. * @param projection projection matrix
  9625. * @returns new ray
  9626. */
  9627. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9628. /**
  9629. * 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
  9630. * transformed to the given world matrix.
  9631. * @param origin The origin point
  9632. * @param end The end point
  9633. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9634. * @returns the new ray
  9635. */
  9636. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9637. /**
  9638. * Transforms a ray by a matrix
  9639. * @param ray ray to transform
  9640. * @param matrix matrix to apply
  9641. * @returns the resulting new ray
  9642. */
  9643. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9644. /**
  9645. * Transforms a ray by a matrix
  9646. * @param ray ray to transform
  9647. * @param matrix matrix to apply
  9648. * @param result ray to store result in
  9649. */
  9650. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9651. /**
  9652. * Unproject a ray from screen space to object space
  9653. * @param sourceX defines the screen space x coordinate to use
  9654. * @param sourceY defines the screen space y coordinate to use
  9655. * @param viewportWidth defines the current width of the viewport
  9656. * @param viewportHeight defines the current height of the viewport
  9657. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9658. * @param view defines the view matrix to use
  9659. * @param projection defines the projection matrix to use
  9660. */
  9661. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9662. }
  9663. /**
  9664. * Type used to define predicate used to select faces when a mesh intersection is detected
  9665. */
  9666. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9667. interface Scene {
  9668. /** @hidden */
  9669. _tempPickingRay: Nullable<Ray>;
  9670. /** @hidden */
  9671. _cachedRayForTransform: Ray;
  9672. /** @hidden */
  9673. _pickWithRayInverseMatrix: Matrix;
  9674. /** @hidden */
  9675. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9676. /** @hidden */
  9677. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9678. }
  9679. }
  9680. declare module BABYLON {
  9681. /**
  9682. * Groups all the scene component constants in one place to ease maintenance.
  9683. * @hidden
  9684. */
  9685. export class SceneComponentConstants {
  9686. static readonly NAME_EFFECTLAYER: string;
  9687. static readonly NAME_LAYER: string;
  9688. static readonly NAME_LENSFLARESYSTEM: string;
  9689. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9690. static readonly NAME_PARTICLESYSTEM: string;
  9691. static readonly NAME_GAMEPAD: string;
  9692. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9693. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9694. static readonly NAME_DEPTHRENDERER: string;
  9695. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9696. static readonly NAME_SPRITE: string;
  9697. static readonly NAME_OUTLINERENDERER: string;
  9698. static readonly NAME_PROCEDURALTEXTURE: string;
  9699. static readonly NAME_SHADOWGENERATOR: string;
  9700. static readonly NAME_OCTREE: string;
  9701. static readonly NAME_PHYSICSENGINE: string;
  9702. static readonly NAME_AUDIO: string;
  9703. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9704. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9705. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9706. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9707. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9708. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9709. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9710. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9711. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9712. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9713. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9714. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9715. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9716. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9717. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9718. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9719. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9720. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9721. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9722. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9723. static readonly STEP_AFTERRENDER_AUDIO: number;
  9724. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9725. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9726. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9727. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9728. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9729. static readonly STEP_POINTERMOVE_SPRITE: number;
  9730. static readonly STEP_POINTERDOWN_SPRITE: number;
  9731. static readonly STEP_POINTERUP_SPRITE: number;
  9732. }
  9733. /**
  9734. * This represents a scene component.
  9735. *
  9736. * This is used to decouple the dependency the scene is having on the different workloads like
  9737. * layers, post processes...
  9738. */
  9739. export interface ISceneComponent {
  9740. /**
  9741. * The name of the component. Each component must have a unique name.
  9742. */
  9743. name: string;
  9744. /**
  9745. * The scene the component belongs to.
  9746. */
  9747. scene: Scene;
  9748. /**
  9749. * Register the component to one instance of a scene.
  9750. */
  9751. register(): void;
  9752. /**
  9753. * Rebuilds the elements related to this component in case of
  9754. * context lost for instance.
  9755. */
  9756. rebuild(): void;
  9757. /**
  9758. * Disposes the component and the associated ressources.
  9759. */
  9760. dispose(): void;
  9761. }
  9762. /**
  9763. * This represents a SERIALIZABLE scene component.
  9764. *
  9765. * This extends Scene Component to add Serialization methods on top.
  9766. */
  9767. export interface ISceneSerializableComponent extends ISceneComponent {
  9768. /**
  9769. * Adds all the elements from the container to the scene
  9770. * @param container the container holding the elements
  9771. */
  9772. addFromContainer(container: AbstractScene): void;
  9773. /**
  9774. * Removes all the elements in the container from the scene
  9775. * @param container contains the elements to remove
  9776. * @param dispose if the removed element should be disposed (default: false)
  9777. */
  9778. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9779. /**
  9780. * Serializes the component data to the specified json object
  9781. * @param serializationObject The object to serialize to
  9782. */
  9783. serialize(serializationObject: any): void;
  9784. }
  9785. /**
  9786. * Strong typing of a Mesh related stage step action
  9787. */
  9788. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9789. /**
  9790. * Strong typing of a Evaluate Sub Mesh related stage step action
  9791. */
  9792. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9793. /**
  9794. * Strong typing of a Active Mesh related stage step action
  9795. */
  9796. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9797. /**
  9798. * Strong typing of a Camera related stage step action
  9799. */
  9800. export type CameraStageAction = (camera: Camera) => void;
  9801. /**
  9802. * Strong typing of a Camera Frame buffer related stage step action
  9803. */
  9804. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9805. /**
  9806. * Strong typing of a Render Target related stage step action
  9807. */
  9808. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9809. /**
  9810. * Strong typing of a RenderingGroup related stage step action
  9811. */
  9812. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9813. /**
  9814. * Strong typing of a Mesh Render related stage step action
  9815. */
  9816. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9817. /**
  9818. * Strong typing of a simple stage step action
  9819. */
  9820. export type SimpleStageAction = () => void;
  9821. /**
  9822. * Strong typing of a render target action.
  9823. */
  9824. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9825. /**
  9826. * Strong typing of a pointer move action.
  9827. */
  9828. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9829. /**
  9830. * Strong typing of a pointer up/down action.
  9831. */
  9832. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9833. /**
  9834. * Representation of a stage in the scene (Basically a list of ordered steps)
  9835. * @hidden
  9836. */
  9837. export class Stage<T extends Function> extends Array<{
  9838. index: number;
  9839. component: ISceneComponent;
  9840. action: T;
  9841. }> {
  9842. /**
  9843. * Hide ctor from the rest of the world.
  9844. * @param items The items to add.
  9845. */
  9846. private constructor();
  9847. /**
  9848. * Creates a new Stage.
  9849. * @returns A new instance of a Stage
  9850. */
  9851. static Create<T extends Function>(): Stage<T>;
  9852. /**
  9853. * Registers a step in an ordered way in the targeted stage.
  9854. * @param index Defines the position to register the step in
  9855. * @param component Defines the component attached to the step
  9856. * @param action Defines the action to launch during the step
  9857. */
  9858. registerStep(index: number, component: ISceneComponent, action: T): void;
  9859. /**
  9860. * Clears all the steps from the stage.
  9861. */
  9862. clear(): void;
  9863. }
  9864. }
  9865. declare module BABYLON {
  9866. interface Scene {
  9867. /** @hidden */
  9868. _pointerOverSprite: Nullable<Sprite>;
  9869. /** @hidden */
  9870. _pickedDownSprite: Nullable<Sprite>;
  9871. /** @hidden */
  9872. _tempSpritePickingRay: Nullable<Ray>;
  9873. /**
  9874. * All of the sprite managers added to this scene
  9875. * @see http://doc.babylonjs.com/babylon101/sprites
  9876. */
  9877. spriteManagers: Array<ISpriteManager>;
  9878. /**
  9879. * An event triggered when sprites rendering is about to start
  9880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9881. */
  9882. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9883. /**
  9884. * An event triggered when sprites rendering is done
  9885. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9886. */
  9887. onAfterSpritesRenderingObservable: Observable<Scene>;
  9888. /** @hidden */
  9889. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9890. /** Launch a ray to try to pick a sprite in the scene
  9891. * @param x position on screen
  9892. * @param y position on screen
  9893. * @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
  9894. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9895. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9896. * @returns a PickingInfo
  9897. */
  9898. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9899. /** Use the given ray to pick a sprite in the scene
  9900. * @param ray The ray (in world space) to use to pick meshes
  9901. * @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
  9902. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9903. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9904. * @returns a PickingInfo
  9905. */
  9906. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9907. /** @hidden */
  9908. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9909. /** Launch a ray to try to pick sprites in the scene
  9910. * @param x position on screen
  9911. * @param y position on screen
  9912. * @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
  9913. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9914. * @returns a PickingInfo array
  9915. */
  9916. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9917. /** Use the given ray to pick sprites in the scene
  9918. * @param ray The ray (in world space) to use to pick meshes
  9919. * @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
  9920. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9921. * @returns a PickingInfo array
  9922. */
  9923. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9924. /**
  9925. * Force the sprite under the pointer
  9926. * @param sprite defines the sprite to use
  9927. */
  9928. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9929. /**
  9930. * Gets the sprite under the pointer
  9931. * @returns a Sprite or null if no sprite is under the pointer
  9932. */
  9933. getPointerOverSprite(): Nullable<Sprite>;
  9934. }
  9935. /**
  9936. * Defines the sprite scene component responsible to manage sprites
  9937. * in a given scene.
  9938. */
  9939. export class SpriteSceneComponent implements ISceneComponent {
  9940. /**
  9941. * The component name helpfull to identify the component in the list of scene components.
  9942. */
  9943. readonly name: string;
  9944. /**
  9945. * The scene the component belongs to.
  9946. */
  9947. scene: Scene;
  9948. /** @hidden */
  9949. private _spritePredicate;
  9950. /**
  9951. * Creates a new instance of the component for the given scene
  9952. * @param scene Defines the scene to register the component in
  9953. */
  9954. constructor(scene: Scene);
  9955. /**
  9956. * Registers the component in a given scene
  9957. */
  9958. register(): void;
  9959. /**
  9960. * Rebuilds the elements related to this component in case of
  9961. * context lost for instance.
  9962. */
  9963. rebuild(): void;
  9964. /**
  9965. * Disposes the component and the associated ressources.
  9966. */
  9967. dispose(): void;
  9968. private _pickSpriteButKeepRay;
  9969. private _pointerMove;
  9970. private _pointerDown;
  9971. private _pointerUp;
  9972. }
  9973. }
  9974. declare module BABYLON {
  9975. /** @hidden */
  9976. export var fogFragmentDeclaration: {
  9977. name: string;
  9978. shader: string;
  9979. };
  9980. }
  9981. declare module BABYLON {
  9982. /** @hidden */
  9983. export var fogFragment: {
  9984. name: string;
  9985. shader: string;
  9986. };
  9987. }
  9988. declare module BABYLON {
  9989. /** @hidden */
  9990. export var spritesPixelShader: {
  9991. name: string;
  9992. shader: string;
  9993. };
  9994. }
  9995. declare module BABYLON {
  9996. /** @hidden */
  9997. export var fogVertexDeclaration: {
  9998. name: string;
  9999. shader: string;
  10000. };
  10001. }
  10002. declare module BABYLON {
  10003. /** @hidden */
  10004. export var spritesVertexShader: {
  10005. name: string;
  10006. shader: string;
  10007. };
  10008. }
  10009. declare module BABYLON {
  10010. /**
  10011. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10012. */
  10013. export interface ISpriteManager extends IDisposable {
  10014. /**
  10015. * Restricts the camera to viewing objects with the same layerMask.
  10016. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10017. */
  10018. layerMask: number;
  10019. /**
  10020. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10021. */
  10022. isPickable: boolean;
  10023. /**
  10024. * Specifies the rendering group id for this mesh (0 by default)
  10025. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10026. */
  10027. renderingGroupId: number;
  10028. /**
  10029. * Defines the list of sprites managed by the manager.
  10030. */
  10031. sprites: Array<Sprite>;
  10032. /**
  10033. * Tests the intersection of a sprite with a specific ray.
  10034. * @param ray The ray we are sending to test the collision
  10035. * @param camera The camera space we are sending rays in
  10036. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10037. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10038. * @returns picking info or null.
  10039. */
  10040. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10041. /**
  10042. * Intersects the sprites with a ray
  10043. * @param ray defines the ray to intersect with
  10044. * @param camera defines the current active camera
  10045. * @param predicate defines a predicate used to select candidate sprites
  10046. * @returns null if no hit or a PickingInfo array
  10047. */
  10048. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10049. /**
  10050. * Renders the list of sprites on screen.
  10051. */
  10052. render(): void;
  10053. }
  10054. /**
  10055. * Class used to manage multiple sprites on the same spritesheet
  10056. * @see http://doc.babylonjs.com/babylon101/sprites
  10057. */
  10058. export class SpriteManager implements ISpriteManager {
  10059. /** defines the manager's name */
  10060. name: string;
  10061. /** Gets the list of sprites */
  10062. sprites: Sprite[];
  10063. /** Gets or sets the rendering group id (0 by default) */
  10064. renderingGroupId: number;
  10065. /** Gets or sets camera layer mask */
  10066. layerMask: number;
  10067. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10068. fogEnabled: boolean;
  10069. /** Gets or sets a boolean indicating if the sprites are pickable */
  10070. isPickable: boolean;
  10071. /** Defines the default width of a cell in the spritesheet */
  10072. cellWidth: number;
  10073. /** Defines the default height of a cell in the spritesheet */
  10074. cellHeight: number;
  10075. /** Associative array from JSON sprite data file */
  10076. private _cellData;
  10077. /** Array of sprite names from JSON sprite data file */
  10078. private _spriteMap;
  10079. /** True when packed cell data from JSON file is ready*/
  10080. private _packedAndReady;
  10081. private _textureContent;
  10082. /**
  10083. * An event triggered when the manager is disposed.
  10084. */
  10085. onDisposeObservable: Observable<SpriteManager>;
  10086. private _onDisposeObserver;
  10087. /**
  10088. * Callback called when the manager is disposed
  10089. */
  10090. set onDispose(callback: () => void);
  10091. private _capacity;
  10092. private _fromPacked;
  10093. private _spriteTexture;
  10094. private _epsilon;
  10095. private _scene;
  10096. private _vertexData;
  10097. private _buffer;
  10098. private _vertexBuffers;
  10099. private _indexBuffer;
  10100. private _effectBase;
  10101. private _effectFog;
  10102. /**
  10103. * Gets or sets the spritesheet texture
  10104. */
  10105. get texture(): Texture;
  10106. set texture(value: Texture);
  10107. private _blendMode;
  10108. /**
  10109. * Blend mode use to render the particle, it can be any of
  10110. * the static Constants.ALPHA_x properties provided in this class.
  10111. * Default value is Constants.ALPHA_COMBINE
  10112. */
  10113. get blendMode(): number;
  10114. set blendMode(blendMode: number);
  10115. /** Disables writing to the depth buffer when rendering the sprites.
  10116. * It can be handy to disable depth writing when using textures without alpha channel
  10117. * and setting some specific blend modes.
  10118. */
  10119. disableDepthWrite: boolean;
  10120. /**
  10121. * Creates a new sprite manager
  10122. * @param name defines the manager's name
  10123. * @param imgUrl defines the sprite sheet url
  10124. * @param capacity defines the maximum allowed number of sprites
  10125. * @param cellSize defines the size of a sprite cell
  10126. * @param scene defines the hosting scene
  10127. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10128. * @param samplingMode defines the smapling mode to use with spritesheet
  10129. * @param fromPacked set to false; do not alter
  10130. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10131. */
  10132. constructor(
  10133. /** defines the manager's name */
  10134. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10135. private _makePacked;
  10136. private _appendSpriteVertex;
  10137. private _checkTextureAlpha;
  10138. /**
  10139. * Intersects the sprites with a ray
  10140. * @param ray defines the ray to intersect with
  10141. * @param camera defines the current active camera
  10142. * @param predicate defines a predicate used to select candidate sprites
  10143. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10144. * @returns null if no hit or a PickingInfo
  10145. */
  10146. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10147. /**
  10148. * Intersects the sprites with a ray
  10149. * @param ray defines the ray to intersect with
  10150. * @param camera defines the current active camera
  10151. * @param predicate defines a predicate used to select candidate sprites
  10152. * @returns null if no hit or a PickingInfo array
  10153. */
  10154. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10155. /**
  10156. * Render all child sprites
  10157. */
  10158. render(): void;
  10159. /**
  10160. * Release associated resources
  10161. */
  10162. dispose(): void;
  10163. }
  10164. }
  10165. declare module BABYLON {
  10166. /** Interface used by value gradients (color, factor, ...) */
  10167. export interface IValueGradient {
  10168. /**
  10169. * Gets or sets the gradient value (between 0 and 1)
  10170. */
  10171. gradient: number;
  10172. }
  10173. /** Class used to store color4 gradient */
  10174. export class ColorGradient implements IValueGradient {
  10175. /**
  10176. * Gets or sets the gradient value (between 0 and 1)
  10177. */
  10178. gradient: number;
  10179. /**
  10180. * Gets or sets first associated color
  10181. */
  10182. color1: Color4;
  10183. /**
  10184. * Gets or sets second associated color
  10185. */
  10186. color2?: Color4 | undefined;
  10187. /**
  10188. * Creates a new color4 gradient
  10189. * @param gradient gets or sets the gradient value (between 0 and 1)
  10190. * @param color1 gets or sets first associated color
  10191. * @param color2 gets or sets first second color
  10192. */
  10193. constructor(
  10194. /**
  10195. * Gets or sets the gradient value (between 0 and 1)
  10196. */
  10197. gradient: number,
  10198. /**
  10199. * Gets or sets first associated color
  10200. */
  10201. color1: Color4,
  10202. /**
  10203. * Gets or sets second associated color
  10204. */
  10205. color2?: Color4 | undefined);
  10206. /**
  10207. * Will get a color picked randomly between color1 and color2.
  10208. * If color2 is undefined then color1 will be used
  10209. * @param result defines the target Color4 to store the result in
  10210. */
  10211. getColorToRef(result: Color4): void;
  10212. }
  10213. /** Class used to store color 3 gradient */
  10214. export class Color3Gradient implements IValueGradient {
  10215. /**
  10216. * Gets or sets the gradient value (between 0 and 1)
  10217. */
  10218. gradient: number;
  10219. /**
  10220. * Gets or sets the associated color
  10221. */
  10222. color: Color3;
  10223. /**
  10224. * Creates a new color3 gradient
  10225. * @param gradient gets or sets the gradient value (between 0 and 1)
  10226. * @param color gets or sets associated color
  10227. */
  10228. constructor(
  10229. /**
  10230. * Gets or sets the gradient value (between 0 and 1)
  10231. */
  10232. gradient: number,
  10233. /**
  10234. * Gets or sets the associated color
  10235. */
  10236. color: Color3);
  10237. }
  10238. /** Class used to store factor gradient */
  10239. export class FactorGradient implements IValueGradient {
  10240. /**
  10241. * Gets or sets the gradient value (between 0 and 1)
  10242. */
  10243. gradient: number;
  10244. /**
  10245. * Gets or sets first associated factor
  10246. */
  10247. factor1: number;
  10248. /**
  10249. * Gets or sets second associated factor
  10250. */
  10251. factor2?: number | undefined;
  10252. /**
  10253. * Creates a new factor gradient
  10254. * @param gradient gets or sets the gradient value (between 0 and 1)
  10255. * @param factor1 gets or sets first associated factor
  10256. * @param factor2 gets or sets second associated factor
  10257. */
  10258. constructor(
  10259. /**
  10260. * Gets or sets the gradient value (between 0 and 1)
  10261. */
  10262. gradient: number,
  10263. /**
  10264. * Gets or sets first associated factor
  10265. */
  10266. factor1: number,
  10267. /**
  10268. * Gets or sets second associated factor
  10269. */
  10270. factor2?: number | undefined);
  10271. /**
  10272. * Will get a number picked randomly between factor1 and factor2.
  10273. * If factor2 is undefined then factor1 will be used
  10274. * @returns the picked number
  10275. */
  10276. getFactor(): number;
  10277. }
  10278. /**
  10279. * Helper used to simplify some generic gradient tasks
  10280. */
  10281. export class GradientHelper {
  10282. /**
  10283. * Gets the current gradient from an array of IValueGradient
  10284. * @param ratio defines the current ratio to get
  10285. * @param gradients defines the array of IValueGradient
  10286. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10287. */
  10288. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10289. }
  10290. }
  10291. declare module BABYLON {
  10292. /**
  10293. * Interface for the size containing width and height
  10294. */
  10295. export interface ISize {
  10296. /**
  10297. * Width
  10298. */
  10299. width: number;
  10300. /**
  10301. * Heighht
  10302. */
  10303. height: number;
  10304. }
  10305. /**
  10306. * Size containing widht and height
  10307. */
  10308. export class Size implements ISize {
  10309. /**
  10310. * Width
  10311. */
  10312. width: number;
  10313. /**
  10314. * Height
  10315. */
  10316. height: number;
  10317. /**
  10318. * Creates a Size object from the given width and height (floats).
  10319. * @param width width of the new size
  10320. * @param height height of the new size
  10321. */
  10322. constructor(width: number, height: number);
  10323. /**
  10324. * Returns a string with the Size width and height
  10325. * @returns a string with the Size width and height
  10326. */
  10327. toString(): string;
  10328. /**
  10329. * "Size"
  10330. * @returns the string "Size"
  10331. */
  10332. getClassName(): string;
  10333. /**
  10334. * Returns the Size hash code.
  10335. * @returns a hash code for a unique width and height
  10336. */
  10337. getHashCode(): number;
  10338. /**
  10339. * Updates the current size from the given one.
  10340. * @param src the given size
  10341. */
  10342. copyFrom(src: Size): void;
  10343. /**
  10344. * Updates in place the current Size from the given floats.
  10345. * @param width width of the new size
  10346. * @param height height of the new size
  10347. * @returns the updated Size.
  10348. */
  10349. copyFromFloats(width: number, height: number): Size;
  10350. /**
  10351. * Updates in place the current Size from the given floats.
  10352. * @param width width to set
  10353. * @param height height to set
  10354. * @returns the updated Size.
  10355. */
  10356. set(width: number, height: number): Size;
  10357. /**
  10358. * Multiplies the width and height by numbers
  10359. * @param w factor to multiple the width by
  10360. * @param h factor to multiple the height by
  10361. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10362. */
  10363. multiplyByFloats(w: number, h: number): Size;
  10364. /**
  10365. * Clones the size
  10366. * @returns a new Size copied from the given one.
  10367. */
  10368. clone(): Size;
  10369. /**
  10370. * True if the current Size and the given one width and height are strictly equal.
  10371. * @param other the other size to compare against
  10372. * @returns True if the current Size and the given one width and height are strictly equal.
  10373. */
  10374. equals(other: Size): boolean;
  10375. /**
  10376. * The surface of the Size : width * height (float).
  10377. */
  10378. get surface(): number;
  10379. /**
  10380. * Create a new size of zero
  10381. * @returns a new Size set to (0.0, 0.0)
  10382. */
  10383. static Zero(): Size;
  10384. /**
  10385. * Sums the width and height of two sizes
  10386. * @param otherSize size to add to this size
  10387. * @returns a new Size set as the addition result of the current Size and the given one.
  10388. */
  10389. add(otherSize: Size): Size;
  10390. /**
  10391. * Subtracts the width and height of two
  10392. * @param otherSize size to subtract to this size
  10393. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10394. */
  10395. subtract(otherSize: Size): Size;
  10396. /**
  10397. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10398. * @param start starting size to lerp between
  10399. * @param end end size to lerp between
  10400. * @param amount amount to lerp between the start and end values
  10401. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10402. */
  10403. static Lerp(start: Size, end: Size, amount: number): Size;
  10404. }
  10405. }
  10406. declare module BABYLON {
  10407. interface ThinEngine {
  10408. /**
  10409. * Creates a dynamic texture
  10410. * @param width defines the width of the texture
  10411. * @param height defines the height of the texture
  10412. * @param generateMipMaps defines if the engine should generate the mip levels
  10413. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10414. * @returns the dynamic texture inside an InternalTexture
  10415. */
  10416. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10417. /**
  10418. * Update the content of a dynamic texture
  10419. * @param texture defines the texture to update
  10420. * @param canvas defines the canvas containing the source
  10421. * @param invertY defines if data must be stored with Y axis inverted
  10422. * @param premulAlpha defines if alpha is stored as premultiplied
  10423. * @param format defines the format of the data
  10424. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10425. */
  10426. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10427. }
  10428. }
  10429. declare module BABYLON {
  10430. /**
  10431. * Helper class used to generate a canvas to manipulate images
  10432. */
  10433. export class CanvasGenerator {
  10434. /**
  10435. * Create a new canvas (or offscreen canvas depending on the context)
  10436. * @param width defines the expected width
  10437. * @param height defines the expected height
  10438. * @return a new canvas or offscreen canvas
  10439. */
  10440. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10441. }
  10442. }
  10443. declare module BABYLON {
  10444. /**
  10445. * A class extending Texture allowing drawing on a texture
  10446. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10447. */
  10448. export class DynamicTexture extends Texture {
  10449. private _generateMipMaps;
  10450. private _canvas;
  10451. private _context;
  10452. private _engine;
  10453. /**
  10454. * Creates a DynamicTexture
  10455. * @param name defines the name of the texture
  10456. * @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
  10457. * @param scene defines the scene where you want the texture
  10458. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10459. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10460. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10461. */
  10462. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10463. /**
  10464. * Get the current class name of the texture useful for serialization or dynamic coding.
  10465. * @returns "DynamicTexture"
  10466. */
  10467. getClassName(): string;
  10468. /**
  10469. * Gets the current state of canRescale
  10470. */
  10471. get canRescale(): boolean;
  10472. private _recreate;
  10473. /**
  10474. * Scales the texture
  10475. * @param ratio the scale factor to apply to both width and height
  10476. */
  10477. scale(ratio: number): void;
  10478. /**
  10479. * Resizes the texture
  10480. * @param width the new width
  10481. * @param height the new height
  10482. */
  10483. scaleTo(width: number, height: number): void;
  10484. /**
  10485. * Gets the context of the canvas used by the texture
  10486. * @returns the canvas context of the dynamic texture
  10487. */
  10488. getContext(): CanvasRenderingContext2D;
  10489. /**
  10490. * Clears the texture
  10491. */
  10492. clear(): void;
  10493. /**
  10494. * Updates the texture
  10495. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10496. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10497. */
  10498. update(invertY?: boolean, premulAlpha?: boolean): void;
  10499. /**
  10500. * Draws text onto the texture
  10501. * @param text defines the text to be drawn
  10502. * @param x defines the placement of the text from the left
  10503. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10504. * @param font defines the font to be used with font-style, font-size, font-name
  10505. * @param color defines the color used for the text
  10506. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10507. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10508. * @param update defines whether texture is immediately update (default is true)
  10509. */
  10510. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10511. /**
  10512. * Clones the texture
  10513. * @returns the clone of the texture.
  10514. */
  10515. clone(): DynamicTexture;
  10516. /**
  10517. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10518. * @returns a serialized dynamic texture object
  10519. */
  10520. serialize(): any;
  10521. /** @hidden */
  10522. _rebuild(): void;
  10523. }
  10524. }
  10525. declare module BABYLON {
  10526. interface ThinEngine {
  10527. /**
  10528. * Creates a raw texture
  10529. * @param data defines the data to store in the texture
  10530. * @param width defines the width of the texture
  10531. * @param height defines the height of the texture
  10532. * @param format defines the format of the data
  10533. * @param generateMipMaps defines if the engine should generate the mip levels
  10534. * @param invertY defines if data must be stored with Y axis inverted
  10535. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10536. * @param compression defines the compression used (null by default)
  10537. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10538. * @returns the raw texture inside an InternalTexture
  10539. */
  10540. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10541. /**
  10542. * Update a raw texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store in the texture
  10545. * @param format defines the format of the data
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. */
  10548. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10549. /**
  10550. * Update a raw texture
  10551. * @param texture defines the texture to update
  10552. * @param data defines the data to store in the texture
  10553. * @param format defines the format of the data
  10554. * @param invertY defines if data must be stored with Y axis inverted
  10555. * @param compression defines the compression used (null by default)
  10556. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10557. */
  10558. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10559. /**
  10560. * Creates a new raw cube texture
  10561. * @param data defines the array of data to use to create each face
  10562. * @param size defines the size of the textures
  10563. * @param format defines the format of the data
  10564. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10565. * @param generateMipMaps defines if the engine should generate the mip levels
  10566. * @param invertY defines if data must be stored with Y axis inverted
  10567. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10568. * @param compression defines the compression used (null by default)
  10569. * @returns the cube texture as an InternalTexture
  10570. */
  10571. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10572. /**
  10573. * Update a raw cube texture
  10574. * @param texture defines the texture to udpdate
  10575. * @param data defines the data to store
  10576. * @param format defines the data format
  10577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10578. * @param invertY defines if data must be stored with Y axis inverted
  10579. */
  10580. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10581. /**
  10582. * Update a raw cube texture
  10583. * @param texture defines the texture to udpdate
  10584. * @param data defines the data to store
  10585. * @param format defines the data format
  10586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10587. * @param invertY defines if data must be stored with Y axis inverted
  10588. * @param compression defines the compression used (null by default)
  10589. */
  10590. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10591. /**
  10592. * Update a raw cube texture
  10593. * @param texture defines the texture to udpdate
  10594. * @param data defines the data to store
  10595. * @param format defines the data format
  10596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10597. * @param invertY defines if data must be stored with Y axis inverted
  10598. * @param compression defines the compression used (null by default)
  10599. * @param level defines which level of the texture to update
  10600. */
  10601. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10602. /**
  10603. * Creates a new raw cube texture from a specified url
  10604. * @param url defines the url where the data is located
  10605. * @param scene defines the current scene
  10606. * @param size defines the size of the textures
  10607. * @param format defines the format of the data
  10608. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10609. * @param noMipmap defines if the engine should avoid generating the mip levels
  10610. * @param callback defines a callback used to extract texture data from loaded data
  10611. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10612. * @param onLoad defines a callback called when texture is loaded
  10613. * @param onError defines a callback called if there is an error
  10614. * @returns the cube texture as an InternalTexture
  10615. */
  10616. 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;
  10617. /**
  10618. * Creates a new raw cube texture from a specified url
  10619. * @param url defines the url where the data is located
  10620. * @param scene defines the current scene
  10621. * @param size defines the size of the textures
  10622. * @param format defines the format of the data
  10623. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10624. * @param noMipmap defines if the engine should avoid generating the mip levels
  10625. * @param callback defines a callback used to extract texture data from loaded data
  10626. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10627. * @param onLoad defines a callback called when texture is loaded
  10628. * @param onError defines a callback called if there is an error
  10629. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. * @returns the cube texture as an InternalTexture
  10632. */
  10633. 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;
  10634. /**
  10635. * Creates a new raw 3D texture
  10636. * @param data defines the data used to create the texture
  10637. * @param width defines the width of the texture
  10638. * @param height defines the height of the texture
  10639. * @param depth defines the depth of the texture
  10640. * @param format defines the format of the texture
  10641. * @param generateMipMaps defines if the engine must generate mip levels
  10642. * @param invertY defines if data must be stored with Y axis inverted
  10643. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10644. * @param compression defines the compressed used (can be null)
  10645. * @param textureType defines the compressed used (can be null)
  10646. * @returns a new raw 3D texture (stored in an InternalTexture)
  10647. */
  10648. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10649. /**
  10650. * Update a raw 3D texture
  10651. * @param texture defines the texture to update
  10652. * @param data defines the data to store
  10653. * @param format defines the data format
  10654. * @param invertY defines if data must be stored with Y axis inverted
  10655. */
  10656. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10657. /**
  10658. * Update a raw 3D texture
  10659. * @param texture defines the texture to update
  10660. * @param data defines the data to store
  10661. * @param format defines the data format
  10662. * @param invertY defines if data must be stored with Y axis inverted
  10663. * @param compression defines the used compression (can be null)
  10664. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10665. */
  10666. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10667. /**
  10668. * Creates a new raw 2D array texture
  10669. * @param data defines the data used to create the texture
  10670. * @param width defines the width of the texture
  10671. * @param height defines the height of the texture
  10672. * @param depth defines the number of layers of the texture
  10673. * @param format defines the format of the texture
  10674. * @param generateMipMaps defines if the engine must generate mip levels
  10675. * @param invertY defines if data must be stored with Y axis inverted
  10676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param compression defines the compressed used (can be null)
  10678. * @param textureType defines the compressed used (can be null)
  10679. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10680. */
  10681. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10682. /**
  10683. * Update a raw 2D array texture
  10684. * @param texture defines the texture to update
  10685. * @param data defines the data to store
  10686. * @param format defines the data format
  10687. * @param invertY defines if data must be stored with Y axis inverted
  10688. */
  10689. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10690. /**
  10691. * Update a raw 2D array texture
  10692. * @param texture defines the texture to update
  10693. * @param data defines the data to store
  10694. * @param format defines the data format
  10695. * @param invertY defines if data must be stored with Y axis inverted
  10696. * @param compression defines the used compression (can be null)
  10697. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10698. */
  10699. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10700. }
  10701. }
  10702. declare module BABYLON {
  10703. /**
  10704. * Raw texture can help creating a texture directly from an array of data.
  10705. * This can be super useful if you either get the data from an uncompressed source or
  10706. * if you wish to create your texture pixel by pixel.
  10707. */
  10708. export class RawTexture extends Texture {
  10709. /**
  10710. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10711. */
  10712. format: number;
  10713. private _engine;
  10714. /**
  10715. * Instantiates a new RawTexture.
  10716. * Raw texture can help creating a texture directly from an array of data.
  10717. * This can be super useful if you either get the data from an uncompressed source or
  10718. * if you wish to create your texture pixel by pixel.
  10719. * @param data define the array of data to use to create the texture
  10720. * @param width define the width of the texture
  10721. * @param height define the height of the texture
  10722. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10723. * @param scene define the scene the texture belongs to
  10724. * @param generateMipMaps define whether mip maps should be generated or not
  10725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10727. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10728. */
  10729. constructor(data: ArrayBufferView, width: number, height: number,
  10730. /**
  10731. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10732. */
  10733. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10734. /**
  10735. * Updates the texture underlying data.
  10736. * @param data Define the new data of the texture
  10737. */
  10738. update(data: ArrayBufferView): void;
  10739. /**
  10740. * Creates a luminance texture from some data.
  10741. * @param data Define the texture data
  10742. * @param width Define the width of the texture
  10743. * @param height Define the height of the texture
  10744. * @param scene Define the scene the texture belongs to
  10745. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10746. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10747. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10748. * @returns the luminance texture
  10749. */
  10750. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10751. /**
  10752. * Creates a luminance alpha texture from some data.
  10753. * @param data Define the texture data
  10754. * @param width Define the width of the texture
  10755. * @param height Define the height of the texture
  10756. * @param scene Define the scene the texture belongs to
  10757. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10758. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10759. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10760. * @returns the luminance alpha texture
  10761. */
  10762. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10763. /**
  10764. * Creates an alpha texture from some data.
  10765. * @param data Define the texture data
  10766. * @param width Define the width of the texture
  10767. * @param height Define the height of the texture
  10768. * @param scene Define the scene the texture belongs to
  10769. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10770. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10771. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10772. * @returns the alpha texture
  10773. */
  10774. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10775. /**
  10776. * Creates a RGB texture from some data.
  10777. * @param data Define the texture data
  10778. * @param width Define the width of the texture
  10779. * @param height Define the height of the texture
  10780. * @param scene Define the scene the texture belongs to
  10781. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10782. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10783. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10784. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10785. * @returns the RGB alpha texture
  10786. */
  10787. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10788. /**
  10789. * Creates a RGBA texture from some data.
  10790. * @param data Define the texture data
  10791. * @param width Define the width of the texture
  10792. * @param height Define the height of the texture
  10793. * @param scene Define the scene the texture belongs to
  10794. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10798. * @returns the RGBA texture
  10799. */
  10800. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10801. /**
  10802. * Creates a R texture from some data.
  10803. * @param data Define the texture data
  10804. * @param width Define the width of the texture
  10805. * @param height Define the height of the texture
  10806. * @param scene Define the scene the texture belongs to
  10807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10811. * @returns the R texture
  10812. */
  10813. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10814. }
  10815. }
  10816. declare module BABYLON {
  10817. interface AbstractScene {
  10818. /**
  10819. * The list of procedural textures added to the scene
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10821. */
  10822. proceduralTextures: Array<ProceduralTexture>;
  10823. }
  10824. /**
  10825. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10826. * in a given scene.
  10827. */
  10828. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10829. /**
  10830. * The component name helpfull to identify the component in the list of scene components.
  10831. */
  10832. readonly name: string;
  10833. /**
  10834. * The scene the component belongs to.
  10835. */
  10836. scene: Scene;
  10837. /**
  10838. * Creates a new instance of the component for the given scene
  10839. * @param scene Defines the scene to register the component in
  10840. */
  10841. constructor(scene: Scene);
  10842. /**
  10843. * Registers the component in a given scene
  10844. */
  10845. register(): void;
  10846. /**
  10847. * Rebuilds the elements related to this component in case of
  10848. * context lost for instance.
  10849. */
  10850. rebuild(): void;
  10851. /**
  10852. * Disposes the component and the associated ressources.
  10853. */
  10854. dispose(): void;
  10855. private _beforeClear;
  10856. }
  10857. }
  10858. declare module BABYLON {
  10859. interface ThinEngine {
  10860. /**
  10861. * Creates a new render target cube texture
  10862. * @param size defines the size of the texture
  10863. * @param options defines the options used to create the texture
  10864. * @returns a new render target cube texture stored in an InternalTexture
  10865. */
  10866. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10867. }
  10868. }
  10869. declare module BABYLON {
  10870. /** @hidden */
  10871. export var proceduralVertexShader: {
  10872. name: string;
  10873. shader: string;
  10874. };
  10875. }
  10876. declare module BABYLON {
  10877. /**
  10878. * 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.
  10879. * This is the base class of any Procedural texture and contains most of the shareable code.
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10881. */
  10882. export class ProceduralTexture extends Texture {
  10883. isCube: boolean;
  10884. /**
  10885. * Define if the texture is enabled or not (disabled texture will not render)
  10886. */
  10887. isEnabled: boolean;
  10888. /**
  10889. * Define if the texture must be cleared before rendering (default is true)
  10890. */
  10891. autoClear: boolean;
  10892. /**
  10893. * Callback called when the texture is generated
  10894. */
  10895. onGenerated: () => void;
  10896. /**
  10897. * Event raised when the texture is generated
  10898. */
  10899. onGeneratedObservable: Observable<ProceduralTexture>;
  10900. /** @hidden */
  10901. _generateMipMaps: boolean;
  10902. /** @hidden **/
  10903. _effect: Effect;
  10904. /** @hidden */
  10905. _textures: {
  10906. [key: string]: Texture;
  10907. };
  10908. /** @hidden */
  10909. protected _fallbackTexture: Nullable<Texture>;
  10910. private _size;
  10911. private _currentRefreshId;
  10912. private _frameId;
  10913. private _refreshRate;
  10914. private _vertexBuffers;
  10915. private _indexBuffer;
  10916. private _uniforms;
  10917. private _samplers;
  10918. private _fragment;
  10919. private _floats;
  10920. private _ints;
  10921. private _floatsArrays;
  10922. private _colors3;
  10923. private _colors4;
  10924. private _vectors2;
  10925. private _vectors3;
  10926. private _matrices;
  10927. private _fallbackTextureUsed;
  10928. private _engine;
  10929. private _cachedDefines;
  10930. private _contentUpdateId;
  10931. private _contentData;
  10932. /**
  10933. * Instantiates a new procedural texture.
  10934. * 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.
  10935. * This is the base class of any Procedural texture and contains most of the shareable code.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10937. * @param name Define the name of the texture
  10938. * @param size Define the size of the texture to create
  10939. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10940. * @param scene Define the scene the texture belongs to
  10941. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10942. * @param generateMipMaps Define if the texture should creates mip maps or not
  10943. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10944. */
  10945. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10946. /**
  10947. * The effect that is created when initializing the post process.
  10948. * @returns The created effect corresponding the the postprocess.
  10949. */
  10950. getEffect(): Effect;
  10951. /**
  10952. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10953. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10954. */
  10955. getContent(): Nullable<ArrayBufferView>;
  10956. private _createIndexBuffer;
  10957. /** @hidden */
  10958. _rebuild(): void;
  10959. /**
  10960. * Resets the texture in order to recreate its associated resources.
  10961. * This can be called in case of context loss
  10962. */
  10963. reset(): void;
  10964. protected _getDefines(): string;
  10965. /**
  10966. * Is the texture ready to be used ? (rendered at least once)
  10967. * @returns true if ready, otherwise, false.
  10968. */
  10969. isReady(): boolean;
  10970. /**
  10971. * Resets the refresh counter of the texture and start bak from scratch.
  10972. * Could be useful to regenerate the texture if it is setup to render only once.
  10973. */
  10974. resetRefreshCounter(): void;
  10975. /**
  10976. * Set the fragment shader to use in order to render the texture.
  10977. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10978. */
  10979. setFragment(fragment: any): void;
  10980. /**
  10981. * Define the refresh rate of the texture or the rendering frequency.
  10982. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10983. */
  10984. get refreshRate(): number;
  10985. set refreshRate(value: number);
  10986. /** @hidden */
  10987. _shouldRender(): boolean;
  10988. /**
  10989. * Get the size the texture is rendering at.
  10990. * @returns the size (texture is always squared)
  10991. */
  10992. getRenderSize(): number;
  10993. /**
  10994. * Resize the texture to new value.
  10995. * @param size Define the new size the texture should have
  10996. * @param generateMipMaps Define whether the new texture should create mip maps
  10997. */
  10998. resize(size: number, generateMipMaps: boolean): void;
  10999. private _checkUniform;
  11000. /**
  11001. * Set a texture in the shader program used to render.
  11002. * @param name Define the name of the uniform samplers as defined in the shader
  11003. * @param texture Define the texture to bind to this sampler
  11004. * @return the texture itself allowing "fluent" like uniform updates
  11005. */
  11006. setTexture(name: string, texture: Texture): ProceduralTexture;
  11007. /**
  11008. * Set a float in the shader.
  11009. * @param name Define the name of the uniform as defined in the shader
  11010. * @param value Define the value to give to the uniform
  11011. * @return the texture itself allowing "fluent" like uniform updates
  11012. */
  11013. setFloat(name: string, value: number): ProceduralTexture;
  11014. /**
  11015. * Set a int in the shader.
  11016. * @param name Define the name of the uniform as defined in the shader
  11017. * @param value Define the value to give to the uniform
  11018. * @return the texture itself allowing "fluent" like uniform updates
  11019. */
  11020. setInt(name: string, value: number): ProceduralTexture;
  11021. /**
  11022. * Set an array of floats in the shader.
  11023. * @param name Define the name of the uniform as defined in the shader
  11024. * @param value Define the value to give to the uniform
  11025. * @return the texture itself allowing "fluent" like uniform updates
  11026. */
  11027. setFloats(name: string, value: number[]): ProceduralTexture;
  11028. /**
  11029. * Set a vec3 in the shader from a Color3.
  11030. * @param name Define the name of the uniform as defined in the shader
  11031. * @param value Define the value to give to the uniform
  11032. * @return the texture itself allowing "fluent" like uniform updates
  11033. */
  11034. setColor3(name: string, value: Color3): ProceduralTexture;
  11035. /**
  11036. * Set a vec4 in the shader from a Color4.
  11037. * @param name Define the name of the uniform as defined in the shader
  11038. * @param value Define the value to give to the uniform
  11039. * @return the texture itself allowing "fluent" like uniform updates
  11040. */
  11041. setColor4(name: string, value: Color4): ProceduralTexture;
  11042. /**
  11043. * Set a vec2 in the shader from a Vector2.
  11044. * @param name Define the name of the uniform as defined in the shader
  11045. * @param value Define the value to give to the uniform
  11046. * @return the texture itself allowing "fluent" like uniform updates
  11047. */
  11048. setVector2(name: string, value: Vector2): ProceduralTexture;
  11049. /**
  11050. * Set a vec3 in the shader from a Vector3.
  11051. * @param name Define the name of the uniform as defined in the shader
  11052. * @param value Define the value to give to the uniform
  11053. * @return the texture itself allowing "fluent" like uniform updates
  11054. */
  11055. setVector3(name: string, value: Vector3): ProceduralTexture;
  11056. /**
  11057. * Set a mat4 in the shader from a MAtrix.
  11058. * @param name Define the name of the uniform as defined in the shader
  11059. * @param value Define the value to give to the uniform
  11060. * @return the texture itself allowing "fluent" like uniform updates
  11061. */
  11062. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11063. /**
  11064. * Render the texture to its associated render target.
  11065. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11066. */
  11067. render(useCameraPostProcess?: boolean): void;
  11068. /**
  11069. * Clone the texture.
  11070. * @returns the cloned texture
  11071. */
  11072. clone(): ProceduralTexture;
  11073. /**
  11074. * Dispose the texture and release its asoociated resources.
  11075. */
  11076. dispose(): void;
  11077. }
  11078. }
  11079. declare module BABYLON {
  11080. /**
  11081. * This represents the base class for particle system in Babylon.
  11082. * 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.
  11083. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11084. * @example https://doc.babylonjs.com/babylon101/particles
  11085. */
  11086. export class BaseParticleSystem {
  11087. /**
  11088. * Source color is added to the destination color without alpha affecting the result
  11089. */
  11090. static BLENDMODE_ONEONE: number;
  11091. /**
  11092. * Blend current color and particle color using particle’s alpha
  11093. */
  11094. static BLENDMODE_STANDARD: number;
  11095. /**
  11096. * Add current color and particle color multiplied by particle’s alpha
  11097. */
  11098. static BLENDMODE_ADD: number;
  11099. /**
  11100. * Multiply current color with particle color
  11101. */
  11102. static BLENDMODE_MULTIPLY: number;
  11103. /**
  11104. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11105. */
  11106. static BLENDMODE_MULTIPLYADD: number;
  11107. /**
  11108. * List of animations used by the particle system.
  11109. */
  11110. animations: Animation[];
  11111. /**
  11112. * Gets or sets the unique id of the particle system
  11113. */
  11114. uniqueId: number;
  11115. /**
  11116. * The id of the Particle system.
  11117. */
  11118. id: string;
  11119. /**
  11120. * The friendly name of the Particle system.
  11121. */
  11122. name: string;
  11123. /**
  11124. * Snippet ID if the particle system was created from the snippet server
  11125. */
  11126. snippetId: string;
  11127. /**
  11128. * The rendering group used by the Particle system to chose when to render.
  11129. */
  11130. renderingGroupId: number;
  11131. /**
  11132. * The emitter represents the Mesh or position we are attaching the particle system to.
  11133. */
  11134. emitter: Nullable<AbstractMesh | Vector3>;
  11135. /**
  11136. * The maximum number of particles to emit per frame
  11137. */
  11138. emitRate: number;
  11139. /**
  11140. * If you want to launch only a few particles at once, that can be done, as well.
  11141. */
  11142. manualEmitCount: number;
  11143. /**
  11144. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11145. */
  11146. updateSpeed: number;
  11147. /**
  11148. * The amount of time the particle system is running (depends of the overall update speed).
  11149. */
  11150. targetStopDuration: number;
  11151. /**
  11152. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11153. */
  11154. disposeOnStop: boolean;
  11155. /**
  11156. * Minimum power of emitting particles.
  11157. */
  11158. minEmitPower: number;
  11159. /**
  11160. * Maximum power of emitting particles.
  11161. */
  11162. maxEmitPower: number;
  11163. /**
  11164. * Minimum life time of emitting particles.
  11165. */
  11166. minLifeTime: number;
  11167. /**
  11168. * Maximum life time of emitting particles.
  11169. */
  11170. maxLifeTime: number;
  11171. /**
  11172. * Minimum Size of emitting particles.
  11173. */
  11174. minSize: number;
  11175. /**
  11176. * Maximum Size of emitting particles.
  11177. */
  11178. maxSize: number;
  11179. /**
  11180. * Minimum scale of emitting particles on X axis.
  11181. */
  11182. minScaleX: number;
  11183. /**
  11184. * Maximum scale of emitting particles on X axis.
  11185. */
  11186. maxScaleX: number;
  11187. /**
  11188. * Minimum scale of emitting particles on Y axis.
  11189. */
  11190. minScaleY: number;
  11191. /**
  11192. * Maximum scale of emitting particles on Y axis.
  11193. */
  11194. maxScaleY: number;
  11195. /**
  11196. * Gets or sets the minimal initial rotation in radians.
  11197. */
  11198. minInitialRotation: number;
  11199. /**
  11200. * Gets or sets the maximal initial rotation in radians.
  11201. */
  11202. maxInitialRotation: number;
  11203. /**
  11204. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11205. */
  11206. minAngularSpeed: number;
  11207. /**
  11208. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11209. */
  11210. maxAngularSpeed: number;
  11211. /**
  11212. * The texture used to render each particle. (this can be a spritesheet)
  11213. */
  11214. particleTexture: Nullable<Texture>;
  11215. /**
  11216. * The layer mask we are rendering the particles through.
  11217. */
  11218. layerMask: number;
  11219. /**
  11220. * This can help using your own shader to render the particle system.
  11221. * The according effect will be created
  11222. */
  11223. customShader: any;
  11224. /**
  11225. * By default particle system starts as soon as they are created. This prevents the
  11226. * automatic start to happen and let you decide when to start emitting particles.
  11227. */
  11228. preventAutoStart: boolean;
  11229. private _noiseTexture;
  11230. /**
  11231. * Gets or sets a texture used to add random noise to particle positions
  11232. */
  11233. get noiseTexture(): Nullable<ProceduralTexture>;
  11234. set noiseTexture(value: Nullable<ProceduralTexture>);
  11235. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11236. noiseStrength: Vector3;
  11237. /**
  11238. * Callback triggered when the particle animation is ending.
  11239. */
  11240. onAnimationEnd: Nullable<() => void>;
  11241. /**
  11242. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11243. */
  11244. blendMode: number;
  11245. /**
  11246. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11247. * to override the particles.
  11248. */
  11249. forceDepthWrite: boolean;
  11250. /** 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 */
  11251. preWarmCycles: number;
  11252. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11253. preWarmStepOffset: number;
  11254. /**
  11255. * 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)
  11256. */
  11257. spriteCellChangeSpeed: number;
  11258. /**
  11259. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11260. */
  11261. startSpriteCellID: number;
  11262. /**
  11263. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11264. */
  11265. endSpriteCellID: number;
  11266. /**
  11267. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11268. */
  11269. spriteCellWidth: number;
  11270. /**
  11271. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11272. */
  11273. spriteCellHeight: number;
  11274. /**
  11275. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11276. */
  11277. spriteRandomStartCell: boolean;
  11278. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11279. translationPivot: Vector2;
  11280. /** @hidden */
  11281. protected _isAnimationSheetEnabled: boolean;
  11282. /**
  11283. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11284. */
  11285. beginAnimationOnStart: boolean;
  11286. /**
  11287. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11288. */
  11289. beginAnimationFrom: number;
  11290. /**
  11291. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11292. */
  11293. beginAnimationTo: number;
  11294. /**
  11295. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11296. */
  11297. beginAnimationLoop: boolean;
  11298. /**
  11299. * Gets or sets a world offset applied to all particles
  11300. */
  11301. worldOffset: Vector3;
  11302. /**
  11303. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11304. */
  11305. get isAnimationSheetEnabled(): boolean;
  11306. set isAnimationSheetEnabled(value: boolean);
  11307. /**
  11308. * Get hosting scene
  11309. * @returns the scene
  11310. */
  11311. getScene(): Scene;
  11312. /**
  11313. * You can use gravity if you want to give an orientation to your particles.
  11314. */
  11315. gravity: Vector3;
  11316. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11317. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11318. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11319. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11320. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11321. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11322. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11323. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11324. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11325. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11326. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11327. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11328. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11329. /**
  11330. * Defines the delay in milliseconds before starting the system (0 by default)
  11331. */
  11332. startDelay: number;
  11333. /**
  11334. * Gets the current list of drag gradients.
  11335. * You must use addDragGradient and removeDragGradient to udpate this list
  11336. * @returns the list of drag gradients
  11337. */
  11338. getDragGradients(): Nullable<Array<FactorGradient>>;
  11339. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11340. limitVelocityDamping: number;
  11341. /**
  11342. * Gets the current list of limit velocity gradients.
  11343. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11344. * @returns the list of limit velocity gradients
  11345. */
  11346. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11347. /**
  11348. * Gets the current list of color gradients.
  11349. * You must use addColorGradient and removeColorGradient to udpate this list
  11350. * @returns the list of color gradients
  11351. */
  11352. getColorGradients(): Nullable<Array<ColorGradient>>;
  11353. /**
  11354. * Gets the current list of size gradients.
  11355. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11356. * @returns the list of size gradients
  11357. */
  11358. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11359. /**
  11360. * Gets the current list of color remap gradients.
  11361. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11362. * @returns the list of color remap gradients
  11363. */
  11364. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11365. /**
  11366. * Gets the current list of alpha remap gradients.
  11367. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11368. * @returns the list of alpha remap gradients
  11369. */
  11370. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11371. /**
  11372. * Gets the current list of life time gradients.
  11373. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11374. * @returns the list of life time gradients
  11375. */
  11376. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11377. /**
  11378. * Gets the current list of angular speed gradients.
  11379. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11380. * @returns the list of angular speed gradients
  11381. */
  11382. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11383. /**
  11384. * Gets the current list of velocity gradients.
  11385. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11386. * @returns the list of velocity gradients
  11387. */
  11388. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11389. /**
  11390. * Gets the current list of start size gradients.
  11391. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11392. * @returns the list of start size gradients
  11393. */
  11394. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11395. /**
  11396. * Gets the current list of emit rate gradients.
  11397. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11398. * @returns the list of emit rate gradients
  11399. */
  11400. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11401. /**
  11402. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11403. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11404. */
  11405. get direction1(): Vector3;
  11406. set direction1(value: Vector3);
  11407. /**
  11408. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11409. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11410. */
  11411. get direction2(): Vector3;
  11412. set direction2(value: Vector3);
  11413. /**
  11414. * 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.
  11415. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11416. */
  11417. get minEmitBox(): Vector3;
  11418. set minEmitBox(value: Vector3);
  11419. /**
  11420. * 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.
  11421. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11422. */
  11423. get maxEmitBox(): Vector3;
  11424. set maxEmitBox(value: Vector3);
  11425. /**
  11426. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11427. */
  11428. color1: Color4;
  11429. /**
  11430. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11431. */
  11432. color2: Color4;
  11433. /**
  11434. * Color the particle will have at the end of its lifetime
  11435. */
  11436. colorDead: Color4;
  11437. /**
  11438. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11439. */
  11440. textureMask: Color4;
  11441. /**
  11442. * The particle emitter type defines the emitter used by the particle system.
  11443. * It can be for example box, sphere, or cone...
  11444. */
  11445. particleEmitterType: IParticleEmitterType;
  11446. /** @hidden */
  11447. _isSubEmitter: boolean;
  11448. /**
  11449. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11450. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11451. */
  11452. billboardMode: number;
  11453. protected _isBillboardBased: boolean;
  11454. /**
  11455. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11456. */
  11457. get isBillboardBased(): boolean;
  11458. set isBillboardBased(value: boolean);
  11459. /**
  11460. * The scene the particle system belongs to.
  11461. */
  11462. protected _scene: Scene;
  11463. /**
  11464. * Local cache of defines for image processing.
  11465. */
  11466. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11467. /**
  11468. * Default configuration related to image processing available in the standard Material.
  11469. */
  11470. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11471. /**
  11472. * Gets the image processing configuration used either in this material.
  11473. */
  11474. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11475. /**
  11476. * Sets the Default image processing configuration used either in the this material.
  11477. *
  11478. * If sets to null, the scene one is in use.
  11479. */
  11480. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11481. /**
  11482. * Attaches a new image processing configuration to the Standard Material.
  11483. * @param configuration
  11484. */
  11485. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11486. /** @hidden */
  11487. protected _reset(): void;
  11488. /** @hidden */
  11489. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11490. /**
  11491. * Instantiates a particle system.
  11492. * 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.
  11493. * @param name The name of the particle system
  11494. */
  11495. constructor(name: string);
  11496. /**
  11497. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11500. * @returns the emitter
  11501. */
  11502. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11503. /**
  11504. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11505. * @param radius The radius of the hemisphere to emit from
  11506. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11507. * @returns the emitter
  11508. */
  11509. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11510. /**
  11511. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11512. * @param radius The radius of the sphere to emit from
  11513. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11514. * @returns the emitter
  11515. */
  11516. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11517. /**
  11518. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11519. * @param radius The radius of the sphere to emit from
  11520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11522. * @returns the emitter
  11523. */
  11524. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11525. /**
  11526. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11527. * @param radius The radius of the emission cylinder
  11528. * @param height The height of the emission cylinder
  11529. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11530. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11531. * @returns the emitter
  11532. */
  11533. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11534. /**
  11535. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11536. * @param radius The radius of the cylinder to emit from
  11537. * @param height The height of the emission cylinder
  11538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11539. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11540. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11541. * @returns the emitter
  11542. */
  11543. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11544. /**
  11545. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11546. * @param radius The radius of the cone to emit from
  11547. * @param angle The base angle of the cone
  11548. * @returns the emitter
  11549. */
  11550. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11551. /**
  11552. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11553. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11554. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11555. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11556. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11557. * @returns the emitter
  11558. */
  11559. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11560. }
  11561. }
  11562. declare module BABYLON {
  11563. /**
  11564. * Type of sub emitter
  11565. */
  11566. export enum SubEmitterType {
  11567. /**
  11568. * Attached to the particle over it's lifetime
  11569. */
  11570. ATTACHED = 0,
  11571. /**
  11572. * Created when the particle dies
  11573. */
  11574. END = 1
  11575. }
  11576. /**
  11577. * Sub emitter class used to emit particles from an existing particle
  11578. */
  11579. export class SubEmitter {
  11580. /**
  11581. * the particle system to be used by the sub emitter
  11582. */
  11583. particleSystem: ParticleSystem;
  11584. /**
  11585. * Type of the submitter (Default: END)
  11586. */
  11587. type: SubEmitterType;
  11588. /**
  11589. * 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)
  11590. * Note: This only is supported when using an emitter of type Mesh
  11591. */
  11592. inheritDirection: boolean;
  11593. /**
  11594. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11595. */
  11596. inheritedVelocityAmount: number;
  11597. /**
  11598. * Creates a sub emitter
  11599. * @param particleSystem the particle system to be used by the sub emitter
  11600. */
  11601. constructor(
  11602. /**
  11603. * the particle system to be used by the sub emitter
  11604. */
  11605. particleSystem: ParticleSystem);
  11606. /**
  11607. * Clones the sub emitter
  11608. * @returns the cloned sub emitter
  11609. */
  11610. clone(): SubEmitter;
  11611. /**
  11612. * Serialize current object to a JSON object
  11613. * @returns the serialized object
  11614. */
  11615. serialize(): any;
  11616. /** @hidden */
  11617. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11618. /**
  11619. * Creates a new SubEmitter from a serialized JSON version
  11620. * @param serializationObject defines the JSON object to read from
  11621. * @param scene defines the hosting scene
  11622. * @param rootUrl defines the rootUrl for data loading
  11623. * @returns a new SubEmitter
  11624. */
  11625. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11626. /** Release associated resources */
  11627. dispose(): void;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /** @hidden */
  11632. export var imageProcessingDeclaration: {
  11633. name: string;
  11634. shader: string;
  11635. };
  11636. }
  11637. declare module BABYLON {
  11638. /** @hidden */
  11639. export var imageProcessingFunctions: {
  11640. name: string;
  11641. shader: string;
  11642. };
  11643. }
  11644. declare module BABYLON {
  11645. /** @hidden */
  11646. export var particlesPixelShader: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module BABYLON {
  11652. /** @hidden */
  11653. export var particlesVertexShader: {
  11654. name: string;
  11655. shader: string;
  11656. };
  11657. }
  11658. declare module BABYLON {
  11659. /**
  11660. * This represents a particle system in Babylon.
  11661. * 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.
  11662. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11663. * @example https://doc.babylonjs.com/babylon101/particles
  11664. */
  11665. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11666. /**
  11667. * Billboard mode will only apply to Y axis
  11668. */
  11669. static readonly BILLBOARDMODE_Y: number;
  11670. /**
  11671. * Billboard mode will apply to all axes
  11672. */
  11673. static readonly BILLBOARDMODE_ALL: number;
  11674. /**
  11675. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11676. */
  11677. static readonly BILLBOARDMODE_STRETCHED: number;
  11678. /**
  11679. * This function can be defined to provide custom update for active particles.
  11680. * This function will be called instead of regular update (age, position, color, etc.).
  11681. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11682. */
  11683. updateFunction: (particles: Particle[]) => void;
  11684. private _emitterWorldMatrix;
  11685. /**
  11686. * This function can be defined to specify initial direction for every new particle.
  11687. * It by default use the emitterType defined function
  11688. */
  11689. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11690. /**
  11691. * This function can be defined to specify initial position for every new particle.
  11692. * It by default use the emitterType defined function
  11693. */
  11694. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11695. /**
  11696. * @hidden
  11697. */
  11698. _inheritedVelocityOffset: Vector3;
  11699. /**
  11700. * An event triggered when the system is disposed
  11701. */
  11702. onDisposeObservable: Observable<ParticleSystem>;
  11703. private _onDisposeObserver;
  11704. /**
  11705. * Sets a callback that will be triggered when the system is disposed
  11706. */
  11707. set onDispose(callback: () => void);
  11708. private _particles;
  11709. private _epsilon;
  11710. private _capacity;
  11711. private _stockParticles;
  11712. private _newPartsExcess;
  11713. private _vertexData;
  11714. private _vertexBuffer;
  11715. private _vertexBuffers;
  11716. private _spriteBuffer;
  11717. private _indexBuffer;
  11718. private _effect;
  11719. private _customEffect;
  11720. private _cachedDefines;
  11721. private _scaledColorStep;
  11722. private _colorDiff;
  11723. private _scaledDirection;
  11724. private _scaledGravity;
  11725. private _currentRenderId;
  11726. private _alive;
  11727. private _useInstancing;
  11728. private _started;
  11729. private _stopped;
  11730. private _actualFrame;
  11731. private _scaledUpdateSpeed;
  11732. private _vertexBufferSize;
  11733. /** @hidden */
  11734. _currentEmitRateGradient: Nullable<FactorGradient>;
  11735. /** @hidden */
  11736. _currentEmitRate1: number;
  11737. /** @hidden */
  11738. _currentEmitRate2: number;
  11739. /** @hidden */
  11740. _currentStartSizeGradient: Nullable<FactorGradient>;
  11741. /** @hidden */
  11742. _currentStartSize1: number;
  11743. /** @hidden */
  11744. _currentStartSize2: number;
  11745. private readonly _rawTextureWidth;
  11746. private _rampGradientsTexture;
  11747. private _useRampGradients;
  11748. /** Gets or sets a boolean indicating that ramp gradients must be used
  11749. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11750. */
  11751. get useRampGradients(): boolean;
  11752. set useRampGradients(value: boolean);
  11753. /**
  11754. * 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.
  11755. * 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: [])
  11756. */
  11757. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11758. private _subEmitters;
  11759. /**
  11760. * @hidden
  11761. * If the particle systems emitter should be disposed when the particle system is disposed
  11762. */
  11763. _disposeEmitterOnDispose: boolean;
  11764. /**
  11765. * The current active Sub-systems, this property is used by the root particle system only.
  11766. */
  11767. activeSubSystems: Array<ParticleSystem>;
  11768. /**
  11769. * Specifies if the particles are updated in emitter local space or world space
  11770. */
  11771. isLocal: boolean;
  11772. private _rootParticleSystem;
  11773. /**
  11774. * Gets the current list of active particles
  11775. */
  11776. get particles(): Particle[];
  11777. /**
  11778. * Gets the number of particles active at the same time.
  11779. * @returns The number of active particles.
  11780. */
  11781. getActiveCount(): number;
  11782. /**
  11783. * Returns the string "ParticleSystem"
  11784. * @returns a string containing the class name
  11785. */
  11786. getClassName(): string;
  11787. /**
  11788. * Gets a boolean indicating that the system is stopping
  11789. * @returns true if the system is currently stopping
  11790. */
  11791. isStopping(): boolean;
  11792. /**
  11793. * Instantiates a particle system.
  11794. * 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.
  11795. * @param name The name of the particle system
  11796. * @param capacity The max number of particles alive at the same time
  11797. * @param scene The scene the particle system belongs to
  11798. * @param customEffect a custom effect used to change the way particles are rendered by default
  11799. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11800. * @param epsilon Offset used to render the particles
  11801. */
  11802. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11803. private _addFactorGradient;
  11804. private _removeFactorGradient;
  11805. /**
  11806. * Adds a new life time gradient
  11807. * @param gradient defines the gradient to use (between 0 and 1)
  11808. * @param factor defines the life time factor to affect to the specified gradient
  11809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11810. * @returns the current particle system
  11811. */
  11812. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11813. /**
  11814. * Remove a specific life time gradient
  11815. * @param gradient defines the gradient to remove
  11816. * @returns the current particle system
  11817. */
  11818. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11819. /**
  11820. * Adds a new size gradient
  11821. * @param gradient defines the gradient to use (between 0 and 1)
  11822. * @param factor defines the size factor to affect to the specified gradient
  11823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11824. * @returns the current particle system
  11825. */
  11826. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11827. /**
  11828. * Remove a specific size gradient
  11829. * @param gradient defines the gradient to remove
  11830. * @returns the current particle system
  11831. */
  11832. removeSizeGradient(gradient: number): IParticleSystem;
  11833. /**
  11834. * Adds a new color remap gradient
  11835. * @param gradient defines the gradient to use (between 0 and 1)
  11836. * @param min defines the color remap minimal range
  11837. * @param max defines the color remap maximal range
  11838. * @returns the current particle system
  11839. */
  11840. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11841. /**
  11842. * Remove a specific color remap gradient
  11843. * @param gradient defines the gradient to remove
  11844. * @returns the current particle system
  11845. */
  11846. removeColorRemapGradient(gradient: number): IParticleSystem;
  11847. /**
  11848. * Adds a new alpha remap gradient
  11849. * @param gradient defines the gradient to use (between 0 and 1)
  11850. * @param min defines the alpha remap minimal range
  11851. * @param max defines the alpha remap maximal range
  11852. * @returns the current particle system
  11853. */
  11854. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11855. /**
  11856. * Remove a specific alpha remap gradient
  11857. * @param gradient defines the gradient to remove
  11858. * @returns the current particle system
  11859. */
  11860. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11861. /**
  11862. * Adds a new angular speed gradient
  11863. * @param gradient defines the gradient to use (between 0 and 1)
  11864. * @param factor defines the angular speed to affect to the specified gradient
  11865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11866. * @returns the current particle system
  11867. */
  11868. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11869. /**
  11870. * Remove a specific angular speed gradient
  11871. * @param gradient defines the gradient to remove
  11872. * @returns the current particle system
  11873. */
  11874. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11875. /**
  11876. * Adds a new velocity gradient
  11877. * @param gradient defines the gradient to use (between 0 and 1)
  11878. * @param factor defines the velocity to affect to the specified gradient
  11879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11880. * @returns the current particle system
  11881. */
  11882. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11883. /**
  11884. * Remove a specific velocity gradient
  11885. * @param gradient defines the gradient to remove
  11886. * @returns the current particle system
  11887. */
  11888. removeVelocityGradient(gradient: number): IParticleSystem;
  11889. /**
  11890. * Adds a new limit velocity gradient
  11891. * @param gradient defines the gradient to use (between 0 and 1)
  11892. * @param factor defines the limit velocity value to affect to the specified gradient
  11893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11894. * @returns the current particle system
  11895. */
  11896. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11897. /**
  11898. * Remove a specific limit velocity gradient
  11899. * @param gradient defines the gradient to remove
  11900. * @returns the current particle system
  11901. */
  11902. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11903. /**
  11904. * Adds a new drag gradient
  11905. * @param gradient defines the gradient to use (between 0 and 1)
  11906. * @param factor defines the drag value to affect to the specified gradient
  11907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11908. * @returns the current particle system
  11909. */
  11910. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11911. /**
  11912. * Remove a specific drag gradient
  11913. * @param gradient defines the gradient to remove
  11914. * @returns the current particle system
  11915. */
  11916. removeDragGradient(gradient: number): IParticleSystem;
  11917. /**
  11918. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11919. * @param gradient defines the gradient to use (between 0 and 1)
  11920. * @param factor defines the emit rate value to affect to the specified gradient
  11921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11922. * @returns the current particle system
  11923. */
  11924. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11925. /**
  11926. * Remove a specific emit rate gradient
  11927. * @param gradient defines the gradient to remove
  11928. * @returns the current particle system
  11929. */
  11930. removeEmitRateGradient(gradient: number): IParticleSystem;
  11931. /**
  11932. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11933. * @param gradient defines the gradient to use (between 0 and 1)
  11934. * @param factor defines the start size value to affect to the specified gradient
  11935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11936. * @returns the current particle system
  11937. */
  11938. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11939. /**
  11940. * Remove a specific start size gradient
  11941. * @param gradient defines the gradient to remove
  11942. * @returns the current particle system
  11943. */
  11944. removeStartSizeGradient(gradient: number): IParticleSystem;
  11945. private _createRampGradientTexture;
  11946. /**
  11947. * Gets the current list of ramp gradients.
  11948. * You must use addRampGradient and removeRampGradient to udpate this list
  11949. * @returns the list of ramp gradients
  11950. */
  11951. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11952. /** Force the system to rebuild all gradients that need to be resync */
  11953. forceRefreshGradients(): void;
  11954. private _syncRampGradientTexture;
  11955. /**
  11956. * Adds a new ramp gradient used to remap particle colors
  11957. * @param gradient defines the gradient to use (between 0 and 1)
  11958. * @param color defines the color to affect to the specified gradient
  11959. * @returns the current particle system
  11960. */
  11961. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11962. /**
  11963. * Remove a specific ramp gradient
  11964. * @param gradient defines the gradient to remove
  11965. * @returns the current particle system
  11966. */
  11967. removeRampGradient(gradient: number): ParticleSystem;
  11968. /**
  11969. * Adds a new color gradient
  11970. * @param gradient defines the gradient to use (between 0 and 1)
  11971. * @param color1 defines the color to affect to the specified gradient
  11972. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11973. * @returns this particle system
  11974. */
  11975. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11976. /**
  11977. * Remove a specific color gradient
  11978. * @param gradient defines the gradient to remove
  11979. * @returns this particle system
  11980. */
  11981. removeColorGradient(gradient: number): IParticleSystem;
  11982. private _fetchR;
  11983. protected _reset(): void;
  11984. private _resetEffect;
  11985. private _createVertexBuffers;
  11986. private _createIndexBuffer;
  11987. /**
  11988. * Gets the maximum number of particles active at the same time.
  11989. * @returns The max number of active particles.
  11990. */
  11991. getCapacity(): number;
  11992. /**
  11993. * Gets whether there are still active particles in the system.
  11994. * @returns True if it is alive, otherwise false.
  11995. */
  11996. isAlive(): boolean;
  11997. /**
  11998. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11999. * @returns True if it has been started, otherwise false.
  12000. */
  12001. isStarted(): boolean;
  12002. private _prepareSubEmitterInternalArray;
  12003. /**
  12004. * Starts the particle system and begins to emit
  12005. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12006. */
  12007. start(delay?: number): void;
  12008. /**
  12009. * Stops the particle system.
  12010. * @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.
  12011. */
  12012. stop(stopSubEmitters?: boolean): void;
  12013. /**
  12014. * Remove all active particles
  12015. */
  12016. reset(): void;
  12017. /**
  12018. * @hidden (for internal use only)
  12019. */
  12020. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12021. /**
  12022. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12023. * Its lifetime will start back at 0.
  12024. */
  12025. recycleParticle: (particle: Particle) => void;
  12026. private _stopSubEmitters;
  12027. private _createParticle;
  12028. private _removeFromRoot;
  12029. private _emitFromParticle;
  12030. private _update;
  12031. /** @hidden */
  12032. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12033. /** @hidden */
  12034. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12035. /** @hidden */
  12036. private _getEffect;
  12037. /**
  12038. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12039. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12040. */
  12041. animate(preWarmOnly?: boolean): void;
  12042. private _appendParticleVertices;
  12043. /**
  12044. * Rebuilds the particle system.
  12045. */
  12046. rebuild(): void;
  12047. /**
  12048. * Is this system ready to be used/rendered
  12049. * @return true if the system is ready
  12050. */
  12051. isReady(): boolean;
  12052. private _render;
  12053. /**
  12054. * Renders the particle system in its current state.
  12055. * @returns the current number of particles
  12056. */
  12057. render(): number;
  12058. /**
  12059. * Disposes the particle system and free the associated resources
  12060. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12061. */
  12062. dispose(disposeTexture?: boolean): void;
  12063. /**
  12064. * Clones the particle system.
  12065. * @param name The name of the cloned object
  12066. * @param newEmitter The new emitter to use
  12067. * @returns the cloned particle system
  12068. */
  12069. clone(name: string, newEmitter: any): ParticleSystem;
  12070. /**
  12071. * Serializes the particle system to a JSON object
  12072. * @param serializeTexture defines if the texture must be serialized as well
  12073. * @returns the JSON object
  12074. */
  12075. serialize(serializeTexture?: boolean): any;
  12076. /** @hidden */
  12077. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12078. /** @hidden */
  12079. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12080. /**
  12081. * Parses a JSON object to create a particle system.
  12082. * @param parsedParticleSystem The JSON object to parse
  12083. * @param scene The scene to create the particle system in
  12084. * @param rootUrl The root url to use to load external dependencies like texture
  12085. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12086. * @returns the Parsed particle system
  12087. */
  12088. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12089. }
  12090. }
  12091. declare module BABYLON {
  12092. /**
  12093. * A particle represents one of the element emitted by a particle system.
  12094. * This is mainly define by its coordinates, direction, velocity and age.
  12095. */
  12096. export class Particle {
  12097. /**
  12098. * The particle system the particle belongs to.
  12099. */
  12100. particleSystem: ParticleSystem;
  12101. private static _Count;
  12102. /**
  12103. * Unique ID of the particle
  12104. */
  12105. id: number;
  12106. /**
  12107. * The world position of the particle in the scene.
  12108. */
  12109. position: Vector3;
  12110. /**
  12111. * The world direction of the particle in the scene.
  12112. */
  12113. direction: Vector3;
  12114. /**
  12115. * The color of the particle.
  12116. */
  12117. color: Color4;
  12118. /**
  12119. * The color change of the particle per step.
  12120. */
  12121. colorStep: Color4;
  12122. /**
  12123. * Defines how long will the life of the particle be.
  12124. */
  12125. lifeTime: number;
  12126. /**
  12127. * The current age of the particle.
  12128. */
  12129. age: number;
  12130. /**
  12131. * The current size of the particle.
  12132. */
  12133. size: number;
  12134. /**
  12135. * The current scale of the particle.
  12136. */
  12137. scale: Vector2;
  12138. /**
  12139. * The current angle of the particle.
  12140. */
  12141. angle: number;
  12142. /**
  12143. * Defines how fast is the angle changing.
  12144. */
  12145. angularSpeed: number;
  12146. /**
  12147. * Defines the cell index used by the particle to be rendered from a sprite.
  12148. */
  12149. cellIndex: number;
  12150. /**
  12151. * The information required to support color remapping
  12152. */
  12153. remapData: Vector4;
  12154. /** @hidden */
  12155. _randomCellOffset?: number;
  12156. /** @hidden */
  12157. _initialDirection: Nullable<Vector3>;
  12158. /** @hidden */
  12159. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12160. /** @hidden */
  12161. _initialStartSpriteCellID: number;
  12162. /** @hidden */
  12163. _initialEndSpriteCellID: number;
  12164. /** @hidden */
  12165. _currentColorGradient: Nullable<ColorGradient>;
  12166. /** @hidden */
  12167. _currentColor1: Color4;
  12168. /** @hidden */
  12169. _currentColor2: Color4;
  12170. /** @hidden */
  12171. _currentSizeGradient: Nullable<FactorGradient>;
  12172. /** @hidden */
  12173. _currentSize1: number;
  12174. /** @hidden */
  12175. _currentSize2: number;
  12176. /** @hidden */
  12177. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12178. /** @hidden */
  12179. _currentAngularSpeed1: number;
  12180. /** @hidden */
  12181. _currentAngularSpeed2: number;
  12182. /** @hidden */
  12183. _currentVelocityGradient: Nullable<FactorGradient>;
  12184. /** @hidden */
  12185. _currentVelocity1: number;
  12186. /** @hidden */
  12187. _currentVelocity2: number;
  12188. /** @hidden */
  12189. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12190. /** @hidden */
  12191. _currentLimitVelocity1: number;
  12192. /** @hidden */
  12193. _currentLimitVelocity2: number;
  12194. /** @hidden */
  12195. _currentDragGradient: Nullable<FactorGradient>;
  12196. /** @hidden */
  12197. _currentDrag1: number;
  12198. /** @hidden */
  12199. _currentDrag2: number;
  12200. /** @hidden */
  12201. _randomNoiseCoordinates1: Vector3;
  12202. /** @hidden */
  12203. _randomNoiseCoordinates2: Vector3;
  12204. /** @hidden */
  12205. _localPosition?: Vector3;
  12206. /**
  12207. * Creates a new instance Particle
  12208. * @param particleSystem the particle system the particle belongs to
  12209. */
  12210. constructor(
  12211. /**
  12212. * The particle system the particle belongs to.
  12213. */
  12214. particleSystem: ParticleSystem);
  12215. private updateCellInfoFromSystem;
  12216. /**
  12217. * Defines how the sprite cell index is updated for the particle
  12218. */
  12219. updateCellIndex(): void;
  12220. /** @hidden */
  12221. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12222. /** @hidden */
  12223. _inheritParticleInfoToSubEmitters(): void;
  12224. /** @hidden */
  12225. _reset(): void;
  12226. /**
  12227. * Copy the properties of particle to another one.
  12228. * @param other the particle to copy the information to.
  12229. */
  12230. copyTo(other: Particle): void;
  12231. }
  12232. }
  12233. declare module BABYLON {
  12234. /**
  12235. * Particle emitter represents a volume emitting particles.
  12236. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12237. */
  12238. export interface IParticleEmitterType {
  12239. /**
  12240. * Called by the particle System when the direction is computed for the created particle.
  12241. * @param worldMatrix is the world matrix of the particle system
  12242. * @param directionToUpdate is the direction vector to update with the result
  12243. * @param particle is the particle we are computed the direction for
  12244. * @param isLocal defines if the direction should be set in local space
  12245. */
  12246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12247. /**
  12248. * Called by the particle System when the position is computed for the created particle.
  12249. * @param worldMatrix is the world matrix of the particle system
  12250. * @param positionToUpdate is the position vector to update with the result
  12251. * @param particle is the particle we are computed the position for
  12252. * @param isLocal defines if the position should be set in local space
  12253. */
  12254. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12255. /**
  12256. * Clones the current emitter and returns a copy of it
  12257. * @returns the new emitter
  12258. */
  12259. clone(): IParticleEmitterType;
  12260. /**
  12261. * Called by the GPUParticleSystem to setup the update shader
  12262. * @param effect defines the update shader
  12263. */
  12264. applyToShader(effect: Effect): void;
  12265. /**
  12266. * Returns a string to use to update the GPU particles update shader
  12267. * @returns the effect defines string
  12268. */
  12269. getEffectDefines(): string;
  12270. /**
  12271. * Returns a string representing the class name
  12272. * @returns a string containing the class name
  12273. */
  12274. getClassName(): string;
  12275. /**
  12276. * Serializes the particle system to a JSON object.
  12277. * @returns the JSON object
  12278. */
  12279. serialize(): any;
  12280. /**
  12281. * Parse properties from a JSON object
  12282. * @param serializationObject defines the JSON object
  12283. * @param scene defines the hosting scene
  12284. */
  12285. parse(serializationObject: any, scene: Scene): void;
  12286. }
  12287. }
  12288. declare module BABYLON {
  12289. /**
  12290. * Particle emitter emitting particles from the inside of a box.
  12291. * It emits the particles randomly between 2 given directions.
  12292. */
  12293. export class BoxParticleEmitter implements IParticleEmitterType {
  12294. /**
  12295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12296. */
  12297. direction1: Vector3;
  12298. /**
  12299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12300. */
  12301. direction2: Vector3;
  12302. /**
  12303. * 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.
  12304. */
  12305. minEmitBox: Vector3;
  12306. /**
  12307. * 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.
  12308. */
  12309. maxEmitBox: Vector3;
  12310. /**
  12311. * Creates a new instance BoxParticleEmitter
  12312. */
  12313. constructor();
  12314. /**
  12315. * Called by the particle System when the direction is computed for the created particle.
  12316. * @param worldMatrix is the world matrix of the particle system
  12317. * @param directionToUpdate is the direction vector to update with the result
  12318. * @param particle is the particle we are computed the direction for
  12319. * @param isLocal defines if the direction should be set in local space
  12320. */
  12321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12322. /**
  12323. * Called by the particle System when the position is computed for the created particle.
  12324. * @param worldMatrix is the world matrix of the particle system
  12325. * @param positionToUpdate is the position vector to update with the result
  12326. * @param particle is the particle we are computed the position for
  12327. * @param isLocal defines if the position should be set in local space
  12328. */
  12329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12330. /**
  12331. * Clones the current emitter and returns a copy of it
  12332. * @returns the new emitter
  12333. */
  12334. clone(): BoxParticleEmitter;
  12335. /**
  12336. * Called by the GPUParticleSystem to setup the update shader
  12337. * @param effect defines the update shader
  12338. */
  12339. applyToShader(effect: Effect): void;
  12340. /**
  12341. * Returns a string to use to update the GPU particles update shader
  12342. * @returns a string containng the defines string
  12343. */
  12344. getEffectDefines(): string;
  12345. /**
  12346. * Returns the string "BoxParticleEmitter"
  12347. * @returns a string containing the class name
  12348. */
  12349. getClassName(): string;
  12350. /**
  12351. * Serializes the particle system to a JSON object.
  12352. * @returns the JSON object
  12353. */
  12354. serialize(): any;
  12355. /**
  12356. * Parse properties from a JSON object
  12357. * @param serializationObject defines the JSON object
  12358. */
  12359. parse(serializationObject: any): void;
  12360. }
  12361. }
  12362. declare module BABYLON {
  12363. /**
  12364. * Particle emitter emitting particles from the inside of a cone.
  12365. * It emits the particles alongside the cone volume from the base to the particle.
  12366. * The emission direction might be randomized.
  12367. */
  12368. export class ConeParticleEmitter implements IParticleEmitterType {
  12369. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12370. directionRandomizer: number;
  12371. private _radius;
  12372. private _angle;
  12373. private _height;
  12374. /**
  12375. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12376. */
  12377. radiusRange: number;
  12378. /**
  12379. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12380. */
  12381. heightRange: number;
  12382. /**
  12383. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12384. */
  12385. emitFromSpawnPointOnly: boolean;
  12386. /**
  12387. * Gets or sets the radius of the emission cone
  12388. */
  12389. get radius(): number;
  12390. set radius(value: number);
  12391. /**
  12392. * Gets or sets the angle of the emission cone
  12393. */
  12394. get angle(): number;
  12395. set angle(value: number);
  12396. private _buildHeight;
  12397. /**
  12398. * Creates a new instance ConeParticleEmitter
  12399. * @param radius the radius of the emission cone (1 by default)
  12400. * @param angle the cone base angle (PI by default)
  12401. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12402. */
  12403. constructor(radius?: number, angle?: number,
  12404. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12405. directionRandomizer?: number);
  12406. /**
  12407. * Called by the particle System when the direction is computed for the created particle.
  12408. * @param worldMatrix is the world matrix of the particle system
  12409. * @param directionToUpdate is the direction vector to update with the result
  12410. * @param particle is the particle we are computed the direction for
  12411. * @param isLocal defines if the direction should be set in local space
  12412. */
  12413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12414. /**
  12415. * Called by the particle System when the position is computed for the created particle.
  12416. * @param worldMatrix is the world matrix of the particle system
  12417. * @param positionToUpdate is the position vector to update with the result
  12418. * @param particle is the particle we are computed the position for
  12419. * @param isLocal defines if the position should be set in local space
  12420. */
  12421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12422. /**
  12423. * Clones the current emitter and returns a copy of it
  12424. * @returns the new emitter
  12425. */
  12426. clone(): ConeParticleEmitter;
  12427. /**
  12428. * Called by the GPUParticleSystem to setup the update shader
  12429. * @param effect defines the update shader
  12430. */
  12431. applyToShader(effect: Effect): void;
  12432. /**
  12433. * Returns a string to use to update the GPU particles update shader
  12434. * @returns a string containng the defines string
  12435. */
  12436. getEffectDefines(): string;
  12437. /**
  12438. * Returns the string "ConeParticleEmitter"
  12439. * @returns a string containing the class name
  12440. */
  12441. getClassName(): string;
  12442. /**
  12443. * Serializes the particle system to a JSON object.
  12444. * @returns the JSON object
  12445. */
  12446. serialize(): any;
  12447. /**
  12448. * Parse properties from a JSON object
  12449. * @param serializationObject defines the JSON object
  12450. */
  12451. parse(serializationObject: any): void;
  12452. }
  12453. }
  12454. declare module BABYLON {
  12455. /**
  12456. * Particle emitter emitting particles from the inside of a cylinder.
  12457. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12458. */
  12459. export class CylinderParticleEmitter implements IParticleEmitterType {
  12460. /**
  12461. * The radius of the emission cylinder.
  12462. */
  12463. radius: number;
  12464. /**
  12465. * The height of the emission cylinder.
  12466. */
  12467. height: number;
  12468. /**
  12469. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12470. */
  12471. radiusRange: number;
  12472. /**
  12473. * How much to randomize the particle direction [0-1].
  12474. */
  12475. directionRandomizer: number;
  12476. /**
  12477. * Creates a new instance CylinderParticleEmitter
  12478. * @param radius the radius of the emission cylinder (1 by default)
  12479. * @param height the height of the emission cylinder (1 by default)
  12480. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12481. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12482. */
  12483. constructor(
  12484. /**
  12485. * The radius of the emission cylinder.
  12486. */
  12487. radius?: number,
  12488. /**
  12489. * The height of the emission cylinder.
  12490. */
  12491. height?: number,
  12492. /**
  12493. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12494. */
  12495. radiusRange?: number,
  12496. /**
  12497. * How much to randomize the particle direction [0-1].
  12498. */
  12499. directionRandomizer?: number);
  12500. /**
  12501. * Called by the particle System when the direction is computed for the created particle.
  12502. * @param worldMatrix is the world matrix of the particle system
  12503. * @param directionToUpdate is the direction vector to update with the result
  12504. * @param particle is the particle we are computed the direction for
  12505. * @param isLocal defines if the direction should be set in local space
  12506. */
  12507. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12508. /**
  12509. * Called by the particle System when the position is computed for the created particle.
  12510. * @param worldMatrix is the world matrix of the particle system
  12511. * @param positionToUpdate is the position vector to update with the result
  12512. * @param particle is the particle we are computed the position for
  12513. * @param isLocal defines if the position should be set in local space
  12514. */
  12515. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12516. /**
  12517. * Clones the current emitter and returns a copy of it
  12518. * @returns the new emitter
  12519. */
  12520. clone(): CylinderParticleEmitter;
  12521. /**
  12522. * Called by the GPUParticleSystem to setup the update shader
  12523. * @param effect defines the update shader
  12524. */
  12525. applyToShader(effect: Effect): void;
  12526. /**
  12527. * Returns a string to use to update the GPU particles update shader
  12528. * @returns a string containng the defines string
  12529. */
  12530. getEffectDefines(): string;
  12531. /**
  12532. * Returns the string "CylinderParticleEmitter"
  12533. * @returns a string containing the class name
  12534. */
  12535. getClassName(): string;
  12536. /**
  12537. * Serializes the particle system to a JSON object.
  12538. * @returns the JSON object
  12539. */
  12540. serialize(): any;
  12541. /**
  12542. * Parse properties from a JSON object
  12543. * @param serializationObject defines the JSON object
  12544. */
  12545. parse(serializationObject: any): void;
  12546. }
  12547. /**
  12548. * Particle emitter emitting particles from the inside of a cylinder.
  12549. * It emits the particles randomly between two vectors.
  12550. */
  12551. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12552. /**
  12553. * The min limit of the emission direction.
  12554. */
  12555. direction1: Vector3;
  12556. /**
  12557. * The max limit of the emission direction.
  12558. */
  12559. direction2: Vector3;
  12560. /**
  12561. * Creates a new instance CylinderDirectedParticleEmitter
  12562. * @param radius the radius of the emission cylinder (1 by default)
  12563. * @param height the height of the emission cylinder (1 by default)
  12564. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12565. * @param direction1 the min limit of the emission direction (up vector by default)
  12566. * @param direction2 the max limit of the emission direction (up vector by default)
  12567. */
  12568. constructor(radius?: number, height?: number, radiusRange?: number,
  12569. /**
  12570. * The min limit of the emission direction.
  12571. */
  12572. direction1?: Vector3,
  12573. /**
  12574. * The max limit of the emission direction.
  12575. */
  12576. direction2?: Vector3);
  12577. /**
  12578. * Called by the particle System when the direction is computed for the created particle.
  12579. * @param worldMatrix is the world matrix of the particle system
  12580. * @param directionToUpdate is the direction vector to update with the result
  12581. * @param particle is the particle we are computed the direction for
  12582. */
  12583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12584. /**
  12585. * Clones the current emitter and returns a copy of it
  12586. * @returns the new emitter
  12587. */
  12588. clone(): CylinderDirectedParticleEmitter;
  12589. /**
  12590. * Called by the GPUParticleSystem to setup the update shader
  12591. * @param effect defines the update shader
  12592. */
  12593. applyToShader(effect: Effect): void;
  12594. /**
  12595. * Returns a string to use to update the GPU particles update shader
  12596. * @returns a string containng the defines string
  12597. */
  12598. getEffectDefines(): string;
  12599. /**
  12600. * Returns the string "CylinderDirectedParticleEmitter"
  12601. * @returns a string containing the class name
  12602. */
  12603. getClassName(): string;
  12604. /**
  12605. * Serializes the particle system to a JSON object.
  12606. * @returns the JSON object
  12607. */
  12608. serialize(): any;
  12609. /**
  12610. * Parse properties from a JSON object
  12611. * @param serializationObject defines the JSON object
  12612. */
  12613. parse(serializationObject: any): void;
  12614. }
  12615. }
  12616. declare module BABYLON {
  12617. /**
  12618. * Particle emitter emitting particles from the inside of a hemisphere.
  12619. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12620. */
  12621. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12622. /**
  12623. * The radius of the emission hemisphere.
  12624. */
  12625. radius: number;
  12626. /**
  12627. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12628. */
  12629. radiusRange: number;
  12630. /**
  12631. * How much to randomize the particle direction [0-1].
  12632. */
  12633. directionRandomizer: number;
  12634. /**
  12635. * Creates a new instance HemisphericParticleEmitter
  12636. * @param radius the radius of the emission hemisphere (1 by default)
  12637. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12638. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12639. */
  12640. constructor(
  12641. /**
  12642. * The radius of the emission hemisphere.
  12643. */
  12644. radius?: number,
  12645. /**
  12646. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12647. */
  12648. radiusRange?: number,
  12649. /**
  12650. * How much to randomize the particle direction [0-1].
  12651. */
  12652. directionRandomizer?: number);
  12653. /**
  12654. * Called by the particle System when the direction is computed for the created particle.
  12655. * @param worldMatrix is the world matrix of the particle system
  12656. * @param directionToUpdate is the direction vector to update with the result
  12657. * @param particle is the particle we are computed the direction for
  12658. * @param isLocal defines if the direction should be set in local space
  12659. */
  12660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12661. /**
  12662. * Called by the particle System when the position is computed for the created particle.
  12663. * @param worldMatrix is the world matrix of the particle system
  12664. * @param positionToUpdate is the position vector to update with the result
  12665. * @param particle is the particle we are computed the position for
  12666. * @param isLocal defines if the position should be set in local space
  12667. */
  12668. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12669. /**
  12670. * Clones the current emitter and returns a copy of it
  12671. * @returns the new emitter
  12672. */
  12673. clone(): HemisphericParticleEmitter;
  12674. /**
  12675. * Called by the GPUParticleSystem to setup the update shader
  12676. * @param effect defines the update shader
  12677. */
  12678. applyToShader(effect: Effect): void;
  12679. /**
  12680. * Returns a string to use to update the GPU particles update shader
  12681. * @returns a string containng the defines string
  12682. */
  12683. getEffectDefines(): string;
  12684. /**
  12685. * Returns the string "HemisphericParticleEmitter"
  12686. * @returns a string containing the class name
  12687. */
  12688. getClassName(): string;
  12689. /**
  12690. * Serializes the particle system to a JSON object.
  12691. * @returns the JSON object
  12692. */
  12693. serialize(): any;
  12694. /**
  12695. * Parse properties from a JSON object
  12696. * @param serializationObject defines the JSON object
  12697. */
  12698. parse(serializationObject: any): void;
  12699. }
  12700. }
  12701. declare module BABYLON {
  12702. /**
  12703. * Particle emitter emitting particles from a point.
  12704. * It emits the particles randomly between 2 given directions.
  12705. */
  12706. export class PointParticleEmitter implements IParticleEmitterType {
  12707. /**
  12708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12709. */
  12710. direction1: Vector3;
  12711. /**
  12712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12713. */
  12714. direction2: Vector3;
  12715. /**
  12716. * Creates a new instance PointParticleEmitter
  12717. */
  12718. constructor();
  12719. /**
  12720. * Called by the particle System when the direction is computed for the created particle.
  12721. * @param worldMatrix is the world matrix of the particle system
  12722. * @param directionToUpdate is the direction vector to update with the result
  12723. * @param particle is the particle we are computed the direction for
  12724. * @param isLocal defines if the direction should be set in local space
  12725. */
  12726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12727. /**
  12728. * Called by the particle System when the position is computed for the created particle.
  12729. * @param worldMatrix is the world matrix of the particle system
  12730. * @param positionToUpdate is the position vector to update with the result
  12731. * @param particle is the particle we are computed the position for
  12732. * @param isLocal defines if the position should be set in local space
  12733. */
  12734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12735. /**
  12736. * Clones the current emitter and returns a copy of it
  12737. * @returns the new emitter
  12738. */
  12739. clone(): PointParticleEmitter;
  12740. /**
  12741. * Called by the GPUParticleSystem to setup the update shader
  12742. * @param effect defines the update shader
  12743. */
  12744. applyToShader(effect: Effect): void;
  12745. /**
  12746. * Returns a string to use to update the GPU particles update shader
  12747. * @returns a string containng the defines string
  12748. */
  12749. getEffectDefines(): string;
  12750. /**
  12751. * Returns the string "PointParticleEmitter"
  12752. * @returns a string containing the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Serializes the particle system to a JSON object.
  12757. * @returns the JSON object
  12758. */
  12759. serialize(): any;
  12760. /**
  12761. * Parse properties from a JSON object
  12762. * @param serializationObject defines the JSON object
  12763. */
  12764. parse(serializationObject: any): void;
  12765. }
  12766. }
  12767. declare module BABYLON {
  12768. /**
  12769. * Particle emitter emitting particles from the inside of a sphere.
  12770. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12771. */
  12772. export class SphereParticleEmitter implements IParticleEmitterType {
  12773. /**
  12774. * The radius of the emission sphere.
  12775. */
  12776. radius: number;
  12777. /**
  12778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12779. */
  12780. radiusRange: number;
  12781. /**
  12782. * How much to randomize the particle direction [0-1].
  12783. */
  12784. directionRandomizer: number;
  12785. /**
  12786. * Creates a new instance SphereParticleEmitter
  12787. * @param radius the radius of the emission sphere (1 by default)
  12788. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12790. */
  12791. constructor(
  12792. /**
  12793. * The radius of the emission sphere.
  12794. */
  12795. radius?: number,
  12796. /**
  12797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12798. */
  12799. radiusRange?: number,
  12800. /**
  12801. * How much to randomize the particle direction [0-1].
  12802. */
  12803. directionRandomizer?: number);
  12804. /**
  12805. * Called by the particle System when the direction is computed for the created particle.
  12806. * @param worldMatrix is the world matrix of the particle system
  12807. * @param directionToUpdate is the direction vector to update with the result
  12808. * @param particle is the particle we are computed the direction for
  12809. * @param isLocal defines if the direction should be set in local space
  12810. */
  12811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12812. /**
  12813. * Called by the particle System when the position is computed for the created particle.
  12814. * @param worldMatrix is the world matrix of the particle system
  12815. * @param positionToUpdate is the position vector to update with the result
  12816. * @param particle is the particle we are computed the position for
  12817. * @param isLocal defines if the position should be set in local space
  12818. */
  12819. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12820. /**
  12821. * Clones the current emitter and returns a copy of it
  12822. * @returns the new emitter
  12823. */
  12824. clone(): SphereParticleEmitter;
  12825. /**
  12826. * Called by the GPUParticleSystem to setup the update shader
  12827. * @param effect defines the update shader
  12828. */
  12829. applyToShader(effect: Effect): void;
  12830. /**
  12831. * Returns a string to use to update the GPU particles update shader
  12832. * @returns a string containng the defines string
  12833. */
  12834. getEffectDefines(): string;
  12835. /**
  12836. * Returns the string "SphereParticleEmitter"
  12837. * @returns a string containing the class name
  12838. */
  12839. getClassName(): string;
  12840. /**
  12841. * Serializes the particle system to a JSON object.
  12842. * @returns the JSON object
  12843. */
  12844. serialize(): any;
  12845. /**
  12846. * Parse properties from a JSON object
  12847. * @param serializationObject defines the JSON object
  12848. */
  12849. parse(serializationObject: any): void;
  12850. }
  12851. /**
  12852. * Particle emitter emitting particles from the inside of a sphere.
  12853. * It emits the particles randomly between two vectors.
  12854. */
  12855. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12856. /**
  12857. * The min limit of the emission direction.
  12858. */
  12859. direction1: Vector3;
  12860. /**
  12861. * The max limit of the emission direction.
  12862. */
  12863. direction2: Vector3;
  12864. /**
  12865. * Creates a new instance SphereDirectedParticleEmitter
  12866. * @param radius the radius of the emission sphere (1 by default)
  12867. * @param direction1 the min limit of the emission direction (up vector by default)
  12868. * @param direction2 the max limit of the emission direction (up vector by default)
  12869. */
  12870. constructor(radius?: number,
  12871. /**
  12872. * The min limit of the emission direction.
  12873. */
  12874. direction1?: Vector3,
  12875. /**
  12876. * The max limit of the emission direction.
  12877. */
  12878. direction2?: Vector3);
  12879. /**
  12880. * Called by the particle System when the direction is computed for the created particle.
  12881. * @param worldMatrix is the world matrix of the particle system
  12882. * @param directionToUpdate is the direction vector to update with the result
  12883. * @param particle is the particle we are computed the direction for
  12884. */
  12885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12886. /**
  12887. * Clones the current emitter and returns a copy of it
  12888. * @returns the new emitter
  12889. */
  12890. clone(): SphereDirectedParticleEmitter;
  12891. /**
  12892. * Called by the GPUParticleSystem to setup the update shader
  12893. * @param effect defines the update shader
  12894. */
  12895. applyToShader(effect: Effect): void;
  12896. /**
  12897. * Returns a string to use to update the GPU particles update shader
  12898. * @returns a string containng the defines string
  12899. */
  12900. getEffectDefines(): string;
  12901. /**
  12902. * Returns the string "SphereDirectedParticleEmitter"
  12903. * @returns a string containing the class name
  12904. */
  12905. getClassName(): string;
  12906. /**
  12907. * Serializes the particle system to a JSON object.
  12908. * @returns the JSON object
  12909. */
  12910. serialize(): any;
  12911. /**
  12912. * Parse properties from a JSON object
  12913. * @param serializationObject defines the JSON object
  12914. */
  12915. parse(serializationObject: any): void;
  12916. }
  12917. }
  12918. declare module BABYLON {
  12919. /**
  12920. * Particle emitter emitting particles from a custom list of positions.
  12921. */
  12922. export class CustomParticleEmitter implements IParticleEmitterType {
  12923. /**
  12924. * Gets or sets the position generator that will create the inital position of each particle.
  12925. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12926. */
  12927. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12928. /**
  12929. * Gets or sets the destination generator that will create the final destination of each particle.
  12930. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12931. */
  12932. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12933. /**
  12934. * Creates a new instance CustomParticleEmitter
  12935. */
  12936. constructor();
  12937. /**
  12938. * Called by the particle System when the direction is computed for the created particle.
  12939. * @param worldMatrix is the world matrix of the particle system
  12940. * @param directionToUpdate is the direction vector to update with the result
  12941. * @param particle is the particle we are computed the direction for
  12942. * @param isLocal defines if the direction should be set in local space
  12943. */
  12944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12945. /**
  12946. * Called by the particle System when the position is computed for the created particle.
  12947. * @param worldMatrix is the world matrix of the particle system
  12948. * @param positionToUpdate is the position vector to update with the result
  12949. * @param particle is the particle we are computed the position for
  12950. * @param isLocal defines if the position should be set in local space
  12951. */
  12952. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12953. /**
  12954. * Clones the current emitter and returns a copy of it
  12955. * @returns the new emitter
  12956. */
  12957. clone(): CustomParticleEmitter;
  12958. /**
  12959. * Called by the GPUParticleSystem to setup the update shader
  12960. * @param effect defines the update shader
  12961. */
  12962. applyToShader(effect: Effect): void;
  12963. /**
  12964. * Returns a string to use to update the GPU particles update shader
  12965. * @returns a string containng the defines string
  12966. */
  12967. getEffectDefines(): string;
  12968. /**
  12969. * Returns the string "PointParticleEmitter"
  12970. * @returns a string containing the class name
  12971. */
  12972. getClassName(): string;
  12973. /**
  12974. * Serializes the particle system to a JSON object.
  12975. * @returns the JSON object
  12976. */
  12977. serialize(): any;
  12978. /**
  12979. * Parse properties from a JSON object
  12980. * @param serializationObject defines the JSON object
  12981. */
  12982. parse(serializationObject: any): void;
  12983. }
  12984. }
  12985. declare module BABYLON {
  12986. /**
  12987. * Particle emitter emitting particles from the inside of a box.
  12988. * It emits the particles randomly between 2 given directions.
  12989. */
  12990. export class MeshParticleEmitter implements IParticleEmitterType {
  12991. private _indices;
  12992. private _positions;
  12993. private _normals;
  12994. private _storedNormal;
  12995. private _mesh;
  12996. /**
  12997. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12998. */
  12999. direction1: Vector3;
  13000. /**
  13001. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13002. */
  13003. direction2: Vector3;
  13004. /**
  13005. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13006. */
  13007. useMeshNormalsForDirection: boolean;
  13008. /** Defines the mesh to use as source */
  13009. get mesh(): Nullable<AbstractMesh>;
  13010. set mesh(value: Nullable<AbstractMesh>);
  13011. /**
  13012. * Creates a new instance MeshParticleEmitter
  13013. * @param mesh defines the mesh to use as source
  13014. */
  13015. constructor(mesh?: Nullable<AbstractMesh>);
  13016. /**
  13017. * Called by the particle System when the direction is computed for the created particle.
  13018. * @param worldMatrix is the world matrix of the particle system
  13019. * @param directionToUpdate is the direction vector to update with the result
  13020. * @param particle is the particle we are computed the direction for
  13021. * @param isLocal defines if the direction should be set in local space
  13022. */
  13023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13024. /**
  13025. * Called by the particle System when the position is computed for the created particle.
  13026. * @param worldMatrix is the world matrix of the particle system
  13027. * @param positionToUpdate is the position vector to update with the result
  13028. * @param particle is the particle we are computed the position for
  13029. * @param isLocal defines if the position should be set in local space
  13030. */
  13031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13032. /**
  13033. * Clones the current emitter and returns a copy of it
  13034. * @returns the new emitter
  13035. */
  13036. clone(): MeshParticleEmitter;
  13037. /**
  13038. * Called by the GPUParticleSystem to setup the update shader
  13039. * @param effect defines the update shader
  13040. */
  13041. applyToShader(effect: Effect): void;
  13042. /**
  13043. * Returns a string to use to update the GPU particles update shader
  13044. * @returns a string containng the defines string
  13045. */
  13046. getEffectDefines(): string;
  13047. /**
  13048. * Returns the string "BoxParticleEmitter"
  13049. * @returns a string containing the class name
  13050. */
  13051. getClassName(): string;
  13052. /**
  13053. * Serializes the particle system to a JSON object.
  13054. * @returns the JSON object
  13055. */
  13056. serialize(): any;
  13057. /**
  13058. * Parse properties from a JSON object
  13059. * @param serializationObject defines the JSON object
  13060. * @param scene defines the hosting scene
  13061. */
  13062. parse(serializationObject: any, scene: Scene): void;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Interface representing a particle system in Babylon.js.
  13068. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13069. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13070. */
  13071. export interface IParticleSystem {
  13072. /**
  13073. * List of animations used by the particle system.
  13074. */
  13075. animations: Animation[];
  13076. /**
  13077. * The id of the Particle system.
  13078. */
  13079. id: string;
  13080. /**
  13081. * The name of the Particle system.
  13082. */
  13083. name: string;
  13084. /**
  13085. * The emitter represents the Mesh or position we are attaching the particle system to.
  13086. */
  13087. emitter: Nullable<AbstractMesh | Vector3>;
  13088. /**
  13089. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13090. */
  13091. isBillboardBased: boolean;
  13092. /**
  13093. * The rendering group used by the Particle system to chose when to render.
  13094. */
  13095. renderingGroupId: number;
  13096. /**
  13097. * The layer mask we are rendering the particles through.
  13098. */
  13099. layerMask: number;
  13100. /**
  13101. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13102. */
  13103. updateSpeed: number;
  13104. /**
  13105. * The amount of time the particle system is running (depends of the overall update speed).
  13106. */
  13107. targetStopDuration: number;
  13108. /**
  13109. * The texture used to render each particle. (this can be a spritesheet)
  13110. */
  13111. particleTexture: Nullable<Texture>;
  13112. /**
  13113. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13114. */
  13115. blendMode: number;
  13116. /**
  13117. * Minimum life time of emitting particles.
  13118. */
  13119. minLifeTime: number;
  13120. /**
  13121. * Maximum life time of emitting particles.
  13122. */
  13123. maxLifeTime: number;
  13124. /**
  13125. * Minimum Size of emitting particles.
  13126. */
  13127. minSize: number;
  13128. /**
  13129. * Maximum Size of emitting particles.
  13130. */
  13131. maxSize: number;
  13132. /**
  13133. * Minimum scale of emitting particles on X axis.
  13134. */
  13135. minScaleX: number;
  13136. /**
  13137. * Maximum scale of emitting particles on X axis.
  13138. */
  13139. maxScaleX: number;
  13140. /**
  13141. * Minimum scale of emitting particles on Y axis.
  13142. */
  13143. minScaleY: number;
  13144. /**
  13145. * Maximum scale of emitting particles on Y axis.
  13146. */
  13147. maxScaleY: number;
  13148. /**
  13149. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13150. */
  13151. color1: Color4;
  13152. /**
  13153. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13154. */
  13155. color2: Color4;
  13156. /**
  13157. * Color the particle will have at the end of its lifetime.
  13158. */
  13159. colorDead: Color4;
  13160. /**
  13161. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13162. */
  13163. emitRate: number;
  13164. /**
  13165. * You can use gravity if you want to give an orientation to your particles.
  13166. */
  13167. gravity: Vector3;
  13168. /**
  13169. * Minimum power of emitting particles.
  13170. */
  13171. minEmitPower: number;
  13172. /**
  13173. * Maximum power of emitting particles.
  13174. */
  13175. maxEmitPower: number;
  13176. /**
  13177. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13178. */
  13179. minAngularSpeed: number;
  13180. /**
  13181. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13182. */
  13183. maxAngularSpeed: number;
  13184. /**
  13185. * Gets or sets the minimal initial rotation in radians.
  13186. */
  13187. minInitialRotation: number;
  13188. /**
  13189. * Gets or sets the maximal initial rotation in radians.
  13190. */
  13191. maxInitialRotation: number;
  13192. /**
  13193. * The particle emitter type defines the emitter used by the particle system.
  13194. * It can be for example box, sphere, or cone...
  13195. */
  13196. particleEmitterType: Nullable<IParticleEmitterType>;
  13197. /**
  13198. * Defines the delay in milliseconds before starting the system (0 by default)
  13199. */
  13200. startDelay: number;
  13201. /**
  13202. * 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
  13203. */
  13204. preWarmCycles: number;
  13205. /**
  13206. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13207. */
  13208. preWarmStepOffset: number;
  13209. /**
  13210. * 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)
  13211. */
  13212. spriteCellChangeSpeed: number;
  13213. /**
  13214. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13215. */
  13216. startSpriteCellID: number;
  13217. /**
  13218. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13219. */
  13220. endSpriteCellID: number;
  13221. /**
  13222. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13223. */
  13224. spriteCellWidth: number;
  13225. /**
  13226. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13227. */
  13228. spriteCellHeight: number;
  13229. /**
  13230. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13231. */
  13232. spriteRandomStartCell: boolean;
  13233. /**
  13234. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13235. */
  13236. isAnimationSheetEnabled: boolean;
  13237. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13238. translationPivot: Vector2;
  13239. /**
  13240. * Gets or sets a texture used to add random noise to particle positions
  13241. */
  13242. noiseTexture: Nullable<BaseTexture>;
  13243. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13244. noiseStrength: Vector3;
  13245. /**
  13246. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13247. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13248. */
  13249. billboardMode: number;
  13250. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13251. limitVelocityDamping: number;
  13252. /**
  13253. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13254. */
  13255. beginAnimationOnStart: boolean;
  13256. /**
  13257. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13258. */
  13259. beginAnimationFrom: number;
  13260. /**
  13261. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13262. */
  13263. beginAnimationTo: number;
  13264. /**
  13265. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13266. */
  13267. beginAnimationLoop: boolean;
  13268. /**
  13269. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13270. */
  13271. disposeOnStop: boolean;
  13272. /**
  13273. * Specifies if the particles are updated in emitter local space or world space
  13274. */
  13275. isLocal: boolean;
  13276. /** Snippet ID if the particle system was created from the snippet server */
  13277. snippetId: string;
  13278. /**
  13279. * Gets the maximum number of particles active at the same time.
  13280. * @returns The max number of active particles.
  13281. */
  13282. getCapacity(): number;
  13283. /**
  13284. * Gets the number of particles active at the same time.
  13285. * @returns The number of active particles.
  13286. */
  13287. getActiveCount(): number;
  13288. /**
  13289. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13290. * @returns True if it has been started, otherwise false.
  13291. */
  13292. isStarted(): boolean;
  13293. /**
  13294. * Animates the particle system for this frame.
  13295. */
  13296. animate(): void;
  13297. /**
  13298. * Renders the particle system in its current state.
  13299. * @returns the current number of particles
  13300. */
  13301. render(): number;
  13302. /**
  13303. * Dispose the particle system and frees its associated resources.
  13304. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13305. */
  13306. dispose(disposeTexture?: boolean): void;
  13307. /**
  13308. * Clones the particle system.
  13309. * @param name The name of the cloned object
  13310. * @param newEmitter The new emitter to use
  13311. * @returns the cloned particle system
  13312. */
  13313. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13314. /**
  13315. * Serializes the particle system to a JSON object
  13316. * @param serializeTexture defines if the texture must be serialized as well
  13317. * @returns the JSON object
  13318. */
  13319. serialize(serializeTexture: boolean): any;
  13320. /**
  13321. * Rebuild the particle system
  13322. */
  13323. rebuild(): void;
  13324. /** Force the system to rebuild all gradients that need to be resync */
  13325. forceRefreshGradients(): void;
  13326. /**
  13327. * Starts the particle system and begins to emit
  13328. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13329. */
  13330. start(delay?: number): void;
  13331. /**
  13332. * Stops the particle system.
  13333. */
  13334. stop(): void;
  13335. /**
  13336. * Remove all active particles
  13337. */
  13338. reset(): void;
  13339. /**
  13340. * Gets a boolean indicating that the system is stopping
  13341. * @returns true if the system is currently stopping
  13342. */
  13343. isStopping(): boolean;
  13344. /**
  13345. * Is this system ready to be used/rendered
  13346. * @return true if the system is ready
  13347. */
  13348. isReady(): boolean;
  13349. /**
  13350. * Returns the string "ParticleSystem"
  13351. * @returns a string containing the class name
  13352. */
  13353. getClassName(): string;
  13354. /**
  13355. * Adds a new color gradient
  13356. * @param gradient defines the gradient to use (between 0 and 1)
  13357. * @param color1 defines the color to affect to the specified gradient
  13358. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13359. * @returns the current particle system
  13360. */
  13361. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13362. /**
  13363. * Remove a specific color gradient
  13364. * @param gradient defines the gradient to remove
  13365. * @returns the current particle system
  13366. */
  13367. removeColorGradient(gradient: number): IParticleSystem;
  13368. /**
  13369. * Adds a new size gradient
  13370. * @param gradient defines the gradient to use (between 0 and 1)
  13371. * @param factor defines the size factor to affect to the specified gradient
  13372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13373. * @returns the current particle system
  13374. */
  13375. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13376. /**
  13377. * Remove a specific size gradient
  13378. * @param gradient defines the gradient to remove
  13379. * @returns the current particle system
  13380. */
  13381. removeSizeGradient(gradient: number): IParticleSystem;
  13382. /**
  13383. * Gets the current list of color gradients.
  13384. * You must use addColorGradient and removeColorGradient to udpate this list
  13385. * @returns the list of color gradients
  13386. */
  13387. getColorGradients(): Nullable<Array<ColorGradient>>;
  13388. /**
  13389. * Gets the current list of size gradients.
  13390. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13391. * @returns the list of size gradients
  13392. */
  13393. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13394. /**
  13395. * Gets the current list of angular speed gradients.
  13396. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13397. * @returns the list of angular speed gradients
  13398. */
  13399. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13400. /**
  13401. * Adds a new angular speed gradient
  13402. * @param gradient defines the gradient to use (between 0 and 1)
  13403. * @param factor defines the angular speed to affect to the specified gradient
  13404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13405. * @returns the current particle system
  13406. */
  13407. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13408. /**
  13409. * Remove a specific angular speed gradient
  13410. * @param gradient defines the gradient to remove
  13411. * @returns the current particle system
  13412. */
  13413. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13414. /**
  13415. * Gets the current list of velocity gradients.
  13416. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13417. * @returns the list of velocity gradients
  13418. */
  13419. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13420. /**
  13421. * Adds a new velocity gradient
  13422. * @param gradient defines the gradient to use (between 0 and 1)
  13423. * @param factor defines the velocity to affect to the specified gradient
  13424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13425. * @returns the current particle system
  13426. */
  13427. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13428. /**
  13429. * Remove a specific velocity gradient
  13430. * @param gradient defines the gradient to remove
  13431. * @returns the current particle system
  13432. */
  13433. removeVelocityGradient(gradient: number): IParticleSystem;
  13434. /**
  13435. * Gets the current list of limit velocity gradients.
  13436. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13437. * @returns the list of limit velocity gradients
  13438. */
  13439. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13440. /**
  13441. * Adds a new limit velocity gradient
  13442. * @param gradient defines the gradient to use (between 0 and 1)
  13443. * @param factor defines the limit velocity to affect to the specified gradient
  13444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13445. * @returns the current particle system
  13446. */
  13447. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13448. /**
  13449. * Remove a specific limit velocity gradient
  13450. * @param gradient defines the gradient to remove
  13451. * @returns the current particle system
  13452. */
  13453. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13454. /**
  13455. * Adds a new drag gradient
  13456. * @param gradient defines the gradient to use (between 0 and 1)
  13457. * @param factor defines the drag to affect to the specified gradient
  13458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13459. * @returns the current particle system
  13460. */
  13461. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13462. /**
  13463. * Remove a specific drag gradient
  13464. * @param gradient defines the gradient to remove
  13465. * @returns the current particle system
  13466. */
  13467. removeDragGradient(gradient: number): IParticleSystem;
  13468. /**
  13469. * Gets the current list of drag gradients.
  13470. * You must use addDragGradient and removeDragGradient to udpate this list
  13471. * @returns the list of drag gradients
  13472. */
  13473. getDragGradients(): Nullable<Array<FactorGradient>>;
  13474. /**
  13475. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13476. * @param gradient defines the gradient to use (between 0 and 1)
  13477. * @param factor defines the emit rate to affect to the specified gradient
  13478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13479. * @returns the current particle system
  13480. */
  13481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13482. /**
  13483. * Remove a specific emit rate gradient
  13484. * @param gradient defines the gradient to remove
  13485. * @returns the current particle system
  13486. */
  13487. removeEmitRateGradient(gradient: number): IParticleSystem;
  13488. /**
  13489. * Gets the current list of emit rate gradients.
  13490. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13491. * @returns the list of emit rate gradients
  13492. */
  13493. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13494. /**
  13495. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13496. * @param gradient defines the gradient to use (between 0 and 1)
  13497. * @param factor defines the start size to affect to the specified gradient
  13498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13499. * @returns the current particle system
  13500. */
  13501. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13502. /**
  13503. * Remove a specific start size gradient
  13504. * @param gradient defines the gradient to remove
  13505. * @returns the current particle system
  13506. */
  13507. removeStartSizeGradient(gradient: number): IParticleSystem;
  13508. /**
  13509. * Gets the current list of start size gradients.
  13510. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13511. * @returns the list of start size gradients
  13512. */
  13513. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13514. /**
  13515. * Adds a new life time gradient
  13516. * @param gradient defines the gradient to use (between 0 and 1)
  13517. * @param factor defines the life time factor to affect to the specified gradient
  13518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13519. * @returns the current particle system
  13520. */
  13521. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13522. /**
  13523. * Remove a specific life time gradient
  13524. * @param gradient defines the gradient to remove
  13525. * @returns the current particle system
  13526. */
  13527. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13528. /**
  13529. * Gets the current list of life time gradients.
  13530. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13531. * @returns the list of life time gradients
  13532. */
  13533. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13534. /**
  13535. * Gets the current list of color gradients.
  13536. * You must use addColorGradient and removeColorGradient to udpate this list
  13537. * @returns the list of color gradients
  13538. */
  13539. getColorGradients(): Nullable<Array<ColorGradient>>;
  13540. /**
  13541. * Adds a new ramp gradient used to remap particle colors
  13542. * @param gradient defines the gradient to use (between 0 and 1)
  13543. * @param color defines the color to affect to the specified gradient
  13544. * @returns the current particle system
  13545. */
  13546. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13547. /**
  13548. * Gets the current list of ramp gradients.
  13549. * You must use addRampGradient and removeRampGradient to udpate this list
  13550. * @returns the list of ramp gradients
  13551. */
  13552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13553. /** Gets or sets a boolean indicating that ramp gradients must be used
  13554. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13555. */
  13556. useRampGradients: boolean;
  13557. /**
  13558. * Adds a new color remap gradient
  13559. * @param gradient defines the gradient to use (between 0 and 1)
  13560. * @param min defines the color remap minimal range
  13561. * @param max defines the color remap maximal range
  13562. * @returns the current particle system
  13563. */
  13564. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13565. /**
  13566. * Gets the current list of color remap gradients.
  13567. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13568. * @returns the list of color remap gradients
  13569. */
  13570. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13571. /**
  13572. * Adds a new alpha remap gradient
  13573. * @param gradient defines the gradient to use (between 0 and 1)
  13574. * @param min defines the alpha remap minimal range
  13575. * @param max defines the alpha remap maximal range
  13576. * @returns the current particle system
  13577. */
  13578. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13579. /**
  13580. * Gets the current list of alpha remap gradients.
  13581. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13582. * @returns the list of alpha remap gradients
  13583. */
  13584. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13585. /**
  13586. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13589. * @returns the emitter
  13590. */
  13591. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13592. /**
  13593. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13594. * @param radius The radius of the hemisphere to emit from
  13595. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13596. * @returns the emitter
  13597. */
  13598. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13599. /**
  13600. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13601. * @param radius The radius of the sphere to emit from
  13602. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13603. * @returns the emitter
  13604. */
  13605. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13606. /**
  13607. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13608. * @param radius The radius of the sphere to emit from
  13609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13611. * @returns the emitter
  13612. */
  13613. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13614. /**
  13615. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13616. * @param radius The radius of the emission cylinder
  13617. * @param height The height of the emission cylinder
  13618. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13619. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13620. * @returns the emitter
  13621. */
  13622. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13623. /**
  13624. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13625. * @param radius The radius of the cylinder to emit from
  13626. * @param height The height of the emission cylinder
  13627. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13630. * @returns the emitter
  13631. */
  13632. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13633. /**
  13634. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13635. * @param radius The radius of the cone to emit from
  13636. * @param angle The base angle of the cone
  13637. * @returns the emitter
  13638. */
  13639. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13640. /**
  13641. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13644. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13645. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13646. * @returns the emitter
  13647. */
  13648. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13649. /**
  13650. * Get hosting scene
  13651. * @returns the scene
  13652. */
  13653. getScene(): Scene;
  13654. }
  13655. }
  13656. declare module BABYLON {
  13657. /**
  13658. * 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.
  13659. * @see https://doc.babylonjs.com/how_to/transformnode
  13660. */
  13661. export class TransformNode extends Node {
  13662. /**
  13663. * Object will not rotate to face the camera
  13664. */
  13665. static BILLBOARDMODE_NONE: number;
  13666. /**
  13667. * Object will rotate to face the camera but only on the x axis
  13668. */
  13669. static BILLBOARDMODE_X: number;
  13670. /**
  13671. * Object will rotate to face the camera but only on the y axis
  13672. */
  13673. static BILLBOARDMODE_Y: number;
  13674. /**
  13675. * Object will rotate to face the camera but only on the z axis
  13676. */
  13677. static BILLBOARDMODE_Z: number;
  13678. /**
  13679. * Object will rotate to face the camera
  13680. */
  13681. static BILLBOARDMODE_ALL: number;
  13682. /**
  13683. * Object will rotate to face the camera's position instead of orientation
  13684. */
  13685. static BILLBOARDMODE_USE_POSITION: number;
  13686. private _forward;
  13687. private _forwardInverted;
  13688. private _up;
  13689. private _right;
  13690. private _rightInverted;
  13691. private _position;
  13692. private _rotation;
  13693. private _rotationQuaternion;
  13694. protected _scaling: Vector3;
  13695. protected _isDirty: boolean;
  13696. private _transformToBoneReferal;
  13697. private _isAbsoluteSynced;
  13698. private _billboardMode;
  13699. /**
  13700. * Gets or sets the billboard mode. Default is 0.
  13701. *
  13702. * | Value | Type | Description |
  13703. * | --- | --- | --- |
  13704. * | 0 | BILLBOARDMODE_NONE | |
  13705. * | 1 | BILLBOARDMODE_X | |
  13706. * | 2 | BILLBOARDMODE_Y | |
  13707. * | 4 | BILLBOARDMODE_Z | |
  13708. * | 7 | BILLBOARDMODE_ALL | |
  13709. *
  13710. */
  13711. get billboardMode(): number;
  13712. set billboardMode(value: number);
  13713. private _preserveParentRotationForBillboard;
  13714. /**
  13715. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13716. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13717. */
  13718. get preserveParentRotationForBillboard(): boolean;
  13719. set preserveParentRotationForBillboard(value: boolean);
  13720. /**
  13721. * 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
  13722. */
  13723. scalingDeterminant: number;
  13724. private _infiniteDistance;
  13725. /**
  13726. * Gets or sets the distance of the object to max, often used by skybox
  13727. */
  13728. get infiniteDistance(): boolean;
  13729. set infiniteDistance(value: boolean);
  13730. /**
  13731. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13732. * By default the system will update normals to compensate
  13733. */
  13734. ignoreNonUniformScaling: boolean;
  13735. /**
  13736. * 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
  13737. */
  13738. reIntegrateRotationIntoRotationQuaternion: boolean;
  13739. /** @hidden */
  13740. _poseMatrix: Nullable<Matrix>;
  13741. /** @hidden */
  13742. _localMatrix: Matrix;
  13743. private _usePivotMatrix;
  13744. private _absolutePosition;
  13745. private _absoluteScaling;
  13746. private _absoluteRotationQuaternion;
  13747. private _pivotMatrix;
  13748. private _pivotMatrixInverse;
  13749. protected _postMultiplyPivotMatrix: boolean;
  13750. protected _isWorldMatrixFrozen: boolean;
  13751. /** @hidden */
  13752. _indexInSceneTransformNodesArray: number;
  13753. /**
  13754. * An event triggered after the world matrix is updated
  13755. */
  13756. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13757. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13758. /**
  13759. * Gets a string identifying the name of the class
  13760. * @returns "TransformNode" string
  13761. */
  13762. getClassName(): string;
  13763. /**
  13764. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13765. */
  13766. get position(): Vector3;
  13767. set position(newPosition: Vector3);
  13768. /**
  13769. * 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)).
  13770. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13771. */
  13772. get rotation(): Vector3;
  13773. set rotation(newRotation: Vector3);
  13774. /**
  13775. * 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)).
  13776. */
  13777. get scaling(): Vector3;
  13778. set scaling(newScaling: Vector3);
  13779. /**
  13780. * 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).
  13781. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13782. */
  13783. get rotationQuaternion(): Nullable<Quaternion>;
  13784. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13785. /**
  13786. * The forward direction of that transform in world space.
  13787. */
  13788. get forward(): Vector3;
  13789. /**
  13790. * The up direction of that transform in world space.
  13791. */
  13792. get up(): Vector3;
  13793. /**
  13794. * The right direction of that transform in world space.
  13795. */
  13796. get right(): Vector3;
  13797. /**
  13798. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13799. * @param matrix the matrix to copy the pose from
  13800. * @returns this TransformNode.
  13801. */
  13802. updatePoseMatrix(matrix: Matrix): TransformNode;
  13803. /**
  13804. * Returns the mesh Pose matrix.
  13805. * @returns the pose matrix
  13806. */
  13807. getPoseMatrix(): Matrix;
  13808. /** @hidden */
  13809. _isSynchronized(): boolean;
  13810. /** @hidden */
  13811. _initCache(): void;
  13812. /**
  13813. * Flag the transform node as dirty (Forcing it to update everything)
  13814. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13815. * @returns this transform node
  13816. */
  13817. markAsDirty(property: string): TransformNode;
  13818. /**
  13819. * Returns the current mesh absolute position.
  13820. * Returns a Vector3.
  13821. */
  13822. get absolutePosition(): Vector3;
  13823. /**
  13824. * Returns the current mesh absolute scaling.
  13825. * Returns a Vector3.
  13826. */
  13827. get absoluteScaling(): Vector3;
  13828. /**
  13829. * Returns the current mesh absolute rotation.
  13830. * Returns a Quaternion.
  13831. */
  13832. get absoluteRotationQuaternion(): Quaternion;
  13833. /**
  13834. * Sets a new matrix to apply before all other transformation
  13835. * @param matrix defines the transform matrix
  13836. * @returns the current TransformNode
  13837. */
  13838. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13839. /**
  13840. * Sets a new pivot matrix to the current node
  13841. * @param matrix defines the new pivot matrix to use
  13842. * @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
  13843. * @returns the current TransformNode
  13844. */
  13845. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13846. /**
  13847. * Returns the mesh pivot matrix.
  13848. * Default : Identity.
  13849. * @returns the matrix
  13850. */
  13851. getPivotMatrix(): Matrix;
  13852. /**
  13853. * Instantiate (when possible) or clone that node with its hierarchy
  13854. * @param newParent defines the new parent to use for the instance (or clone)
  13855. * @param options defines options to configure how copy is done
  13856. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13857. * @returns an instance (or a clone) of the current node with its hiearchy
  13858. */
  13859. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13860. doNotInstantiate: boolean;
  13861. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13862. /**
  13863. * Prevents the World matrix to be computed any longer
  13864. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13865. * @returns the TransformNode.
  13866. */
  13867. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13868. /**
  13869. * Allows back the World matrix computation.
  13870. * @returns the TransformNode.
  13871. */
  13872. unfreezeWorldMatrix(): this;
  13873. /**
  13874. * True if the World matrix has been frozen.
  13875. */
  13876. get isWorldMatrixFrozen(): boolean;
  13877. /**
  13878. * Retuns the mesh absolute position in the World.
  13879. * @returns a Vector3.
  13880. */
  13881. getAbsolutePosition(): Vector3;
  13882. /**
  13883. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13884. * @param absolutePosition the absolute position to set
  13885. * @returns the TransformNode.
  13886. */
  13887. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13888. /**
  13889. * Sets the mesh position in its local space.
  13890. * @param vector3 the position to set in localspace
  13891. * @returns the TransformNode.
  13892. */
  13893. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13894. /**
  13895. * Returns the mesh position in the local space from the current World matrix values.
  13896. * @returns a new Vector3.
  13897. */
  13898. getPositionExpressedInLocalSpace(): Vector3;
  13899. /**
  13900. * Translates the mesh along the passed Vector3 in its local space.
  13901. * @param vector3 the distance to translate in localspace
  13902. * @returns the TransformNode.
  13903. */
  13904. locallyTranslate(vector3: Vector3): TransformNode;
  13905. private static _lookAtVectorCache;
  13906. /**
  13907. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13908. * @param targetPoint the position (must be in same space as current mesh) to look at
  13909. * @param yawCor optional yaw (y-axis) correction in radians
  13910. * @param pitchCor optional pitch (x-axis) correction in radians
  13911. * @param rollCor optional roll (z-axis) correction in radians
  13912. * @param space the choosen space of the target
  13913. * @returns the TransformNode.
  13914. */
  13915. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13916. /**
  13917. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13918. * This Vector3 is expressed in the World space.
  13919. * @param localAxis axis to rotate
  13920. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13921. */
  13922. getDirection(localAxis: Vector3): Vector3;
  13923. /**
  13924. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13925. * localAxis is expressed in the mesh local space.
  13926. * result is computed in the Wordl space from the mesh World matrix.
  13927. * @param localAxis axis to rotate
  13928. * @param result the resulting transformnode
  13929. * @returns this TransformNode.
  13930. */
  13931. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13932. /**
  13933. * Sets this transform node rotation to the given local axis.
  13934. * @param localAxis the axis in local space
  13935. * @param yawCor optional yaw (y-axis) correction in radians
  13936. * @param pitchCor optional pitch (x-axis) correction in radians
  13937. * @param rollCor optional roll (z-axis) correction in radians
  13938. * @returns this TransformNode
  13939. */
  13940. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13941. /**
  13942. * Sets a new pivot point to the current node
  13943. * @param point defines the new pivot point to use
  13944. * @param space defines if the point is in world or local space (local by default)
  13945. * @returns the current TransformNode
  13946. */
  13947. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13948. /**
  13949. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13950. * @returns the pivot point
  13951. */
  13952. getPivotPoint(): Vector3;
  13953. /**
  13954. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13955. * @param result the vector3 to store the result
  13956. * @returns this TransformNode.
  13957. */
  13958. getPivotPointToRef(result: Vector3): TransformNode;
  13959. /**
  13960. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13961. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13962. */
  13963. getAbsolutePivotPoint(): Vector3;
  13964. /**
  13965. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13966. * @param result vector3 to store the result
  13967. * @returns this TransformNode.
  13968. */
  13969. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13970. /**
  13971. * Defines the passed node as the parent of the current node.
  13972. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13973. * @see https://doc.babylonjs.com/how_to/parenting
  13974. * @param node the node ot set as the parent
  13975. * @returns this TransformNode.
  13976. */
  13977. setParent(node: Nullable<Node>): TransformNode;
  13978. private _nonUniformScaling;
  13979. /**
  13980. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13981. */
  13982. get nonUniformScaling(): boolean;
  13983. /** @hidden */
  13984. _updateNonUniformScalingState(value: boolean): boolean;
  13985. /**
  13986. * Attach the current TransformNode to another TransformNode associated with a bone
  13987. * @param bone Bone affecting the TransformNode
  13988. * @param affectedTransformNode TransformNode associated with the bone
  13989. * @returns this object
  13990. */
  13991. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13992. /**
  13993. * Detach the transform node if its associated with a bone
  13994. * @returns this object
  13995. */
  13996. detachFromBone(): TransformNode;
  13997. private static _rotationAxisCache;
  13998. /**
  13999. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14000. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14001. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14002. * The passed axis is also normalized.
  14003. * @param axis the axis to rotate around
  14004. * @param amount the amount to rotate in radians
  14005. * @param space Space to rotate in (Default: local)
  14006. * @returns the TransformNode.
  14007. */
  14008. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14009. /**
  14010. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14011. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14012. * The passed axis is also normalized. .
  14013. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14014. * @param point the point to rotate around
  14015. * @param axis the axis to rotate around
  14016. * @param amount the amount to rotate in radians
  14017. * @returns the TransformNode
  14018. */
  14019. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14020. /**
  14021. * Translates the mesh along the axis vector for the passed distance in the given space.
  14022. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14023. * @param axis the axis to translate in
  14024. * @param distance the distance to translate
  14025. * @param space Space to rotate in (Default: local)
  14026. * @returns the TransformNode.
  14027. */
  14028. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14029. /**
  14030. * Adds a rotation step to the mesh current rotation.
  14031. * x, y, z are Euler angles expressed in radians.
  14032. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14033. * This means this rotation is made in the mesh local space only.
  14034. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14035. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14036. * ```javascript
  14037. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14038. * ```
  14039. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14040. * 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.
  14041. * @param x Rotation to add
  14042. * @param y Rotation to add
  14043. * @param z Rotation to add
  14044. * @returns the TransformNode.
  14045. */
  14046. addRotation(x: number, y: number, z: number): TransformNode;
  14047. /**
  14048. * @hidden
  14049. */
  14050. protected _getEffectiveParent(): Nullable<Node>;
  14051. /**
  14052. * Computes the world matrix of the node
  14053. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14054. * @returns the world matrix
  14055. */
  14056. computeWorldMatrix(force?: boolean): Matrix;
  14057. /**
  14058. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14059. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14060. */
  14061. resetLocalMatrix(independentOfChildren?: boolean): void;
  14062. protected _afterComputeWorldMatrix(): void;
  14063. /**
  14064. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14065. * @param func callback function to add
  14066. *
  14067. * @returns the TransformNode.
  14068. */
  14069. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14070. /**
  14071. * Removes a registered callback function.
  14072. * @param func callback function to remove
  14073. * @returns the TransformNode.
  14074. */
  14075. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14076. /**
  14077. * Gets the position of the current mesh in camera space
  14078. * @param camera defines the camera to use
  14079. * @returns a position
  14080. */
  14081. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14082. /**
  14083. * Returns the distance from the mesh to the active camera
  14084. * @param camera defines the camera to use
  14085. * @returns the distance
  14086. */
  14087. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14088. /**
  14089. * Clone the current transform node
  14090. * @param name Name of the new clone
  14091. * @param newParent New parent for the clone
  14092. * @param doNotCloneChildren Do not clone children hierarchy
  14093. * @returns the new transform node
  14094. */
  14095. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14096. /**
  14097. * Serializes the objects information.
  14098. * @param currentSerializationObject defines the object to serialize in
  14099. * @returns the serialized object
  14100. */
  14101. serialize(currentSerializationObject?: any): any;
  14102. /**
  14103. * Returns a new TransformNode object parsed from the source provided.
  14104. * @param parsedTransformNode is the source.
  14105. * @param scene the scne the object belongs to
  14106. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14107. * @returns a new TransformNode object parsed from the source provided.
  14108. */
  14109. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14110. /**
  14111. * Get all child-transformNodes of this node
  14112. * @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
  14113. * @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
  14114. * @returns an array of TransformNode
  14115. */
  14116. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14117. /**
  14118. * Releases resources associated with this transform node.
  14119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14121. */
  14122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14123. /**
  14124. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14125. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14126. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14127. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14128. * @returns the current mesh
  14129. */
  14130. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14131. private _syncAbsoluteScalingAndRotation;
  14132. }
  14133. }
  14134. declare module BABYLON {
  14135. /**
  14136. * Class used to override all child animations of a given target
  14137. */
  14138. export class AnimationPropertiesOverride {
  14139. /**
  14140. * Gets or sets a value indicating if animation blending must be used
  14141. */
  14142. enableBlending: boolean;
  14143. /**
  14144. * Gets or sets the blending speed to use when enableBlending is true
  14145. */
  14146. blendingSpeed: number;
  14147. /**
  14148. * Gets or sets the default loop mode to use
  14149. */
  14150. loopMode: number;
  14151. }
  14152. }
  14153. declare module BABYLON {
  14154. /**
  14155. * Class used to store bone information
  14156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14157. */
  14158. export class Bone extends Node {
  14159. /**
  14160. * defines the bone name
  14161. */
  14162. name: string;
  14163. private static _tmpVecs;
  14164. private static _tmpQuat;
  14165. private static _tmpMats;
  14166. /**
  14167. * Gets the list of child bones
  14168. */
  14169. children: Bone[];
  14170. /** Gets the animations associated with this bone */
  14171. animations: Animation[];
  14172. /**
  14173. * Gets or sets bone length
  14174. */
  14175. length: number;
  14176. /**
  14177. * @hidden Internal only
  14178. * Set this value to map this bone to a different index in the transform matrices
  14179. * Set this value to -1 to exclude the bone from the transform matrices
  14180. */
  14181. _index: Nullable<number>;
  14182. private _skeleton;
  14183. private _localMatrix;
  14184. private _restPose;
  14185. private _baseMatrix;
  14186. private _absoluteTransform;
  14187. private _invertedAbsoluteTransform;
  14188. private _parent;
  14189. private _scalingDeterminant;
  14190. private _worldTransform;
  14191. private _localScaling;
  14192. private _localRotation;
  14193. private _localPosition;
  14194. private _needToDecompose;
  14195. private _needToCompose;
  14196. /** @hidden */
  14197. _linkedTransformNode: Nullable<TransformNode>;
  14198. /** @hidden */
  14199. _waitingTransformNodeId: Nullable<string>;
  14200. /** @hidden */
  14201. get _matrix(): Matrix;
  14202. /** @hidden */
  14203. set _matrix(value: Matrix);
  14204. /**
  14205. * Create a new bone
  14206. * @param name defines the bone name
  14207. * @param skeleton defines the parent skeleton
  14208. * @param parentBone defines the parent (can be null if the bone is the root)
  14209. * @param localMatrix defines the local matrix
  14210. * @param restPose defines the rest pose matrix
  14211. * @param baseMatrix defines the base matrix
  14212. * @param index defines index of the bone in the hiearchy
  14213. */
  14214. constructor(
  14215. /**
  14216. * defines the bone name
  14217. */
  14218. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14219. /**
  14220. * Gets the current object class name.
  14221. * @return the class name
  14222. */
  14223. getClassName(): string;
  14224. /**
  14225. * Gets the parent skeleton
  14226. * @returns a skeleton
  14227. */
  14228. getSkeleton(): Skeleton;
  14229. /**
  14230. * Gets parent bone
  14231. * @returns a bone or null if the bone is the root of the bone hierarchy
  14232. */
  14233. getParent(): Nullable<Bone>;
  14234. /**
  14235. * Returns an array containing the root bones
  14236. * @returns an array containing the root bones
  14237. */
  14238. getChildren(): Array<Bone>;
  14239. /**
  14240. * Gets the node index in matrix array generated for rendering
  14241. * @returns the node index
  14242. */
  14243. getIndex(): number;
  14244. /**
  14245. * Sets the parent bone
  14246. * @param parent defines the parent (can be null if the bone is the root)
  14247. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14248. */
  14249. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14250. /**
  14251. * Gets the local matrix
  14252. * @returns a matrix
  14253. */
  14254. getLocalMatrix(): Matrix;
  14255. /**
  14256. * Gets the base matrix (initial matrix which remains unchanged)
  14257. * @returns a matrix
  14258. */
  14259. getBaseMatrix(): Matrix;
  14260. /**
  14261. * Gets the rest pose matrix
  14262. * @returns a matrix
  14263. */
  14264. getRestPose(): Matrix;
  14265. /**
  14266. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14267. */
  14268. getWorldMatrix(): Matrix;
  14269. /**
  14270. * Sets the local matrix to rest pose matrix
  14271. */
  14272. returnToRest(): void;
  14273. /**
  14274. * Gets the inverse of the absolute transform matrix.
  14275. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14276. * @returns a matrix
  14277. */
  14278. getInvertedAbsoluteTransform(): Matrix;
  14279. /**
  14280. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14281. * @returns a matrix
  14282. */
  14283. getAbsoluteTransform(): Matrix;
  14284. /**
  14285. * Links with the given transform node.
  14286. * The local matrix of this bone is copied from the transform node every frame.
  14287. * @param transformNode defines the transform node to link to
  14288. */
  14289. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14290. /**
  14291. * Gets the node used to drive the bone's transformation
  14292. * @returns a transform node or null
  14293. */
  14294. getTransformNode(): Nullable<TransformNode>;
  14295. /** Gets or sets current position (in local space) */
  14296. get position(): Vector3;
  14297. set position(newPosition: Vector3);
  14298. /** Gets or sets current rotation (in local space) */
  14299. get rotation(): Vector3;
  14300. set rotation(newRotation: Vector3);
  14301. /** Gets or sets current rotation quaternion (in local space) */
  14302. get rotationQuaternion(): Quaternion;
  14303. set rotationQuaternion(newRotation: Quaternion);
  14304. /** Gets or sets current scaling (in local space) */
  14305. get scaling(): Vector3;
  14306. set scaling(newScaling: Vector3);
  14307. /**
  14308. * Gets the animation properties override
  14309. */
  14310. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14311. private _decompose;
  14312. private _compose;
  14313. /**
  14314. * Update the base and local matrices
  14315. * @param matrix defines the new base or local matrix
  14316. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14317. * @param updateLocalMatrix defines if the local matrix should be updated
  14318. */
  14319. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14320. /** @hidden */
  14321. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14322. /**
  14323. * Flag the bone as dirty (Forcing it to update everything)
  14324. */
  14325. markAsDirty(): void;
  14326. /** @hidden */
  14327. _markAsDirtyAndCompose(): void;
  14328. private _markAsDirtyAndDecompose;
  14329. /**
  14330. * Translate the bone in local or world space
  14331. * @param vec The amount to translate the bone
  14332. * @param space The space that the translation is in
  14333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14334. */
  14335. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14336. /**
  14337. * Set the postion of the bone in local or world space
  14338. * @param position The position to set the bone
  14339. * @param space The space that the position is in
  14340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14341. */
  14342. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14343. /**
  14344. * Set the absolute position of the bone (world space)
  14345. * @param position The position to set the bone
  14346. * @param mesh The mesh that this bone is attached to
  14347. */
  14348. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14349. /**
  14350. * Scale the bone on the x, y and z axes (in local space)
  14351. * @param x The amount to scale the bone on the x axis
  14352. * @param y The amount to scale the bone on the y axis
  14353. * @param z The amount to scale the bone on the z axis
  14354. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14355. */
  14356. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14357. /**
  14358. * Set the bone scaling in local space
  14359. * @param scale defines the scaling vector
  14360. */
  14361. setScale(scale: Vector3): void;
  14362. /**
  14363. * Gets the current scaling in local space
  14364. * @returns the current scaling vector
  14365. */
  14366. getScale(): Vector3;
  14367. /**
  14368. * Gets the current scaling in local space and stores it in a target vector
  14369. * @param result defines the target vector
  14370. */
  14371. getScaleToRef(result: Vector3): void;
  14372. /**
  14373. * Set the yaw, pitch, and roll of the bone in local or world space
  14374. * @param yaw The rotation of the bone on the y axis
  14375. * @param pitch The rotation of the bone on the x axis
  14376. * @param roll The rotation of the bone on the z axis
  14377. * @param space The space that the axes of rotation are in
  14378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14379. */
  14380. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14381. /**
  14382. * Add a rotation to the bone on an axis in local or world space
  14383. * @param axis The axis to rotate the bone on
  14384. * @param amount The amount to rotate the bone
  14385. * @param space The space that the axis is in
  14386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14387. */
  14388. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14389. /**
  14390. * Set the rotation of the bone to a particular axis angle in local or world space
  14391. * @param axis The axis to rotate the bone on
  14392. * @param angle The angle that the bone should be rotated to
  14393. * @param space The space that the axis is in
  14394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14395. */
  14396. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14397. /**
  14398. * Set the euler rotation of the bone in local of world space
  14399. * @param rotation The euler rotation that the bone should be set to
  14400. * @param space The space that the rotation is in
  14401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14402. */
  14403. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14404. /**
  14405. * Set the quaternion rotation of the bone in local of world space
  14406. * @param quat The quaternion rotation that the bone should be set to
  14407. * @param space The space that the rotation is in
  14408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14409. */
  14410. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14411. /**
  14412. * Set the rotation matrix of the bone in local of world space
  14413. * @param rotMat The rotation matrix that the bone should be set to
  14414. * @param space The space that the rotation is in
  14415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14416. */
  14417. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14418. private _rotateWithMatrix;
  14419. private _getNegativeRotationToRef;
  14420. /**
  14421. * Get the position of the bone in local or world space
  14422. * @param space The space that the returned position is in
  14423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14424. * @returns The position of the bone
  14425. */
  14426. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14427. /**
  14428. * Copy the position of the bone to a vector3 in local or world space
  14429. * @param space The space that the returned position is in
  14430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14431. * @param result The vector3 to copy the position to
  14432. */
  14433. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14434. /**
  14435. * Get the absolute position of the bone (world space)
  14436. * @param mesh The mesh that this bone is attached to
  14437. * @returns The absolute position of the bone
  14438. */
  14439. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14440. /**
  14441. * Copy the absolute position of the bone (world space) to the result param
  14442. * @param mesh The mesh that this bone is attached to
  14443. * @param result The vector3 to copy the absolute position to
  14444. */
  14445. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14446. /**
  14447. * Compute the absolute transforms of this bone and its children
  14448. */
  14449. computeAbsoluteTransforms(): void;
  14450. /**
  14451. * Get the world direction from an axis that is in the local space of the bone
  14452. * @param localAxis The local direction that is used to compute the world direction
  14453. * @param mesh The mesh that this bone is attached to
  14454. * @returns The world direction
  14455. */
  14456. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14457. /**
  14458. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14459. * @param localAxis The local direction that is used to compute the world direction
  14460. * @param mesh The mesh that this bone is attached to
  14461. * @param result The vector3 that the world direction will be copied to
  14462. */
  14463. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14464. /**
  14465. * Get the euler rotation of the bone in local or world space
  14466. * @param space The space that the rotation should be in
  14467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14468. * @returns The euler rotation
  14469. */
  14470. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14471. /**
  14472. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14473. * @param space The space that the rotation should be in
  14474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14475. * @param result The vector3 that the rotation should be copied to
  14476. */
  14477. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14478. /**
  14479. * Get the quaternion rotation of the bone in either local or world space
  14480. * @param space The space that the rotation should be in
  14481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14482. * @returns The quaternion rotation
  14483. */
  14484. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14485. /**
  14486. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14487. * @param space The space that the rotation should be in
  14488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14489. * @param result The quaternion that the rotation should be copied to
  14490. */
  14491. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14492. /**
  14493. * Get the rotation matrix of the bone in local or world space
  14494. * @param space The space that the rotation should be in
  14495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14496. * @returns The rotation matrix
  14497. */
  14498. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14499. /**
  14500. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14501. * @param space The space that the rotation should be in
  14502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14503. * @param result The quaternion that the rotation should be copied to
  14504. */
  14505. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14506. /**
  14507. * Get the world position of a point that is in the local space of the bone
  14508. * @param position The local position
  14509. * @param mesh The mesh that this bone is attached to
  14510. * @returns The world position
  14511. */
  14512. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14513. /**
  14514. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14515. * @param position The local position
  14516. * @param mesh The mesh that this bone is attached to
  14517. * @param result The vector3 that the world position should be copied to
  14518. */
  14519. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14520. /**
  14521. * Get the local position of a point that is in world space
  14522. * @param position The world position
  14523. * @param mesh The mesh that this bone is attached to
  14524. * @returns The local position
  14525. */
  14526. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14527. /**
  14528. * Get the local position of a point that is in world space and copy it to the result param
  14529. * @param position The world position
  14530. * @param mesh The mesh that this bone is attached to
  14531. * @param result The vector3 that the local position should be copied to
  14532. */
  14533. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14534. }
  14535. }
  14536. declare module BABYLON {
  14537. /**
  14538. * Defines a runtime animation
  14539. */
  14540. export class RuntimeAnimation {
  14541. private _events;
  14542. /**
  14543. * The current frame of the runtime animation
  14544. */
  14545. private _currentFrame;
  14546. /**
  14547. * The animation used by the runtime animation
  14548. */
  14549. private _animation;
  14550. /**
  14551. * The target of the runtime animation
  14552. */
  14553. private _target;
  14554. /**
  14555. * The initiating animatable
  14556. */
  14557. private _host;
  14558. /**
  14559. * The original value of the runtime animation
  14560. */
  14561. private _originalValue;
  14562. /**
  14563. * The original blend value of the runtime animation
  14564. */
  14565. private _originalBlendValue;
  14566. /**
  14567. * The offsets cache of the runtime animation
  14568. */
  14569. private _offsetsCache;
  14570. /**
  14571. * The high limits cache of the runtime animation
  14572. */
  14573. private _highLimitsCache;
  14574. /**
  14575. * Specifies if the runtime animation has been stopped
  14576. */
  14577. private _stopped;
  14578. /**
  14579. * The blending factor of the runtime animation
  14580. */
  14581. private _blendingFactor;
  14582. /**
  14583. * The BabylonJS scene
  14584. */
  14585. private _scene;
  14586. /**
  14587. * The current value of the runtime animation
  14588. */
  14589. private _currentValue;
  14590. /** @hidden */
  14591. _animationState: _IAnimationState;
  14592. /**
  14593. * The active target of the runtime animation
  14594. */
  14595. private _activeTargets;
  14596. private _currentActiveTarget;
  14597. private _directTarget;
  14598. /**
  14599. * The target path of the runtime animation
  14600. */
  14601. private _targetPath;
  14602. /**
  14603. * The weight of the runtime animation
  14604. */
  14605. private _weight;
  14606. /**
  14607. * The ratio offset of the runtime animation
  14608. */
  14609. private _ratioOffset;
  14610. /**
  14611. * The previous delay of the runtime animation
  14612. */
  14613. private _previousDelay;
  14614. /**
  14615. * The previous ratio of the runtime animation
  14616. */
  14617. private _previousRatio;
  14618. private _enableBlending;
  14619. private _keys;
  14620. private _minFrame;
  14621. private _maxFrame;
  14622. private _minValue;
  14623. private _maxValue;
  14624. private _targetIsArray;
  14625. /**
  14626. * Gets the current frame of the runtime animation
  14627. */
  14628. get currentFrame(): number;
  14629. /**
  14630. * Gets the weight of the runtime animation
  14631. */
  14632. get weight(): number;
  14633. /**
  14634. * Gets the current value of the runtime animation
  14635. */
  14636. get currentValue(): any;
  14637. /**
  14638. * Gets the target path of the runtime animation
  14639. */
  14640. get targetPath(): string;
  14641. /**
  14642. * Gets the actual target of the runtime animation
  14643. */
  14644. get target(): any;
  14645. /**
  14646. * Gets the additive state of the runtime animation
  14647. */
  14648. get isAdditive(): boolean;
  14649. /** @hidden */
  14650. _onLoop: () => void;
  14651. /**
  14652. * Create a new RuntimeAnimation object
  14653. * @param target defines the target of the animation
  14654. * @param animation defines the source animation object
  14655. * @param scene defines the hosting scene
  14656. * @param host defines the initiating Animatable
  14657. */
  14658. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14659. private _preparePath;
  14660. /**
  14661. * Gets the animation from the runtime animation
  14662. */
  14663. get animation(): Animation;
  14664. /**
  14665. * Resets the runtime animation to the beginning
  14666. * @param restoreOriginal defines whether to restore the target property to the original value
  14667. */
  14668. reset(restoreOriginal?: boolean): void;
  14669. /**
  14670. * Specifies if the runtime animation is stopped
  14671. * @returns Boolean specifying if the runtime animation is stopped
  14672. */
  14673. isStopped(): boolean;
  14674. /**
  14675. * Disposes of the runtime animation
  14676. */
  14677. dispose(): void;
  14678. /**
  14679. * Apply the interpolated value to the target
  14680. * @param currentValue defines the value computed by the animation
  14681. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14682. */
  14683. setValue(currentValue: any, weight: number): void;
  14684. private _getOriginalValues;
  14685. private _setValue;
  14686. /**
  14687. * Gets the loop pmode of the runtime animation
  14688. * @returns Loop Mode
  14689. */
  14690. private _getCorrectLoopMode;
  14691. /**
  14692. * Move the current animation to a given frame
  14693. * @param frame defines the frame to move to
  14694. */
  14695. goToFrame(frame: number): void;
  14696. /**
  14697. * @hidden Internal use only
  14698. */
  14699. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14700. /**
  14701. * Execute the current animation
  14702. * @param delay defines the delay to add to the current frame
  14703. * @param from defines the lower bound of the animation range
  14704. * @param to defines the upper bound of the animation range
  14705. * @param loop defines if the current animation must loop
  14706. * @param speedRatio defines the current speed ratio
  14707. * @param weight defines the weight of the animation (default is -1 so no weight)
  14708. * @param onLoop optional callback called when animation loops
  14709. * @returns a boolean indicating if the animation is running
  14710. */
  14711. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14712. }
  14713. }
  14714. declare module BABYLON {
  14715. /**
  14716. * Class used to store an actual running animation
  14717. */
  14718. export class Animatable {
  14719. /** defines the target object */
  14720. target: any;
  14721. /** defines the starting frame number (default is 0) */
  14722. fromFrame: number;
  14723. /** defines the ending frame number (default is 100) */
  14724. toFrame: number;
  14725. /** defines if the animation must loop (default is false) */
  14726. loopAnimation: boolean;
  14727. /** defines a callback to call when animation ends if it is not looping */
  14728. onAnimationEnd?: (() => void) | null | undefined;
  14729. /** defines a callback to call when animation loops */
  14730. onAnimationLoop?: (() => void) | null | undefined;
  14731. /** defines whether the animation should be evaluated additively */
  14732. isAdditive: boolean;
  14733. private _localDelayOffset;
  14734. private _pausedDelay;
  14735. private _runtimeAnimations;
  14736. private _paused;
  14737. private _scene;
  14738. private _speedRatio;
  14739. private _weight;
  14740. private _syncRoot;
  14741. /**
  14742. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14743. * This will only apply for non looping animation (default is true)
  14744. */
  14745. disposeOnEnd: boolean;
  14746. /**
  14747. * Gets a boolean indicating if the animation has started
  14748. */
  14749. animationStarted: boolean;
  14750. /**
  14751. * Observer raised when the animation ends
  14752. */
  14753. onAnimationEndObservable: Observable<Animatable>;
  14754. /**
  14755. * Observer raised when the animation loops
  14756. */
  14757. onAnimationLoopObservable: Observable<Animatable>;
  14758. /**
  14759. * Gets the root Animatable used to synchronize and normalize animations
  14760. */
  14761. get syncRoot(): Nullable<Animatable>;
  14762. /**
  14763. * Gets the current frame of the first RuntimeAnimation
  14764. * Used to synchronize Animatables
  14765. */
  14766. get masterFrame(): number;
  14767. /**
  14768. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14769. */
  14770. get weight(): number;
  14771. set weight(value: number);
  14772. /**
  14773. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14774. */
  14775. get speedRatio(): number;
  14776. set speedRatio(value: number);
  14777. /**
  14778. * Creates a new Animatable
  14779. * @param scene defines the hosting scene
  14780. * @param target defines the target object
  14781. * @param fromFrame defines the starting frame number (default is 0)
  14782. * @param toFrame defines the ending frame number (default is 100)
  14783. * @param loopAnimation defines if the animation must loop (default is false)
  14784. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14785. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14786. * @param animations defines a group of animation to add to the new Animatable
  14787. * @param onAnimationLoop defines a callback to call when animation loops
  14788. * @param isAdditive defines whether the animation should be evaluated additively
  14789. */
  14790. constructor(scene: Scene,
  14791. /** defines the target object */
  14792. target: any,
  14793. /** defines the starting frame number (default is 0) */
  14794. fromFrame?: number,
  14795. /** defines the ending frame number (default is 100) */
  14796. toFrame?: number,
  14797. /** defines if the animation must loop (default is false) */
  14798. loopAnimation?: boolean, speedRatio?: number,
  14799. /** defines a callback to call when animation ends if it is not looping */
  14800. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14801. /** defines a callback to call when animation loops */
  14802. onAnimationLoop?: (() => void) | null | undefined,
  14803. /** defines whether the animation should be evaluated additively */
  14804. isAdditive?: boolean);
  14805. /**
  14806. * Synchronize and normalize current Animatable with a source Animatable
  14807. * This is useful when using animation weights and when animations are not of the same length
  14808. * @param root defines the root Animatable to synchronize with
  14809. * @returns the current Animatable
  14810. */
  14811. syncWith(root: Animatable): Animatable;
  14812. /**
  14813. * Gets the list of runtime animations
  14814. * @returns an array of RuntimeAnimation
  14815. */
  14816. getAnimations(): RuntimeAnimation[];
  14817. /**
  14818. * Adds more animations to the current animatable
  14819. * @param target defines the target of the animations
  14820. * @param animations defines the new animations to add
  14821. */
  14822. appendAnimations(target: any, animations: Animation[]): void;
  14823. /**
  14824. * Gets the source animation for a specific property
  14825. * @param property defines the propertyu to look for
  14826. * @returns null or the source animation for the given property
  14827. */
  14828. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14829. /**
  14830. * Gets the runtime animation for a specific property
  14831. * @param property defines the propertyu to look for
  14832. * @returns null or the runtime animation for the given property
  14833. */
  14834. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14835. /**
  14836. * Resets the animatable to its original state
  14837. */
  14838. reset(): void;
  14839. /**
  14840. * Allows the animatable to blend with current running animations
  14841. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14842. * @param blendingSpeed defines the blending speed to use
  14843. */
  14844. enableBlending(blendingSpeed: number): void;
  14845. /**
  14846. * Disable animation blending
  14847. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14848. */
  14849. disableBlending(): void;
  14850. /**
  14851. * Jump directly to a given frame
  14852. * @param frame defines the frame to jump to
  14853. */
  14854. goToFrame(frame: number): void;
  14855. /**
  14856. * Pause the animation
  14857. */
  14858. pause(): void;
  14859. /**
  14860. * Restart the animation
  14861. */
  14862. restart(): void;
  14863. private _raiseOnAnimationEnd;
  14864. /**
  14865. * Stop and delete the current animation
  14866. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14867. * @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)
  14868. */
  14869. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14870. /**
  14871. * Wait asynchronously for the animation to end
  14872. * @returns a promise which will be fullfilled when the animation ends
  14873. */
  14874. waitAsync(): Promise<Animatable>;
  14875. /** @hidden */
  14876. _animate(delay: number): boolean;
  14877. }
  14878. interface Scene {
  14879. /** @hidden */
  14880. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14881. /** @hidden */
  14882. _processLateAnimationBindingsForMatrices(holder: {
  14883. totalWeight: number;
  14884. totalAdditiveWeight: number;
  14885. animations: RuntimeAnimation[];
  14886. additiveAnimations: RuntimeAnimation[];
  14887. originalValue: Matrix;
  14888. }): any;
  14889. /** @hidden */
  14890. _processLateAnimationBindingsForQuaternions(holder: {
  14891. totalWeight: number;
  14892. totalAdditiveWeight: number;
  14893. animations: RuntimeAnimation[];
  14894. additiveAnimations: RuntimeAnimation[];
  14895. originalValue: Quaternion;
  14896. }, refQuaternion: Quaternion): Quaternion;
  14897. /** @hidden */
  14898. _processLateAnimationBindings(): void;
  14899. /**
  14900. * Will start the animation sequence of a given target
  14901. * @param target defines the target
  14902. * @param from defines from which frame should animation start
  14903. * @param to defines until which frame should animation run.
  14904. * @param weight defines the weight to apply to the animation (1.0 by default)
  14905. * @param loop defines if the animation loops
  14906. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14907. * @param onAnimationEnd defines the function to be executed when the animation ends
  14908. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14909. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14910. * @param onAnimationLoop defines the callback to call when an animation loops
  14911. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14912. * @returns the animatable object created for this animation
  14913. */
  14914. 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;
  14915. /**
  14916. * Will start the animation sequence of a given target
  14917. * @param target defines the target
  14918. * @param from defines from which frame should animation start
  14919. * @param to defines until which frame should animation run.
  14920. * @param loop defines if the animation loops
  14921. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14922. * @param onAnimationEnd defines the function to be executed when the animation ends
  14923. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14924. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14925. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14926. * @param onAnimationLoop defines the callback to call when an animation loops
  14927. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14928. * @returns the animatable object created for this animation
  14929. */
  14930. 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;
  14931. /**
  14932. * Will start the animation sequence of a given target and its hierarchy
  14933. * @param target defines the target
  14934. * @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.
  14935. * @param from defines from which frame should animation start
  14936. * @param to defines until which frame should animation run.
  14937. * @param loop defines if the animation loops
  14938. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14939. * @param onAnimationEnd defines the function to be executed when the animation ends
  14940. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14941. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14942. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14943. * @param onAnimationLoop defines the callback to call when an animation loops
  14944. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14945. * @returns the list of created animatables
  14946. */
  14947. 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[];
  14948. /**
  14949. * Begin a new animation on a given node
  14950. * @param target defines the target where the animation will take place
  14951. * @param animations defines the list of animations to start
  14952. * @param from defines the initial value
  14953. * @param to defines the final value
  14954. * @param loop defines if you want animation to loop (off by default)
  14955. * @param speedRatio defines the speed ratio to apply to all animations
  14956. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14957. * @param onAnimationLoop defines the callback to call when an animation loops
  14958. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14959. * @returns the list of created animatables
  14960. */
  14961. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14962. /**
  14963. * Begin a new animation on a given node and its hierarchy
  14964. * @param target defines the root node where the animation will take place
  14965. * @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.
  14966. * @param animations defines the list of animations to start
  14967. * @param from defines the initial value
  14968. * @param to defines the final value
  14969. * @param loop defines if you want animation to loop (off by default)
  14970. * @param speedRatio defines the speed ratio to apply to all animations
  14971. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14972. * @param onAnimationLoop defines the callback to call when an animation loops
  14973. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14974. * @returns the list of animatables created for all nodes
  14975. */
  14976. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14977. /**
  14978. * Gets the animatable associated with a specific target
  14979. * @param target defines the target of the animatable
  14980. * @returns the required animatable if found
  14981. */
  14982. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14983. /**
  14984. * Gets all animatables associated with a given target
  14985. * @param target defines the target to look animatables for
  14986. * @returns an array of Animatables
  14987. */
  14988. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14989. /**
  14990. * Stops and removes all animations that have been applied to the scene
  14991. */
  14992. stopAllAnimations(): void;
  14993. /**
  14994. * Gets the current delta time used by animation engine
  14995. */
  14996. deltaTime: number;
  14997. }
  14998. interface Bone {
  14999. /**
  15000. * Copy an animation range from another bone
  15001. * @param source defines the source bone
  15002. * @param rangeName defines the range name to copy
  15003. * @param frameOffset defines the frame offset
  15004. * @param rescaleAsRequired defines if rescaling must be applied if required
  15005. * @param skelDimensionsRatio defines the scaling ratio
  15006. * @returns true if operation was successful
  15007. */
  15008. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15009. }
  15010. }
  15011. declare module BABYLON {
  15012. /**
  15013. * Class used to handle skinning animations
  15014. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15015. */
  15016. export class Skeleton implements IAnimatable {
  15017. /** defines the skeleton name */
  15018. name: string;
  15019. /** defines the skeleton Id */
  15020. id: string;
  15021. /**
  15022. * Defines the list of child bones
  15023. */
  15024. bones: Bone[];
  15025. /**
  15026. * Defines an estimate of the dimension of the skeleton at rest
  15027. */
  15028. dimensionsAtRest: Vector3;
  15029. /**
  15030. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15031. */
  15032. needInitialSkinMatrix: boolean;
  15033. /**
  15034. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15035. */
  15036. overrideMesh: Nullable<AbstractMesh>;
  15037. /**
  15038. * Gets the list of animations attached to this skeleton
  15039. */
  15040. animations: Array<Animation>;
  15041. private _scene;
  15042. private _isDirty;
  15043. private _transformMatrices;
  15044. private _transformMatrixTexture;
  15045. private _meshesWithPoseMatrix;
  15046. private _animatables;
  15047. private _identity;
  15048. private _synchronizedWithMesh;
  15049. private _ranges;
  15050. private _lastAbsoluteTransformsUpdateId;
  15051. private _canUseTextureForBones;
  15052. private _uniqueId;
  15053. /** @hidden */
  15054. _numBonesWithLinkedTransformNode: number;
  15055. /** @hidden */
  15056. _hasWaitingData: Nullable<boolean>;
  15057. /**
  15058. * Specifies if the skeleton should be serialized
  15059. */
  15060. doNotSerialize: boolean;
  15061. private _useTextureToStoreBoneMatrices;
  15062. /**
  15063. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15064. * Please note that this option is not available if the hardware does not support it
  15065. */
  15066. get useTextureToStoreBoneMatrices(): boolean;
  15067. set useTextureToStoreBoneMatrices(value: boolean);
  15068. private _animationPropertiesOverride;
  15069. /**
  15070. * Gets or sets the animation properties override
  15071. */
  15072. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15073. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15074. /**
  15075. * List of inspectable custom properties (used by the Inspector)
  15076. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15077. */
  15078. inspectableCustomProperties: IInspectable[];
  15079. /**
  15080. * An observable triggered before computing the skeleton's matrices
  15081. */
  15082. onBeforeComputeObservable: Observable<Skeleton>;
  15083. /**
  15084. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15085. */
  15086. get isUsingTextureForMatrices(): boolean;
  15087. /**
  15088. * Gets the unique ID of this skeleton
  15089. */
  15090. get uniqueId(): number;
  15091. /**
  15092. * Creates a new skeleton
  15093. * @param name defines the skeleton name
  15094. * @param id defines the skeleton Id
  15095. * @param scene defines the hosting scene
  15096. */
  15097. constructor(
  15098. /** defines the skeleton name */
  15099. name: string,
  15100. /** defines the skeleton Id */
  15101. id: string, scene: Scene);
  15102. /**
  15103. * Gets the current object class name.
  15104. * @return the class name
  15105. */
  15106. getClassName(): string;
  15107. /**
  15108. * Returns an array containing the root bones
  15109. * @returns an array containing the root bones
  15110. */
  15111. getChildren(): Array<Bone>;
  15112. /**
  15113. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15114. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15115. * @returns a Float32Array containing matrices data
  15116. */
  15117. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15118. /**
  15119. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15120. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15121. * @returns a raw texture containing the data
  15122. */
  15123. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15124. /**
  15125. * Gets the current hosting scene
  15126. * @returns a scene object
  15127. */
  15128. getScene(): Scene;
  15129. /**
  15130. * Gets a string representing the current skeleton data
  15131. * @param fullDetails defines a boolean indicating if we want a verbose version
  15132. * @returns a string representing the current skeleton data
  15133. */
  15134. toString(fullDetails?: boolean): string;
  15135. /**
  15136. * Get bone's index searching by name
  15137. * @param name defines bone's name to search for
  15138. * @return the indice of the bone. Returns -1 if not found
  15139. */
  15140. getBoneIndexByName(name: string): number;
  15141. /**
  15142. * Creater a new animation range
  15143. * @param name defines the name of the range
  15144. * @param from defines the start key
  15145. * @param to defines the end key
  15146. */
  15147. createAnimationRange(name: string, from: number, to: number): void;
  15148. /**
  15149. * Delete a specific animation range
  15150. * @param name defines the name of the range
  15151. * @param deleteFrames defines if frames must be removed as well
  15152. */
  15153. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15154. /**
  15155. * Gets a specific animation range
  15156. * @param name defines the name of the range to look for
  15157. * @returns the requested animation range or null if not found
  15158. */
  15159. getAnimationRange(name: string): Nullable<AnimationRange>;
  15160. /**
  15161. * Gets the list of all animation ranges defined on this skeleton
  15162. * @returns an array
  15163. */
  15164. getAnimationRanges(): Nullable<AnimationRange>[];
  15165. /**
  15166. * Copy animation range from a source skeleton.
  15167. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15168. * @param source defines the source skeleton
  15169. * @param name defines the name of the range to copy
  15170. * @param rescaleAsRequired defines if rescaling must be applied if required
  15171. * @returns true if operation was successful
  15172. */
  15173. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15174. /**
  15175. * Forces the skeleton to go to rest pose
  15176. */
  15177. returnToRest(): void;
  15178. private _getHighestAnimationFrame;
  15179. /**
  15180. * Begin a specific animation range
  15181. * @param name defines the name of the range to start
  15182. * @param loop defines if looping must be turned on (false by default)
  15183. * @param speedRatio defines the speed ratio to apply (1 by default)
  15184. * @param onAnimationEnd defines a callback which will be called when animation will end
  15185. * @returns a new animatable
  15186. */
  15187. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15188. /**
  15189. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15190. * @param skeleton defines the Skeleton containing the animation range to convert
  15191. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15192. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15193. * @returns the original skeleton
  15194. */
  15195. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15196. /** @hidden */
  15197. _markAsDirty(): void;
  15198. /** @hidden */
  15199. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15200. /** @hidden */
  15201. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15202. private _computeTransformMatrices;
  15203. /**
  15204. * Build all resources required to render a skeleton
  15205. */
  15206. prepare(): void;
  15207. /**
  15208. * Gets the list of animatables currently running for this skeleton
  15209. * @returns an array of animatables
  15210. */
  15211. getAnimatables(): IAnimatable[];
  15212. /**
  15213. * Clone the current skeleton
  15214. * @param name defines the name of the new skeleton
  15215. * @param id defines the id of the new skeleton
  15216. * @returns the new skeleton
  15217. */
  15218. clone(name: string, id?: string): Skeleton;
  15219. /**
  15220. * Enable animation blending for this skeleton
  15221. * @param blendingSpeed defines the blending speed to apply
  15222. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15223. */
  15224. enableBlending(blendingSpeed?: number): void;
  15225. /**
  15226. * Releases all resources associated with the current skeleton
  15227. */
  15228. dispose(): void;
  15229. /**
  15230. * Serialize the skeleton in a JSON object
  15231. * @returns a JSON object
  15232. */
  15233. serialize(): any;
  15234. /**
  15235. * Creates a new skeleton from serialized data
  15236. * @param parsedSkeleton defines the serialized data
  15237. * @param scene defines the hosting scene
  15238. * @returns a new skeleton
  15239. */
  15240. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15241. /**
  15242. * Compute all node absolute transforms
  15243. * @param forceUpdate defines if computation must be done even if cache is up to date
  15244. */
  15245. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15246. /**
  15247. * Gets the root pose matrix
  15248. * @returns a matrix
  15249. */
  15250. getPoseMatrix(): Nullable<Matrix>;
  15251. /**
  15252. * Sorts bones per internal index
  15253. */
  15254. sortBones(): void;
  15255. private _sortBones;
  15256. }
  15257. }
  15258. declare module BABYLON {
  15259. /**
  15260. * Creates an instance based on a source mesh.
  15261. */
  15262. export class InstancedMesh extends AbstractMesh {
  15263. private _sourceMesh;
  15264. private _currentLOD;
  15265. /** @hidden */
  15266. _indexInSourceMeshInstanceArray: number;
  15267. constructor(name: string, source: Mesh);
  15268. /**
  15269. * Returns the string "InstancedMesh".
  15270. */
  15271. getClassName(): string;
  15272. /** Gets the list of lights affecting that mesh */
  15273. get lightSources(): Light[];
  15274. _resyncLightSources(): void;
  15275. _resyncLightSource(light: Light): void;
  15276. _removeLightSource(light: Light, dispose: boolean): void;
  15277. /**
  15278. * If the source mesh receives shadows
  15279. */
  15280. get receiveShadows(): boolean;
  15281. /**
  15282. * The material of the source mesh
  15283. */
  15284. get material(): Nullable<Material>;
  15285. /**
  15286. * Visibility of the source mesh
  15287. */
  15288. get visibility(): number;
  15289. /**
  15290. * Skeleton of the source mesh
  15291. */
  15292. get skeleton(): Nullable<Skeleton>;
  15293. /**
  15294. * Rendering ground id of the source mesh
  15295. */
  15296. get renderingGroupId(): number;
  15297. set renderingGroupId(value: number);
  15298. /**
  15299. * Returns the total number of vertices (integer).
  15300. */
  15301. getTotalVertices(): number;
  15302. /**
  15303. * Returns a positive integer : the total number of indices in this mesh geometry.
  15304. * @returns the numner of indices or zero if the mesh has no geometry.
  15305. */
  15306. getTotalIndices(): number;
  15307. /**
  15308. * The source mesh of the instance
  15309. */
  15310. get sourceMesh(): Mesh;
  15311. /**
  15312. * Is this node ready to be used/rendered
  15313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15314. * @return {boolean} is it ready
  15315. */
  15316. isReady(completeCheck?: boolean): boolean;
  15317. /**
  15318. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15319. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15320. * @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.
  15321. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15322. */
  15323. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15324. /**
  15325. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15326. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15327. * The `data` are either a numeric array either a Float32Array.
  15328. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15329. * 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).
  15330. * Note that a new underlying VertexBuffer object is created each call.
  15331. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15332. *
  15333. * Possible `kind` values :
  15334. * - VertexBuffer.PositionKind
  15335. * - VertexBuffer.UVKind
  15336. * - VertexBuffer.UV2Kind
  15337. * - VertexBuffer.UV3Kind
  15338. * - VertexBuffer.UV4Kind
  15339. * - VertexBuffer.UV5Kind
  15340. * - VertexBuffer.UV6Kind
  15341. * - VertexBuffer.ColorKind
  15342. * - VertexBuffer.MatricesIndicesKind
  15343. * - VertexBuffer.MatricesIndicesExtraKind
  15344. * - VertexBuffer.MatricesWeightsKind
  15345. * - VertexBuffer.MatricesWeightsExtraKind
  15346. *
  15347. * Returns the Mesh.
  15348. */
  15349. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15350. /**
  15351. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15352. * If the mesh has no geometry, it is simply returned as it is.
  15353. * The `data` are either a numeric array either a Float32Array.
  15354. * No new underlying VertexBuffer object is created.
  15355. * 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.
  15356. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15357. *
  15358. * Possible `kind` values :
  15359. * - VertexBuffer.PositionKind
  15360. * - VertexBuffer.UVKind
  15361. * - VertexBuffer.UV2Kind
  15362. * - VertexBuffer.UV3Kind
  15363. * - VertexBuffer.UV4Kind
  15364. * - VertexBuffer.UV5Kind
  15365. * - VertexBuffer.UV6Kind
  15366. * - VertexBuffer.ColorKind
  15367. * - VertexBuffer.MatricesIndicesKind
  15368. * - VertexBuffer.MatricesIndicesExtraKind
  15369. * - VertexBuffer.MatricesWeightsKind
  15370. * - VertexBuffer.MatricesWeightsExtraKind
  15371. *
  15372. * Returns the Mesh.
  15373. */
  15374. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15375. /**
  15376. * Sets the mesh indices.
  15377. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15378. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15379. * This method creates a new index buffer each call.
  15380. * Returns the Mesh.
  15381. */
  15382. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15383. /**
  15384. * Boolean : True if the mesh owns the requested kind of data.
  15385. */
  15386. isVerticesDataPresent(kind: string): boolean;
  15387. /**
  15388. * Returns an array of indices (IndicesArray).
  15389. */
  15390. getIndices(): Nullable<IndicesArray>;
  15391. get _positions(): Nullable<Vector3[]>;
  15392. /**
  15393. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15394. * This means the mesh underlying bounding box and sphere are recomputed.
  15395. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15396. * @returns the current mesh
  15397. */
  15398. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15399. /** @hidden */
  15400. _preActivate(): InstancedMesh;
  15401. /** @hidden */
  15402. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15403. /** @hidden */
  15404. _postActivate(): void;
  15405. getWorldMatrix(): Matrix;
  15406. get isAnInstance(): boolean;
  15407. /**
  15408. * Returns the current associated LOD AbstractMesh.
  15409. */
  15410. getLOD(camera: Camera): AbstractMesh;
  15411. /** @hidden */
  15412. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15413. /** @hidden */
  15414. _syncSubMeshes(): InstancedMesh;
  15415. /** @hidden */
  15416. _generatePointsArray(): boolean;
  15417. /**
  15418. * Creates a new InstancedMesh from the current mesh.
  15419. * - name (string) : the cloned mesh name
  15420. * - newParent (optional Node) : the optional Node to parent the clone to.
  15421. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15422. *
  15423. * Returns the clone.
  15424. */
  15425. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15426. /**
  15427. * Disposes the InstancedMesh.
  15428. * Returns nothing.
  15429. */
  15430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15431. }
  15432. interface Mesh {
  15433. /**
  15434. * Register a custom buffer that will be instanced
  15435. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15436. * @param kind defines the buffer kind
  15437. * @param stride defines the stride in floats
  15438. */
  15439. registerInstancedBuffer(kind: string, stride: number): void;
  15440. /** @hidden */
  15441. _userInstancedBuffersStorage: {
  15442. data: {
  15443. [key: string]: Float32Array;
  15444. };
  15445. sizes: {
  15446. [key: string]: number;
  15447. };
  15448. vertexBuffers: {
  15449. [key: string]: Nullable<VertexBuffer>;
  15450. };
  15451. strides: {
  15452. [key: string]: number;
  15453. };
  15454. };
  15455. }
  15456. interface AbstractMesh {
  15457. /**
  15458. * Object used to store instanced buffers defined by user
  15459. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15460. */
  15461. instancedBuffers: {
  15462. [key: string]: any;
  15463. };
  15464. }
  15465. }
  15466. declare module BABYLON {
  15467. /**
  15468. * Defines the options associated with the creation of a shader material.
  15469. */
  15470. export interface IShaderMaterialOptions {
  15471. /**
  15472. * Does the material work in alpha blend mode
  15473. */
  15474. needAlphaBlending: boolean;
  15475. /**
  15476. * Does the material work in alpha test mode
  15477. */
  15478. needAlphaTesting: boolean;
  15479. /**
  15480. * The list of attribute names used in the shader
  15481. */
  15482. attributes: string[];
  15483. /**
  15484. * The list of unifrom names used in the shader
  15485. */
  15486. uniforms: string[];
  15487. /**
  15488. * The list of UBO names used in the shader
  15489. */
  15490. uniformBuffers: string[];
  15491. /**
  15492. * The list of sampler names used in the shader
  15493. */
  15494. samplers: string[];
  15495. /**
  15496. * The list of defines used in the shader
  15497. */
  15498. defines: string[];
  15499. }
  15500. /**
  15501. * 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.
  15502. *
  15503. * This returned material effects how the mesh will look based on the code in the shaders.
  15504. *
  15505. * @see http://doc.babylonjs.com/how_to/shader_material
  15506. */
  15507. export class ShaderMaterial extends Material {
  15508. private _shaderPath;
  15509. private _options;
  15510. private _textures;
  15511. private _textureArrays;
  15512. private _floats;
  15513. private _ints;
  15514. private _floatsArrays;
  15515. private _colors3;
  15516. private _colors3Arrays;
  15517. private _colors4;
  15518. private _colors4Arrays;
  15519. private _vectors2;
  15520. private _vectors3;
  15521. private _vectors4;
  15522. private _matrices;
  15523. private _matrixArrays;
  15524. private _matrices3x3;
  15525. private _matrices2x2;
  15526. private _vectors2Arrays;
  15527. private _vectors3Arrays;
  15528. private _vectors4Arrays;
  15529. private _cachedWorldViewMatrix;
  15530. private _cachedWorldViewProjectionMatrix;
  15531. private _renderId;
  15532. private _multiview;
  15533. private _cachedDefines;
  15534. /**
  15535. * Instantiate a new shader material.
  15536. * 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.
  15537. * This returned material effects how the mesh will look based on the code in the shaders.
  15538. * @see http://doc.babylonjs.com/how_to/shader_material
  15539. * @param name Define the name of the material in the scene
  15540. * @param scene Define the scene the material belongs to
  15541. * @param shaderPath Defines the route to the shader code in one of three ways:
  15542. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15543. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15544. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15545. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15546. * @param options Define the options used to create the shader
  15547. */
  15548. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15549. /**
  15550. * Gets the shader path used to define the shader code
  15551. * It can be modified to trigger a new compilation
  15552. */
  15553. get shaderPath(): any;
  15554. /**
  15555. * Sets the shader path used to define the shader code
  15556. * It can be modified to trigger a new compilation
  15557. */
  15558. set shaderPath(shaderPath: any);
  15559. /**
  15560. * Gets the options used to compile the shader.
  15561. * They can be modified to trigger a new compilation
  15562. */
  15563. get options(): IShaderMaterialOptions;
  15564. /**
  15565. * Gets the current class name of the material e.g. "ShaderMaterial"
  15566. * Mainly use in serialization.
  15567. * @returns the class name
  15568. */
  15569. getClassName(): string;
  15570. /**
  15571. * Specifies if the material will require alpha blending
  15572. * @returns a boolean specifying if alpha blending is needed
  15573. */
  15574. needAlphaBlending(): boolean;
  15575. /**
  15576. * Specifies if this material should be rendered in alpha test mode
  15577. * @returns a boolean specifying if an alpha test is needed.
  15578. */
  15579. needAlphaTesting(): boolean;
  15580. private _checkUniform;
  15581. /**
  15582. * Set a texture in the shader.
  15583. * @param name Define the name of the uniform samplers as defined in the shader
  15584. * @param texture Define the texture to bind to this sampler
  15585. * @return the material itself allowing "fluent" like uniform updates
  15586. */
  15587. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15588. /**
  15589. * Set a texture array in the shader.
  15590. * @param name Define the name of the uniform sampler array as defined in the shader
  15591. * @param textures Define the list of textures to bind to this sampler
  15592. * @return the material itself allowing "fluent" like uniform updates
  15593. */
  15594. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15595. /**
  15596. * Set a float in the shader.
  15597. * @param name Define the name of the uniform as defined in the shader
  15598. * @param value Define the value to give to the uniform
  15599. * @return the material itself allowing "fluent" like uniform updates
  15600. */
  15601. setFloat(name: string, value: number): ShaderMaterial;
  15602. /**
  15603. * Set a int in the shader.
  15604. * @param name Define the name of the uniform as defined in the shader
  15605. * @param value Define the value to give to the uniform
  15606. * @return the material itself allowing "fluent" like uniform updates
  15607. */
  15608. setInt(name: string, value: number): ShaderMaterial;
  15609. /**
  15610. * Set an array of floats in the shader.
  15611. * @param name Define the name of the uniform as defined in the shader
  15612. * @param value Define the value to give to the uniform
  15613. * @return the material itself allowing "fluent" like uniform updates
  15614. */
  15615. setFloats(name: string, value: number[]): ShaderMaterial;
  15616. /**
  15617. * Set a vec3 in the shader from a Color3.
  15618. * @param name Define the name of the uniform as defined in the shader
  15619. * @param value Define the value to give to the uniform
  15620. * @return the material itself allowing "fluent" like uniform updates
  15621. */
  15622. setColor3(name: string, value: Color3): ShaderMaterial;
  15623. /**
  15624. * Set a vec3 array in the shader from a Color3 array.
  15625. * @param name Define the name of the uniform as defined in the shader
  15626. * @param value Define the value to give to the uniform
  15627. * @return the material itself allowing "fluent" like uniform updates
  15628. */
  15629. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15630. /**
  15631. * Set a vec4 in the shader from a Color4.
  15632. * @param name Define the name of the uniform as defined in the shader
  15633. * @param value Define the value to give to the uniform
  15634. * @return the material itself allowing "fluent" like uniform updates
  15635. */
  15636. setColor4(name: string, value: Color4): ShaderMaterial;
  15637. /**
  15638. * Set a vec4 array in the shader from a Color4 array.
  15639. * @param name Define the name of the uniform as defined in the shader
  15640. * @param value Define the value to give to the uniform
  15641. * @return the material itself allowing "fluent" like uniform updates
  15642. */
  15643. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15644. /**
  15645. * Set a vec2 in the shader from a Vector2.
  15646. * @param name Define the name of the uniform as defined in the shader
  15647. * @param value Define the value to give to the uniform
  15648. * @return the material itself allowing "fluent" like uniform updates
  15649. */
  15650. setVector2(name: string, value: Vector2): ShaderMaterial;
  15651. /**
  15652. * Set a vec3 in the shader from a Vector3.
  15653. * @param name Define the name of the uniform as defined in the shader
  15654. * @param value Define the value to give to the uniform
  15655. * @return the material itself allowing "fluent" like uniform updates
  15656. */
  15657. setVector3(name: string, value: Vector3): ShaderMaterial;
  15658. /**
  15659. * Set a vec4 in the shader from a Vector4.
  15660. * @param name Define the name of the uniform as defined in the shader
  15661. * @param value Define the value to give to the uniform
  15662. * @return the material itself allowing "fluent" like uniform updates
  15663. */
  15664. setVector4(name: string, value: Vector4): ShaderMaterial;
  15665. /**
  15666. * Set a mat4 in the shader from a Matrix.
  15667. * @param name Define the name of the uniform as defined in the shader
  15668. * @param value Define the value to give to the uniform
  15669. * @return the material itself allowing "fluent" like uniform updates
  15670. */
  15671. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15672. /**
  15673. * Set a float32Array in the shader from a matrix array.
  15674. * @param name Define the name of the uniform as defined in the shader
  15675. * @param value Define the value to give to the uniform
  15676. * @return the material itself allowing "fluent" like uniform updates
  15677. */
  15678. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15679. /**
  15680. * Set a mat3 in the shader from a Float32Array.
  15681. * @param name Define the name of the uniform as defined in the shader
  15682. * @param value Define the value to give to the uniform
  15683. * @return the material itself allowing "fluent" like uniform updates
  15684. */
  15685. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15686. /**
  15687. * Set a mat2 in the shader from a Float32Array.
  15688. * @param name Define the name of the uniform as defined in the shader
  15689. * @param value Define the value to give to the uniform
  15690. * @return the material itself allowing "fluent" like uniform updates
  15691. */
  15692. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15693. /**
  15694. * Set a vec2 array in the shader from a number array.
  15695. * @param name Define the name of the uniform as defined in the shader
  15696. * @param value Define the value to give to the uniform
  15697. * @return the material itself allowing "fluent" like uniform updates
  15698. */
  15699. setArray2(name: string, value: number[]): ShaderMaterial;
  15700. /**
  15701. * Set a vec3 array in the shader from a number array.
  15702. * @param name Define the name of the uniform as defined in the shader
  15703. * @param value Define the value to give to the uniform
  15704. * @return the material itself allowing "fluent" like uniform updates
  15705. */
  15706. setArray3(name: string, value: number[]): ShaderMaterial;
  15707. /**
  15708. * Set a vec4 array in the shader from a number array.
  15709. * @param name Define the name of the uniform as defined in the shader
  15710. * @param value Define the value to give to the uniform
  15711. * @return the material itself allowing "fluent" like uniform updates
  15712. */
  15713. setArray4(name: string, value: number[]): ShaderMaterial;
  15714. private _checkCache;
  15715. /**
  15716. * Specifies that the submesh is ready to be used
  15717. * @param mesh defines the mesh to check
  15718. * @param subMesh defines which submesh to check
  15719. * @param useInstances specifies that instances should be used
  15720. * @returns a boolean indicating that the submesh is ready or not
  15721. */
  15722. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15723. /**
  15724. * Checks if the material is ready to render the requested mesh
  15725. * @param mesh Define the mesh to render
  15726. * @param useInstances Define whether or not the material is used with instances
  15727. * @returns true if ready, otherwise false
  15728. */
  15729. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15730. /**
  15731. * Binds the world matrix to the material
  15732. * @param world defines the world transformation matrix
  15733. * @param effectOverride - If provided, use this effect instead of internal effect
  15734. */
  15735. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15736. /**
  15737. * Binds the submesh to this material by preparing the effect and shader to draw
  15738. * @param world defines the world transformation matrix
  15739. * @param mesh defines the mesh containing the submesh
  15740. * @param subMesh defines the submesh to bind the material to
  15741. */
  15742. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15743. /**
  15744. * Binds the material to the mesh
  15745. * @param world defines the world transformation matrix
  15746. * @param mesh defines the mesh to bind the material to
  15747. * @param effectOverride - If provided, use this effect instead of internal effect
  15748. */
  15749. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15750. protected _afterBind(mesh?: Mesh): void;
  15751. /**
  15752. * Gets the active textures from the material
  15753. * @returns an array of textures
  15754. */
  15755. getActiveTextures(): BaseTexture[];
  15756. /**
  15757. * Specifies if the material uses a texture
  15758. * @param texture defines the texture to check against the material
  15759. * @returns a boolean specifying if the material uses the texture
  15760. */
  15761. hasTexture(texture: BaseTexture): boolean;
  15762. /**
  15763. * Makes a duplicate of the material, and gives it a new name
  15764. * @param name defines the new name for the duplicated material
  15765. * @returns the cloned material
  15766. */
  15767. clone(name: string): ShaderMaterial;
  15768. /**
  15769. * Disposes the material
  15770. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15771. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15772. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15773. */
  15774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15775. /**
  15776. * Serializes this material in a JSON representation
  15777. * @returns the serialized material object
  15778. */
  15779. serialize(): any;
  15780. /**
  15781. * Creates a shader material from parsed shader material data
  15782. * @param source defines the JSON represnetation of the material
  15783. * @param scene defines the hosting scene
  15784. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15785. * @returns a new material
  15786. */
  15787. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15788. }
  15789. }
  15790. declare module BABYLON {
  15791. /** @hidden */
  15792. export var colorPixelShader: {
  15793. name: string;
  15794. shader: string;
  15795. };
  15796. }
  15797. declare module BABYLON {
  15798. /** @hidden */
  15799. export var colorVertexShader: {
  15800. name: string;
  15801. shader: string;
  15802. };
  15803. }
  15804. declare module BABYLON {
  15805. /**
  15806. * Line mesh
  15807. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15808. */
  15809. export class LinesMesh extends Mesh {
  15810. /**
  15811. * If vertex color should be applied to the mesh
  15812. */
  15813. readonly useVertexColor?: boolean | undefined;
  15814. /**
  15815. * If vertex alpha should be applied to the mesh
  15816. */
  15817. readonly useVertexAlpha?: boolean | undefined;
  15818. /**
  15819. * Color of the line (Default: White)
  15820. */
  15821. color: Color3;
  15822. /**
  15823. * Alpha of the line (Default: 1)
  15824. */
  15825. alpha: number;
  15826. /**
  15827. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15828. * This margin is expressed in world space coordinates, so its value may vary.
  15829. * Default value is 0.1
  15830. */
  15831. intersectionThreshold: number;
  15832. private _colorShader;
  15833. private color4;
  15834. /**
  15835. * Creates a new LinesMesh
  15836. * @param name defines the name
  15837. * @param scene defines the hosting scene
  15838. * @param parent defines the parent mesh if any
  15839. * @param source defines the optional source LinesMesh used to clone data from
  15840. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15841. * When false, achieved by calling a clone(), also passing False.
  15842. * This will make creation of children, recursive.
  15843. * @param useVertexColor defines if this LinesMesh supports vertex color
  15844. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15845. */
  15846. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15847. /**
  15848. * If vertex color should be applied to the mesh
  15849. */
  15850. useVertexColor?: boolean | undefined,
  15851. /**
  15852. * If vertex alpha should be applied to the mesh
  15853. */
  15854. useVertexAlpha?: boolean | undefined);
  15855. private _addClipPlaneDefine;
  15856. private _removeClipPlaneDefine;
  15857. isReady(): boolean;
  15858. /**
  15859. * Returns the string "LineMesh"
  15860. */
  15861. getClassName(): string;
  15862. /**
  15863. * @hidden
  15864. */
  15865. get material(): Material;
  15866. /**
  15867. * @hidden
  15868. */
  15869. set material(value: Material);
  15870. /**
  15871. * @hidden
  15872. */
  15873. get checkCollisions(): boolean;
  15874. /** @hidden */
  15875. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15876. /** @hidden */
  15877. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15878. /**
  15879. * Disposes of the line mesh
  15880. * @param doNotRecurse If children should be disposed
  15881. */
  15882. dispose(doNotRecurse?: boolean): void;
  15883. /**
  15884. * Returns a new LineMesh object cloned from the current one.
  15885. */
  15886. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15887. /**
  15888. * Creates a new InstancedLinesMesh object from the mesh model.
  15889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15890. * @param name defines the name of the new instance
  15891. * @returns a new InstancedLinesMesh
  15892. */
  15893. createInstance(name: string): InstancedLinesMesh;
  15894. }
  15895. /**
  15896. * Creates an instance based on a source LinesMesh
  15897. */
  15898. export class InstancedLinesMesh extends InstancedMesh {
  15899. /**
  15900. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15901. * This margin is expressed in world space coordinates, so its value may vary.
  15902. * Initilized with the intersectionThreshold value of the source LinesMesh
  15903. */
  15904. intersectionThreshold: number;
  15905. constructor(name: string, source: LinesMesh);
  15906. /**
  15907. * Returns the string "InstancedLinesMesh".
  15908. */
  15909. getClassName(): string;
  15910. }
  15911. }
  15912. declare module BABYLON {
  15913. /** @hidden */
  15914. export var linePixelShader: {
  15915. name: string;
  15916. shader: string;
  15917. };
  15918. }
  15919. declare module BABYLON {
  15920. /** @hidden */
  15921. export var lineVertexShader: {
  15922. name: string;
  15923. shader: string;
  15924. };
  15925. }
  15926. declare module BABYLON {
  15927. interface AbstractMesh {
  15928. /**
  15929. * Gets the edgesRenderer associated with the mesh
  15930. */
  15931. edgesRenderer: Nullable<EdgesRenderer>;
  15932. }
  15933. interface LinesMesh {
  15934. /**
  15935. * Enables the edge rendering mode on the mesh.
  15936. * This mode makes the mesh edges visible
  15937. * @param epsilon defines the maximal distance between two angles to detect a face
  15938. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15939. * @returns the currentAbstractMesh
  15940. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15941. */
  15942. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15943. }
  15944. interface InstancedLinesMesh {
  15945. /**
  15946. * Enables the edge rendering mode on the mesh.
  15947. * This mode makes the mesh edges visible
  15948. * @param epsilon defines the maximal distance between two angles to detect a face
  15949. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15950. * @returns the current InstancedLinesMesh
  15951. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15952. */
  15953. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15954. }
  15955. /**
  15956. * Defines the minimum contract an Edges renderer should follow.
  15957. */
  15958. export interface IEdgesRenderer extends IDisposable {
  15959. /**
  15960. * Gets or sets a boolean indicating if the edgesRenderer is active
  15961. */
  15962. isEnabled: boolean;
  15963. /**
  15964. * Renders the edges of the attached mesh,
  15965. */
  15966. render(): void;
  15967. /**
  15968. * Checks wether or not the edges renderer is ready to render.
  15969. * @return true if ready, otherwise false.
  15970. */
  15971. isReady(): boolean;
  15972. }
  15973. /**
  15974. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15975. */
  15976. export class EdgesRenderer implements IEdgesRenderer {
  15977. /**
  15978. * Define the size of the edges with an orthographic camera
  15979. */
  15980. edgesWidthScalerForOrthographic: number;
  15981. /**
  15982. * Define the size of the edges with a perspective camera
  15983. */
  15984. edgesWidthScalerForPerspective: number;
  15985. protected _source: AbstractMesh;
  15986. protected _linesPositions: number[];
  15987. protected _linesNormals: number[];
  15988. protected _linesIndices: number[];
  15989. protected _epsilon: number;
  15990. protected _indicesCount: number;
  15991. protected _lineShader: ShaderMaterial;
  15992. protected _ib: DataBuffer;
  15993. protected _buffers: {
  15994. [key: string]: Nullable<VertexBuffer>;
  15995. };
  15996. protected _checkVerticesInsteadOfIndices: boolean;
  15997. private _meshRebuildObserver;
  15998. private _meshDisposeObserver;
  15999. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16000. isEnabled: boolean;
  16001. /**
  16002. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16003. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16004. * @param source Mesh used to create edges
  16005. * @param epsilon sum of angles in adjacency to check for edge
  16006. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16007. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16008. */
  16009. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16010. protected _prepareRessources(): void;
  16011. /** @hidden */
  16012. _rebuild(): void;
  16013. /**
  16014. * Releases the required resources for the edges renderer
  16015. */
  16016. dispose(): void;
  16017. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16018. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16019. /**
  16020. * Checks if the pair of p0 and p1 is en edge
  16021. * @param faceIndex
  16022. * @param edge
  16023. * @param faceNormals
  16024. * @param p0
  16025. * @param p1
  16026. * @private
  16027. */
  16028. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16029. /**
  16030. * push line into the position, normal and index buffer
  16031. * @protected
  16032. */
  16033. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16034. /**
  16035. * Generates lines edges from adjacencjes
  16036. * @private
  16037. */
  16038. _generateEdgesLines(): void;
  16039. /**
  16040. * Checks wether or not the edges renderer is ready to render.
  16041. * @return true if ready, otherwise false.
  16042. */
  16043. isReady(): boolean;
  16044. /**
  16045. * Renders the edges of the attached mesh,
  16046. */
  16047. render(): void;
  16048. }
  16049. /**
  16050. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16051. */
  16052. export class LineEdgesRenderer extends EdgesRenderer {
  16053. /**
  16054. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16055. * @param source LineMesh used to generate edges
  16056. * @param epsilon not important (specified angle for edge detection)
  16057. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16058. */
  16059. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16060. /**
  16061. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16062. */
  16063. _generateEdgesLines(): void;
  16064. }
  16065. }
  16066. declare module BABYLON {
  16067. /**
  16068. * This represents the object necessary to create a rendering group.
  16069. * This is exclusively used and created by the rendering manager.
  16070. * To modify the behavior, you use the available helpers in your scene or meshes.
  16071. * @hidden
  16072. */
  16073. export class RenderingGroup {
  16074. index: number;
  16075. private static _zeroVector;
  16076. private _scene;
  16077. private _opaqueSubMeshes;
  16078. private _transparentSubMeshes;
  16079. private _alphaTestSubMeshes;
  16080. private _depthOnlySubMeshes;
  16081. private _particleSystems;
  16082. private _spriteManagers;
  16083. private _opaqueSortCompareFn;
  16084. private _alphaTestSortCompareFn;
  16085. private _transparentSortCompareFn;
  16086. private _renderOpaque;
  16087. private _renderAlphaTest;
  16088. private _renderTransparent;
  16089. /** @hidden */
  16090. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16091. onBeforeTransparentRendering: () => void;
  16092. /**
  16093. * Set the opaque sort comparison function.
  16094. * If null the sub meshes will be render in the order they were created
  16095. */
  16096. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16097. /**
  16098. * Set the alpha test sort comparison function.
  16099. * If null the sub meshes will be render in the order they were created
  16100. */
  16101. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16102. /**
  16103. * Set the transparent sort comparison function.
  16104. * If null the sub meshes will be render in the order they were created
  16105. */
  16106. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16107. /**
  16108. * Creates a new rendering group.
  16109. * @param index The rendering group index
  16110. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16111. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16112. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16113. */
  16114. 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>);
  16115. /**
  16116. * Render all the sub meshes contained in the group.
  16117. * @param customRenderFunction Used to override the default render behaviour of the group.
  16118. * @returns true if rendered some submeshes.
  16119. */
  16120. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16121. /**
  16122. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16123. * @param subMeshes The submeshes to render
  16124. */
  16125. private renderOpaqueSorted;
  16126. /**
  16127. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16128. * @param subMeshes The submeshes to render
  16129. */
  16130. private renderAlphaTestSorted;
  16131. /**
  16132. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16133. * @param subMeshes The submeshes to render
  16134. */
  16135. private renderTransparentSorted;
  16136. /**
  16137. * Renders the submeshes in a specified order.
  16138. * @param subMeshes The submeshes to sort before render
  16139. * @param sortCompareFn The comparison function use to sort
  16140. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16141. * @param transparent Specifies to activate blending if true
  16142. */
  16143. private static renderSorted;
  16144. /**
  16145. * Renders the submeshes in the order they were dispatched (no sort applied).
  16146. * @param subMeshes The submeshes to render
  16147. */
  16148. private static renderUnsorted;
  16149. /**
  16150. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16151. * are rendered back to front if in the same alpha index.
  16152. *
  16153. * @param a The first submesh
  16154. * @param b The second submesh
  16155. * @returns The result of the comparison
  16156. */
  16157. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16158. /**
  16159. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16160. * are rendered back to front.
  16161. *
  16162. * @param a The first submesh
  16163. * @param b The second submesh
  16164. * @returns The result of the comparison
  16165. */
  16166. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16167. /**
  16168. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16169. * are rendered front to back (prevent overdraw).
  16170. *
  16171. * @param a The first submesh
  16172. * @param b The second submesh
  16173. * @returns The result of the comparison
  16174. */
  16175. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16176. /**
  16177. * Resets the different lists of submeshes to prepare a new frame.
  16178. */
  16179. prepare(): void;
  16180. dispose(): void;
  16181. /**
  16182. * Inserts the submesh in its correct queue depending on its material.
  16183. * @param subMesh The submesh to dispatch
  16184. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16185. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16186. */
  16187. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16188. dispatchSprites(spriteManager: ISpriteManager): void;
  16189. dispatchParticles(particleSystem: IParticleSystem): void;
  16190. private _renderParticles;
  16191. private _renderSprites;
  16192. }
  16193. }
  16194. declare module BABYLON {
  16195. /**
  16196. * Interface describing the different options available in the rendering manager
  16197. * regarding Auto Clear between groups.
  16198. */
  16199. export interface IRenderingManagerAutoClearSetup {
  16200. /**
  16201. * Defines whether or not autoclear is enable.
  16202. */
  16203. autoClear: boolean;
  16204. /**
  16205. * Defines whether or not to autoclear the depth buffer.
  16206. */
  16207. depth: boolean;
  16208. /**
  16209. * Defines whether or not to autoclear the stencil buffer.
  16210. */
  16211. stencil: boolean;
  16212. }
  16213. /**
  16214. * This class is used by the onRenderingGroupObservable
  16215. */
  16216. export class RenderingGroupInfo {
  16217. /**
  16218. * The Scene that being rendered
  16219. */
  16220. scene: Scene;
  16221. /**
  16222. * The camera currently used for the rendering pass
  16223. */
  16224. camera: Nullable<Camera>;
  16225. /**
  16226. * The ID of the renderingGroup being processed
  16227. */
  16228. renderingGroupId: number;
  16229. }
  16230. /**
  16231. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16232. * It is enable to manage the different groups as well as the different necessary sort functions.
  16233. * This should not be used directly aside of the few static configurations
  16234. */
  16235. export class RenderingManager {
  16236. /**
  16237. * The max id used for rendering groups (not included)
  16238. */
  16239. static MAX_RENDERINGGROUPS: number;
  16240. /**
  16241. * The min id used for rendering groups (included)
  16242. */
  16243. static MIN_RENDERINGGROUPS: number;
  16244. /**
  16245. * Used to globally prevent autoclearing scenes.
  16246. */
  16247. static AUTOCLEAR: boolean;
  16248. /**
  16249. * @hidden
  16250. */
  16251. _useSceneAutoClearSetup: boolean;
  16252. private _scene;
  16253. private _renderingGroups;
  16254. private _depthStencilBufferAlreadyCleaned;
  16255. private _autoClearDepthStencil;
  16256. private _customOpaqueSortCompareFn;
  16257. private _customAlphaTestSortCompareFn;
  16258. private _customTransparentSortCompareFn;
  16259. private _renderingGroupInfo;
  16260. /**
  16261. * Instantiates a new rendering group for a particular scene
  16262. * @param scene Defines the scene the groups belongs to
  16263. */
  16264. constructor(scene: Scene);
  16265. private _clearDepthStencilBuffer;
  16266. /**
  16267. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16268. * @hidden
  16269. */
  16270. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16271. /**
  16272. * Resets the different information of the group to prepare a new frame
  16273. * @hidden
  16274. */
  16275. reset(): void;
  16276. /**
  16277. * Dispose and release the group and its associated resources.
  16278. * @hidden
  16279. */
  16280. dispose(): void;
  16281. /**
  16282. * Clear the info related to rendering groups preventing retention points during dispose.
  16283. */
  16284. freeRenderingGroups(): void;
  16285. private _prepareRenderingGroup;
  16286. /**
  16287. * Add a sprite manager to the rendering manager in order to render it this frame.
  16288. * @param spriteManager Define the sprite manager to render
  16289. */
  16290. dispatchSprites(spriteManager: ISpriteManager): void;
  16291. /**
  16292. * Add a particle system to the rendering manager in order to render it this frame.
  16293. * @param particleSystem Define the particle system to render
  16294. */
  16295. dispatchParticles(particleSystem: IParticleSystem): void;
  16296. /**
  16297. * Add a submesh to the manager in order to render it this frame
  16298. * @param subMesh The submesh to dispatch
  16299. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16300. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16301. */
  16302. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16303. /**
  16304. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16305. * This allowed control for front to back rendering or reversly depending of the special needs.
  16306. *
  16307. * @param renderingGroupId The rendering group id corresponding to its index
  16308. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16309. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16310. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16311. */
  16312. 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;
  16313. /**
  16314. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16315. *
  16316. * @param renderingGroupId The rendering group id corresponding to its index
  16317. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16318. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16319. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16320. */
  16321. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16322. /**
  16323. * Gets the current auto clear configuration for one rendering group of the rendering
  16324. * manager.
  16325. * @param index the rendering group index to get the information for
  16326. * @returns The auto clear setup for the requested rendering group
  16327. */
  16328. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16329. }
  16330. }
  16331. declare module BABYLON {
  16332. /**
  16333. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16334. */
  16335. export interface ICustomShaderOptions {
  16336. /**
  16337. * Gets or sets the custom shader name to use
  16338. */
  16339. shaderName: string;
  16340. /**
  16341. * The list of attribute names used in the shader
  16342. */
  16343. attributes?: string[];
  16344. /**
  16345. * The list of unifrom names used in the shader
  16346. */
  16347. uniforms?: string[];
  16348. /**
  16349. * The list of sampler names used in the shader
  16350. */
  16351. samplers?: string[];
  16352. /**
  16353. * The list of defines used in the shader
  16354. */
  16355. defines?: string[];
  16356. }
  16357. /**
  16358. * Interface to implement to create a shadow generator compatible with BJS.
  16359. */
  16360. export interface IShadowGenerator {
  16361. /**
  16362. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16363. * @returns The render target texture if present otherwise, null
  16364. */
  16365. getShadowMap(): Nullable<RenderTargetTexture>;
  16366. /**
  16367. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16368. * @param subMesh The submesh we want to render in the shadow map
  16369. * @param useInstances Defines wether will draw in the map using instances
  16370. * @returns true if ready otherwise, false
  16371. */
  16372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16373. /**
  16374. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16375. * @param defines Defines of the material we want to update
  16376. * @param lightIndex Index of the light in the enabled light list of the material
  16377. */
  16378. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16379. /**
  16380. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16381. * defined in the generator but impacting the effect).
  16382. * It implies the unifroms available on the materials are the standard BJS ones.
  16383. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16384. * @param effect The effect we are binfing the information for
  16385. */
  16386. bindShadowLight(lightIndex: string, effect: Effect): void;
  16387. /**
  16388. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16389. * (eq to shadow prjection matrix * light transform matrix)
  16390. * @returns The transform matrix used to create the shadow map
  16391. */
  16392. getTransformMatrix(): Matrix;
  16393. /**
  16394. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16395. * Cube and 2D textures for instance.
  16396. */
  16397. recreateShadowMap(): void;
  16398. /**
  16399. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16400. * @param onCompiled Callback triggered at the and of the effects compilation
  16401. * @param options Sets of optional options forcing the compilation with different modes
  16402. */
  16403. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16404. useInstances: boolean;
  16405. }>): void;
  16406. /**
  16407. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16408. * @param options Sets of optional options forcing the compilation with different modes
  16409. * @returns A promise that resolves when the compilation completes
  16410. */
  16411. forceCompilationAsync(options?: Partial<{
  16412. useInstances: boolean;
  16413. }>): Promise<void>;
  16414. /**
  16415. * Serializes the shadow generator setup to a json object.
  16416. * @returns The serialized JSON object
  16417. */
  16418. serialize(): any;
  16419. /**
  16420. * Disposes the Shadow map and related Textures and effects.
  16421. */
  16422. dispose(): void;
  16423. }
  16424. /**
  16425. * Default implementation IShadowGenerator.
  16426. * This is the main object responsible of generating shadows in the framework.
  16427. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16428. */
  16429. export class ShadowGenerator implements IShadowGenerator {
  16430. /**
  16431. * Name of the shadow generator class
  16432. */
  16433. static CLASSNAME: string;
  16434. /**
  16435. * Shadow generator mode None: no filtering applied.
  16436. */
  16437. static readonly FILTER_NONE: number;
  16438. /**
  16439. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16440. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16441. */
  16442. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16443. /**
  16444. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16445. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16446. */
  16447. static readonly FILTER_POISSONSAMPLING: number;
  16448. /**
  16449. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16450. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16451. */
  16452. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16453. /**
  16454. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16455. * edge artifacts on steep falloff.
  16456. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16457. */
  16458. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16459. /**
  16460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16461. * edge artifacts on steep falloff.
  16462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16463. */
  16464. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16465. /**
  16466. * Shadow generator mode PCF: Percentage Closer Filtering
  16467. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16468. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16469. */
  16470. static readonly FILTER_PCF: number;
  16471. /**
  16472. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16473. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16474. * Contact Hardening
  16475. */
  16476. static readonly FILTER_PCSS: number;
  16477. /**
  16478. * Reserved for PCF and PCSS
  16479. * Highest Quality.
  16480. *
  16481. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16482. *
  16483. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16484. */
  16485. static readonly QUALITY_HIGH: number;
  16486. /**
  16487. * Reserved for PCF and PCSS
  16488. * Good tradeoff for quality/perf cross devices
  16489. *
  16490. * Execute PCF on a 3*3 kernel.
  16491. *
  16492. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16493. */
  16494. static readonly QUALITY_MEDIUM: number;
  16495. /**
  16496. * Reserved for PCF and PCSS
  16497. * The lowest quality but the fastest.
  16498. *
  16499. * Execute PCF on a 1*1 kernel.
  16500. *
  16501. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16502. */
  16503. static readonly QUALITY_LOW: number;
  16504. /** Gets or sets the custom shader name to use */
  16505. customShaderOptions: ICustomShaderOptions;
  16506. /**
  16507. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16508. */
  16509. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16510. /**
  16511. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16512. */
  16513. onAfterShadowMapRenderObservable: Observable<Effect>;
  16514. /**
  16515. * Observable triggered before a mesh is rendered in the shadow map.
  16516. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16517. */
  16518. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16519. /**
  16520. * Observable triggered after a mesh is rendered in the shadow map.
  16521. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16522. */
  16523. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16524. protected _bias: number;
  16525. /**
  16526. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16527. */
  16528. get bias(): number;
  16529. /**
  16530. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16531. */
  16532. set bias(bias: number);
  16533. protected _normalBias: number;
  16534. /**
  16535. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16536. */
  16537. get normalBias(): number;
  16538. /**
  16539. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16540. */
  16541. set normalBias(normalBias: number);
  16542. protected _blurBoxOffset: number;
  16543. /**
  16544. * Gets the blur box offset: offset applied during the blur pass.
  16545. * Only useful if useKernelBlur = false
  16546. */
  16547. get blurBoxOffset(): number;
  16548. /**
  16549. * Sets the blur box offset: offset applied during the blur pass.
  16550. * Only useful if useKernelBlur = false
  16551. */
  16552. set blurBoxOffset(value: number);
  16553. protected _blurScale: number;
  16554. /**
  16555. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16556. * 2 means half of the size.
  16557. */
  16558. get blurScale(): number;
  16559. /**
  16560. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16561. * 2 means half of the size.
  16562. */
  16563. set blurScale(value: number);
  16564. protected _blurKernel: number;
  16565. /**
  16566. * Gets the blur kernel: kernel size of the blur pass.
  16567. * Only useful if useKernelBlur = true
  16568. */
  16569. get blurKernel(): number;
  16570. /**
  16571. * Sets the blur kernel: kernel size of the blur pass.
  16572. * Only useful if useKernelBlur = true
  16573. */
  16574. set blurKernel(value: number);
  16575. protected _useKernelBlur: boolean;
  16576. /**
  16577. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16578. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16579. */
  16580. get useKernelBlur(): boolean;
  16581. /**
  16582. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16583. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16584. */
  16585. set useKernelBlur(value: boolean);
  16586. protected _depthScale: number;
  16587. /**
  16588. * Gets the depth scale used in ESM mode.
  16589. */
  16590. get depthScale(): number;
  16591. /**
  16592. * Sets the depth scale used in ESM mode.
  16593. * This can override the scale stored on the light.
  16594. */
  16595. set depthScale(value: number);
  16596. protected _validateFilter(filter: number): number;
  16597. protected _filter: number;
  16598. /**
  16599. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16600. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16601. */
  16602. get filter(): number;
  16603. /**
  16604. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16605. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16606. */
  16607. set filter(value: number);
  16608. /**
  16609. * Gets if the current filter is set to Poisson Sampling.
  16610. */
  16611. get usePoissonSampling(): boolean;
  16612. /**
  16613. * Sets the current filter to Poisson Sampling.
  16614. */
  16615. set usePoissonSampling(value: boolean);
  16616. /**
  16617. * Gets if the current filter is set to ESM.
  16618. */
  16619. get useExponentialShadowMap(): boolean;
  16620. /**
  16621. * Sets the current filter is to ESM.
  16622. */
  16623. set useExponentialShadowMap(value: boolean);
  16624. /**
  16625. * Gets if the current filter is set to filtered ESM.
  16626. */
  16627. get useBlurExponentialShadowMap(): boolean;
  16628. /**
  16629. * Gets if the current filter is set to filtered ESM.
  16630. */
  16631. set useBlurExponentialShadowMap(value: boolean);
  16632. /**
  16633. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16634. * exponential to prevent steep falloff artifacts).
  16635. */
  16636. get useCloseExponentialShadowMap(): boolean;
  16637. /**
  16638. * Sets the current filter to "close ESM" (using the inverse of the
  16639. * exponential to prevent steep falloff artifacts).
  16640. */
  16641. set useCloseExponentialShadowMap(value: boolean);
  16642. /**
  16643. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16644. * exponential to prevent steep falloff artifacts).
  16645. */
  16646. get useBlurCloseExponentialShadowMap(): boolean;
  16647. /**
  16648. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16649. * exponential to prevent steep falloff artifacts).
  16650. */
  16651. set useBlurCloseExponentialShadowMap(value: boolean);
  16652. /**
  16653. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16654. */
  16655. get usePercentageCloserFiltering(): boolean;
  16656. /**
  16657. * Sets the current filter to "PCF" (percentage closer filtering).
  16658. */
  16659. set usePercentageCloserFiltering(value: boolean);
  16660. protected _filteringQuality: number;
  16661. /**
  16662. * Gets the PCF or PCSS Quality.
  16663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16664. */
  16665. get filteringQuality(): number;
  16666. /**
  16667. * Sets the PCF or PCSS Quality.
  16668. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16669. */
  16670. set filteringQuality(filteringQuality: number);
  16671. /**
  16672. * Gets if the current filter is set to "PCSS" (contact hardening).
  16673. */
  16674. get useContactHardeningShadow(): boolean;
  16675. /**
  16676. * Sets the current filter to "PCSS" (contact hardening).
  16677. */
  16678. set useContactHardeningShadow(value: boolean);
  16679. protected _contactHardeningLightSizeUVRatio: number;
  16680. /**
  16681. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16682. * Using a ratio helps keeping shape stability independently of the map size.
  16683. *
  16684. * It does not account for the light projection as it was having too much
  16685. * instability during the light setup or during light position changes.
  16686. *
  16687. * Only valid if useContactHardeningShadow is true.
  16688. */
  16689. get contactHardeningLightSizeUVRatio(): number;
  16690. /**
  16691. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16692. * Using a ratio helps keeping shape stability independently of the map size.
  16693. *
  16694. * It does not account for the light projection as it was having too much
  16695. * instability during the light setup or during light position changes.
  16696. *
  16697. * Only valid if useContactHardeningShadow is true.
  16698. */
  16699. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16700. protected _darkness: number;
  16701. /** Gets or sets the actual darkness of a shadow */
  16702. get darkness(): number;
  16703. set darkness(value: number);
  16704. /**
  16705. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16706. * 0 means strongest and 1 would means no shadow.
  16707. * @returns the darkness.
  16708. */
  16709. getDarkness(): number;
  16710. /**
  16711. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16712. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16713. * @returns the shadow generator allowing fluent coding.
  16714. */
  16715. setDarkness(darkness: number): ShadowGenerator;
  16716. protected _transparencyShadow: boolean;
  16717. /** Gets or sets the ability to have transparent shadow */
  16718. get transparencyShadow(): boolean;
  16719. set transparencyShadow(value: boolean);
  16720. /**
  16721. * Sets the ability to have transparent shadow (boolean).
  16722. * @param transparent True if transparent else False
  16723. * @returns the shadow generator allowing fluent coding
  16724. */
  16725. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16726. protected _shadowMap: Nullable<RenderTargetTexture>;
  16727. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16728. /**
  16729. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16730. * @returns The render target texture if present otherwise, null
  16731. */
  16732. getShadowMap(): Nullable<RenderTargetTexture>;
  16733. /**
  16734. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16735. * @returns The render target texture if the shadow map is present otherwise, null
  16736. */
  16737. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16738. /**
  16739. * Gets the class name of that object
  16740. * @returns "ShadowGenerator"
  16741. */
  16742. getClassName(): string;
  16743. /**
  16744. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16745. * @param mesh Mesh to add
  16746. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16747. * @returns the Shadow Generator itself
  16748. */
  16749. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16750. /**
  16751. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16752. * @param mesh Mesh to remove
  16753. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16754. * @returns the Shadow Generator itself
  16755. */
  16756. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16757. /**
  16758. * Controls the extent to which the shadows fade out at the edge of the frustum
  16759. */
  16760. frustumEdgeFalloff: number;
  16761. protected _light: IShadowLight;
  16762. /**
  16763. * Returns the associated light object.
  16764. * @returns the light generating the shadow
  16765. */
  16766. getLight(): IShadowLight;
  16767. /**
  16768. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16769. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16770. * It might on the other hand introduce peter panning.
  16771. */
  16772. forceBackFacesOnly: boolean;
  16773. protected _scene: Scene;
  16774. protected _lightDirection: Vector3;
  16775. protected _effect: Effect;
  16776. protected _viewMatrix: Matrix;
  16777. protected _projectionMatrix: Matrix;
  16778. protected _transformMatrix: Matrix;
  16779. protected _cachedPosition: Vector3;
  16780. protected _cachedDirection: Vector3;
  16781. protected _cachedDefines: string;
  16782. protected _currentRenderID: number;
  16783. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16784. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16785. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16786. protected _blurPostProcesses: PostProcess[];
  16787. protected _mapSize: number;
  16788. protected _currentFaceIndex: number;
  16789. protected _currentFaceIndexCache: number;
  16790. protected _textureType: number;
  16791. protected _defaultTextureMatrix: Matrix;
  16792. protected _storedUniqueId: Nullable<number>;
  16793. /** @hidden */
  16794. static _SceneComponentInitialization: (scene: Scene) => void;
  16795. /**
  16796. * Creates a ShadowGenerator object.
  16797. * A ShadowGenerator is the required tool to use the shadows.
  16798. * Each light casting shadows needs to use its own ShadowGenerator.
  16799. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16800. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16801. * @param light The light object generating the shadows.
  16802. * @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.
  16803. */
  16804. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16805. protected _initializeGenerator(): void;
  16806. protected _createTargetRenderTexture(): void;
  16807. protected _initializeShadowMap(): void;
  16808. protected _initializeBlurRTTAndPostProcesses(): void;
  16809. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16810. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16811. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16812. protected _applyFilterValues(): void;
  16813. /**
  16814. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16815. * @param onCompiled Callback triggered at the and of the effects compilation
  16816. * @param options Sets of optional options forcing the compilation with different modes
  16817. */
  16818. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16819. useInstances: boolean;
  16820. }>): void;
  16821. /**
  16822. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16823. * @param options Sets of optional options forcing the compilation with different modes
  16824. * @returns A promise that resolves when the compilation completes
  16825. */
  16826. forceCompilationAsync(options?: Partial<{
  16827. useInstances: boolean;
  16828. }>): Promise<void>;
  16829. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16830. private _prepareShadowDefines;
  16831. /**
  16832. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16833. * @param subMesh The submesh we want to render in the shadow map
  16834. * @param useInstances Defines wether will draw in the map using instances
  16835. * @returns true if ready otherwise, false
  16836. */
  16837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16838. /**
  16839. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16840. * @param defines Defines of the material we want to update
  16841. * @param lightIndex Index of the light in the enabled light list of the material
  16842. */
  16843. prepareDefines(defines: any, lightIndex: number): void;
  16844. /**
  16845. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16846. * defined in the generator but impacting the effect).
  16847. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16848. * @param effect The effect we are binfing the information for
  16849. */
  16850. bindShadowLight(lightIndex: string, effect: Effect): void;
  16851. /**
  16852. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16853. * (eq to shadow prjection matrix * light transform matrix)
  16854. * @returns The transform matrix used to create the shadow map
  16855. */
  16856. getTransformMatrix(): Matrix;
  16857. /**
  16858. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16859. * Cube and 2D textures for instance.
  16860. */
  16861. recreateShadowMap(): void;
  16862. protected _disposeBlurPostProcesses(): void;
  16863. protected _disposeRTTandPostProcesses(): void;
  16864. /**
  16865. * Disposes the ShadowGenerator.
  16866. * Returns nothing.
  16867. */
  16868. dispose(): void;
  16869. /**
  16870. * Serializes the shadow generator setup to a json object.
  16871. * @returns The serialized JSON object
  16872. */
  16873. serialize(): any;
  16874. /**
  16875. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16876. * @param parsedShadowGenerator The JSON object to parse
  16877. * @param scene The scene to create the shadow map for
  16878. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16879. * @returns The parsed shadow generator
  16880. */
  16881. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16882. }
  16883. }
  16884. declare module BABYLON {
  16885. /**
  16886. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16887. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16888. * 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.
  16889. */
  16890. export abstract class Light extends Node {
  16891. /**
  16892. * Falloff Default: light is falling off following the material specification:
  16893. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16894. */
  16895. static readonly FALLOFF_DEFAULT: number;
  16896. /**
  16897. * Falloff Physical: light is falling off following the inverse squared distance law.
  16898. */
  16899. static readonly FALLOFF_PHYSICAL: number;
  16900. /**
  16901. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16902. * to enhance interoperability with other engines.
  16903. */
  16904. static readonly FALLOFF_GLTF: number;
  16905. /**
  16906. * Falloff Standard: light is falling off like in the standard material
  16907. * to enhance interoperability with other materials.
  16908. */
  16909. static readonly FALLOFF_STANDARD: number;
  16910. /**
  16911. * If every light affecting the material is in this lightmapMode,
  16912. * material.lightmapTexture adds or multiplies
  16913. * (depends on material.useLightmapAsShadowmap)
  16914. * after every other light calculations.
  16915. */
  16916. static readonly LIGHTMAP_DEFAULT: number;
  16917. /**
  16918. * material.lightmapTexture as only diffuse lighting from this light
  16919. * adds only specular lighting from this light
  16920. * adds dynamic shadows
  16921. */
  16922. static readonly LIGHTMAP_SPECULAR: number;
  16923. /**
  16924. * material.lightmapTexture as only lighting
  16925. * no light calculation from this light
  16926. * only adds dynamic shadows from this light
  16927. */
  16928. static readonly LIGHTMAP_SHADOWSONLY: number;
  16929. /**
  16930. * Each light type uses the default quantity according to its type:
  16931. * point/spot lights use luminous intensity
  16932. * directional lights use illuminance
  16933. */
  16934. static readonly INTENSITYMODE_AUTOMATIC: number;
  16935. /**
  16936. * lumen (lm)
  16937. */
  16938. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16939. /**
  16940. * candela (lm/sr)
  16941. */
  16942. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16943. /**
  16944. * lux (lm/m^2)
  16945. */
  16946. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16947. /**
  16948. * nit (cd/m^2)
  16949. */
  16950. static readonly INTENSITYMODE_LUMINANCE: number;
  16951. /**
  16952. * Light type const id of the point light.
  16953. */
  16954. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16955. /**
  16956. * Light type const id of the directional light.
  16957. */
  16958. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16959. /**
  16960. * Light type const id of the spot light.
  16961. */
  16962. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16963. /**
  16964. * Light type const id of the hemispheric light.
  16965. */
  16966. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16967. /**
  16968. * Diffuse gives the basic color to an object.
  16969. */
  16970. diffuse: Color3;
  16971. /**
  16972. * Specular produces a highlight color on an object.
  16973. * Note: This is note affecting PBR materials.
  16974. */
  16975. specular: Color3;
  16976. /**
  16977. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16978. * falling off base on range or angle.
  16979. * This can be set to any values in Light.FALLOFF_x.
  16980. *
  16981. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16982. * other types of materials.
  16983. */
  16984. falloffType: number;
  16985. /**
  16986. * Strength of the light.
  16987. * Note: By default it is define in the framework own unit.
  16988. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16989. */
  16990. intensity: number;
  16991. private _range;
  16992. protected _inverseSquaredRange: number;
  16993. /**
  16994. * Defines how far from the source the light is impacting in scene units.
  16995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16996. */
  16997. get range(): number;
  16998. /**
  16999. * Defines how far from the source the light is impacting in scene units.
  17000. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17001. */
  17002. set range(value: number);
  17003. /**
  17004. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17005. * of light.
  17006. */
  17007. private _photometricScale;
  17008. private _intensityMode;
  17009. /**
  17010. * Gets the photometric scale used to interpret the intensity.
  17011. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17012. */
  17013. get intensityMode(): number;
  17014. /**
  17015. * Sets the photometric scale used to interpret the intensity.
  17016. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17017. */
  17018. set intensityMode(value: number);
  17019. private _radius;
  17020. /**
  17021. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17022. */
  17023. get radius(): number;
  17024. /**
  17025. * sets the light radius used by PBR Materials to simulate soft area lights.
  17026. */
  17027. set radius(value: number);
  17028. private _renderPriority;
  17029. /**
  17030. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17031. * exceeding the number allowed of the materials.
  17032. */
  17033. renderPriority: number;
  17034. private _shadowEnabled;
  17035. /**
  17036. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17037. * the current shadow generator.
  17038. */
  17039. get shadowEnabled(): boolean;
  17040. /**
  17041. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17042. * the current shadow generator.
  17043. */
  17044. set shadowEnabled(value: boolean);
  17045. private _includedOnlyMeshes;
  17046. /**
  17047. * Gets the only meshes impacted by this light.
  17048. */
  17049. get includedOnlyMeshes(): AbstractMesh[];
  17050. /**
  17051. * Sets the only meshes impacted by this light.
  17052. */
  17053. set includedOnlyMeshes(value: AbstractMesh[]);
  17054. private _excludedMeshes;
  17055. /**
  17056. * Gets the meshes not impacted by this light.
  17057. */
  17058. get excludedMeshes(): AbstractMesh[];
  17059. /**
  17060. * Sets the meshes not impacted by this light.
  17061. */
  17062. set excludedMeshes(value: AbstractMesh[]);
  17063. private _excludeWithLayerMask;
  17064. /**
  17065. * Gets the layer id use to find what meshes are not impacted by the light.
  17066. * Inactive if 0
  17067. */
  17068. get excludeWithLayerMask(): number;
  17069. /**
  17070. * Sets the layer id use to find what meshes are not impacted by the light.
  17071. * Inactive if 0
  17072. */
  17073. set excludeWithLayerMask(value: number);
  17074. private _includeOnlyWithLayerMask;
  17075. /**
  17076. * Gets the layer id use to find what meshes are impacted by the light.
  17077. * Inactive if 0
  17078. */
  17079. get includeOnlyWithLayerMask(): number;
  17080. /**
  17081. * Sets the layer id use to find what meshes are impacted by the light.
  17082. * Inactive if 0
  17083. */
  17084. set includeOnlyWithLayerMask(value: number);
  17085. private _lightmapMode;
  17086. /**
  17087. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17088. */
  17089. get lightmapMode(): number;
  17090. /**
  17091. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17092. */
  17093. set lightmapMode(value: number);
  17094. /**
  17095. * Shadow generator associted to the light.
  17096. * @hidden Internal use only.
  17097. */
  17098. _shadowGenerator: Nullable<IShadowGenerator>;
  17099. /**
  17100. * @hidden Internal use only.
  17101. */
  17102. _excludedMeshesIds: string[];
  17103. /**
  17104. * @hidden Internal use only.
  17105. */
  17106. _includedOnlyMeshesIds: string[];
  17107. /**
  17108. * The current light unifom buffer.
  17109. * @hidden Internal use only.
  17110. */
  17111. _uniformBuffer: UniformBuffer;
  17112. /** @hidden */
  17113. _renderId: number;
  17114. /**
  17115. * Creates a Light object in the scene.
  17116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17117. * @param name The firendly name of the light
  17118. * @param scene The scene the light belongs too
  17119. */
  17120. constructor(name: string, scene: Scene);
  17121. protected abstract _buildUniformLayout(): void;
  17122. /**
  17123. * Sets the passed Effect "effect" with the Light information.
  17124. * @param effect The effect to update
  17125. * @param lightIndex The index of the light in the effect to update
  17126. * @returns The light
  17127. */
  17128. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17129. /**
  17130. * Sets the passed Effect "effect" with the Light textures.
  17131. * @param effect The effect to update
  17132. * @param lightIndex The index of the light in the effect to update
  17133. * @returns The light
  17134. */
  17135. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17136. /**
  17137. * Binds the lights information from the scene to the effect for the given mesh.
  17138. * @param lightIndex Light index
  17139. * @param scene The scene where the light belongs to
  17140. * @param effect The effect we are binding the data to
  17141. * @param useSpecular Defines if specular is supported
  17142. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17143. */
  17144. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17145. /**
  17146. * Sets the passed Effect "effect" with the Light information.
  17147. * @param effect The effect to update
  17148. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17149. * @returns The light
  17150. */
  17151. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17152. /**
  17153. * Returns the string "Light".
  17154. * @returns the class name
  17155. */
  17156. getClassName(): string;
  17157. /** @hidden */
  17158. readonly _isLight: boolean;
  17159. /**
  17160. * Converts the light information to a readable string for debug purpose.
  17161. * @param fullDetails Supports for multiple levels of logging within scene loading
  17162. * @returns the human readable light info
  17163. */
  17164. toString(fullDetails?: boolean): string;
  17165. /** @hidden */
  17166. protected _syncParentEnabledState(): void;
  17167. /**
  17168. * Set the enabled state of this node.
  17169. * @param value - the new enabled state
  17170. */
  17171. setEnabled(value: boolean): void;
  17172. /**
  17173. * Returns the Light associated shadow generator if any.
  17174. * @return the associated shadow generator.
  17175. */
  17176. getShadowGenerator(): Nullable<IShadowGenerator>;
  17177. /**
  17178. * Returns a Vector3, the absolute light position in the World.
  17179. * @returns the world space position of the light
  17180. */
  17181. getAbsolutePosition(): Vector3;
  17182. /**
  17183. * Specifies if the light will affect the passed mesh.
  17184. * @param mesh The mesh to test against the light
  17185. * @return true the mesh is affected otherwise, false.
  17186. */
  17187. canAffectMesh(mesh: AbstractMesh): boolean;
  17188. /**
  17189. * Sort function to order lights for rendering.
  17190. * @param a First Light object to compare to second.
  17191. * @param b Second Light object to compare first.
  17192. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17193. */
  17194. static CompareLightsPriority(a: Light, b: Light): number;
  17195. /**
  17196. * Releases resources associated with this node.
  17197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17199. */
  17200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17201. /**
  17202. * Returns the light type ID (integer).
  17203. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17204. */
  17205. getTypeID(): number;
  17206. /**
  17207. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17208. * @returns the scaled intensity in intensity mode unit
  17209. */
  17210. getScaledIntensity(): number;
  17211. /**
  17212. * Returns a new Light object, named "name", from the current one.
  17213. * @param name The name of the cloned light
  17214. * @returns the new created light
  17215. */
  17216. clone(name: string): Nullable<Light>;
  17217. /**
  17218. * Serializes the current light into a Serialization object.
  17219. * @returns the serialized object.
  17220. */
  17221. serialize(): any;
  17222. /**
  17223. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17224. * This new light is named "name" and added to the passed scene.
  17225. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17226. * @param name The friendly name of the light
  17227. * @param scene The scene the new light will belong to
  17228. * @returns the constructor function
  17229. */
  17230. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17231. /**
  17232. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17233. * @param parsedLight The JSON representation of the light
  17234. * @param scene The scene to create the parsed light in
  17235. * @returns the created light after parsing
  17236. */
  17237. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17238. private _hookArrayForExcluded;
  17239. private _hookArrayForIncludedOnly;
  17240. private _resyncMeshes;
  17241. /**
  17242. * Forces the meshes to update their light related information in their rendering used effects
  17243. * @hidden Internal Use Only
  17244. */
  17245. _markMeshesAsLightDirty(): void;
  17246. /**
  17247. * Recomputes the cached photometric scale if needed.
  17248. */
  17249. private _computePhotometricScale;
  17250. /**
  17251. * Returns the Photometric Scale according to the light type and intensity mode.
  17252. */
  17253. private _getPhotometricScale;
  17254. /**
  17255. * Reorder the light in the scene according to their defined priority.
  17256. * @hidden Internal Use Only
  17257. */
  17258. _reorderLightsInScene(): void;
  17259. /**
  17260. * Prepares the list of defines specific to the light type.
  17261. * @param defines the list of defines
  17262. * @param lightIndex defines the index of the light for the effect
  17263. */
  17264. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17265. }
  17266. }
  17267. declare module BABYLON {
  17268. /**
  17269. * Interface used to define Action
  17270. */
  17271. export interface IAction {
  17272. /**
  17273. * Trigger for the action
  17274. */
  17275. trigger: number;
  17276. /** Options of the trigger */
  17277. triggerOptions: any;
  17278. /**
  17279. * Gets the trigger parameters
  17280. * @returns the trigger parameters
  17281. */
  17282. getTriggerParameter(): any;
  17283. /**
  17284. * Internal only - executes current action event
  17285. * @hidden
  17286. */
  17287. _executeCurrent(evt?: ActionEvent): void;
  17288. /**
  17289. * Serialize placeholder for child classes
  17290. * @param parent of child
  17291. * @returns the serialized object
  17292. */
  17293. serialize(parent: any): any;
  17294. /**
  17295. * Internal only
  17296. * @hidden
  17297. */
  17298. _prepare(): void;
  17299. /**
  17300. * Internal only - manager for action
  17301. * @hidden
  17302. */
  17303. _actionManager: AbstractActionManager;
  17304. /**
  17305. * Adds action to chain of actions, may be a DoNothingAction
  17306. * @param action defines the next action to execute
  17307. * @returns The action passed in
  17308. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17309. */
  17310. then(action: IAction): IAction;
  17311. }
  17312. /**
  17313. * The action to be carried out following a trigger
  17314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17315. */
  17316. export class Action implements IAction {
  17317. /** the trigger, with or without parameters, for the action */
  17318. triggerOptions: any;
  17319. /**
  17320. * Trigger for the action
  17321. */
  17322. trigger: number;
  17323. /**
  17324. * Internal only - manager for action
  17325. * @hidden
  17326. */
  17327. _actionManager: ActionManager;
  17328. private _nextActiveAction;
  17329. private _child;
  17330. private _condition?;
  17331. private _triggerParameter;
  17332. /**
  17333. * An event triggered prior to action being executed.
  17334. */
  17335. onBeforeExecuteObservable: Observable<Action>;
  17336. /**
  17337. * Creates a new Action
  17338. * @param triggerOptions the trigger, with or without parameters, for the action
  17339. * @param condition an optional determinant of action
  17340. */
  17341. constructor(
  17342. /** the trigger, with or without parameters, for the action */
  17343. triggerOptions: any, condition?: Condition);
  17344. /**
  17345. * Internal only
  17346. * @hidden
  17347. */
  17348. _prepare(): void;
  17349. /**
  17350. * Gets the trigger parameters
  17351. * @returns the trigger parameters
  17352. */
  17353. getTriggerParameter(): any;
  17354. /**
  17355. * Internal only - executes current action event
  17356. * @hidden
  17357. */
  17358. _executeCurrent(evt?: ActionEvent): void;
  17359. /**
  17360. * Execute placeholder for child classes
  17361. * @param evt optional action event
  17362. */
  17363. execute(evt?: ActionEvent): void;
  17364. /**
  17365. * Skips to next active action
  17366. */
  17367. skipToNextActiveAction(): void;
  17368. /**
  17369. * Adds action to chain of actions, may be a DoNothingAction
  17370. * @param action defines the next action to execute
  17371. * @returns The action passed in
  17372. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17373. */
  17374. then(action: Action): Action;
  17375. /**
  17376. * Internal only
  17377. * @hidden
  17378. */
  17379. _getProperty(propertyPath: string): string;
  17380. /**
  17381. * Internal only
  17382. * @hidden
  17383. */
  17384. _getEffectiveTarget(target: any, propertyPath: string): any;
  17385. /**
  17386. * Serialize placeholder for child classes
  17387. * @param parent of child
  17388. * @returns the serialized object
  17389. */
  17390. serialize(parent: any): any;
  17391. /**
  17392. * Internal only called by serialize
  17393. * @hidden
  17394. */
  17395. protected _serialize(serializedAction: any, parent?: any): any;
  17396. /**
  17397. * Internal only
  17398. * @hidden
  17399. */
  17400. static _SerializeValueAsString: (value: any) => string;
  17401. /**
  17402. * Internal only
  17403. * @hidden
  17404. */
  17405. static _GetTargetProperty: (target: Node | Scene) => {
  17406. name: string;
  17407. targetType: string;
  17408. value: string;
  17409. };
  17410. }
  17411. }
  17412. declare module BABYLON {
  17413. /**
  17414. * A Condition applied to an Action
  17415. */
  17416. export class Condition {
  17417. /**
  17418. * Internal only - manager for action
  17419. * @hidden
  17420. */
  17421. _actionManager: ActionManager;
  17422. /**
  17423. * Internal only
  17424. * @hidden
  17425. */
  17426. _evaluationId: number;
  17427. /**
  17428. * Internal only
  17429. * @hidden
  17430. */
  17431. _currentResult: boolean;
  17432. /**
  17433. * Creates a new Condition
  17434. * @param actionManager the manager of the action the condition is applied to
  17435. */
  17436. constructor(actionManager: ActionManager);
  17437. /**
  17438. * Check if the current condition is valid
  17439. * @returns a boolean
  17440. */
  17441. isValid(): boolean;
  17442. /**
  17443. * Internal only
  17444. * @hidden
  17445. */
  17446. _getProperty(propertyPath: string): string;
  17447. /**
  17448. * Internal only
  17449. * @hidden
  17450. */
  17451. _getEffectiveTarget(target: any, propertyPath: string): any;
  17452. /**
  17453. * Serialize placeholder for child classes
  17454. * @returns the serialized object
  17455. */
  17456. serialize(): any;
  17457. /**
  17458. * Internal only
  17459. * @hidden
  17460. */
  17461. protected _serialize(serializedCondition: any): any;
  17462. }
  17463. /**
  17464. * Defines specific conditional operators as extensions of Condition
  17465. */
  17466. export class ValueCondition extends Condition {
  17467. /** path to specify the property of the target the conditional operator uses */
  17468. propertyPath: string;
  17469. /** the value compared by the conditional operator against the current value of the property */
  17470. value: any;
  17471. /** the conditional operator, default ValueCondition.IsEqual */
  17472. operator: number;
  17473. /**
  17474. * Internal only
  17475. * @hidden
  17476. */
  17477. private static _IsEqual;
  17478. /**
  17479. * Internal only
  17480. * @hidden
  17481. */
  17482. private static _IsDifferent;
  17483. /**
  17484. * Internal only
  17485. * @hidden
  17486. */
  17487. private static _IsGreater;
  17488. /**
  17489. * Internal only
  17490. * @hidden
  17491. */
  17492. private static _IsLesser;
  17493. /**
  17494. * returns the number for IsEqual
  17495. */
  17496. static get IsEqual(): number;
  17497. /**
  17498. * Returns the number for IsDifferent
  17499. */
  17500. static get IsDifferent(): number;
  17501. /**
  17502. * Returns the number for IsGreater
  17503. */
  17504. static get IsGreater(): number;
  17505. /**
  17506. * Returns the number for IsLesser
  17507. */
  17508. static get IsLesser(): number;
  17509. /**
  17510. * Internal only The action manager for the condition
  17511. * @hidden
  17512. */
  17513. _actionManager: ActionManager;
  17514. /**
  17515. * Internal only
  17516. * @hidden
  17517. */
  17518. private _target;
  17519. /**
  17520. * Internal only
  17521. * @hidden
  17522. */
  17523. private _effectiveTarget;
  17524. /**
  17525. * Internal only
  17526. * @hidden
  17527. */
  17528. private _property;
  17529. /**
  17530. * Creates a new ValueCondition
  17531. * @param actionManager manager for the action the condition applies to
  17532. * @param target for the action
  17533. * @param propertyPath path to specify the property of the target the conditional operator uses
  17534. * @param value the value compared by the conditional operator against the current value of the property
  17535. * @param operator the conditional operator, default ValueCondition.IsEqual
  17536. */
  17537. constructor(actionManager: ActionManager, target: any,
  17538. /** path to specify the property of the target the conditional operator uses */
  17539. propertyPath: string,
  17540. /** the value compared by the conditional operator against the current value of the property */
  17541. value: any,
  17542. /** the conditional operator, default ValueCondition.IsEqual */
  17543. operator?: number);
  17544. /**
  17545. * Compares the given value with the property value for the specified conditional operator
  17546. * @returns the result of the comparison
  17547. */
  17548. isValid(): boolean;
  17549. /**
  17550. * Serialize the ValueCondition into a JSON compatible object
  17551. * @returns serialization object
  17552. */
  17553. serialize(): any;
  17554. /**
  17555. * Gets the name of the conditional operator for the ValueCondition
  17556. * @param operator the conditional operator
  17557. * @returns the name
  17558. */
  17559. static GetOperatorName(operator: number): string;
  17560. }
  17561. /**
  17562. * Defines a predicate condition as an extension of Condition
  17563. */
  17564. export class PredicateCondition extends Condition {
  17565. /** defines the predicate function used to validate the condition */
  17566. predicate: () => boolean;
  17567. /**
  17568. * Internal only - manager for action
  17569. * @hidden
  17570. */
  17571. _actionManager: ActionManager;
  17572. /**
  17573. * Creates a new PredicateCondition
  17574. * @param actionManager manager for the action the condition applies to
  17575. * @param predicate defines the predicate function used to validate the condition
  17576. */
  17577. constructor(actionManager: ActionManager,
  17578. /** defines the predicate function used to validate the condition */
  17579. predicate: () => boolean);
  17580. /**
  17581. * @returns the validity of the predicate condition
  17582. */
  17583. isValid(): boolean;
  17584. }
  17585. /**
  17586. * Defines a state condition as an extension of Condition
  17587. */
  17588. export class StateCondition extends Condition {
  17589. /** Value to compare with target state */
  17590. value: string;
  17591. /**
  17592. * Internal only - manager for action
  17593. * @hidden
  17594. */
  17595. _actionManager: ActionManager;
  17596. /**
  17597. * Internal only
  17598. * @hidden
  17599. */
  17600. private _target;
  17601. /**
  17602. * Creates a new StateCondition
  17603. * @param actionManager manager for the action the condition applies to
  17604. * @param target of the condition
  17605. * @param value to compare with target state
  17606. */
  17607. constructor(actionManager: ActionManager, target: any,
  17608. /** Value to compare with target state */
  17609. value: string);
  17610. /**
  17611. * Gets a boolean indicating if the current condition is met
  17612. * @returns the validity of the state
  17613. */
  17614. isValid(): boolean;
  17615. /**
  17616. * Serialize the StateCondition into a JSON compatible object
  17617. * @returns serialization object
  17618. */
  17619. serialize(): any;
  17620. }
  17621. }
  17622. declare module BABYLON {
  17623. /**
  17624. * This defines an action responsible to toggle a boolean once triggered.
  17625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17626. */
  17627. export class SwitchBooleanAction extends Action {
  17628. /**
  17629. * The path to the boolean property in the target object
  17630. */
  17631. propertyPath: string;
  17632. private _target;
  17633. private _effectiveTarget;
  17634. private _property;
  17635. /**
  17636. * Instantiate the action
  17637. * @param triggerOptions defines the trigger options
  17638. * @param target defines the object containing the boolean
  17639. * @param propertyPath defines the path to the boolean property in the target object
  17640. * @param condition defines the trigger related conditions
  17641. */
  17642. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17643. /** @hidden */
  17644. _prepare(): void;
  17645. /**
  17646. * Execute the action toggle the boolean value.
  17647. */
  17648. execute(): void;
  17649. /**
  17650. * Serializes the actions and its related information.
  17651. * @param parent defines the object to serialize in
  17652. * @returns the serialized object
  17653. */
  17654. serialize(parent: any): any;
  17655. }
  17656. /**
  17657. * This defines an action responsible to set a the state field of the target
  17658. * to a desired value once triggered.
  17659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17660. */
  17661. export class SetStateAction extends Action {
  17662. /**
  17663. * The value to store in the state field.
  17664. */
  17665. value: string;
  17666. private _target;
  17667. /**
  17668. * Instantiate the action
  17669. * @param triggerOptions defines the trigger options
  17670. * @param target defines the object containing the state property
  17671. * @param value defines the value to store in the state field
  17672. * @param condition defines the trigger related conditions
  17673. */
  17674. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17675. /**
  17676. * Execute the action and store the value on the target state property.
  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 set a property of the target
  17688. * to a desired value once triggered.
  17689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17690. */
  17691. export class SetValueAction extends Action {
  17692. /**
  17693. * The path of the property to set in the target.
  17694. */
  17695. propertyPath: string;
  17696. /**
  17697. * The value to set in the property
  17698. */
  17699. value: any;
  17700. private _target;
  17701. private _effectiveTarget;
  17702. private _property;
  17703. /**
  17704. * Instantiate the action
  17705. * @param triggerOptions defines the trigger options
  17706. * @param target defines the object containing the property
  17707. * @param propertyPath defines the path of the property to set in the target
  17708. * @param value defines the value to set in the property
  17709. * @param condition defines the trigger related conditions
  17710. */
  17711. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17712. /** @hidden */
  17713. _prepare(): void;
  17714. /**
  17715. * Execute the action and set the targetted property to the desired value.
  17716. */
  17717. execute(): void;
  17718. /**
  17719. * Serializes the actions and its related information.
  17720. * @param parent defines the object to serialize in
  17721. * @returns the serialized object
  17722. */
  17723. serialize(parent: any): any;
  17724. }
  17725. /**
  17726. * This defines an action responsible to increment the target value
  17727. * to a desired value once triggered.
  17728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17729. */
  17730. export class IncrementValueAction extends Action {
  17731. /**
  17732. * The path of the property to increment in the target.
  17733. */
  17734. propertyPath: string;
  17735. /**
  17736. * The value we should increment the property by.
  17737. */
  17738. value: any;
  17739. private _target;
  17740. private _effectiveTarget;
  17741. private _property;
  17742. /**
  17743. * Instantiate the action
  17744. * @param triggerOptions defines the trigger options
  17745. * @param target defines the object containing the property
  17746. * @param propertyPath defines the path of the property to increment in the target
  17747. * @param value defines the value value we should increment the property by
  17748. * @param condition defines the trigger related conditions
  17749. */
  17750. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17751. /** @hidden */
  17752. _prepare(): void;
  17753. /**
  17754. * Execute the action and increment the target of the value amount.
  17755. */
  17756. execute(): void;
  17757. /**
  17758. * Serializes the actions and its related information.
  17759. * @param parent defines the object to serialize in
  17760. * @returns the serialized object
  17761. */
  17762. serialize(parent: any): any;
  17763. }
  17764. /**
  17765. * This defines an action responsible to start an animation once triggered.
  17766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17767. */
  17768. export class PlayAnimationAction extends Action {
  17769. /**
  17770. * Where the animation should start (animation frame)
  17771. */
  17772. from: number;
  17773. /**
  17774. * Where the animation should stop (animation frame)
  17775. */
  17776. to: number;
  17777. /**
  17778. * Define if the animation should loop or stop after the first play.
  17779. */
  17780. loop?: boolean;
  17781. private _target;
  17782. /**
  17783. * Instantiate the action
  17784. * @param triggerOptions defines the trigger options
  17785. * @param target defines the target animation or animation name
  17786. * @param from defines from where the animation should start (animation frame)
  17787. * @param end defines where the animation should stop (animation frame)
  17788. * @param loop defines if the animation should loop or stop after the first play
  17789. * @param condition defines the trigger related conditions
  17790. */
  17791. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17792. /** @hidden */
  17793. _prepare(): void;
  17794. /**
  17795. * Execute the action and play the animation.
  17796. */
  17797. execute(): void;
  17798. /**
  17799. * Serializes the actions and its related information.
  17800. * @param parent defines the object to serialize in
  17801. * @returns the serialized object
  17802. */
  17803. serialize(parent: any): any;
  17804. }
  17805. /**
  17806. * This defines an action responsible to stop an animation once triggered.
  17807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17808. */
  17809. export class StopAnimationAction extends Action {
  17810. private _target;
  17811. /**
  17812. * Instantiate the action
  17813. * @param triggerOptions defines the trigger options
  17814. * @param target defines the target animation or animation name
  17815. * @param condition defines the trigger related conditions
  17816. */
  17817. constructor(triggerOptions: any, target: any, condition?: Condition);
  17818. /** @hidden */
  17819. _prepare(): void;
  17820. /**
  17821. * Execute the action and stop the animation.
  17822. */
  17823. execute(): void;
  17824. /**
  17825. * Serializes the actions and its related information.
  17826. * @param parent defines the object to serialize in
  17827. * @returns the serialized object
  17828. */
  17829. serialize(parent: any): any;
  17830. }
  17831. /**
  17832. * This defines an action responsible that does nothing once triggered.
  17833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17834. */
  17835. export class DoNothingAction extends Action {
  17836. /**
  17837. * Instantiate the action
  17838. * @param triggerOptions defines the trigger options
  17839. * @param condition defines the trigger related conditions
  17840. */
  17841. constructor(triggerOptions?: any, condition?: Condition);
  17842. /**
  17843. * Execute the action and do nothing.
  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. * This defines an action responsible to trigger several actions once triggered.
  17855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17856. */
  17857. export class CombineAction extends Action {
  17858. /**
  17859. * The list of aggregated animations to run.
  17860. */
  17861. children: Action[];
  17862. /**
  17863. * Instantiate the action
  17864. * @param triggerOptions defines the trigger options
  17865. * @param children defines the list of aggregated animations to run
  17866. * @param condition defines the trigger related conditions
  17867. */
  17868. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17869. /** @hidden */
  17870. _prepare(): void;
  17871. /**
  17872. * Execute the action and executes all the aggregated actions.
  17873. */
  17874. execute(evt: ActionEvent): void;
  17875. /**
  17876. * Serializes the actions and its related information.
  17877. * @param parent defines the object to serialize in
  17878. * @returns the serialized object
  17879. */
  17880. serialize(parent: any): any;
  17881. }
  17882. /**
  17883. * This defines an action responsible to run code (external event) once triggered.
  17884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17885. */
  17886. export class ExecuteCodeAction extends Action {
  17887. /**
  17888. * The callback function to run.
  17889. */
  17890. func: (evt: ActionEvent) => void;
  17891. /**
  17892. * Instantiate the action
  17893. * @param triggerOptions defines the trigger options
  17894. * @param func defines the callback function to run
  17895. * @param condition defines the trigger related conditions
  17896. */
  17897. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17898. /**
  17899. * Execute the action and run the attached code.
  17900. */
  17901. execute(evt: ActionEvent): void;
  17902. }
  17903. /**
  17904. * This defines an action responsible to set the parent property of the target once triggered.
  17905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17906. */
  17907. export class SetParentAction extends Action {
  17908. private _parent;
  17909. private _target;
  17910. /**
  17911. * Instantiate the action
  17912. * @param triggerOptions defines the trigger options
  17913. * @param target defines the target containing the parent property
  17914. * @param parent defines from where the animation should start (animation frame)
  17915. * @param condition defines the trigger related conditions
  17916. */
  17917. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17918. /** @hidden */
  17919. _prepare(): void;
  17920. /**
  17921. * Execute the action and set the parent property.
  17922. */
  17923. execute(): void;
  17924. /**
  17925. * Serializes the actions and its related information.
  17926. * @param parent defines the object to serialize in
  17927. * @returns the serialized object
  17928. */
  17929. serialize(parent: any): any;
  17930. }
  17931. }
  17932. declare module BABYLON {
  17933. /**
  17934. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17935. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17937. */
  17938. export class ActionManager extends AbstractActionManager {
  17939. /**
  17940. * Nothing
  17941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17942. */
  17943. static readonly NothingTrigger: number;
  17944. /**
  17945. * On pick
  17946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17947. */
  17948. static readonly OnPickTrigger: number;
  17949. /**
  17950. * On left pick
  17951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17952. */
  17953. static readonly OnLeftPickTrigger: number;
  17954. /**
  17955. * On right pick
  17956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17957. */
  17958. static readonly OnRightPickTrigger: number;
  17959. /**
  17960. * On center pick
  17961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17962. */
  17963. static readonly OnCenterPickTrigger: number;
  17964. /**
  17965. * On pick down
  17966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17967. */
  17968. static readonly OnPickDownTrigger: number;
  17969. /**
  17970. * On double pick
  17971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17972. */
  17973. static readonly OnDoublePickTrigger: number;
  17974. /**
  17975. * On pick up
  17976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17977. */
  17978. static readonly OnPickUpTrigger: number;
  17979. /**
  17980. * On pick out.
  17981. * This trigger will only be raised if you also declared a OnPickDown
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17983. */
  17984. static readonly OnPickOutTrigger: number;
  17985. /**
  17986. * On long press
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17988. */
  17989. static readonly OnLongPressTrigger: number;
  17990. /**
  17991. * On pointer over
  17992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17993. */
  17994. static readonly OnPointerOverTrigger: number;
  17995. /**
  17996. * On pointer out
  17997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17998. */
  17999. static readonly OnPointerOutTrigger: number;
  18000. /**
  18001. * On every frame
  18002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18003. */
  18004. static readonly OnEveryFrameTrigger: number;
  18005. /**
  18006. * On intersection enter
  18007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18008. */
  18009. static readonly OnIntersectionEnterTrigger: number;
  18010. /**
  18011. * On intersection exit
  18012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18013. */
  18014. static readonly OnIntersectionExitTrigger: number;
  18015. /**
  18016. * On key down
  18017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18018. */
  18019. static readonly OnKeyDownTrigger: number;
  18020. /**
  18021. * On key up
  18022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18023. */
  18024. static readonly OnKeyUpTrigger: number;
  18025. private _scene;
  18026. /**
  18027. * Creates a new action manager
  18028. * @param scene defines the hosting scene
  18029. */
  18030. constructor(scene: Scene);
  18031. /**
  18032. * Releases all associated resources
  18033. */
  18034. dispose(): void;
  18035. /**
  18036. * Gets hosting scene
  18037. * @returns the hosting scene
  18038. */
  18039. getScene(): Scene;
  18040. /**
  18041. * Does this action manager handles actions of any of the given triggers
  18042. * @param triggers defines the triggers to be tested
  18043. * @return a boolean indicating whether one (or more) of the triggers is handled
  18044. */
  18045. hasSpecificTriggers(triggers: number[]): boolean;
  18046. /**
  18047. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18048. * speed.
  18049. * @param triggerA defines the trigger to be tested
  18050. * @param triggerB defines the trigger to be tested
  18051. * @return a boolean indicating whether one (or more) of the triggers is handled
  18052. */
  18053. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18054. /**
  18055. * Does this action manager handles actions of a given trigger
  18056. * @param trigger defines the trigger to be tested
  18057. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18058. * @return whether the trigger is handled
  18059. */
  18060. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18061. /**
  18062. * Does this action manager has pointer triggers
  18063. */
  18064. get hasPointerTriggers(): boolean;
  18065. /**
  18066. * Does this action manager has pick triggers
  18067. */
  18068. get hasPickTriggers(): boolean;
  18069. /**
  18070. * Registers an action to this action manager
  18071. * @param action defines the action to be registered
  18072. * @return the action amended (prepared) after registration
  18073. */
  18074. registerAction(action: IAction): Nullable<IAction>;
  18075. /**
  18076. * Unregisters an action to this action manager
  18077. * @param action defines the action to be unregistered
  18078. * @return a boolean indicating whether the action has been unregistered
  18079. */
  18080. unregisterAction(action: IAction): Boolean;
  18081. /**
  18082. * Process a specific trigger
  18083. * @param trigger defines the trigger to process
  18084. * @param evt defines the event details to be processed
  18085. */
  18086. processTrigger(trigger: number, evt?: IActionEvent): void;
  18087. /** @hidden */
  18088. _getEffectiveTarget(target: any, propertyPath: string): any;
  18089. /** @hidden */
  18090. _getProperty(propertyPath: string): string;
  18091. /**
  18092. * Serialize this manager to a JSON object
  18093. * @param name defines the property name to store this manager
  18094. * @returns a JSON representation of this manager
  18095. */
  18096. serialize(name: string): any;
  18097. /**
  18098. * Creates a new ActionManager from a JSON data
  18099. * @param parsedActions defines the JSON data to read from
  18100. * @param object defines the hosting mesh
  18101. * @param scene defines the hosting scene
  18102. */
  18103. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18104. /**
  18105. * Get a trigger name by index
  18106. * @param trigger defines the trigger index
  18107. * @returns a trigger name
  18108. */
  18109. static GetTriggerName(trigger: number): string;
  18110. }
  18111. }
  18112. declare module BABYLON {
  18113. /**
  18114. * Class used to represent a sprite
  18115. * @see http://doc.babylonjs.com/babylon101/sprites
  18116. */
  18117. export class Sprite {
  18118. /** defines the name */
  18119. name: string;
  18120. /** Gets or sets the current world position */
  18121. position: Vector3;
  18122. /** Gets or sets the main color */
  18123. color: Color4;
  18124. /** Gets or sets the width */
  18125. width: number;
  18126. /** Gets or sets the height */
  18127. height: number;
  18128. /** Gets or sets rotation angle */
  18129. angle: number;
  18130. /** Gets or sets the cell index in the sprite sheet */
  18131. cellIndex: number;
  18132. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18133. cellRef: string;
  18134. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18135. invertU: number;
  18136. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18137. invertV: number;
  18138. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18139. disposeWhenFinishedAnimating: boolean;
  18140. /** Gets the list of attached animations */
  18141. animations: Animation[];
  18142. /** Gets or sets a boolean indicating if the sprite can be picked */
  18143. isPickable: boolean;
  18144. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18145. useAlphaForPicking: boolean;
  18146. /** @hidden */
  18147. _xOffset: number;
  18148. /** @hidden */
  18149. _yOffset: number;
  18150. /** @hidden */
  18151. _xSize: number;
  18152. /** @hidden */
  18153. _ySize: number;
  18154. /**
  18155. * Gets or sets the associated action manager
  18156. */
  18157. actionManager: Nullable<ActionManager>;
  18158. /**
  18159. * An event triggered when the control has been disposed
  18160. */
  18161. onDisposeObservable: Observable<Sprite>;
  18162. private _animationStarted;
  18163. private _loopAnimation;
  18164. private _fromIndex;
  18165. private _toIndex;
  18166. private _delay;
  18167. private _direction;
  18168. private _manager;
  18169. private _time;
  18170. private _onAnimationEnd;
  18171. /**
  18172. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18173. */
  18174. isVisible: boolean;
  18175. /**
  18176. * Gets or sets the sprite size
  18177. */
  18178. get size(): number;
  18179. set size(value: number);
  18180. /**
  18181. * Creates a new Sprite
  18182. * @param name defines the name
  18183. * @param manager defines the manager
  18184. */
  18185. constructor(
  18186. /** defines the name */
  18187. name: string, manager: ISpriteManager);
  18188. /**
  18189. * Starts an animation
  18190. * @param from defines the initial key
  18191. * @param to defines the end key
  18192. * @param loop defines if the animation must loop
  18193. * @param delay defines the start delay (in ms)
  18194. * @param onAnimationEnd defines a callback to call when animation ends
  18195. */
  18196. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18197. /** Stops current animation (if any) */
  18198. stopAnimation(): void;
  18199. /** @hidden */
  18200. _animate(deltaTime: number): void;
  18201. /** Release associated resources */
  18202. dispose(): void;
  18203. }
  18204. }
  18205. declare module BABYLON {
  18206. /**
  18207. * Information about the result of picking within a scene
  18208. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18209. */
  18210. export class PickingInfo {
  18211. /** @hidden */
  18212. _pickingUnavailable: boolean;
  18213. /**
  18214. * If the pick collided with an object
  18215. */
  18216. hit: boolean;
  18217. /**
  18218. * Distance away where the pick collided
  18219. */
  18220. distance: number;
  18221. /**
  18222. * The location of pick collision
  18223. */
  18224. pickedPoint: Nullable<Vector3>;
  18225. /**
  18226. * The mesh corresponding the the pick collision
  18227. */
  18228. pickedMesh: Nullable<AbstractMesh>;
  18229. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18230. bu: number;
  18231. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18232. bv: number;
  18233. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18234. faceId: number;
  18235. /** Id of the the submesh that was picked */
  18236. subMeshId: number;
  18237. /** If a sprite was picked, this will be the sprite the pick collided with */
  18238. pickedSprite: Nullable<Sprite>;
  18239. /**
  18240. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18241. */
  18242. originMesh: Nullable<AbstractMesh>;
  18243. /**
  18244. * The ray that was used to perform the picking.
  18245. */
  18246. ray: Nullable<Ray>;
  18247. /**
  18248. * Gets the normal correspodning to the face the pick collided with
  18249. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18250. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18251. * @returns The normal correspodning to the face the pick collided with
  18252. */
  18253. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18254. /**
  18255. * Gets the texture coordinates of where the pick occured
  18256. * @returns the vector containing the coordnates of the texture
  18257. */
  18258. getTextureCoordinates(): Nullable<Vector2>;
  18259. }
  18260. }
  18261. declare module BABYLON {
  18262. /**
  18263. * Gather the list of pointer event types as constants.
  18264. */
  18265. export class PointerEventTypes {
  18266. /**
  18267. * 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.
  18268. */
  18269. static readonly POINTERDOWN: number;
  18270. /**
  18271. * The pointerup event is fired when a pointer is no longer active.
  18272. */
  18273. static readonly POINTERUP: number;
  18274. /**
  18275. * The pointermove event is fired when a pointer changes coordinates.
  18276. */
  18277. static readonly POINTERMOVE: number;
  18278. /**
  18279. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18280. */
  18281. static readonly POINTERWHEEL: number;
  18282. /**
  18283. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18284. */
  18285. static readonly POINTERPICK: number;
  18286. /**
  18287. * The pointertap event is fired when a the object has been touched and released without drag.
  18288. */
  18289. static readonly POINTERTAP: number;
  18290. /**
  18291. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18292. */
  18293. static readonly POINTERDOUBLETAP: number;
  18294. }
  18295. /**
  18296. * Base class of pointer info types.
  18297. */
  18298. export class PointerInfoBase {
  18299. /**
  18300. * Defines the type of event (PointerEventTypes)
  18301. */
  18302. type: number;
  18303. /**
  18304. * Defines the related dom event
  18305. */
  18306. event: PointerEvent | MouseWheelEvent;
  18307. /**
  18308. * Instantiates the base class of pointers info.
  18309. * @param type Defines the type of event (PointerEventTypes)
  18310. * @param event Defines the related dom event
  18311. */
  18312. constructor(
  18313. /**
  18314. * Defines the type of event (PointerEventTypes)
  18315. */
  18316. type: number,
  18317. /**
  18318. * Defines the related dom event
  18319. */
  18320. event: PointerEvent | MouseWheelEvent);
  18321. }
  18322. /**
  18323. * This class is used to store pointer related info for the onPrePointerObservable event.
  18324. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18325. */
  18326. export class PointerInfoPre extends PointerInfoBase {
  18327. /**
  18328. * Ray from a pointer if availible (eg. 6dof controller)
  18329. */
  18330. ray: Nullable<Ray>;
  18331. /**
  18332. * Defines the local position of the pointer on the canvas.
  18333. */
  18334. localPosition: Vector2;
  18335. /**
  18336. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18337. */
  18338. skipOnPointerObservable: boolean;
  18339. /**
  18340. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18341. * @param type Defines the type of event (PointerEventTypes)
  18342. * @param event Defines the related dom event
  18343. * @param localX Defines the local x coordinates of the pointer when the event occured
  18344. * @param localY Defines the local y coordinates of the pointer when the event occured
  18345. */
  18346. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18347. }
  18348. /**
  18349. * This type contains all the data related to a pointer event in Babylon.js.
  18350. * 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.
  18351. */
  18352. export class PointerInfo extends PointerInfoBase {
  18353. /**
  18354. * Defines the picking info associated to the info (if any)\
  18355. */
  18356. pickInfo: Nullable<PickingInfo>;
  18357. /**
  18358. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18359. * @param type Defines the type of event (PointerEventTypes)
  18360. * @param event Defines the related dom event
  18361. * @param pickInfo Defines the picking info associated to the info (if any)\
  18362. */
  18363. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18364. /**
  18365. * Defines the picking info associated to the info (if any)\
  18366. */
  18367. pickInfo: Nullable<PickingInfo>);
  18368. }
  18369. /**
  18370. * Data relating to a touch event on the screen.
  18371. */
  18372. export interface PointerTouch {
  18373. /**
  18374. * X coordinate of touch.
  18375. */
  18376. x: number;
  18377. /**
  18378. * Y coordinate of touch.
  18379. */
  18380. y: number;
  18381. /**
  18382. * Id of touch. Unique for each finger.
  18383. */
  18384. pointerId: number;
  18385. /**
  18386. * Event type passed from DOM.
  18387. */
  18388. type: any;
  18389. }
  18390. }
  18391. declare module BABYLON {
  18392. /**
  18393. * Manage the mouse inputs to control the movement of a free camera.
  18394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18395. */
  18396. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18397. /**
  18398. * Define if touch is enabled in the mouse input
  18399. */
  18400. touchEnabled: boolean;
  18401. /**
  18402. * Defines the camera the input is attached to.
  18403. */
  18404. camera: FreeCamera;
  18405. /**
  18406. * Defines the buttons associated with the input to handle camera move.
  18407. */
  18408. buttons: number[];
  18409. /**
  18410. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18411. */
  18412. angularSensibility: number;
  18413. private _pointerInput;
  18414. private _onMouseMove;
  18415. private _observer;
  18416. private previousPosition;
  18417. /**
  18418. * Observable for when a pointer move event occurs containing the move offset
  18419. */
  18420. onPointerMovedObservable: Observable<{
  18421. offsetX: number;
  18422. offsetY: number;
  18423. }>;
  18424. /**
  18425. * @hidden
  18426. * If the camera should be rotated automatically based on pointer movement
  18427. */
  18428. _allowCameraRotation: boolean;
  18429. /**
  18430. * Manage the mouse inputs to control the movement of a free camera.
  18431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18432. * @param touchEnabled Defines if touch is enabled or not
  18433. */
  18434. constructor(
  18435. /**
  18436. * Define if touch is enabled in the mouse input
  18437. */
  18438. touchEnabled?: boolean);
  18439. /**
  18440. * Attach the input controls to a specific dom element to get the input from.
  18441. * @param element Defines the element the controls should be listened from
  18442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18443. */
  18444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18445. /**
  18446. * Called on JS contextmenu event.
  18447. * Override this method to provide functionality.
  18448. */
  18449. protected onContextMenu(evt: PointerEvent): void;
  18450. /**
  18451. * Detach the current controls from the specified dom element.
  18452. * @param element Defines the element to stop listening the inputs from
  18453. */
  18454. detachControl(element: Nullable<HTMLElement>): void;
  18455. /**
  18456. * Gets the class name of the current intput.
  18457. * @returns the class name
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Get the friendly name associated with the input class.
  18462. * @returns the input friendly name
  18463. */
  18464. getSimpleName(): string;
  18465. }
  18466. }
  18467. declare module BABYLON {
  18468. /**
  18469. * Manage the touch inputs to control the movement of a free camera.
  18470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18471. */
  18472. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18473. /**
  18474. * Defines the camera the input is attached to.
  18475. */
  18476. camera: FreeCamera;
  18477. /**
  18478. * Defines the touch sensibility for rotation.
  18479. * The higher the faster.
  18480. */
  18481. touchAngularSensibility: number;
  18482. /**
  18483. * Defines the touch sensibility for move.
  18484. * The higher the faster.
  18485. */
  18486. touchMoveSensibility: number;
  18487. private _offsetX;
  18488. private _offsetY;
  18489. private _pointerPressed;
  18490. private _pointerInput;
  18491. private _observer;
  18492. private _onLostFocus;
  18493. /**
  18494. * Attach the input controls to a specific dom element to get the input from.
  18495. * @param element Defines the element the controls should be listened from
  18496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18497. */
  18498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18499. /**
  18500. * Detach the current controls from the specified dom element.
  18501. * @param element Defines the element to stop listening the inputs from
  18502. */
  18503. detachControl(element: Nullable<HTMLElement>): void;
  18504. /**
  18505. * Update the current camera state depending on the inputs that have been used this frame.
  18506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18507. */
  18508. checkInputs(): void;
  18509. /**
  18510. * Gets the class name of the current intput.
  18511. * @returns the class name
  18512. */
  18513. getClassName(): string;
  18514. /**
  18515. * Get the friendly name associated with the input class.
  18516. * @returns the input friendly name
  18517. */
  18518. getSimpleName(): string;
  18519. }
  18520. }
  18521. declare module BABYLON {
  18522. /**
  18523. * Default Inputs manager for the FreeCamera.
  18524. * It groups all the default supported inputs for ease of use.
  18525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18526. */
  18527. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18528. /**
  18529. * @hidden
  18530. */
  18531. _mouseInput: Nullable<FreeCameraMouseInput>;
  18532. /**
  18533. * Instantiates a new FreeCameraInputsManager.
  18534. * @param camera Defines the camera the inputs belong to
  18535. */
  18536. constructor(camera: FreeCamera);
  18537. /**
  18538. * Add keyboard input support to the input manager.
  18539. * @returns the current input manager
  18540. */
  18541. addKeyboard(): FreeCameraInputsManager;
  18542. /**
  18543. * Add mouse input support to the input manager.
  18544. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18545. * @returns the current input manager
  18546. */
  18547. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18548. /**
  18549. * Removes the mouse input support from the manager
  18550. * @returns the current input manager
  18551. */
  18552. removeMouse(): FreeCameraInputsManager;
  18553. /**
  18554. * Add touch input support to the input manager.
  18555. * @returns the current input manager
  18556. */
  18557. addTouch(): FreeCameraInputsManager;
  18558. /**
  18559. * Remove all attached input methods from a camera
  18560. */
  18561. clear(): void;
  18562. }
  18563. }
  18564. declare module BABYLON {
  18565. /**
  18566. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18567. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18569. */
  18570. export class FreeCamera extends TargetCamera {
  18571. /**
  18572. * Define the collision ellipsoid of the camera.
  18573. * This is helpful to simulate a camera body like the player body around the camera
  18574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18575. */
  18576. ellipsoid: Vector3;
  18577. /**
  18578. * Define an offset for the position of the ellipsoid around the camera.
  18579. * This can be helpful to determine the center of the body near the gravity center of the body
  18580. * instead of its head.
  18581. */
  18582. ellipsoidOffset: Vector3;
  18583. /**
  18584. * Enable or disable collisions of the camera with the rest of the scene objects.
  18585. */
  18586. checkCollisions: boolean;
  18587. /**
  18588. * Enable or disable gravity on the camera.
  18589. */
  18590. applyGravity: boolean;
  18591. /**
  18592. * Define the input manager associated to the camera.
  18593. */
  18594. inputs: FreeCameraInputsManager;
  18595. /**
  18596. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18597. * Higher values reduce sensitivity.
  18598. */
  18599. get angularSensibility(): number;
  18600. /**
  18601. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18602. * Higher values reduce sensitivity.
  18603. */
  18604. set angularSensibility(value: number);
  18605. /**
  18606. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18607. */
  18608. get keysUp(): number[];
  18609. set keysUp(value: number[]);
  18610. /**
  18611. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18612. */
  18613. get keysUpward(): number[];
  18614. set keysUpward(value: number[]);
  18615. /**
  18616. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18617. */
  18618. get keysDown(): number[];
  18619. set keysDown(value: number[]);
  18620. /**
  18621. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18622. */
  18623. get keysDownward(): number[];
  18624. set keysDownward(value: number[]);
  18625. /**
  18626. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18627. */
  18628. get keysLeft(): number[];
  18629. set keysLeft(value: number[]);
  18630. /**
  18631. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18632. */
  18633. get keysRight(): number[];
  18634. set keysRight(value: number[]);
  18635. /**
  18636. * Event raised when the camera collide with a mesh in the scene.
  18637. */
  18638. onCollide: (collidedMesh: AbstractMesh) => void;
  18639. private _collider;
  18640. private _needMoveForGravity;
  18641. private _oldPosition;
  18642. private _diffPosition;
  18643. private _newPosition;
  18644. /** @hidden */
  18645. _localDirection: Vector3;
  18646. /** @hidden */
  18647. _transformedDirection: Vector3;
  18648. /**
  18649. * Instantiates a Free Camera.
  18650. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18651. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18652. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18653. * @param name Define the name of the camera in the scene
  18654. * @param position Define the start position of the camera in the scene
  18655. * @param scene Define the scene the camera belongs to
  18656. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18657. */
  18658. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18659. /**
  18660. * Attached controls to the current camera.
  18661. * @param element Defines the element the controls should be listened from
  18662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18663. */
  18664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18665. /**
  18666. * Detach the current controls from the camera.
  18667. * The camera will stop reacting to inputs.
  18668. * @param element Defines the element to stop listening the inputs from
  18669. */
  18670. detachControl(element: HTMLElement): void;
  18671. private _collisionMask;
  18672. /**
  18673. * Define a collision mask to limit the list of object the camera can collide with
  18674. */
  18675. get collisionMask(): number;
  18676. set collisionMask(mask: number);
  18677. /** @hidden */
  18678. _collideWithWorld(displacement: Vector3): void;
  18679. private _onCollisionPositionChange;
  18680. /** @hidden */
  18681. _checkInputs(): void;
  18682. /** @hidden */
  18683. _decideIfNeedsToMove(): boolean;
  18684. /** @hidden */
  18685. _updatePosition(): void;
  18686. /**
  18687. * Destroy the camera and release the current resources hold by it.
  18688. */
  18689. dispose(): void;
  18690. /**
  18691. * Gets the current object class name.
  18692. * @return the class name
  18693. */
  18694. getClassName(): string;
  18695. }
  18696. }
  18697. declare module BABYLON {
  18698. /**
  18699. * Represents a gamepad control stick position
  18700. */
  18701. export class StickValues {
  18702. /**
  18703. * The x component of the control stick
  18704. */
  18705. x: number;
  18706. /**
  18707. * The y component of the control stick
  18708. */
  18709. y: number;
  18710. /**
  18711. * Initializes the gamepad x and y control stick values
  18712. * @param x The x component of the gamepad control stick value
  18713. * @param y The y component of the gamepad control stick value
  18714. */
  18715. constructor(
  18716. /**
  18717. * The x component of the control stick
  18718. */
  18719. x: number,
  18720. /**
  18721. * The y component of the control stick
  18722. */
  18723. y: number);
  18724. }
  18725. /**
  18726. * An interface which manages callbacks for gamepad button changes
  18727. */
  18728. export interface GamepadButtonChanges {
  18729. /**
  18730. * Called when a gamepad has been changed
  18731. */
  18732. changed: boolean;
  18733. /**
  18734. * Called when a gamepad press event has been triggered
  18735. */
  18736. pressChanged: boolean;
  18737. /**
  18738. * Called when a touch event has been triggered
  18739. */
  18740. touchChanged: boolean;
  18741. /**
  18742. * Called when a value has changed
  18743. */
  18744. valueChanged: boolean;
  18745. }
  18746. /**
  18747. * Represents a gamepad
  18748. */
  18749. export class Gamepad {
  18750. /**
  18751. * The id of the gamepad
  18752. */
  18753. id: string;
  18754. /**
  18755. * The index of the gamepad
  18756. */
  18757. index: number;
  18758. /**
  18759. * The browser gamepad
  18760. */
  18761. browserGamepad: any;
  18762. /**
  18763. * Specifies what type of gamepad this represents
  18764. */
  18765. type: number;
  18766. private _leftStick;
  18767. private _rightStick;
  18768. /** @hidden */
  18769. _isConnected: boolean;
  18770. private _leftStickAxisX;
  18771. private _leftStickAxisY;
  18772. private _rightStickAxisX;
  18773. private _rightStickAxisY;
  18774. /**
  18775. * Triggered when the left control stick has been changed
  18776. */
  18777. private _onleftstickchanged;
  18778. /**
  18779. * Triggered when the right control stick has been changed
  18780. */
  18781. private _onrightstickchanged;
  18782. /**
  18783. * Represents a gamepad controller
  18784. */
  18785. static GAMEPAD: number;
  18786. /**
  18787. * Represents a generic controller
  18788. */
  18789. static GENERIC: number;
  18790. /**
  18791. * Represents an XBox controller
  18792. */
  18793. static XBOX: number;
  18794. /**
  18795. * Represents a pose-enabled controller
  18796. */
  18797. static POSE_ENABLED: number;
  18798. /**
  18799. * Represents an Dual Shock controller
  18800. */
  18801. static DUALSHOCK: number;
  18802. /**
  18803. * Specifies whether the left control stick should be Y-inverted
  18804. */
  18805. protected _invertLeftStickY: boolean;
  18806. /**
  18807. * Specifies if the gamepad has been connected
  18808. */
  18809. get isConnected(): boolean;
  18810. /**
  18811. * Initializes the gamepad
  18812. * @param id The id of the gamepad
  18813. * @param index The index of the gamepad
  18814. * @param browserGamepad The browser gamepad
  18815. * @param leftStickX The x component of the left joystick
  18816. * @param leftStickY The y component of the left joystick
  18817. * @param rightStickX The x component of the right joystick
  18818. * @param rightStickY The y component of the right joystick
  18819. */
  18820. constructor(
  18821. /**
  18822. * The id of the gamepad
  18823. */
  18824. id: string,
  18825. /**
  18826. * The index of the gamepad
  18827. */
  18828. index: number,
  18829. /**
  18830. * The browser gamepad
  18831. */
  18832. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18833. /**
  18834. * Callback triggered when the left joystick has changed
  18835. * @param callback
  18836. */
  18837. onleftstickchanged(callback: (values: StickValues) => void): void;
  18838. /**
  18839. * Callback triggered when the right joystick has changed
  18840. * @param callback
  18841. */
  18842. onrightstickchanged(callback: (values: StickValues) => void): void;
  18843. /**
  18844. * Gets the left joystick
  18845. */
  18846. get leftStick(): StickValues;
  18847. /**
  18848. * Sets the left joystick values
  18849. */
  18850. set leftStick(newValues: StickValues);
  18851. /**
  18852. * Gets the right joystick
  18853. */
  18854. get rightStick(): StickValues;
  18855. /**
  18856. * Sets the right joystick value
  18857. */
  18858. set rightStick(newValues: StickValues);
  18859. /**
  18860. * Updates the gamepad joystick positions
  18861. */
  18862. update(): void;
  18863. /**
  18864. * Disposes the gamepad
  18865. */
  18866. dispose(): void;
  18867. }
  18868. /**
  18869. * Represents a generic gamepad
  18870. */
  18871. export class GenericPad extends Gamepad {
  18872. private _buttons;
  18873. private _onbuttondown;
  18874. private _onbuttonup;
  18875. /**
  18876. * Observable triggered when a button has been pressed
  18877. */
  18878. onButtonDownObservable: Observable<number>;
  18879. /**
  18880. * Observable triggered when a button has been released
  18881. */
  18882. onButtonUpObservable: Observable<number>;
  18883. /**
  18884. * Callback triggered when a button has been pressed
  18885. * @param callback Called when a button has been pressed
  18886. */
  18887. onbuttondown(callback: (buttonPressed: number) => void): void;
  18888. /**
  18889. * Callback triggered when a button has been released
  18890. * @param callback Called when a button has been released
  18891. */
  18892. onbuttonup(callback: (buttonReleased: number) => void): void;
  18893. /**
  18894. * Initializes the generic gamepad
  18895. * @param id The id of the generic gamepad
  18896. * @param index The index of the generic gamepad
  18897. * @param browserGamepad The browser gamepad
  18898. */
  18899. constructor(id: string, index: number, browserGamepad: any);
  18900. private _setButtonValue;
  18901. /**
  18902. * Updates the generic gamepad
  18903. */
  18904. update(): void;
  18905. /**
  18906. * Disposes the generic gamepad
  18907. */
  18908. dispose(): void;
  18909. }
  18910. }
  18911. declare module BABYLON {
  18912. /**
  18913. * Defines the types of pose enabled controllers that are supported
  18914. */
  18915. export enum PoseEnabledControllerType {
  18916. /**
  18917. * HTC Vive
  18918. */
  18919. VIVE = 0,
  18920. /**
  18921. * Oculus Rift
  18922. */
  18923. OCULUS = 1,
  18924. /**
  18925. * Windows mixed reality
  18926. */
  18927. WINDOWS = 2,
  18928. /**
  18929. * Samsung gear VR
  18930. */
  18931. GEAR_VR = 3,
  18932. /**
  18933. * Google Daydream
  18934. */
  18935. DAYDREAM = 4,
  18936. /**
  18937. * Generic
  18938. */
  18939. GENERIC = 5
  18940. }
  18941. /**
  18942. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18943. */
  18944. export interface MutableGamepadButton {
  18945. /**
  18946. * Value of the button/trigger
  18947. */
  18948. value: number;
  18949. /**
  18950. * If the button/trigger is currently touched
  18951. */
  18952. touched: boolean;
  18953. /**
  18954. * If the button/trigger is currently pressed
  18955. */
  18956. pressed: boolean;
  18957. }
  18958. /**
  18959. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18960. * @hidden
  18961. */
  18962. export interface ExtendedGamepadButton extends GamepadButton {
  18963. /**
  18964. * If the button/trigger is currently pressed
  18965. */
  18966. readonly pressed: boolean;
  18967. /**
  18968. * If the button/trigger is currently touched
  18969. */
  18970. readonly touched: boolean;
  18971. /**
  18972. * Value of the button/trigger
  18973. */
  18974. readonly value: number;
  18975. }
  18976. /** @hidden */
  18977. export interface _GamePadFactory {
  18978. /**
  18979. * Returns whether or not the current gamepad can be created for this type of controller.
  18980. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18981. * @returns true if it can be created, otherwise false
  18982. */
  18983. canCreate(gamepadInfo: any): boolean;
  18984. /**
  18985. * Creates a new instance of the Gamepad.
  18986. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18987. * @returns the new gamepad instance
  18988. */
  18989. create(gamepadInfo: any): Gamepad;
  18990. }
  18991. /**
  18992. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18993. */
  18994. export class PoseEnabledControllerHelper {
  18995. /** @hidden */
  18996. static _ControllerFactories: _GamePadFactory[];
  18997. /** @hidden */
  18998. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18999. /**
  19000. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19001. * @param vrGamepad the gamepad to initialized
  19002. * @returns a vr controller of the type the gamepad identified as
  19003. */
  19004. static InitiateController(vrGamepad: any): Gamepad;
  19005. }
  19006. /**
  19007. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19008. */
  19009. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19010. /**
  19011. * If the controller is used in a webXR session
  19012. */
  19013. isXR: boolean;
  19014. private _deviceRoomPosition;
  19015. private _deviceRoomRotationQuaternion;
  19016. /**
  19017. * The device position in babylon space
  19018. */
  19019. devicePosition: Vector3;
  19020. /**
  19021. * The device rotation in babylon space
  19022. */
  19023. deviceRotationQuaternion: Quaternion;
  19024. /**
  19025. * The scale factor of the device in babylon space
  19026. */
  19027. deviceScaleFactor: number;
  19028. /**
  19029. * (Likely devicePosition should be used instead) The device position in its room space
  19030. */
  19031. position: Vector3;
  19032. /**
  19033. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19034. */
  19035. rotationQuaternion: Quaternion;
  19036. /**
  19037. * The type of controller (Eg. Windows mixed reality)
  19038. */
  19039. controllerType: PoseEnabledControllerType;
  19040. protected _calculatedPosition: Vector3;
  19041. private _calculatedRotation;
  19042. /**
  19043. * The raw pose from the device
  19044. */
  19045. rawPose: DevicePose;
  19046. private _trackPosition;
  19047. private _maxRotationDistFromHeadset;
  19048. private _draggedRoomRotation;
  19049. /**
  19050. * @hidden
  19051. */
  19052. _disableTrackPosition(fixedPosition: Vector3): void;
  19053. /**
  19054. * Internal, the mesh attached to the controller
  19055. * @hidden
  19056. */
  19057. _mesh: Nullable<AbstractMesh>;
  19058. private _poseControlledCamera;
  19059. private _leftHandSystemQuaternion;
  19060. /**
  19061. * Internal, matrix used to convert room space to babylon space
  19062. * @hidden
  19063. */
  19064. _deviceToWorld: Matrix;
  19065. /**
  19066. * Node to be used when casting a ray from the controller
  19067. * @hidden
  19068. */
  19069. _pointingPoseNode: Nullable<TransformNode>;
  19070. /**
  19071. * Name of the child mesh that can be used to cast a ray from the controller
  19072. */
  19073. static readonly POINTING_POSE: string;
  19074. /**
  19075. * Creates a new PoseEnabledController from a gamepad
  19076. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19077. */
  19078. constructor(browserGamepad: any);
  19079. private _workingMatrix;
  19080. /**
  19081. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19082. */
  19083. update(): void;
  19084. /**
  19085. * Updates only the pose device and mesh without doing any button event checking
  19086. */
  19087. protected _updatePoseAndMesh(): void;
  19088. /**
  19089. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19090. * @param poseData raw pose fromthe device
  19091. */
  19092. updateFromDevice(poseData: DevicePose): void;
  19093. /**
  19094. * @hidden
  19095. */
  19096. _meshAttachedObservable: Observable<AbstractMesh>;
  19097. /**
  19098. * Attaches a mesh to the controller
  19099. * @param mesh the mesh to be attached
  19100. */
  19101. attachToMesh(mesh: AbstractMesh): void;
  19102. /**
  19103. * Attaches the controllers mesh to a camera
  19104. * @param camera the camera the mesh should be attached to
  19105. */
  19106. attachToPoseControlledCamera(camera: TargetCamera): void;
  19107. /**
  19108. * Disposes of the controller
  19109. */
  19110. dispose(): void;
  19111. /**
  19112. * The mesh that is attached to the controller
  19113. */
  19114. get mesh(): Nullable<AbstractMesh>;
  19115. /**
  19116. * Gets the ray of the controller in the direction the controller is pointing
  19117. * @param length the length the resulting ray should be
  19118. * @returns a ray in the direction the controller is pointing
  19119. */
  19120. getForwardRay(length?: number): Ray;
  19121. }
  19122. }
  19123. declare module BABYLON {
  19124. /**
  19125. * Defines the WebVRController object that represents controllers tracked in 3D space
  19126. */
  19127. export abstract class WebVRController extends PoseEnabledController {
  19128. /**
  19129. * Internal, the default controller model for the controller
  19130. */
  19131. protected _defaultModel: Nullable<AbstractMesh>;
  19132. /**
  19133. * Fired when the trigger state has changed
  19134. */
  19135. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19136. /**
  19137. * Fired when the main button state has changed
  19138. */
  19139. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19140. /**
  19141. * Fired when the secondary button state has changed
  19142. */
  19143. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19144. /**
  19145. * Fired when the pad state has changed
  19146. */
  19147. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19148. /**
  19149. * Fired when controllers stick values have changed
  19150. */
  19151. onPadValuesChangedObservable: Observable<StickValues>;
  19152. /**
  19153. * Array of button availible on the controller
  19154. */
  19155. protected _buttons: Array<MutableGamepadButton>;
  19156. private _onButtonStateChange;
  19157. /**
  19158. * Fired when a controller button's state has changed
  19159. * @param callback the callback containing the button that was modified
  19160. */
  19161. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19162. /**
  19163. * X and Y axis corresponding to the controllers joystick
  19164. */
  19165. pad: StickValues;
  19166. /**
  19167. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19168. */
  19169. hand: string;
  19170. /**
  19171. * The default controller model for the controller
  19172. */
  19173. get defaultModel(): Nullable<AbstractMesh>;
  19174. /**
  19175. * Creates a new WebVRController from a gamepad
  19176. * @param vrGamepad the gamepad that the WebVRController should be created from
  19177. */
  19178. constructor(vrGamepad: any);
  19179. /**
  19180. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19181. */
  19182. update(): void;
  19183. /**
  19184. * Function to be called when a button is modified
  19185. */
  19186. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19187. /**
  19188. * Loads a mesh and attaches it to the controller
  19189. * @param scene the scene the mesh should be added to
  19190. * @param meshLoaded callback for when the mesh has been loaded
  19191. */
  19192. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19193. private _setButtonValue;
  19194. private _changes;
  19195. private _checkChanges;
  19196. /**
  19197. * Disposes of th webVRCOntroller
  19198. */
  19199. dispose(): void;
  19200. }
  19201. }
  19202. declare module BABYLON {
  19203. /**
  19204. * The HemisphericLight simulates the ambient environment light,
  19205. * so the passed direction is the light reflection direction, not the incoming direction.
  19206. */
  19207. export class HemisphericLight extends Light {
  19208. /**
  19209. * The groundColor is the light in the opposite direction to the one specified during creation.
  19210. * 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.
  19211. */
  19212. groundColor: Color3;
  19213. /**
  19214. * The light reflection direction, not the incoming direction.
  19215. */
  19216. direction: Vector3;
  19217. /**
  19218. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19219. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19220. * The HemisphericLight can't cast shadows.
  19221. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19222. * @param name The friendly name of the light
  19223. * @param direction The direction of the light reflection
  19224. * @param scene The scene the light belongs to
  19225. */
  19226. constructor(name: string, direction: Vector3, scene: Scene);
  19227. protected _buildUniformLayout(): void;
  19228. /**
  19229. * Returns the string "HemisphericLight".
  19230. * @return The class name
  19231. */
  19232. getClassName(): string;
  19233. /**
  19234. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19235. * Returns the updated direction.
  19236. * @param target The target the direction should point to
  19237. * @return The computed direction
  19238. */
  19239. setDirectionToTarget(target: Vector3): Vector3;
  19240. /**
  19241. * Returns the shadow generator associated to the light.
  19242. * @returns Always null for hemispheric lights because it does not support shadows.
  19243. */
  19244. getShadowGenerator(): Nullable<IShadowGenerator>;
  19245. /**
  19246. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19247. * @param effect The effect to update
  19248. * @param lightIndex The index of the light in the effect to update
  19249. * @returns The hemispheric light
  19250. */
  19251. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19252. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19253. /**
  19254. * Computes the world matrix of the node
  19255. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19256. * @param useWasUpdatedFlag defines a reserved property
  19257. * @returns the world matrix
  19258. */
  19259. computeWorldMatrix(): Matrix;
  19260. /**
  19261. * Returns the integer 3.
  19262. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19263. */
  19264. getTypeID(): number;
  19265. /**
  19266. * Prepares the list of defines specific to the light type.
  19267. * @param defines the list of defines
  19268. * @param lightIndex defines the index of the light for the effect
  19269. */
  19270. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19271. }
  19272. }
  19273. declare module BABYLON {
  19274. /** @hidden */
  19275. export var vrMultiviewToSingleviewPixelShader: {
  19276. name: string;
  19277. shader: string;
  19278. };
  19279. }
  19280. declare module BABYLON {
  19281. /**
  19282. * Renders to multiple views with a single draw call
  19283. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19284. */
  19285. export class MultiviewRenderTarget extends RenderTargetTexture {
  19286. /**
  19287. * Creates a multiview render target
  19288. * @param scene scene used with the render target
  19289. * @param size the size of the render target (used for each view)
  19290. */
  19291. constructor(scene: Scene, size?: number | {
  19292. width: number;
  19293. height: number;
  19294. } | {
  19295. ratio: number;
  19296. });
  19297. /**
  19298. * @hidden
  19299. * @param faceIndex the face index, if its a cube texture
  19300. */
  19301. _bindFrameBuffer(faceIndex?: number): void;
  19302. /**
  19303. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19304. * @returns the view count
  19305. */
  19306. getViewCount(): number;
  19307. }
  19308. }
  19309. declare module BABYLON {
  19310. /**
  19311. * Represents a camera frustum
  19312. */
  19313. export class Frustum {
  19314. /**
  19315. * Gets the planes representing the frustum
  19316. * @param transform matrix to be applied to the returned planes
  19317. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19318. */
  19319. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19320. /**
  19321. * Gets the near frustum plane transformed by the transform matrix
  19322. * @param transform transformation matrix to be applied to the resulting frustum plane
  19323. * @param frustumPlane the resuling frustum plane
  19324. */
  19325. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19326. /**
  19327. * Gets the far frustum plane transformed by the transform matrix
  19328. * @param transform transformation matrix to be applied to the resulting frustum plane
  19329. * @param frustumPlane the resuling frustum plane
  19330. */
  19331. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19332. /**
  19333. * Gets the left frustum plane transformed by the transform matrix
  19334. * @param transform transformation matrix to be applied to the resulting frustum plane
  19335. * @param frustumPlane the resuling frustum plane
  19336. */
  19337. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19338. /**
  19339. * Gets the right frustum plane transformed by the transform matrix
  19340. * @param transform transformation matrix to be applied to the resulting frustum plane
  19341. * @param frustumPlane the resuling frustum plane
  19342. */
  19343. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19344. /**
  19345. * Gets the top frustum plane transformed by the transform matrix
  19346. * @param transform transformation matrix to be applied to the resulting frustum plane
  19347. * @param frustumPlane the resuling frustum plane
  19348. */
  19349. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19350. /**
  19351. * Gets the bottom frustum plane transformed by the transform matrix
  19352. * @param transform transformation matrix to be applied to the resulting frustum plane
  19353. * @param frustumPlane the resuling frustum plane
  19354. */
  19355. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19356. /**
  19357. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19358. * @param transform transformation matrix to be applied to the resulting frustum planes
  19359. * @param frustumPlanes the resuling frustum planes
  19360. */
  19361. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19362. }
  19363. }
  19364. declare module BABYLON {
  19365. interface Engine {
  19366. /**
  19367. * Creates a new multiview render target
  19368. * @param width defines the width of the texture
  19369. * @param height defines the height of the texture
  19370. * @returns the created multiview texture
  19371. */
  19372. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19373. /**
  19374. * Binds a multiview framebuffer to be drawn to
  19375. * @param multiviewTexture texture to bind
  19376. */
  19377. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19378. }
  19379. interface Camera {
  19380. /**
  19381. * @hidden
  19382. * 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)
  19383. */
  19384. _useMultiviewToSingleView: boolean;
  19385. /**
  19386. * @hidden
  19387. * 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)
  19388. */
  19389. _multiviewTexture: Nullable<RenderTargetTexture>;
  19390. /**
  19391. * @hidden
  19392. * ensures the multiview texture of the camera exists and has the specified width/height
  19393. * @param width height to set on the multiview texture
  19394. * @param height width to set on the multiview texture
  19395. */
  19396. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19397. }
  19398. interface Scene {
  19399. /** @hidden */
  19400. _transformMatrixR: Matrix;
  19401. /** @hidden */
  19402. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19403. /** @hidden */
  19404. _createMultiviewUbo(): void;
  19405. /** @hidden */
  19406. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19407. /** @hidden */
  19408. _renderMultiviewToSingleView(camera: Camera): void;
  19409. }
  19410. }
  19411. declare module BABYLON {
  19412. /**
  19413. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19414. * This will not be used for webXR as it supports displaying texture arrays directly
  19415. */
  19416. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19417. /**
  19418. * Initializes a VRMultiviewToSingleview
  19419. * @param name name of the post process
  19420. * @param camera camera to be applied to
  19421. * @param scaleFactor scaling factor to the size of the output texture
  19422. */
  19423. constructor(name: string, camera: Camera, scaleFactor: number);
  19424. }
  19425. }
  19426. declare module BABYLON {
  19427. /**
  19428. * Interface used to define additional presentation attributes
  19429. */
  19430. export interface IVRPresentationAttributes {
  19431. /**
  19432. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19433. */
  19434. highRefreshRate: boolean;
  19435. /**
  19436. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19437. */
  19438. foveationLevel: number;
  19439. }
  19440. interface Engine {
  19441. /** @hidden */
  19442. _vrDisplay: any;
  19443. /** @hidden */
  19444. _vrSupported: boolean;
  19445. /** @hidden */
  19446. _oldSize: Size;
  19447. /** @hidden */
  19448. _oldHardwareScaleFactor: number;
  19449. /** @hidden */
  19450. _vrExclusivePointerMode: boolean;
  19451. /** @hidden */
  19452. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19453. /** @hidden */
  19454. _onVRDisplayPointerRestricted: () => void;
  19455. /** @hidden */
  19456. _onVRDisplayPointerUnrestricted: () => void;
  19457. /** @hidden */
  19458. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19459. /** @hidden */
  19460. _onVrDisplayDisconnect: Nullable<() => void>;
  19461. /** @hidden */
  19462. _onVrDisplayPresentChange: Nullable<() => void>;
  19463. /**
  19464. * Observable signaled when VR display mode changes
  19465. */
  19466. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19467. /**
  19468. * Observable signaled when VR request present is complete
  19469. */
  19470. onVRRequestPresentComplete: Observable<boolean>;
  19471. /**
  19472. * Observable signaled when VR request present starts
  19473. */
  19474. onVRRequestPresentStart: Observable<Engine>;
  19475. /**
  19476. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19477. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19478. */
  19479. isInVRExclusivePointerMode: boolean;
  19480. /**
  19481. * Gets a boolean indicating if a webVR device was detected
  19482. * @returns true if a webVR device was detected
  19483. */
  19484. isVRDevicePresent(): boolean;
  19485. /**
  19486. * Gets the current webVR device
  19487. * @returns the current webVR device (or null)
  19488. */
  19489. getVRDevice(): any;
  19490. /**
  19491. * Initializes a webVR display and starts listening to display change events
  19492. * The onVRDisplayChangedObservable will be notified upon these changes
  19493. * @returns A promise containing a VRDisplay and if vr is supported
  19494. */
  19495. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19496. /** @hidden */
  19497. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19498. /**
  19499. * Gets or sets the presentation attributes used to configure VR rendering
  19500. */
  19501. vrPresentationAttributes?: IVRPresentationAttributes;
  19502. /**
  19503. * Call this function to switch to webVR mode
  19504. * Will do nothing if webVR is not supported or if there is no webVR device
  19505. * @param options the webvr options provided to the camera. mainly used for multiview
  19506. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19507. */
  19508. enableVR(options: WebVROptions): void;
  19509. /** @hidden */
  19510. _onVRFullScreenTriggered(): void;
  19511. }
  19512. }
  19513. declare module BABYLON {
  19514. /**
  19515. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19516. * IMPORTANT!! The data is right-hand data.
  19517. * @export
  19518. * @interface DevicePose
  19519. */
  19520. export interface DevicePose {
  19521. /**
  19522. * The position of the device, values in array are [x,y,z].
  19523. */
  19524. readonly position: Nullable<Float32Array>;
  19525. /**
  19526. * The linearVelocity of the device, values in array are [x,y,z].
  19527. */
  19528. readonly linearVelocity: Nullable<Float32Array>;
  19529. /**
  19530. * The linearAcceleration of the device, values in array are [x,y,z].
  19531. */
  19532. readonly linearAcceleration: Nullable<Float32Array>;
  19533. /**
  19534. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19535. */
  19536. readonly orientation: Nullable<Float32Array>;
  19537. /**
  19538. * The angularVelocity of the device, values in array are [x,y,z].
  19539. */
  19540. readonly angularVelocity: Nullable<Float32Array>;
  19541. /**
  19542. * The angularAcceleration of the device, values in array are [x,y,z].
  19543. */
  19544. readonly angularAcceleration: Nullable<Float32Array>;
  19545. }
  19546. /**
  19547. * Interface representing a pose controlled object in Babylon.
  19548. * A pose controlled object has both regular pose values as well as pose values
  19549. * from an external device such as a VR head mounted display
  19550. */
  19551. export interface PoseControlled {
  19552. /**
  19553. * The position of the object in babylon space.
  19554. */
  19555. position: Vector3;
  19556. /**
  19557. * The rotation quaternion of the object in babylon space.
  19558. */
  19559. rotationQuaternion: Quaternion;
  19560. /**
  19561. * The position of the device in babylon space.
  19562. */
  19563. devicePosition?: Vector3;
  19564. /**
  19565. * The rotation quaternion of the device in babylon space.
  19566. */
  19567. deviceRotationQuaternion: Quaternion;
  19568. /**
  19569. * The raw pose coming from the device.
  19570. */
  19571. rawPose: Nullable<DevicePose>;
  19572. /**
  19573. * The scale of the device to be used when translating from device space to babylon space.
  19574. */
  19575. deviceScaleFactor: number;
  19576. /**
  19577. * Updates the poseControlled values based on the input device pose.
  19578. * @param poseData the pose data to update the object with
  19579. */
  19580. updateFromDevice(poseData: DevicePose): void;
  19581. }
  19582. /**
  19583. * Set of options to customize the webVRCamera
  19584. */
  19585. export interface WebVROptions {
  19586. /**
  19587. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19588. */
  19589. trackPosition?: boolean;
  19590. /**
  19591. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19592. */
  19593. positionScale?: number;
  19594. /**
  19595. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19596. */
  19597. displayName?: string;
  19598. /**
  19599. * Should the native controller meshes be initialized. (default: true)
  19600. */
  19601. controllerMeshes?: boolean;
  19602. /**
  19603. * Creating a default HemiLight only on controllers. (default: true)
  19604. */
  19605. defaultLightingOnControllers?: boolean;
  19606. /**
  19607. * If you don't want to use the default VR button of the helper. (default: false)
  19608. */
  19609. useCustomVRButton?: boolean;
  19610. /**
  19611. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19612. */
  19613. customVRButton?: HTMLButtonElement;
  19614. /**
  19615. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19616. */
  19617. rayLength?: number;
  19618. /**
  19619. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19620. */
  19621. defaultHeight?: number;
  19622. /**
  19623. * If multiview should be used if availible (default: false)
  19624. */
  19625. useMultiview?: boolean;
  19626. }
  19627. /**
  19628. * This represents a WebVR camera.
  19629. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19630. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19631. */
  19632. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19633. private webVROptions;
  19634. /**
  19635. * @hidden
  19636. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19637. */
  19638. _vrDevice: any;
  19639. /**
  19640. * The rawPose of the vrDevice.
  19641. */
  19642. rawPose: Nullable<DevicePose>;
  19643. private _onVREnabled;
  19644. private _specsVersion;
  19645. private _attached;
  19646. private _frameData;
  19647. protected _descendants: Array<Node>;
  19648. private _deviceRoomPosition;
  19649. /** @hidden */
  19650. _deviceRoomRotationQuaternion: Quaternion;
  19651. private _standingMatrix;
  19652. /**
  19653. * Represents device position in babylon space.
  19654. */
  19655. devicePosition: Vector3;
  19656. /**
  19657. * Represents device rotation in babylon space.
  19658. */
  19659. deviceRotationQuaternion: Quaternion;
  19660. /**
  19661. * The scale of the device to be used when translating from device space to babylon space.
  19662. */
  19663. deviceScaleFactor: number;
  19664. private _deviceToWorld;
  19665. private _worldToDevice;
  19666. /**
  19667. * References to the webVR controllers for the vrDevice.
  19668. */
  19669. controllers: Array<WebVRController>;
  19670. /**
  19671. * Emits an event when a controller is attached.
  19672. */
  19673. onControllersAttachedObservable: Observable<WebVRController[]>;
  19674. /**
  19675. * Emits an event when a controller's mesh has been loaded;
  19676. */
  19677. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19678. /**
  19679. * Emits an event when the HMD's pose has been updated.
  19680. */
  19681. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19682. private _poseSet;
  19683. /**
  19684. * If the rig cameras be used as parent instead of this camera.
  19685. */
  19686. rigParenting: boolean;
  19687. private _lightOnControllers;
  19688. private _defaultHeight?;
  19689. /**
  19690. * Instantiates a WebVRFreeCamera.
  19691. * @param name The name of the WebVRFreeCamera
  19692. * @param position The starting anchor position for the camera
  19693. * @param scene The scene the camera belongs to
  19694. * @param webVROptions a set of customizable options for the webVRCamera
  19695. */
  19696. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19697. /**
  19698. * Gets the device distance from the ground in meters.
  19699. * @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.
  19700. */
  19701. deviceDistanceToRoomGround(): number;
  19702. /**
  19703. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19704. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19705. */
  19706. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19707. /**
  19708. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19709. * @returns A promise with a boolean set to if the standing matrix is supported.
  19710. */
  19711. useStandingMatrixAsync(): Promise<boolean>;
  19712. /**
  19713. * Disposes the camera
  19714. */
  19715. dispose(): void;
  19716. /**
  19717. * Gets a vrController by name.
  19718. * @param name The name of the controller to retreive
  19719. * @returns the controller matching the name specified or null if not found
  19720. */
  19721. getControllerByName(name: string): Nullable<WebVRController>;
  19722. private _leftController;
  19723. /**
  19724. * The controller corresponding to the users left hand.
  19725. */
  19726. get leftController(): Nullable<WebVRController>;
  19727. private _rightController;
  19728. /**
  19729. * The controller corresponding to the users right hand.
  19730. */
  19731. get rightController(): Nullable<WebVRController>;
  19732. /**
  19733. * Casts a ray forward from the vrCamera's gaze.
  19734. * @param length Length of the ray (default: 100)
  19735. * @returns the ray corresponding to the gaze
  19736. */
  19737. getForwardRay(length?: number): Ray;
  19738. /**
  19739. * @hidden
  19740. * Updates the camera based on device's frame data
  19741. */
  19742. _checkInputs(): void;
  19743. /**
  19744. * Updates the poseControlled values based on the input device pose.
  19745. * @param poseData Pose coming from the device
  19746. */
  19747. updateFromDevice(poseData: DevicePose): void;
  19748. private _htmlElementAttached;
  19749. private _detachIfAttached;
  19750. /**
  19751. * WebVR's attach control will start broadcasting frames to the device.
  19752. * Note that in certain browsers (chrome for example) this function must be called
  19753. * within a user-interaction callback. Example:
  19754. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19755. *
  19756. * @param element html element to attach the vrDevice to
  19757. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19758. */
  19759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19760. /**
  19761. * Detaches the camera from the html element and disables VR
  19762. *
  19763. * @param element html element to detach from
  19764. */
  19765. detachControl(element: HTMLElement): void;
  19766. /**
  19767. * @returns the name of this class
  19768. */
  19769. getClassName(): string;
  19770. /**
  19771. * Calls resetPose on the vrDisplay
  19772. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19773. */
  19774. resetToCurrentRotation(): void;
  19775. /**
  19776. * @hidden
  19777. * Updates the rig cameras (left and right eye)
  19778. */
  19779. _updateRigCameras(): void;
  19780. private _workingVector;
  19781. private _oneVector;
  19782. private _workingMatrix;
  19783. private updateCacheCalled;
  19784. private _correctPositionIfNotTrackPosition;
  19785. /**
  19786. * @hidden
  19787. * Updates the cached values of the camera
  19788. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19789. */
  19790. _updateCache(ignoreParentClass?: boolean): void;
  19791. /**
  19792. * @hidden
  19793. * Get current device position in babylon world
  19794. */
  19795. _computeDevicePosition(): void;
  19796. /**
  19797. * Updates the current device position and rotation in the babylon world
  19798. */
  19799. update(): void;
  19800. /**
  19801. * @hidden
  19802. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19803. * @returns an identity matrix
  19804. */
  19805. _getViewMatrix(): Matrix;
  19806. private _tmpMatrix;
  19807. /**
  19808. * This function is called by the two RIG cameras.
  19809. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19810. * @hidden
  19811. */
  19812. _getWebVRViewMatrix(): Matrix;
  19813. /** @hidden */
  19814. _getWebVRProjectionMatrix(): Matrix;
  19815. private _onGamepadConnectedObserver;
  19816. private _onGamepadDisconnectedObserver;
  19817. private _updateCacheWhenTrackingDisabledObserver;
  19818. /**
  19819. * Initializes the controllers and their meshes
  19820. */
  19821. initControllers(): void;
  19822. }
  19823. }
  19824. declare module BABYLON {
  19825. /**
  19826. * Size options for a post process
  19827. */
  19828. export type PostProcessOptions = {
  19829. width: number;
  19830. height: number;
  19831. };
  19832. /**
  19833. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19834. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19835. */
  19836. export class PostProcess {
  19837. /** Name of the PostProcess. */
  19838. name: string;
  19839. /**
  19840. * Gets or sets the unique id of the post process
  19841. */
  19842. uniqueId: number;
  19843. /**
  19844. * Width of the texture to apply the post process on
  19845. */
  19846. width: number;
  19847. /**
  19848. * Height of the texture to apply the post process on
  19849. */
  19850. height: number;
  19851. /**
  19852. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19853. * @hidden
  19854. */
  19855. _outputTexture: Nullable<InternalTexture>;
  19856. /**
  19857. * Sampling mode used by the shader
  19858. * See https://doc.babylonjs.com/classes/3.1/texture
  19859. */
  19860. renderTargetSamplingMode: number;
  19861. /**
  19862. * Clear color to use when screen clearing
  19863. */
  19864. clearColor: Color4;
  19865. /**
  19866. * If the buffer needs to be cleared before applying the post process. (default: true)
  19867. * Should be set to false if shader will overwrite all previous pixels.
  19868. */
  19869. autoClear: boolean;
  19870. /**
  19871. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19872. */
  19873. alphaMode: number;
  19874. /**
  19875. * Sets the setAlphaBlendConstants of the babylon engine
  19876. */
  19877. alphaConstants: Color4;
  19878. /**
  19879. * Animations to be used for the post processing
  19880. */
  19881. animations: Animation[];
  19882. /**
  19883. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19884. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19885. */
  19886. enablePixelPerfectMode: boolean;
  19887. /**
  19888. * Force the postprocess to be applied without taking in account viewport
  19889. */
  19890. forceFullscreenViewport: boolean;
  19891. /**
  19892. * List of inspectable custom properties (used by the Inspector)
  19893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19894. */
  19895. inspectableCustomProperties: IInspectable[];
  19896. /**
  19897. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19898. *
  19899. * | Value | Type | Description |
  19900. * | ----- | ----------------------------------- | ----------- |
  19901. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19902. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19903. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19904. *
  19905. */
  19906. scaleMode: number;
  19907. /**
  19908. * Force textures to be a power of two (default: false)
  19909. */
  19910. alwaysForcePOT: boolean;
  19911. private _samples;
  19912. /**
  19913. * Number of sample textures (default: 1)
  19914. */
  19915. get samples(): number;
  19916. set samples(n: number);
  19917. /**
  19918. * Modify the scale of the post process to be the same as the viewport (default: false)
  19919. */
  19920. adaptScaleToCurrentViewport: boolean;
  19921. private _camera;
  19922. private _scene;
  19923. private _engine;
  19924. private _options;
  19925. private _reusable;
  19926. private _textureType;
  19927. private _textureFormat;
  19928. /**
  19929. * Smart array of input and output textures for the post process.
  19930. * @hidden
  19931. */
  19932. _textures: SmartArray<InternalTexture>;
  19933. /**
  19934. * The index in _textures that corresponds to the output texture.
  19935. * @hidden
  19936. */
  19937. _currentRenderTextureInd: number;
  19938. private _effect;
  19939. private _samplers;
  19940. private _fragmentUrl;
  19941. private _vertexUrl;
  19942. private _parameters;
  19943. private _scaleRatio;
  19944. protected _indexParameters: any;
  19945. private _shareOutputWithPostProcess;
  19946. private _texelSize;
  19947. private _forcedOutputTexture;
  19948. /**
  19949. * Returns the fragment url or shader name used in the post process.
  19950. * @returns the fragment url or name in the shader store.
  19951. */
  19952. getEffectName(): string;
  19953. /**
  19954. * An event triggered when the postprocess is activated.
  19955. */
  19956. onActivateObservable: Observable<Camera>;
  19957. private _onActivateObserver;
  19958. /**
  19959. * A function that is added to the onActivateObservable
  19960. */
  19961. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19962. /**
  19963. * An event triggered when the postprocess changes its size.
  19964. */
  19965. onSizeChangedObservable: Observable<PostProcess>;
  19966. private _onSizeChangedObserver;
  19967. /**
  19968. * A function that is added to the onSizeChangedObservable
  19969. */
  19970. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19971. /**
  19972. * An event triggered when the postprocess applies its effect.
  19973. */
  19974. onApplyObservable: Observable<Effect>;
  19975. private _onApplyObserver;
  19976. /**
  19977. * A function that is added to the onApplyObservable
  19978. */
  19979. set onApply(callback: (effect: Effect) => void);
  19980. /**
  19981. * An event triggered before rendering the postprocess
  19982. */
  19983. onBeforeRenderObservable: Observable<Effect>;
  19984. private _onBeforeRenderObserver;
  19985. /**
  19986. * A function that is added to the onBeforeRenderObservable
  19987. */
  19988. set onBeforeRender(callback: (effect: Effect) => void);
  19989. /**
  19990. * An event triggered after rendering the postprocess
  19991. */
  19992. onAfterRenderObservable: Observable<Effect>;
  19993. private _onAfterRenderObserver;
  19994. /**
  19995. * A function that is added to the onAfterRenderObservable
  19996. */
  19997. set onAfterRender(callback: (efect: Effect) => void);
  19998. /**
  19999. * 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
  20000. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20001. */
  20002. get inputTexture(): InternalTexture;
  20003. set inputTexture(value: InternalTexture);
  20004. /**
  20005. * Gets the camera which post process is applied to.
  20006. * @returns The camera the post process is applied to.
  20007. */
  20008. getCamera(): Camera;
  20009. /**
  20010. * Gets the texel size of the postprocess.
  20011. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20012. */
  20013. get texelSize(): Vector2;
  20014. /**
  20015. * Creates a new instance PostProcess
  20016. * @param name The name of the PostProcess.
  20017. * @param fragmentUrl The url of the fragment shader to be used.
  20018. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20019. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20020. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20021. * @param camera The camera to apply the render pass to.
  20022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20023. * @param engine The engine which the post process will be applied. (default: current engine)
  20024. * @param reusable If the post process can be reused on the same frame. (default: false)
  20025. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20026. * @param textureType Type of textures used when performing the post process. (default: 0)
  20027. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20028. * @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
  20029. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20030. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20031. */
  20032. constructor(
  20033. /** Name of the PostProcess. */
  20034. 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);
  20035. /**
  20036. * Gets a string idenfifying the name of the class
  20037. * @returns "PostProcess" string
  20038. */
  20039. getClassName(): string;
  20040. /**
  20041. * Gets the engine which this post process belongs to.
  20042. * @returns The engine the post process was enabled with.
  20043. */
  20044. getEngine(): Engine;
  20045. /**
  20046. * The effect that is created when initializing the post process.
  20047. * @returns The created effect corresponding the the postprocess.
  20048. */
  20049. getEffect(): Effect;
  20050. /**
  20051. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20052. * @param postProcess The post process to share the output with.
  20053. * @returns This post process.
  20054. */
  20055. shareOutputWith(postProcess: PostProcess): PostProcess;
  20056. /**
  20057. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20058. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20059. */
  20060. useOwnOutput(): void;
  20061. /**
  20062. * Updates the effect with the current post process compile time values and recompiles the shader.
  20063. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20064. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20065. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20066. * @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
  20067. * @param onCompiled Called when the shader has been compiled.
  20068. * @param onError Called if there is an error when compiling a shader.
  20069. */
  20070. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20071. /**
  20072. * The post process is reusable if it can be used multiple times within one frame.
  20073. * @returns If the post process is reusable
  20074. */
  20075. isReusable(): boolean;
  20076. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20077. markTextureDirty(): void;
  20078. /**
  20079. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20080. * 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.
  20081. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20082. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20083. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20084. * @returns The target texture that was bound to be written to.
  20085. */
  20086. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20087. /**
  20088. * If the post process is supported.
  20089. */
  20090. get isSupported(): boolean;
  20091. /**
  20092. * The aspect ratio of the output texture.
  20093. */
  20094. get aspectRatio(): number;
  20095. /**
  20096. * Get a value indicating if the post-process is ready to be used
  20097. * @returns true if the post-process is ready (shader is compiled)
  20098. */
  20099. isReady(): boolean;
  20100. /**
  20101. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20102. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20103. */
  20104. apply(): Nullable<Effect>;
  20105. private _disposeTextures;
  20106. /**
  20107. * Disposes the post process.
  20108. * @param camera The camera to dispose the post process on.
  20109. */
  20110. dispose(camera?: Camera): void;
  20111. }
  20112. }
  20113. declare module BABYLON {
  20114. /** @hidden */
  20115. export var kernelBlurVaryingDeclaration: {
  20116. name: string;
  20117. shader: string;
  20118. };
  20119. }
  20120. declare module BABYLON {
  20121. /** @hidden */
  20122. export var kernelBlurFragment: {
  20123. name: string;
  20124. shader: string;
  20125. };
  20126. }
  20127. declare module BABYLON {
  20128. /** @hidden */
  20129. export var kernelBlurFragment2: {
  20130. name: string;
  20131. shader: string;
  20132. };
  20133. }
  20134. declare module BABYLON {
  20135. /** @hidden */
  20136. export var kernelBlurPixelShader: {
  20137. name: string;
  20138. shader: string;
  20139. };
  20140. }
  20141. declare module BABYLON {
  20142. /** @hidden */
  20143. export var kernelBlurVertex: {
  20144. name: string;
  20145. shader: string;
  20146. };
  20147. }
  20148. declare module BABYLON {
  20149. /** @hidden */
  20150. export var kernelBlurVertexShader: {
  20151. name: string;
  20152. shader: string;
  20153. };
  20154. }
  20155. declare module BABYLON {
  20156. /**
  20157. * The Blur Post Process which blurs an image based on a kernel and direction.
  20158. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20159. */
  20160. export class BlurPostProcess extends PostProcess {
  20161. /** The direction in which to blur the image. */
  20162. direction: Vector2;
  20163. private blockCompilation;
  20164. protected _kernel: number;
  20165. protected _idealKernel: number;
  20166. protected _packedFloat: boolean;
  20167. private _staticDefines;
  20168. /**
  20169. * Sets the length in pixels of the blur sample region
  20170. */
  20171. set kernel(v: number);
  20172. /**
  20173. * Gets the length in pixels of the blur sample region
  20174. */
  20175. get kernel(): number;
  20176. /**
  20177. * Sets wether or not the blur needs to unpack/repack floats
  20178. */
  20179. set packedFloat(v: boolean);
  20180. /**
  20181. * Gets wether or not the blur is unpacking/repacking floats
  20182. */
  20183. get packedFloat(): boolean;
  20184. /**
  20185. * Creates a new instance BlurPostProcess
  20186. * @param name The name of the effect.
  20187. * @param direction The direction in which to blur the image.
  20188. * @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.
  20189. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20190. * @param camera The camera to apply the render pass to.
  20191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20192. * @param engine The engine which the post process will be applied. (default: current engine)
  20193. * @param reusable If the post process can be reused on the same frame. (default: false)
  20194. * @param textureType Type of textures used when performing the post process. (default: 0)
  20195. * @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)
  20196. */
  20197. constructor(name: string,
  20198. /** The direction in which to blur the image. */
  20199. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20200. /**
  20201. * Updates the effect with the current post process compile time values and recompiles the shader.
  20202. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20203. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20204. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20205. * @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
  20206. * @param onCompiled Called when the shader has been compiled.
  20207. * @param onError Called if there is an error when compiling a shader.
  20208. */
  20209. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20210. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20211. /**
  20212. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20213. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20214. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20215. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20216. * The gaps between physical kernels are compensated for in the weighting of the samples
  20217. * @param idealKernel Ideal blur kernel.
  20218. * @return Nearest best kernel.
  20219. */
  20220. protected _nearestBestKernel(idealKernel: number): number;
  20221. /**
  20222. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20223. * @param x The point on the Gaussian distribution to sample.
  20224. * @return the value of the Gaussian function at x.
  20225. */
  20226. protected _gaussianWeight(x: number): number;
  20227. /**
  20228. * Generates a string that can be used as a floating point number in GLSL.
  20229. * @param x Value to print.
  20230. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20231. * @return GLSL float string.
  20232. */
  20233. protected _glslFloat(x: number, decimalFigures?: number): string;
  20234. }
  20235. }
  20236. declare module BABYLON {
  20237. /**
  20238. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20239. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20240. * You can then easily use it as a reflectionTexture on a flat surface.
  20241. * In case the surface is not a plane, please consider relying on reflection probes.
  20242. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20243. */
  20244. export class MirrorTexture extends RenderTargetTexture {
  20245. private scene;
  20246. /**
  20247. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20248. * 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.
  20249. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20250. */
  20251. mirrorPlane: Plane;
  20252. /**
  20253. * Define the blur ratio used to blur the reflection if needed.
  20254. */
  20255. set blurRatio(value: number);
  20256. get blurRatio(): number;
  20257. /**
  20258. * Define the adaptive blur kernel used to blur the reflection if needed.
  20259. * This will autocompute the closest best match for the `blurKernel`
  20260. */
  20261. set adaptiveBlurKernel(value: number);
  20262. /**
  20263. * Define the blur kernel used to blur the reflection if needed.
  20264. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20265. */
  20266. set blurKernel(value: number);
  20267. /**
  20268. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20269. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20270. */
  20271. set blurKernelX(value: number);
  20272. get blurKernelX(): number;
  20273. /**
  20274. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20275. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20276. */
  20277. set blurKernelY(value: number);
  20278. get blurKernelY(): number;
  20279. private _autoComputeBlurKernel;
  20280. protected _onRatioRescale(): void;
  20281. private _updateGammaSpace;
  20282. private _imageProcessingConfigChangeObserver;
  20283. private _transformMatrix;
  20284. private _mirrorMatrix;
  20285. private _savedViewMatrix;
  20286. private _blurX;
  20287. private _blurY;
  20288. private _adaptiveBlurKernel;
  20289. private _blurKernelX;
  20290. private _blurKernelY;
  20291. private _blurRatio;
  20292. /**
  20293. * Instantiates a Mirror Texture.
  20294. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20295. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20296. * You can then easily use it as a reflectionTexture on a flat surface.
  20297. * In case the surface is not a plane, please consider relying on reflection probes.
  20298. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20299. * @param name
  20300. * @param size
  20301. * @param scene
  20302. * @param generateMipMaps
  20303. * @param type
  20304. * @param samplingMode
  20305. * @param generateDepthBuffer
  20306. */
  20307. constructor(name: string, size: number | {
  20308. width: number;
  20309. height: number;
  20310. } | {
  20311. ratio: number;
  20312. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20313. private _preparePostProcesses;
  20314. /**
  20315. * Clone the mirror texture.
  20316. * @returns the cloned texture
  20317. */
  20318. clone(): MirrorTexture;
  20319. /**
  20320. * Serialize the texture to a JSON representation you could use in Parse later on
  20321. * @returns the serialized JSON representation
  20322. */
  20323. serialize(): any;
  20324. /**
  20325. * Dispose the texture and release its associated resources.
  20326. */
  20327. dispose(): void;
  20328. }
  20329. }
  20330. declare module BABYLON {
  20331. /**
  20332. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20333. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20334. */
  20335. export class Texture extends BaseTexture {
  20336. /**
  20337. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20338. */
  20339. static SerializeBuffers: boolean;
  20340. /** @hidden */
  20341. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20342. /** @hidden */
  20343. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20344. /** @hidden */
  20345. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20346. /** nearest is mag = nearest and min = nearest and mip = linear */
  20347. static readonly NEAREST_SAMPLINGMODE: number;
  20348. /** nearest is mag = nearest and min = nearest and mip = linear */
  20349. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20350. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20351. static readonly BILINEAR_SAMPLINGMODE: number;
  20352. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20353. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20354. /** Trilinear is mag = linear and min = linear and mip = linear */
  20355. static readonly TRILINEAR_SAMPLINGMODE: number;
  20356. /** Trilinear is mag = linear and min = linear and mip = linear */
  20357. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20358. /** mag = nearest and min = nearest and mip = nearest */
  20359. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20360. /** mag = nearest and min = linear and mip = nearest */
  20361. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20362. /** mag = nearest and min = linear and mip = linear */
  20363. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20364. /** mag = nearest and min = linear and mip = none */
  20365. static readonly NEAREST_LINEAR: number;
  20366. /** mag = nearest and min = nearest and mip = none */
  20367. static readonly NEAREST_NEAREST: number;
  20368. /** mag = linear and min = nearest and mip = nearest */
  20369. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20370. /** mag = linear and min = nearest and mip = linear */
  20371. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20372. /** mag = linear and min = linear and mip = none */
  20373. static readonly LINEAR_LINEAR: number;
  20374. /** mag = linear and min = nearest and mip = none */
  20375. static readonly LINEAR_NEAREST: number;
  20376. /** Explicit coordinates mode */
  20377. static readonly EXPLICIT_MODE: number;
  20378. /** Spherical coordinates mode */
  20379. static readonly SPHERICAL_MODE: number;
  20380. /** Planar coordinates mode */
  20381. static readonly PLANAR_MODE: number;
  20382. /** Cubic coordinates mode */
  20383. static readonly CUBIC_MODE: number;
  20384. /** Projection coordinates mode */
  20385. static readonly PROJECTION_MODE: number;
  20386. /** Inverse Cubic coordinates mode */
  20387. static readonly SKYBOX_MODE: number;
  20388. /** Inverse Cubic coordinates mode */
  20389. static readonly INVCUBIC_MODE: number;
  20390. /** Equirectangular coordinates mode */
  20391. static readonly EQUIRECTANGULAR_MODE: number;
  20392. /** Equirectangular Fixed coordinates mode */
  20393. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20394. /** Equirectangular Fixed Mirrored coordinates mode */
  20395. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20396. /** Texture is not repeating outside of 0..1 UVs */
  20397. static readonly CLAMP_ADDRESSMODE: number;
  20398. /** Texture is repeating outside of 0..1 UVs */
  20399. static readonly WRAP_ADDRESSMODE: number;
  20400. /** Texture is repeating and mirrored */
  20401. static readonly MIRROR_ADDRESSMODE: number;
  20402. /**
  20403. * 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
  20404. */
  20405. static UseSerializedUrlIfAny: boolean;
  20406. /**
  20407. * Define the url of the texture.
  20408. */
  20409. url: Nullable<string>;
  20410. /**
  20411. * Define an offset on the texture to offset the u coordinates of the UVs
  20412. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20413. */
  20414. uOffset: number;
  20415. /**
  20416. * Define an offset on the texture to offset the v coordinates of the UVs
  20417. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20418. */
  20419. vOffset: number;
  20420. /**
  20421. * Define an offset on the texture to scale the u coordinates of the UVs
  20422. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20423. */
  20424. uScale: number;
  20425. /**
  20426. * Define an offset on the texture to scale the v coordinates of the UVs
  20427. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20428. */
  20429. vScale: number;
  20430. /**
  20431. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20432. * @see http://doc.babylonjs.com/how_to/more_materials
  20433. */
  20434. uAng: number;
  20435. /**
  20436. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20437. * @see http://doc.babylonjs.com/how_to/more_materials
  20438. */
  20439. vAng: number;
  20440. /**
  20441. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20442. * @see http://doc.babylonjs.com/how_to/more_materials
  20443. */
  20444. wAng: number;
  20445. /**
  20446. * Defines the center of rotation (U)
  20447. */
  20448. uRotationCenter: number;
  20449. /**
  20450. * Defines the center of rotation (V)
  20451. */
  20452. vRotationCenter: number;
  20453. /**
  20454. * Defines the center of rotation (W)
  20455. */
  20456. wRotationCenter: number;
  20457. /**
  20458. * Are mip maps generated for this texture or not.
  20459. */
  20460. get noMipmap(): boolean;
  20461. /**
  20462. * List of inspectable custom properties (used by the Inspector)
  20463. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20464. */
  20465. inspectableCustomProperties: Nullable<IInspectable[]>;
  20466. private _noMipmap;
  20467. /** @hidden */
  20468. _invertY: boolean;
  20469. private _rowGenerationMatrix;
  20470. private _cachedTextureMatrix;
  20471. private _projectionModeMatrix;
  20472. private _t0;
  20473. private _t1;
  20474. private _t2;
  20475. private _cachedUOffset;
  20476. private _cachedVOffset;
  20477. private _cachedUScale;
  20478. private _cachedVScale;
  20479. private _cachedUAng;
  20480. private _cachedVAng;
  20481. private _cachedWAng;
  20482. private _cachedProjectionMatrixId;
  20483. private _cachedCoordinatesMode;
  20484. /** @hidden */
  20485. protected _initialSamplingMode: number;
  20486. /** @hidden */
  20487. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20488. private _deleteBuffer;
  20489. protected _format: Nullable<number>;
  20490. private _delayedOnLoad;
  20491. private _delayedOnError;
  20492. private _mimeType?;
  20493. /**
  20494. * Observable triggered once the texture has been loaded.
  20495. */
  20496. onLoadObservable: Observable<Texture>;
  20497. protected _isBlocking: boolean;
  20498. /**
  20499. * Is the texture preventing material to render while loading.
  20500. * If false, a default texture will be used instead of the loading one during the preparation step.
  20501. */
  20502. set isBlocking(value: boolean);
  20503. get isBlocking(): boolean;
  20504. /**
  20505. * Get the current sampling mode associated with the texture.
  20506. */
  20507. get samplingMode(): number;
  20508. /**
  20509. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20510. */
  20511. get invertY(): boolean;
  20512. /**
  20513. * Instantiates a new texture.
  20514. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20515. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20516. * @param url defines the url of the picture to load as a texture
  20517. * @param scene defines the scene or engine the texture will belong to
  20518. * @param noMipmap defines if the texture will require mip maps or not
  20519. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20520. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20521. * @param onLoad defines a callback triggered when the texture has been loaded
  20522. * @param onError defines a callback triggered when an error occurred during the loading session
  20523. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20524. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20525. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20526. * @param mimeType defines an optional mime type information
  20527. */
  20528. 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);
  20529. /**
  20530. * Update the url (and optional buffer) of this texture if url was null during construction.
  20531. * @param url the url of the texture
  20532. * @param buffer the buffer of the texture (defaults to null)
  20533. * @param onLoad callback called when the texture is loaded (defaults to null)
  20534. */
  20535. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20536. /**
  20537. * Finish the loading sequence of a texture flagged as delayed load.
  20538. * @hidden
  20539. */
  20540. delayLoad(): void;
  20541. private _prepareRowForTextureGeneration;
  20542. /**
  20543. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20544. * @returns the transform matrix of the texture.
  20545. */
  20546. getTextureMatrix(uBase?: number): Matrix;
  20547. /**
  20548. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20549. * @returns The reflection texture transform
  20550. */
  20551. getReflectionTextureMatrix(): Matrix;
  20552. /**
  20553. * Clones the texture.
  20554. * @returns the cloned texture
  20555. */
  20556. clone(): Texture;
  20557. /**
  20558. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20559. * @returns The JSON representation of the texture
  20560. */
  20561. serialize(): any;
  20562. /**
  20563. * Get the current class name of the texture useful for serialization or dynamic coding.
  20564. * @returns "Texture"
  20565. */
  20566. getClassName(): string;
  20567. /**
  20568. * Dispose the texture and release its associated resources.
  20569. */
  20570. dispose(): void;
  20571. /**
  20572. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20573. * @param parsedTexture Define the JSON representation of the texture
  20574. * @param scene Define the scene the parsed texture should be instantiated in
  20575. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20576. * @returns The parsed texture if successful
  20577. */
  20578. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20579. /**
  20580. * Creates a texture from its base 64 representation.
  20581. * @param data Define the base64 payload without the data: prefix
  20582. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20583. * @param scene Define the scene the texture should belong to
  20584. * @param noMipmap Forces the texture to not create mip map information if true
  20585. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20586. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20587. * @param onLoad define a callback triggered when the texture has been loaded
  20588. * @param onError define a callback triggered when an error occurred during the loading session
  20589. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20590. * @returns the created texture
  20591. */
  20592. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20593. /**
  20594. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20595. * @param data Define the base64 payload without the data: prefix
  20596. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20597. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20598. * @param scene Define the scene the texture should belong to
  20599. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20600. * @param noMipmap Forces the texture to not create mip map information if true
  20601. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20602. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20603. * @param onLoad define a callback triggered when the texture has been loaded
  20604. * @param onError define a callback triggered when an error occurred during the loading session
  20605. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20606. * @returns the created texture
  20607. */
  20608. 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;
  20609. }
  20610. }
  20611. declare module BABYLON {
  20612. /**
  20613. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20614. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20615. */
  20616. export class PostProcessManager {
  20617. private _scene;
  20618. private _indexBuffer;
  20619. private _vertexBuffers;
  20620. /**
  20621. * Creates a new instance PostProcess
  20622. * @param scene The scene that the post process is associated with.
  20623. */
  20624. constructor(scene: Scene);
  20625. private _prepareBuffers;
  20626. private _buildIndexBuffer;
  20627. /**
  20628. * Rebuilds the vertex buffers of the manager.
  20629. * @hidden
  20630. */
  20631. _rebuild(): void;
  20632. /**
  20633. * Prepares a frame to be run through a post process.
  20634. * @param sourceTexture The input texture to the post procesess. (default: null)
  20635. * @param postProcesses An array of post processes to be run. (default: null)
  20636. * @returns True if the post processes were able to be run.
  20637. * @hidden
  20638. */
  20639. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20640. /**
  20641. * Manually render a set of post processes to a texture.
  20642. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  20643. * @param postProcesses An array of post processes to be run.
  20644. * @param targetTexture The target texture to render to.
  20645. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20646. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20647. * @param lodLevel defines which lod of the texture to render to
  20648. */
  20649. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20650. /**
  20651. * Finalize the result of the output of the postprocesses.
  20652. * @param doNotPresent If true the result will not be displayed to the screen.
  20653. * @param targetTexture The target texture to render to.
  20654. * @param faceIndex The index of the face to bind the target texture to.
  20655. * @param postProcesses The array of post processes to render.
  20656. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20657. * @hidden
  20658. */
  20659. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20660. /**
  20661. * Disposes of the post process manager.
  20662. */
  20663. dispose(): void;
  20664. }
  20665. }
  20666. declare module BABYLON {
  20667. /**
  20668. * This Helps creating a texture that will be created from a camera in your scene.
  20669. * It is basically a dynamic texture that could be used to create special effects for instance.
  20670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20671. */
  20672. export class RenderTargetTexture extends Texture {
  20673. isCube: boolean;
  20674. /**
  20675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20676. */
  20677. static readonly REFRESHRATE_RENDER_ONCE: number;
  20678. /**
  20679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20680. */
  20681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20682. /**
  20683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20684. * the central point of your effect and can save a lot of performances.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20687. /**
  20688. * Use this predicate to dynamically define the list of mesh you want to render.
  20689. * If set, the renderList property will be overwritten.
  20690. */
  20691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20692. private _renderList;
  20693. /**
  20694. * Use this list to define the list of mesh you want to render.
  20695. */
  20696. get renderList(): Nullable<Array<AbstractMesh>>;
  20697. set renderList(value: Nullable<Array<AbstractMesh>>);
  20698. /**
  20699. * Use this function to overload the renderList array at rendering time.
  20700. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20701. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20702. * the cube (if the RTT is a cube, else layerOrFace=0).
  20703. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20704. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20705. * hold dummy elements!
  20706. */
  20707. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20708. private _hookArray;
  20709. /**
  20710. * Define if particles should be rendered in your texture.
  20711. */
  20712. renderParticles: boolean;
  20713. /**
  20714. * Define if sprites should be rendered in your texture.
  20715. */
  20716. renderSprites: boolean;
  20717. /**
  20718. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20719. */
  20720. coordinatesMode: number;
  20721. /**
  20722. * Define the camera used to render the texture.
  20723. */
  20724. activeCamera: Nullable<Camera>;
  20725. /**
  20726. * Override the mesh isReady function with your own one.
  20727. */
  20728. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20729. /**
  20730. * Override the render function of the texture with your own one.
  20731. */
  20732. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20733. /**
  20734. * Define if camera post processes should be use while rendering the texture.
  20735. */
  20736. useCameraPostProcesses: boolean;
  20737. /**
  20738. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20739. */
  20740. ignoreCameraViewport: boolean;
  20741. private _postProcessManager;
  20742. private _postProcesses;
  20743. private _resizeObserver;
  20744. /**
  20745. * An event triggered when the texture is unbind.
  20746. */
  20747. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20748. /**
  20749. * An event triggered when the texture is unbind.
  20750. */
  20751. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20752. private _onAfterUnbindObserver;
  20753. /**
  20754. * Set a after unbind callback in the texture.
  20755. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20756. */
  20757. set onAfterUnbind(callback: () => void);
  20758. /**
  20759. * An event triggered before rendering the texture
  20760. */
  20761. onBeforeRenderObservable: Observable<number>;
  20762. private _onBeforeRenderObserver;
  20763. /**
  20764. * Set a before render callback in the texture.
  20765. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20766. */
  20767. set onBeforeRender(callback: (faceIndex: number) => void);
  20768. /**
  20769. * An event triggered after rendering the texture
  20770. */
  20771. onAfterRenderObservable: Observable<number>;
  20772. private _onAfterRenderObserver;
  20773. /**
  20774. * Set a after render callback in the texture.
  20775. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20776. */
  20777. set onAfterRender(callback: (faceIndex: number) => void);
  20778. /**
  20779. * An event triggered after the texture clear
  20780. */
  20781. onClearObservable: Observable<Engine>;
  20782. private _onClearObserver;
  20783. /**
  20784. * Set a clear callback in the texture.
  20785. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20786. */
  20787. set onClear(callback: (Engine: Engine) => void);
  20788. /**
  20789. * An event triggered when the texture is resized.
  20790. */
  20791. onResizeObservable: Observable<RenderTargetTexture>;
  20792. /**
  20793. * Define the clear color of the Render Target if it should be different from the scene.
  20794. */
  20795. clearColor: Color4;
  20796. protected _size: number | {
  20797. width: number;
  20798. height: number;
  20799. layers?: number;
  20800. };
  20801. protected _initialSizeParameter: number | {
  20802. width: number;
  20803. height: number;
  20804. } | {
  20805. ratio: number;
  20806. };
  20807. protected _sizeRatio: Nullable<number>;
  20808. /** @hidden */
  20809. _generateMipMaps: boolean;
  20810. protected _renderingManager: RenderingManager;
  20811. /** @hidden */
  20812. _waitingRenderList: string[];
  20813. protected _doNotChangeAspectRatio: boolean;
  20814. protected _currentRefreshId: number;
  20815. protected _refreshRate: number;
  20816. protected _textureMatrix: Matrix;
  20817. protected _samples: number;
  20818. protected _renderTargetOptions: RenderTargetCreationOptions;
  20819. /**
  20820. * Gets render target creation options that were used.
  20821. */
  20822. get renderTargetOptions(): RenderTargetCreationOptions;
  20823. protected _engine: Engine;
  20824. protected _onRatioRescale(): void;
  20825. /**
  20826. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20827. * It must define where the camera used to render the texture is set
  20828. */
  20829. boundingBoxPosition: Vector3;
  20830. private _boundingBoxSize;
  20831. /**
  20832. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20833. * When defined, the cubemap will switch to local mode
  20834. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20835. * @example https://www.babylonjs-playground.com/#RNASML
  20836. */
  20837. set boundingBoxSize(value: Vector3);
  20838. get boundingBoxSize(): Vector3;
  20839. /**
  20840. * In case the RTT has been created with a depth texture, get the associated
  20841. * depth texture.
  20842. * Otherwise, return null.
  20843. */
  20844. get depthStencilTexture(): Nullable<InternalTexture>;
  20845. /**
  20846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20847. * or used a shadow, depth texture...
  20848. * @param name The friendly name of the texture
  20849. * @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)
  20850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20851. * @param generateMipMaps True if mip maps need to be generated after render.
  20852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20853. * @param type The type of the buffer in the RTT (int, half float, float...)
  20854. * @param isCube True if a cube texture needs to be created
  20855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20856. * @param generateDepthBuffer True to generate a depth buffer
  20857. * @param generateStencilBuffer True to generate a stencil buffer
  20858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20861. */
  20862. constructor(name: string, size: number | {
  20863. width: number;
  20864. height: number;
  20865. layers?: number;
  20866. } | {
  20867. ratio: number;
  20868. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20869. /**
  20870. * Creates a depth stencil texture.
  20871. * This is only available in WebGL 2 or with the depth texture extension available.
  20872. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20873. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20874. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20875. */
  20876. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20877. private _processSizeParameter;
  20878. /**
  20879. * Define the number of samples to use in case of MSAA.
  20880. * It defaults to one meaning no MSAA has been enabled.
  20881. */
  20882. get samples(): number;
  20883. set samples(value: number);
  20884. /**
  20885. * Resets the refresh counter of the texture and start bak from scratch.
  20886. * Could be useful to regenerate the texture if it is setup to render only once.
  20887. */
  20888. resetRefreshCounter(): void;
  20889. /**
  20890. * Define the refresh rate of the texture or the rendering frequency.
  20891. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20892. */
  20893. get refreshRate(): number;
  20894. set refreshRate(value: number);
  20895. /**
  20896. * Adds a post process to the render target rendering passes.
  20897. * @param postProcess define the post process to add
  20898. */
  20899. addPostProcess(postProcess: PostProcess): void;
  20900. /**
  20901. * Clear all the post processes attached to the render target
  20902. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20903. */
  20904. clearPostProcesses(dispose?: boolean): void;
  20905. /**
  20906. * Remove one of the post process from the list of attached post processes to the texture
  20907. * @param postProcess define the post process to remove from the list
  20908. */
  20909. removePostProcess(postProcess: PostProcess): void;
  20910. /** @hidden */
  20911. _shouldRender(): boolean;
  20912. /**
  20913. * Gets the actual render size of the texture.
  20914. * @returns the width of the render size
  20915. */
  20916. getRenderSize(): number;
  20917. /**
  20918. * Gets the actual render width of the texture.
  20919. * @returns the width of the render size
  20920. */
  20921. getRenderWidth(): number;
  20922. /**
  20923. * Gets the actual render height of the texture.
  20924. * @returns the height of the render size
  20925. */
  20926. getRenderHeight(): number;
  20927. /**
  20928. * Gets the actual number of layers of the texture.
  20929. * @returns the number of layers
  20930. */
  20931. getRenderLayers(): number;
  20932. /**
  20933. * Get if the texture can be rescaled or not.
  20934. */
  20935. get canRescale(): boolean;
  20936. /**
  20937. * Resize the texture using a ratio.
  20938. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20939. */
  20940. scale(ratio: number): void;
  20941. /**
  20942. * Get the texture reflection matrix used to rotate/transform the reflection.
  20943. * @returns the reflection matrix
  20944. */
  20945. getReflectionTextureMatrix(): Matrix;
  20946. /**
  20947. * Resize the texture to a new desired size.
  20948. * Be carrefull as it will recreate all the data in the new texture.
  20949. * @param size Define the new size. It can be:
  20950. * - a number for squared texture,
  20951. * - an object containing { width: number, height: number }
  20952. * - or an object containing a ratio { ratio: number }
  20953. */
  20954. resize(size: number | {
  20955. width: number;
  20956. height: number;
  20957. } | {
  20958. ratio: number;
  20959. }): void;
  20960. private _defaultRenderListPrepared;
  20961. /**
  20962. * Renders all the objects from the render list into the texture.
  20963. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20964. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20965. */
  20966. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20967. private _bestReflectionRenderTargetDimension;
  20968. private _prepareRenderingManager;
  20969. /**
  20970. * @hidden
  20971. * @param faceIndex face index to bind to if this is a cubetexture
  20972. * @param layer defines the index of the texture to bind in the array
  20973. */
  20974. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20975. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20976. private renderToTarget;
  20977. /**
  20978. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20979. * This allowed control for front to back rendering or reversly depending of the special needs.
  20980. *
  20981. * @param renderingGroupId The rendering group id corresponding to its index
  20982. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20983. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20984. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20985. */
  20986. 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;
  20987. /**
  20988. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20989. *
  20990. * @param renderingGroupId The rendering group id corresponding to its index
  20991. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20992. */
  20993. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20994. /**
  20995. * Clones the texture.
  20996. * @returns the cloned texture
  20997. */
  20998. clone(): RenderTargetTexture;
  20999. /**
  21000. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21001. * @returns The JSON representation of the texture
  21002. */
  21003. serialize(): any;
  21004. /**
  21005. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21006. */
  21007. disposeFramebufferObjects(): void;
  21008. /**
  21009. * Dispose the texture and release its associated resources.
  21010. */
  21011. dispose(): void;
  21012. /** @hidden */
  21013. _rebuild(): void;
  21014. /**
  21015. * Clear the info related to rendering groups preventing retention point in material dispose.
  21016. */
  21017. freeRenderingGroups(): void;
  21018. /**
  21019. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21020. * @returns the view count
  21021. */
  21022. getViewCount(): number;
  21023. }
  21024. }
  21025. declare module BABYLON {
  21026. /**
  21027. * Class used to manipulate GUIDs
  21028. */
  21029. export class GUID {
  21030. /**
  21031. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21032. * Be aware Math.random() could cause collisions, but:
  21033. * "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"
  21034. * @returns a pseudo random id
  21035. */
  21036. static RandomId(): string;
  21037. }
  21038. }
  21039. declare module BABYLON {
  21040. /**
  21041. * Options to be used when creating a shadow depth material
  21042. */
  21043. export interface IIOptionShadowDepthMaterial {
  21044. /** Variables in the vertex shader code that need to have their names remapped.
  21045. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21046. * "var_name" should be either: worldPos or vNormalW
  21047. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21048. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21049. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21050. */
  21051. remappedVariables?: string[];
  21052. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21053. standalone?: boolean;
  21054. }
  21055. /**
  21056. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21057. */
  21058. export class ShadowDepthWrapper {
  21059. private _scene;
  21060. private _options?;
  21061. private _baseMaterial;
  21062. private _onEffectCreatedObserver;
  21063. private _subMeshToEffect;
  21064. private _subMeshToDepthEffect;
  21065. private _meshes;
  21066. /** @hidden */
  21067. _matriceNames: any;
  21068. /** Gets the standalone status of the wrapper */
  21069. get standalone(): boolean;
  21070. /** Gets the base material the wrapper is built upon */
  21071. get baseMaterial(): Material;
  21072. /**
  21073. * Instantiate a new shadow depth wrapper.
  21074. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21075. * generate the shadow depth map. For more information, please refer to the documentation:
  21076. * https://doc.babylonjs.com/babylon101/shadows
  21077. * @param baseMaterial Material to wrap
  21078. * @param scene Define the scene the material belongs to
  21079. * @param options Options used to create the wrapper
  21080. */
  21081. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21082. /**
  21083. * Gets the effect to use to generate the depth map
  21084. * @param subMesh subMesh to get the effect for
  21085. * @param shadowGenerator shadow generator to get the effect for
  21086. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21087. */
  21088. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21089. /**
  21090. * Specifies that the submesh is ready to be used for depth rendering
  21091. * @param subMesh submesh to check
  21092. * @param defines the list of defines to take into account when checking the effect
  21093. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21094. * @param useInstances specifies that instances should be used
  21095. * @returns a boolean indicating that the submesh is ready or not
  21096. */
  21097. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21098. /**
  21099. * Disposes the resources
  21100. */
  21101. dispose(): void;
  21102. private _makeEffect;
  21103. }
  21104. }
  21105. declare module BABYLON {
  21106. /**
  21107. * Options for compiling materials.
  21108. */
  21109. export interface IMaterialCompilationOptions {
  21110. /**
  21111. * Defines whether clip planes are enabled.
  21112. */
  21113. clipPlane: boolean;
  21114. /**
  21115. * Defines whether instances are enabled.
  21116. */
  21117. useInstances: boolean;
  21118. }
  21119. /**
  21120. * Base class for the main features of a material in Babylon.js
  21121. */
  21122. export class Material implements IAnimatable {
  21123. /**
  21124. * Returns the triangle fill mode
  21125. */
  21126. static readonly TriangleFillMode: number;
  21127. /**
  21128. * Returns the wireframe mode
  21129. */
  21130. static readonly WireFrameFillMode: number;
  21131. /**
  21132. * Returns the point fill mode
  21133. */
  21134. static readonly PointFillMode: number;
  21135. /**
  21136. * Returns the point list draw mode
  21137. */
  21138. static readonly PointListDrawMode: number;
  21139. /**
  21140. * Returns the line list draw mode
  21141. */
  21142. static readonly LineListDrawMode: number;
  21143. /**
  21144. * Returns the line loop draw mode
  21145. */
  21146. static readonly LineLoopDrawMode: number;
  21147. /**
  21148. * Returns the line strip draw mode
  21149. */
  21150. static readonly LineStripDrawMode: number;
  21151. /**
  21152. * Returns the triangle strip draw mode
  21153. */
  21154. static readonly TriangleStripDrawMode: number;
  21155. /**
  21156. * Returns the triangle fan draw mode
  21157. */
  21158. static readonly TriangleFanDrawMode: number;
  21159. /**
  21160. * Stores the clock-wise side orientation
  21161. */
  21162. static readonly ClockWiseSideOrientation: number;
  21163. /**
  21164. * Stores the counter clock-wise side orientation
  21165. */
  21166. static readonly CounterClockWiseSideOrientation: number;
  21167. /**
  21168. * The dirty texture flag value
  21169. */
  21170. static readonly TextureDirtyFlag: number;
  21171. /**
  21172. * The dirty light flag value
  21173. */
  21174. static readonly LightDirtyFlag: number;
  21175. /**
  21176. * The dirty fresnel flag value
  21177. */
  21178. static readonly FresnelDirtyFlag: number;
  21179. /**
  21180. * The dirty attribute flag value
  21181. */
  21182. static readonly AttributesDirtyFlag: number;
  21183. /**
  21184. * The dirty misc flag value
  21185. */
  21186. static readonly MiscDirtyFlag: number;
  21187. /**
  21188. * The all dirty flag value
  21189. */
  21190. static readonly AllDirtyFlag: number;
  21191. /**
  21192. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21193. */
  21194. static readonly MATERIAL_OPAQUE: number;
  21195. /**
  21196. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21197. */
  21198. static readonly MATERIAL_ALPHATEST: number;
  21199. /**
  21200. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21201. */
  21202. static readonly MATERIAL_ALPHABLEND: number;
  21203. /**
  21204. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21205. * They are also discarded below the alpha cutoff threshold to improve performances.
  21206. */
  21207. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21208. /**
  21209. * Custom callback helping to override the default shader used in the material.
  21210. */
  21211. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21212. /**
  21213. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21214. */
  21215. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21216. /**
  21217. * The ID of the material
  21218. */
  21219. id: string;
  21220. /**
  21221. * Gets or sets the unique id of the material
  21222. */
  21223. uniqueId: number;
  21224. /**
  21225. * The name of the material
  21226. */
  21227. name: string;
  21228. /**
  21229. * Gets or sets user defined metadata
  21230. */
  21231. metadata: any;
  21232. /**
  21233. * For internal use only. Please do not use.
  21234. */
  21235. reservedDataStore: any;
  21236. /**
  21237. * Specifies if the ready state should be checked on each call
  21238. */
  21239. checkReadyOnEveryCall: boolean;
  21240. /**
  21241. * Specifies if the ready state should be checked once
  21242. */
  21243. checkReadyOnlyOnce: boolean;
  21244. /**
  21245. * The state of the material
  21246. */
  21247. state: string;
  21248. /**
  21249. * The alpha value of the material
  21250. */
  21251. protected _alpha: number;
  21252. /**
  21253. * List of inspectable custom properties (used by the Inspector)
  21254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21255. */
  21256. inspectableCustomProperties: IInspectable[];
  21257. /**
  21258. * Sets the alpha value of the material
  21259. */
  21260. set alpha(value: number);
  21261. /**
  21262. * Gets the alpha value of the material
  21263. */
  21264. get alpha(): number;
  21265. /**
  21266. * Specifies if back face culling is enabled
  21267. */
  21268. protected _backFaceCulling: boolean;
  21269. /**
  21270. * Sets the back-face culling state
  21271. */
  21272. set backFaceCulling(value: boolean);
  21273. /**
  21274. * Gets the back-face culling state
  21275. */
  21276. get backFaceCulling(): boolean;
  21277. /**
  21278. * Stores the value for side orientation
  21279. */
  21280. sideOrientation: number;
  21281. /**
  21282. * Callback triggered when the material is compiled
  21283. */
  21284. onCompiled: Nullable<(effect: Effect) => void>;
  21285. /**
  21286. * Callback triggered when an error occurs
  21287. */
  21288. onError: Nullable<(effect: Effect, errors: string) => void>;
  21289. /**
  21290. * Callback triggered to get the render target textures
  21291. */
  21292. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21293. /**
  21294. * Gets a boolean indicating that current material needs to register RTT
  21295. */
  21296. get hasRenderTargetTextures(): boolean;
  21297. /**
  21298. * Specifies if the material should be serialized
  21299. */
  21300. doNotSerialize: boolean;
  21301. /**
  21302. * @hidden
  21303. */
  21304. _storeEffectOnSubMeshes: boolean;
  21305. /**
  21306. * Stores the animations for the material
  21307. */
  21308. animations: Nullable<Array<Animation>>;
  21309. /**
  21310. * An event triggered when the material is disposed
  21311. */
  21312. onDisposeObservable: Observable<Material>;
  21313. /**
  21314. * An observer which watches for dispose events
  21315. */
  21316. private _onDisposeObserver;
  21317. private _onUnBindObservable;
  21318. /**
  21319. * Called during a dispose event
  21320. */
  21321. set onDispose(callback: () => void);
  21322. private _onBindObservable;
  21323. /**
  21324. * An event triggered when the material is bound
  21325. */
  21326. get onBindObservable(): Observable<AbstractMesh>;
  21327. /**
  21328. * An observer which watches for bind events
  21329. */
  21330. private _onBindObserver;
  21331. /**
  21332. * Called during a bind event
  21333. */
  21334. set onBind(callback: (Mesh: AbstractMesh) => void);
  21335. /**
  21336. * An event triggered when the material is unbound
  21337. */
  21338. get onUnBindObservable(): Observable<Material>;
  21339. protected _onEffectCreatedObservable: Nullable<Observable<{
  21340. effect: Effect;
  21341. subMesh: Nullable<SubMesh>;
  21342. }>>;
  21343. /**
  21344. * An event triggered when the effect is (re)created
  21345. */
  21346. get onEffectCreatedObservable(): Observable<{
  21347. effect: Effect;
  21348. subMesh: Nullable<SubMesh>;
  21349. }>;
  21350. /**
  21351. * Stores the value of the alpha mode
  21352. */
  21353. private _alphaMode;
  21354. /**
  21355. * Sets the value of the alpha mode.
  21356. *
  21357. * | Value | Type | Description |
  21358. * | --- | --- | --- |
  21359. * | 0 | ALPHA_DISABLE | |
  21360. * | 1 | ALPHA_ADD | |
  21361. * | 2 | ALPHA_COMBINE | |
  21362. * | 3 | ALPHA_SUBTRACT | |
  21363. * | 4 | ALPHA_MULTIPLY | |
  21364. * | 5 | ALPHA_MAXIMIZED | |
  21365. * | 6 | ALPHA_ONEONE | |
  21366. * | 7 | ALPHA_PREMULTIPLIED | |
  21367. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21368. * | 9 | ALPHA_INTERPOLATE | |
  21369. * | 10 | ALPHA_SCREENMODE | |
  21370. *
  21371. */
  21372. set alphaMode(value: number);
  21373. /**
  21374. * Gets the value of the alpha mode
  21375. */
  21376. get alphaMode(): number;
  21377. /**
  21378. * Stores the state of the need depth pre-pass value
  21379. */
  21380. private _needDepthPrePass;
  21381. /**
  21382. * Sets the need depth pre-pass value
  21383. */
  21384. set needDepthPrePass(value: boolean);
  21385. /**
  21386. * Gets the depth pre-pass value
  21387. */
  21388. get needDepthPrePass(): boolean;
  21389. /**
  21390. * Specifies if depth writing should be disabled
  21391. */
  21392. disableDepthWrite: boolean;
  21393. /**
  21394. * Specifies if color writing should be disabled
  21395. */
  21396. disableColorWrite: boolean;
  21397. /**
  21398. * Specifies if depth writing should be forced
  21399. */
  21400. forceDepthWrite: boolean;
  21401. /**
  21402. * Specifies the depth function that should be used. 0 means the default engine function
  21403. */
  21404. depthFunction: number;
  21405. /**
  21406. * Specifies if there should be a separate pass for culling
  21407. */
  21408. separateCullingPass: boolean;
  21409. /**
  21410. * Stores the state specifing if fog should be enabled
  21411. */
  21412. private _fogEnabled;
  21413. /**
  21414. * Sets the state for enabling fog
  21415. */
  21416. set fogEnabled(value: boolean);
  21417. /**
  21418. * Gets the value of the fog enabled state
  21419. */
  21420. get fogEnabled(): boolean;
  21421. /**
  21422. * Stores the size of points
  21423. */
  21424. pointSize: number;
  21425. /**
  21426. * Stores the z offset value
  21427. */
  21428. zOffset: number;
  21429. get wireframe(): boolean;
  21430. /**
  21431. * Sets the state of wireframe mode
  21432. */
  21433. set wireframe(value: boolean);
  21434. /**
  21435. * Gets the value specifying if point clouds are enabled
  21436. */
  21437. get pointsCloud(): boolean;
  21438. /**
  21439. * Sets the state of point cloud mode
  21440. */
  21441. set pointsCloud(value: boolean);
  21442. /**
  21443. * Gets the material fill mode
  21444. */
  21445. get fillMode(): number;
  21446. /**
  21447. * Sets the material fill mode
  21448. */
  21449. set fillMode(value: number);
  21450. /**
  21451. * @hidden
  21452. * Stores the effects for the material
  21453. */
  21454. _effect: Nullable<Effect>;
  21455. /**
  21456. * Specifies if uniform buffers should be used
  21457. */
  21458. private _useUBO;
  21459. /**
  21460. * Stores a reference to the scene
  21461. */
  21462. private _scene;
  21463. /**
  21464. * Stores the fill mode state
  21465. */
  21466. private _fillMode;
  21467. /**
  21468. * Specifies if the depth write state should be cached
  21469. */
  21470. private _cachedDepthWriteState;
  21471. /**
  21472. * Specifies if the color write state should be cached
  21473. */
  21474. private _cachedColorWriteState;
  21475. /**
  21476. * Specifies if the depth function state should be cached
  21477. */
  21478. private _cachedDepthFunctionState;
  21479. /**
  21480. * Stores the uniform buffer
  21481. */
  21482. protected _uniformBuffer: UniformBuffer;
  21483. /** @hidden */
  21484. _indexInSceneMaterialArray: number;
  21485. /** @hidden */
  21486. meshMap: Nullable<{
  21487. [id: string]: AbstractMesh | undefined;
  21488. }>;
  21489. /**
  21490. * Creates a material instance
  21491. * @param name defines the name of the material
  21492. * @param scene defines the scene to reference
  21493. * @param doNotAdd specifies if the material should be added to the scene
  21494. */
  21495. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21496. /**
  21497. * Returns a string representation of the current material
  21498. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21499. * @returns a string with material information
  21500. */
  21501. toString(fullDetails?: boolean): string;
  21502. /**
  21503. * Gets the class name of the material
  21504. * @returns a string with the class name of the material
  21505. */
  21506. getClassName(): string;
  21507. /**
  21508. * Specifies if updates for the material been locked
  21509. */
  21510. get isFrozen(): boolean;
  21511. /**
  21512. * Locks updates for the material
  21513. */
  21514. freeze(): void;
  21515. /**
  21516. * Unlocks updates for the material
  21517. */
  21518. unfreeze(): void;
  21519. /**
  21520. * Specifies if the material is ready to be used
  21521. * @param mesh defines the mesh to check
  21522. * @param useInstances specifies if instances should be used
  21523. * @returns a boolean indicating if the material is ready to be used
  21524. */
  21525. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21526. /**
  21527. * Specifies that the submesh is ready to be used
  21528. * @param mesh defines the mesh to check
  21529. * @param subMesh defines which submesh to check
  21530. * @param useInstances specifies that instances should be used
  21531. * @returns a boolean indicating that the submesh is ready or not
  21532. */
  21533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21534. /**
  21535. * Returns the material effect
  21536. * @returns the effect associated with the material
  21537. */
  21538. getEffect(): Nullable<Effect>;
  21539. /**
  21540. * Returns the current scene
  21541. * @returns a Scene
  21542. */
  21543. getScene(): Scene;
  21544. /**
  21545. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21546. */
  21547. protected _forceAlphaTest: boolean;
  21548. /**
  21549. * The transparency mode of the material.
  21550. */
  21551. protected _transparencyMode: Nullable<number>;
  21552. /**
  21553. * Gets the current transparency mode.
  21554. */
  21555. get transparencyMode(): Nullable<number>;
  21556. /**
  21557. * Sets the transparency mode of the material.
  21558. *
  21559. * | Value | Type | Description |
  21560. * | ----- | ----------------------------------- | ----------- |
  21561. * | 0 | OPAQUE | |
  21562. * | 1 | ALPHATEST | |
  21563. * | 2 | ALPHABLEND | |
  21564. * | 3 | ALPHATESTANDBLEND | |
  21565. *
  21566. */
  21567. set transparencyMode(value: Nullable<number>);
  21568. /**
  21569. * Returns true if alpha blending should be disabled.
  21570. */
  21571. protected get _disableAlphaBlending(): boolean;
  21572. /**
  21573. * Specifies whether or not this material should be rendered in alpha blend mode.
  21574. * @returns a boolean specifying if alpha blending is needed
  21575. */
  21576. needAlphaBlending(): boolean;
  21577. /**
  21578. * Specifies if the mesh will require alpha blending
  21579. * @param mesh defines the mesh to check
  21580. * @returns a boolean specifying if alpha blending is needed for the mesh
  21581. */
  21582. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21583. /**
  21584. * Specifies whether or not this material should be rendered in alpha test mode.
  21585. * @returns a boolean specifying if an alpha test is needed.
  21586. */
  21587. needAlphaTesting(): boolean;
  21588. /**
  21589. * Specifies if material alpha testing should be turned on for the mesh
  21590. * @param mesh defines the mesh to check
  21591. */
  21592. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21593. /**
  21594. * Gets the texture used for the alpha test
  21595. * @returns the texture to use for alpha testing
  21596. */
  21597. getAlphaTestTexture(): Nullable<BaseTexture>;
  21598. /**
  21599. * Marks the material to indicate that it needs to be re-calculated
  21600. */
  21601. markDirty(): void;
  21602. /** @hidden */
  21603. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21604. /**
  21605. * Binds the material to the mesh
  21606. * @param world defines the world transformation matrix
  21607. * @param mesh defines the mesh to bind the material to
  21608. */
  21609. bind(world: Matrix, mesh?: Mesh): void;
  21610. /**
  21611. * Binds the submesh to the material
  21612. * @param world defines the world transformation matrix
  21613. * @param mesh defines the mesh containing the submesh
  21614. * @param subMesh defines the submesh to bind the material to
  21615. */
  21616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21617. /**
  21618. * Binds the world matrix to the material
  21619. * @param world defines the world transformation matrix
  21620. */
  21621. bindOnlyWorldMatrix(world: Matrix): void;
  21622. /**
  21623. * Binds the scene's uniform buffer to the effect.
  21624. * @param effect defines the effect to bind to the scene uniform buffer
  21625. * @param sceneUbo defines the uniform buffer storing scene data
  21626. */
  21627. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21628. /**
  21629. * Binds the view matrix to the effect
  21630. * @param effect defines the effect to bind the view matrix to
  21631. */
  21632. bindView(effect: Effect): void;
  21633. /**
  21634. * Binds the view projection matrix to the effect
  21635. * @param effect defines the effect to bind the view projection matrix to
  21636. */
  21637. bindViewProjection(effect: Effect): void;
  21638. /**
  21639. * Processes to execute after binding the material to a mesh
  21640. * @param mesh defines the rendered mesh
  21641. */
  21642. protected _afterBind(mesh?: Mesh): void;
  21643. /**
  21644. * Unbinds the material from the mesh
  21645. */
  21646. unbind(): void;
  21647. /**
  21648. * Gets the active textures from the material
  21649. * @returns an array of textures
  21650. */
  21651. getActiveTextures(): BaseTexture[];
  21652. /**
  21653. * Specifies if the material uses a texture
  21654. * @param texture defines the texture to check against the material
  21655. * @returns a boolean specifying if the material uses the texture
  21656. */
  21657. hasTexture(texture: BaseTexture): boolean;
  21658. /**
  21659. * Makes a duplicate of the material, and gives it a new name
  21660. * @param name defines the new name for the duplicated material
  21661. * @returns the cloned material
  21662. */
  21663. clone(name: string): Nullable<Material>;
  21664. /**
  21665. * Gets the meshes bound to the material
  21666. * @returns an array of meshes bound to the material
  21667. */
  21668. getBindedMeshes(): AbstractMesh[];
  21669. /**
  21670. * Force shader compilation
  21671. * @param mesh defines the mesh associated with this material
  21672. * @param onCompiled defines a function to execute once the material is compiled
  21673. * @param options defines the options to configure the compilation
  21674. * @param onError defines a function to execute if the material fails compiling
  21675. */
  21676. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21677. /**
  21678. * Force shader compilation
  21679. * @param mesh defines the mesh that will use this material
  21680. * @param options defines additional options for compiling the shaders
  21681. * @returns a promise that resolves when the compilation completes
  21682. */
  21683. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21684. private static readonly _AllDirtyCallBack;
  21685. private static readonly _ImageProcessingDirtyCallBack;
  21686. private static readonly _TextureDirtyCallBack;
  21687. private static readonly _FresnelDirtyCallBack;
  21688. private static readonly _MiscDirtyCallBack;
  21689. private static readonly _LightsDirtyCallBack;
  21690. private static readonly _AttributeDirtyCallBack;
  21691. private static _FresnelAndMiscDirtyCallBack;
  21692. private static _TextureAndMiscDirtyCallBack;
  21693. private static readonly _DirtyCallbackArray;
  21694. private static readonly _RunDirtyCallBacks;
  21695. /**
  21696. * Marks a define in the material to indicate that it needs to be re-computed
  21697. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21698. */
  21699. markAsDirty(flag: number): void;
  21700. /**
  21701. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21702. * @param func defines a function which checks material defines against the submeshes
  21703. */
  21704. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21705. /**
  21706. * Indicates that we need to re-calculated for all submeshes
  21707. */
  21708. protected _markAllSubMeshesAsAllDirty(): void;
  21709. /**
  21710. * Indicates that image processing needs to be re-calculated for all submeshes
  21711. */
  21712. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21713. /**
  21714. * Indicates that textures need to be re-calculated for all submeshes
  21715. */
  21716. protected _markAllSubMeshesAsTexturesDirty(): void;
  21717. /**
  21718. * Indicates that fresnel needs to be re-calculated for all submeshes
  21719. */
  21720. protected _markAllSubMeshesAsFresnelDirty(): void;
  21721. /**
  21722. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21723. */
  21724. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21725. /**
  21726. * Indicates that lights need to be re-calculated for all submeshes
  21727. */
  21728. protected _markAllSubMeshesAsLightsDirty(): void;
  21729. /**
  21730. * Indicates that attributes need to be re-calculated for all submeshes
  21731. */
  21732. protected _markAllSubMeshesAsAttributesDirty(): void;
  21733. /**
  21734. * Indicates that misc needs to be re-calculated for all submeshes
  21735. */
  21736. protected _markAllSubMeshesAsMiscDirty(): void;
  21737. /**
  21738. * Indicates that textures and misc need to be re-calculated for all submeshes
  21739. */
  21740. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21741. /**
  21742. * Disposes the material
  21743. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21744. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21745. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21746. */
  21747. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21748. /** @hidden */
  21749. private releaseVertexArrayObject;
  21750. /**
  21751. * Serializes this material
  21752. * @returns the serialized material object
  21753. */
  21754. serialize(): any;
  21755. /**
  21756. * Creates a material from parsed material data
  21757. * @param parsedMaterial defines parsed material data
  21758. * @param scene defines the hosting scene
  21759. * @param rootUrl defines the root URL to use to load textures
  21760. * @returns a new material
  21761. */
  21762. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21763. }
  21764. }
  21765. declare module BABYLON {
  21766. /**
  21767. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21768. * separate meshes. This can be use to improve performances.
  21769. * @see http://doc.babylonjs.com/how_to/multi_materials
  21770. */
  21771. export class MultiMaterial extends Material {
  21772. private _subMaterials;
  21773. /**
  21774. * Gets or Sets the list of Materials used within the multi material.
  21775. * They need to be ordered according to the submeshes order in the associated mesh
  21776. */
  21777. get subMaterials(): Nullable<Material>[];
  21778. set subMaterials(value: Nullable<Material>[]);
  21779. /**
  21780. * Function used to align with Node.getChildren()
  21781. * @returns the list of Materials used within the multi material
  21782. */
  21783. getChildren(): Nullable<Material>[];
  21784. /**
  21785. * Instantiates a new Multi Material
  21786. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21787. * separate meshes. This can be use to improve performances.
  21788. * @see http://doc.babylonjs.com/how_to/multi_materials
  21789. * @param name Define the name in the scene
  21790. * @param scene Define the scene the material belongs to
  21791. */
  21792. constructor(name: string, scene: Scene);
  21793. private _hookArray;
  21794. /**
  21795. * Get one of the submaterial by its index in the submaterials array
  21796. * @param index The index to look the sub material at
  21797. * @returns The Material if the index has been defined
  21798. */
  21799. getSubMaterial(index: number): Nullable<Material>;
  21800. /**
  21801. * Get the list of active textures for the whole sub materials list.
  21802. * @returns All the textures that will be used during the rendering
  21803. */
  21804. getActiveTextures(): BaseTexture[];
  21805. /**
  21806. * Gets the current class name of the material e.g. "MultiMaterial"
  21807. * Mainly use in serialization.
  21808. * @returns the class name
  21809. */
  21810. getClassName(): string;
  21811. /**
  21812. * Checks if the material is ready to render the requested sub mesh
  21813. * @param mesh Define the mesh the submesh belongs to
  21814. * @param subMesh Define the sub mesh to look readyness for
  21815. * @param useInstances Define whether or not the material is used with instances
  21816. * @returns true if ready, otherwise false
  21817. */
  21818. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21819. /**
  21820. * Clones the current material and its related sub materials
  21821. * @param name Define the name of the newly cloned material
  21822. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21823. * @returns the cloned material
  21824. */
  21825. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21826. /**
  21827. * Serializes the materials into a JSON representation.
  21828. * @returns the JSON representation
  21829. */
  21830. serialize(): any;
  21831. /**
  21832. * Dispose the material and release its associated resources
  21833. * @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)
  21834. * @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)
  21835. * @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)
  21836. */
  21837. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21838. /**
  21839. * Creates a MultiMaterial from parsed MultiMaterial data.
  21840. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21841. * @param scene defines the hosting scene
  21842. * @returns a new MultiMaterial
  21843. */
  21844. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21845. }
  21846. }
  21847. declare module BABYLON {
  21848. /**
  21849. * Base class for submeshes
  21850. */
  21851. export class BaseSubMesh {
  21852. /** @hidden */
  21853. _materialDefines: Nullable<MaterialDefines>;
  21854. /** @hidden */
  21855. _materialEffect: Nullable<Effect>;
  21856. /** @hidden */
  21857. _effectOverride: Nullable<Effect>;
  21858. /**
  21859. * Gets material defines used by the effect associated to the sub mesh
  21860. */
  21861. get materialDefines(): Nullable<MaterialDefines>;
  21862. /**
  21863. * Sets material defines used by the effect associated to the sub mesh
  21864. */
  21865. set materialDefines(defines: Nullable<MaterialDefines>);
  21866. /**
  21867. * Gets associated effect
  21868. */
  21869. get effect(): Nullable<Effect>;
  21870. /**
  21871. * Sets associated effect (effect used to render this submesh)
  21872. * @param effect defines the effect to associate with
  21873. * @param defines defines the set of defines used to compile this effect
  21874. */
  21875. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21876. }
  21877. /**
  21878. * Defines a subdivision inside a mesh
  21879. */
  21880. export class SubMesh extends BaseSubMesh implements ICullable {
  21881. /** the material index to use */
  21882. materialIndex: number;
  21883. /** vertex index start */
  21884. verticesStart: number;
  21885. /** vertices count */
  21886. verticesCount: number;
  21887. /** index start */
  21888. indexStart: number;
  21889. /** indices count */
  21890. indexCount: number;
  21891. /** @hidden */
  21892. _linesIndexCount: number;
  21893. private _mesh;
  21894. private _renderingMesh;
  21895. private _boundingInfo;
  21896. private _linesIndexBuffer;
  21897. /** @hidden */
  21898. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21899. /** @hidden */
  21900. _trianglePlanes: Plane[];
  21901. /** @hidden */
  21902. _lastColliderTransformMatrix: Nullable<Matrix>;
  21903. /** @hidden */
  21904. _renderId: number;
  21905. /** @hidden */
  21906. _alphaIndex: number;
  21907. /** @hidden */
  21908. _distanceToCamera: number;
  21909. /** @hidden */
  21910. _id: number;
  21911. private _currentMaterial;
  21912. /**
  21913. * Add a new submesh to a mesh
  21914. * @param materialIndex defines the material index to use
  21915. * @param verticesStart defines vertex index start
  21916. * @param verticesCount defines vertices count
  21917. * @param indexStart defines index start
  21918. * @param indexCount defines indices count
  21919. * @param mesh defines the parent mesh
  21920. * @param renderingMesh defines an optional rendering mesh
  21921. * @param createBoundingBox defines if bounding box should be created for this submesh
  21922. * @returns the new submesh
  21923. */
  21924. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21925. /**
  21926. * Creates a new submesh
  21927. * @param materialIndex defines the material index to use
  21928. * @param verticesStart defines vertex index start
  21929. * @param verticesCount defines vertices count
  21930. * @param indexStart defines index start
  21931. * @param indexCount defines indices count
  21932. * @param mesh defines the parent mesh
  21933. * @param renderingMesh defines an optional rendering mesh
  21934. * @param createBoundingBox defines if bounding box should be created for this submesh
  21935. */
  21936. constructor(
  21937. /** the material index to use */
  21938. materialIndex: number,
  21939. /** vertex index start */
  21940. verticesStart: number,
  21941. /** vertices count */
  21942. verticesCount: number,
  21943. /** index start */
  21944. indexStart: number,
  21945. /** indices count */
  21946. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21947. /**
  21948. * Returns true if this submesh covers the entire parent mesh
  21949. * @ignorenaming
  21950. */
  21951. get IsGlobal(): boolean;
  21952. /**
  21953. * Returns the submesh BoudingInfo object
  21954. * @returns current bounding info (or mesh's one if the submesh is global)
  21955. */
  21956. getBoundingInfo(): BoundingInfo;
  21957. /**
  21958. * Sets the submesh BoundingInfo
  21959. * @param boundingInfo defines the new bounding info to use
  21960. * @returns the SubMesh
  21961. */
  21962. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21963. /**
  21964. * Returns the mesh of the current submesh
  21965. * @return the parent mesh
  21966. */
  21967. getMesh(): AbstractMesh;
  21968. /**
  21969. * Returns the rendering mesh of the submesh
  21970. * @returns the rendering mesh (could be different from parent mesh)
  21971. */
  21972. getRenderingMesh(): Mesh;
  21973. /**
  21974. * Returns the submesh material
  21975. * @returns null or the current material
  21976. */
  21977. getMaterial(): Nullable<Material>;
  21978. /**
  21979. * Sets a new updated BoundingInfo object to the submesh
  21980. * @param data defines an optional position array to use to determine the bounding info
  21981. * @returns the SubMesh
  21982. */
  21983. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21984. /** @hidden */
  21985. _checkCollision(collider: Collider): boolean;
  21986. /**
  21987. * Updates the submesh BoundingInfo
  21988. * @param world defines the world matrix to use to update the bounding info
  21989. * @returns the submesh
  21990. */
  21991. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21992. /**
  21993. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21994. * @param frustumPlanes defines the frustum planes
  21995. * @returns true if the submesh is intersecting with the frustum
  21996. */
  21997. isInFrustum(frustumPlanes: Plane[]): boolean;
  21998. /**
  21999. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22000. * @param frustumPlanes defines the frustum planes
  22001. * @returns true if the submesh is inside the frustum
  22002. */
  22003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22004. /**
  22005. * Renders the submesh
  22006. * @param enableAlphaMode defines if alpha needs to be used
  22007. * @returns the submesh
  22008. */
  22009. render(enableAlphaMode: boolean): SubMesh;
  22010. /**
  22011. * @hidden
  22012. */
  22013. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22014. /**
  22015. * Checks if the submesh intersects with a ray
  22016. * @param ray defines the ray to test
  22017. * @returns true is the passed ray intersects the submesh bounding box
  22018. */
  22019. canIntersects(ray: Ray): boolean;
  22020. /**
  22021. * Intersects current submesh with a ray
  22022. * @param ray defines the ray to test
  22023. * @param positions defines mesh's positions array
  22024. * @param indices defines mesh's indices array
  22025. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22026. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22027. * @returns intersection info or null if no intersection
  22028. */
  22029. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22030. /** @hidden */
  22031. private _intersectLines;
  22032. /** @hidden */
  22033. private _intersectUnIndexedLines;
  22034. /** @hidden */
  22035. private _intersectTriangles;
  22036. /** @hidden */
  22037. private _intersectUnIndexedTriangles;
  22038. /** @hidden */
  22039. _rebuild(): void;
  22040. /**
  22041. * Creates a new submesh from the passed mesh
  22042. * @param newMesh defines the new hosting mesh
  22043. * @param newRenderingMesh defines an optional rendering mesh
  22044. * @returns the new submesh
  22045. */
  22046. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22047. /**
  22048. * Release associated resources
  22049. */
  22050. dispose(): void;
  22051. /**
  22052. * Gets the class name
  22053. * @returns the string "SubMesh".
  22054. */
  22055. getClassName(): string;
  22056. /**
  22057. * Creates a new submesh from indices data
  22058. * @param materialIndex the index of the main mesh material
  22059. * @param startIndex the index where to start the copy in the mesh indices array
  22060. * @param indexCount the number of indices to copy then from the startIndex
  22061. * @param mesh the main mesh to create the submesh from
  22062. * @param renderingMesh the optional rendering mesh
  22063. * @returns a new submesh
  22064. */
  22065. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22066. }
  22067. }
  22068. declare module BABYLON {
  22069. /**
  22070. * Class used to represent data loading progression
  22071. */
  22072. export class SceneLoaderFlags {
  22073. private static _ForceFullSceneLoadingForIncremental;
  22074. private static _ShowLoadingScreen;
  22075. private static _CleanBoneMatrixWeights;
  22076. private static _loggingLevel;
  22077. /**
  22078. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22079. */
  22080. static get ForceFullSceneLoadingForIncremental(): boolean;
  22081. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22082. /**
  22083. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22084. */
  22085. static get ShowLoadingScreen(): boolean;
  22086. static set ShowLoadingScreen(value: boolean);
  22087. /**
  22088. * Defines the current logging level (while loading the scene)
  22089. * @ignorenaming
  22090. */
  22091. static get loggingLevel(): number;
  22092. static set loggingLevel(value: number);
  22093. /**
  22094. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22095. */
  22096. static get CleanBoneMatrixWeights(): boolean;
  22097. static set CleanBoneMatrixWeights(value: boolean);
  22098. }
  22099. }
  22100. declare module BABYLON {
  22101. /**
  22102. * Class used to store geometry data (vertex buffers + index buffer)
  22103. */
  22104. export class Geometry implements IGetSetVerticesData {
  22105. /**
  22106. * Gets or sets the ID of the geometry
  22107. */
  22108. id: string;
  22109. /**
  22110. * Gets or sets the unique ID of the geometry
  22111. */
  22112. uniqueId: number;
  22113. /**
  22114. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22115. */
  22116. delayLoadState: number;
  22117. /**
  22118. * Gets the file containing the data to load when running in delay load state
  22119. */
  22120. delayLoadingFile: Nullable<string>;
  22121. /**
  22122. * Callback called when the geometry is updated
  22123. */
  22124. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22125. private _scene;
  22126. private _engine;
  22127. private _meshes;
  22128. private _totalVertices;
  22129. /** @hidden */
  22130. _indices: IndicesArray;
  22131. /** @hidden */
  22132. _vertexBuffers: {
  22133. [key: string]: VertexBuffer;
  22134. };
  22135. private _isDisposed;
  22136. private _extend;
  22137. private _boundingBias;
  22138. /** @hidden */
  22139. _delayInfo: Array<string>;
  22140. private _indexBuffer;
  22141. private _indexBufferIsUpdatable;
  22142. /** @hidden */
  22143. _boundingInfo: Nullable<BoundingInfo>;
  22144. /** @hidden */
  22145. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22146. /** @hidden */
  22147. _softwareSkinningFrameId: number;
  22148. private _vertexArrayObjects;
  22149. private _updatable;
  22150. /** @hidden */
  22151. _positions: Nullable<Vector3[]>;
  22152. /**
  22153. * 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
  22154. */
  22155. get boundingBias(): Vector2;
  22156. /**
  22157. * 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
  22158. */
  22159. set boundingBias(value: Vector2);
  22160. /**
  22161. * Static function used to attach a new empty geometry to a mesh
  22162. * @param mesh defines the mesh to attach the geometry to
  22163. * @returns the new Geometry
  22164. */
  22165. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22166. /** Get the list of meshes using this geometry */
  22167. get meshes(): Mesh[];
  22168. /**
  22169. * Creates a new geometry
  22170. * @param id defines the unique ID
  22171. * @param scene defines the hosting scene
  22172. * @param vertexData defines the VertexData used to get geometry data
  22173. * @param updatable defines if geometry must be updatable (false by default)
  22174. * @param mesh defines the mesh that will be associated with the geometry
  22175. */
  22176. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22177. /**
  22178. * Gets the current extend of the geometry
  22179. */
  22180. get extend(): {
  22181. minimum: Vector3;
  22182. maximum: Vector3;
  22183. };
  22184. /**
  22185. * Gets the hosting scene
  22186. * @returns the hosting Scene
  22187. */
  22188. getScene(): Scene;
  22189. /**
  22190. * Gets the hosting engine
  22191. * @returns the hosting Engine
  22192. */
  22193. getEngine(): Engine;
  22194. /**
  22195. * Defines if the geometry is ready to use
  22196. * @returns true if the geometry is ready to be used
  22197. */
  22198. isReady(): boolean;
  22199. /**
  22200. * Gets a value indicating that the geometry should not be serialized
  22201. */
  22202. get doNotSerialize(): boolean;
  22203. /** @hidden */
  22204. _rebuild(): void;
  22205. /**
  22206. * Affects all geometry data in one call
  22207. * @param vertexData defines the geometry data
  22208. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22209. */
  22210. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22211. /**
  22212. * Set specific vertex data
  22213. * @param kind defines the data kind (Position, normal, etc...)
  22214. * @param data defines the vertex data to use
  22215. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22216. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22217. */
  22218. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22219. /**
  22220. * Removes a specific vertex data
  22221. * @param kind defines the data kind (Position, normal, etc...)
  22222. */
  22223. removeVerticesData(kind: string): void;
  22224. /**
  22225. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22226. * @param buffer defines the vertex buffer to use
  22227. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22228. */
  22229. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22230. /**
  22231. * Update a specific vertex buffer
  22232. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22233. * It will do nothing if the buffer is not updatable
  22234. * @param kind defines the data kind (Position, normal, etc...)
  22235. * @param data defines the data to use
  22236. * @param offset defines the offset in the target buffer where to store the data
  22237. * @param useBytes set to true if the offset is in bytes
  22238. */
  22239. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22240. /**
  22241. * Update a specific vertex buffer
  22242. * This function will create a new buffer if the current one is not updatable
  22243. * @param kind defines the data kind (Position, normal, etc...)
  22244. * @param data defines the data to use
  22245. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22246. */
  22247. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22248. private _updateBoundingInfo;
  22249. /** @hidden */
  22250. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22251. /**
  22252. * Gets total number of vertices
  22253. * @returns the total number of vertices
  22254. */
  22255. getTotalVertices(): number;
  22256. /**
  22257. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22258. * @param kind defines the data kind (Position, normal, etc...)
  22259. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22260. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22261. * @returns a float array containing vertex data
  22262. */
  22263. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22264. /**
  22265. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22266. * @param kind defines the data kind (Position, normal, etc...)
  22267. * @returns true if the vertex buffer with the specified kind is updatable
  22268. */
  22269. isVertexBufferUpdatable(kind: string): boolean;
  22270. /**
  22271. * Gets a specific vertex buffer
  22272. * @param kind defines the data kind (Position, normal, etc...)
  22273. * @returns a VertexBuffer
  22274. */
  22275. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22276. /**
  22277. * Returns all vertex buffers
  22278. * @return an object holding all vertex buffers indexed by kind
  22279. */
  22280. getVertexBuffers(): Nullable<{
  22281. [key: string]: VertexBuffer;
  22282. }>;
  22283. /**
  22284. * Gets a boolean indicating if specific vertex buffer is present
  22285. * @param kind defines the data kind (Position, normal, etc...)
  22286. * @returns true if data is present
  22287. */
  22288. isVerticesDataPresent(kind: string): boolean;
  22289. /**
  22290. * Gets a list of all attached data kinds (Position, normal, etc...)
  22291. * @returns a list of string containing all kinds
  22292. */
  22293. getVerticesDataKinds(): string[];
  22294. /**
  22295. * Update index buffer
  22296. * @param indices defines the indices to store in the index buffer
  22297. * @param offset defines the offset in the target buffer where to store the data
  22298. * @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)
  22299. */
  22300. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22301. /**
  22302. * Creates a new index buffer
  22303. * @param indices defines the indices to store in the index buffer
  22304. * @param totalVertices defines the total number of vertices (could be null)
  22305. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22306. */
  22307. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22308. /**
  22309. * Return the total number of indices
  22310. * @returns the total number of indices
  22311. */
  22312. getTotalIndices(): number;
  22313. /**
  22314. * Gets the index buffer array
  22315. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22316. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22317. * @returns the index buffer array
  22318. */
  22319. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22320. /**
  22321. * Gets the index buffer
  22322. * @return the index buffer
  22323. */
  22324. getIndexBuffer(): Nullable<DataBuffer>;
  22325. /** @hidden */
  22326. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22327. /**
  22328. * Release the associated resources for a specific mesh
  22329. * @param mesh defines the source mesh
  22330. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22331. */
  22332. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22333. /**
  22334. * Apply current geometry to a given mesh
  22335. * @param mesh defines the mesh to apply geometry to
  22336. */
  22337. applyToMesh(mesh: Mesh): void;
  22338. private _updateExtend;
  22339. private _applyToMesh;
  22340. private notifyUpdate;
  22341. /**
  22342. * Load the geometry if it was flagged as delay loaded
  22343. * @param scene defines the hosting scene
  22344. * @param onLoaded defines a callback called when the geometry is loaded
  22345. */
  22346. load(scene: Scene, onLoaded?: () => void): void;
  22347. private _queueLoad;
  22348. /**
  22349. * Invert the geometry to move from a right handed system to a left handed one.
  22350. */
  22351. toLeftHanded(): void;
  22352. /** @hidden */
  22353. _resetPointsArrayCache(): void;
  22354. /** @hidden */
  22355. _generatePointsArray(): boolean;
  22356. /**
  22357. * Gets a value indicating if the geometry is disposed
  22358. * @returns true if the geometry was disposed
  22359. */
  22360. isDisposed(): boolean;
  22361. private _disposeVertexArrayObjects;
  22362. /**
  22363. * Free all associated resources
  22364. */
  22365. dispose(): void;
  22366. /**
  22367. * Clone the current geometry into a new geometry
  22368. * @param id defines the unique ID of the new geometry
  22369. * @returns a new geometry object
  22370. */
  22371. copy(id: string): Geometry;
  22372. /**
  22373. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22374. * @return a JSON representation of the current geometry data (without the vertices data)
  22375. */
  22376. serialize(): any;
  22377. private toNumberArray;
  22378. /**
  22379. * Serialize all vertices data into a JSON oject
  22380. * @returns a JSON representation of the current geometry data
  22381. */
  22382. serializeVerticeData(): any;
  22383. /**
  22384. * Extracts a clone of a mesh geometry
  22385. * @param mesh defines the source mesh
  22386. * @param id defines the unique ID of the new geometry object
  22387. * @returns the new geometry object
  22388. */
  22389. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22390. /**
  22391. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22392. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22393. * Be aware Math.random() could cause collisions, but:
  22394. * "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"
  22395. * @returns a string containing a new GUID
  22396. */
  22397. static RandomId(): string;
  22398. /** @hidden */
  22399. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22400. private static _CleanMatricesWeights;
  22401. /**
  22402. * Create a new geometry from persisted data (Using .babylon file format)
  22403. * @param parsedVertexData defines the persisted data
  22404. * @param scene defines the hosting scene
  22405. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22406. * @returns the new geometry object
  22407. */
  22408. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22409. }
  22410. }
  22411. declare module BABYLON {
  22412. /**
  22413. * Define an interface for all classes that will get and set the data on vertices
  22414. */
  22415. export interface IGetSetVerticesData {
  22416. /**
  22417. * Gets a boolean indicating if specific vertex data is present
  22418. * @param kind defines the vertex data kind to use
  22419. * @returns true is data kind is present
  22420. */
  22421. isVerticesDataPresent(kind: string): boolean;
  22422. /**
  22423. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22424. * @param kind defines the data kind (Position, normal, etc...)
  22425. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22426. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22427. * @returns a float array containing vertex data
  22428. */
  22429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22430. /**
  22431. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22432. * @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.
  22433. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22434. * @returns the indices array or an empty array if the mesh has no geometry
  22435. */
  22436. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22437. /**
  22438. * Set specific vertex data
  22439. * @param kind defines the data kind (Position, normal, etc...)
  22440. * @param data defines the vertex data to use
  22441. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22442. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22443. */
  22444. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22445. /**
  22446. * Update a specific associated vertex buffer
  22447. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22448. * - VertexBuffer.PositionKind
  22449. * - VertexBuffer.UVKind
  22450. * - VertexBuffer.UV2Kind
  22451. * - VertexBuffer.UV3Kind
  22452. * - VertexBuffer.UV4Kind
  22453. * - VertexBuffer.UV5Kind
  22454. * - VertexBuffer.UV6Kind
  22455. * - VertexBuffer.ColorKind
  22456. * - VertexBuffer.MatricesIndicesKind
  22457. * - VertexBuffer.MatricesIndicesExtraKind
  22458. * - VertexBuffer.MatricesWeightsKind
  22459. * - VertexBuffer.MatricesWeightsExtraKind
  22460. * @param data defines the data source
  22461. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22462. * @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)
  22463. */
  22464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22465. /**
  22466. * Creates a new index buffer
  22467. * @param indices defines the indices to store in the index buffer
  22468. * @param totalVertices defines the total number of vertices (could be null)
  22469. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22470. */
  22471. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22472. }
  22473. /**
  22474. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22475. */
  22476. export class VertexData {
  22477. /**
  22478. * Mesh side orientation : usually the external or front surface
  22479. */
  22480. static readonly FRONTSIDE: number;
  22481. /**
  22482. * Mesh side orientation : usually the internal or back surface
  22483. */
  22484. static readonly BACKSIDE: number;
  22485. /**
  22486. * Mesh side orientation : both internal and external or front and back surfaces
  22487. */
  22488. static readonly DOUBLESIDE: number;
  22489. /**
  22490. * Mesh side orientation : by default, `FRONTSIDE`
  22491. */
  22492. static readonly DEFAULTSIDE: number;
  22493. /**
  22494. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22495. */
  22496. positions: Nullable<FloatArray>;
  22497. /**
  22498. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22499. */
  22500. normals: Nullable<FloatArray>;
  22501. /**
  22502. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22503. */
  22504. tangents: Nullable<FloatArray>;
  22505. /**
  22506. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22507. */
  22508. uvs: Nullable<FloatArray>;
  22509. /**
  22510. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22511. */
  22512. uvs2: Nullable<FloatArray>;
  22513. /**
  22514. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22515. */
  22516. uvs3: Nullable<FloatArray>;
  22517. /**
  22518. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22519. */
  22520. uvs4: Nullable<FloatArray>;
  22521. /**
  22522. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22523. */
  22524. uvs5: Nullable<FloatArray>;
  22525. /**
  22526. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22527. */
  22528. uvs6: Nullable<FloatArray>;
  22529. /**
  22530. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22531. */
  22532. colors: Nullable<FloatArray>;
  22533. /**
  22534. * 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).
  22535. */
  22536. matricesIndices: Nullable<FloatArray>;
  22537. /**
  22538. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22539. */
  22540. matricesWeights: Nullable<FloatArray>;
  22541. /**
  22542. * An array extending the number of possible indices
  22543. */
  22544. matricesIndicesExtra: Nullable<FloatArray>;
  22545. /**
  22546. * An array extending the number of possible weights when the number of indices is extended
  22547. */
  22548. matricesWeightsExtra: Nullable<FloatArray>;
  22549. /**
  22550. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22551. */
  22552. indices: Nullable<IndicesArray>;
  22553. /**
  22554. * Uses the passed data array to set the set the values for the specified kind of data
  22555. * @param data a linear array of floating numbers
  22556. * @param kind the type of data that is being set, eg positions, colors etc
  22557. */
  22558. set(data: FloatArray, kind: string): void;
  22559. /**
  22560. * Associates the vertexData to the passed Mesh.
  22561. * Sets it as updatable or not (default `false`)
  22562. * @param mesh the mesh the vertexData is applied to
  22563. * @param updatable when used and having the value true allows new data to update the vertexData
  22564. * @returns the VertexData
  22565. */
  22566. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22567. /**
  22568. * Associates the vertexData to the passed Geometry.
  22569. * Sets it as updatable or not (default `false`)
  22570. * @param geometry the geometry the vertexData is applied to
  22571. * @param updatable when used and having the value true allows new data to update the vertexData
  22572. * @returns VertexData
  22573. */
  22574. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22575. /**
  22576. * Updates the associated mesh
  22577. * @param mesh the mesh to be updated
  22578. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22579. * @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
  22580. * @returns VertexData
  22581. */
  22582. updateMesh(mesh: Mesh): VertexData;
  22583. /**
  22584. * Updates the associated geometry
  22585. * @param geometry the geometry to be updated
  22586. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22587. * @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
  22588. * @returns VertexData.
  22589. */
  22590. updateGeometry(geometry: Geometry): VertexData;
  22591. private _applyTo;
  22592. private _update;
  22593. /**
  22594. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22595. * @param matrix the transforming matrix
  22596. * @returns the VertexData
  22597. */
  22598. transform(matrix: Matrix): VertexData;
  22599. /**
  22600. * Merges the passed VertexData into the current one
  22601. * @param other the VertexData to be merged into the current one
  22602. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22603. * @returns the modified VertexData
  22604. */
  22605. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22606. private _mergeElement;
  22607. private _validate;
  22608. /**
  22609. * Serializes the VertexData
  22610. * @returns a serialized object
  22611. */
  22612. serialize(): any;
  22613. /**
  22614. * Extracts the vertexData from a mesh
  22615. * @param mesh the mesh from which to extract the VertexData
  22616. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22617. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22618. * @returns the object VertexData associated to the passed mesh
  22619. */
  22620. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22621. /**
  22622. * Extracts the vertexData from the geometry
  22623. * @param geometry the geometry from which to extract the VertexData
  22624. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22625. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22626. * @returns the object VertexData associated to the passed mesh
  22627. */
  22628. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22629. private static _ExtractFrom;
  22630. /**
  22631. * Creates the VertexData for a Ribbon
  22632. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22633. * * pathArray array of paths, each of which an array of successive Vector3
  22634. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22635. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22636. * * 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
  22637. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22638. * * 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)
  22639. * * 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)
  22640. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22641. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22642. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22643. * @returns the VertexData of the ribbon
  22644. */
  22645. static CreateRibbon(options: {
  22646. pathArray: Vector3[][];
  22647. closeArray?: boolean;
  22648. closePath?: boolean;
  22649. offset?: number;
  22650. sideOrientation?: number;
  22651. frontUVs?: Vector4;
  22652. backUVs?: Vector4;
  22653. invertUV?: boolean;
  22654. uvs?: Vector2[];
  22655. colors?: Color4[];
  22656. }): VertexData;
  22657. /**
  22658. * Creates the VertexData for a box
  22659. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22660. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22661. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22662. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22663. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22664. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22665. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22667. * * 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)
  22668. * * 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)
  22669. * @returns the VertexData of the box
  22670. */
  22671. static CreateBox(options: {
  22672. size?: number;
  22673. width?: number;
  22674. height?: number;
  22675. depth?: number;
  22676. faceUV?: Vector4[];
  22677. faceColors?: Color4[];
  22678. sideOrientation?: number;
  22679. frontUVs?: Vector4;
  22680. backUVs?: Vector4;
  22681. }): VertexData;
  22682. /**
  22683. * Creates the VertexData for a tiled box
  22684. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22685. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22686. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22687. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22688. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22689. * @returns the VertexData of the box
  22690. */
  22691. static CreateTiledBox(options: {
  22692. pattern?: number;
  22693. width?: number;
  22694. height?: number;
  22695. depth?: number;
  22696. tileSize?: number;
  22697. tileWidth?: number;
  22698. tileHeight?: number;
  22699. alignHorizontal?: number;
  22700. alignVertical?: number;
  22701. faceUV?: Vector4[];
  22702. faceColors?: Color4[];
  22703. sideOrientation?: number;
  22704. }): VertexData;
  22705. /**
  22706. * Creates the VertexData for a tiled plane
  22707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22708. * * pattern a limited pattern arrangement depending on the number
  22709. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22710. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22711. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22713. * * 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)
  22714. * * 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)
  22715. * @returns the VertexData of the tiled plane
  22716. */
  22717. static CreateTiledPlane(options: {
  22718. pattern?: number;
  22719. tileSize?: number;
  22720. tileWidth?: number;
  22721. tileHeight?: number;
  22722. size?: number;
  22723. width?: number;
  22724. height?: number;
  22725. alignHorizontal?: number;
  22726. alignVertical?: number;
  22727. sideOrientation?: number;
  22728. frontUVs?: Vector4;
  22729. backUVs?: Vector4;
  22730. }): VertexData;
  22731. /**
  22732. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22733. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22734. * * segments sets the number of horizontal strips optional, default 32
  22735. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22736. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22737. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22738. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22739. * * 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
  22740. * * 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
  22741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22742. * * 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)
  22743. * * 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)
  22744. * @returns the VertexData of the ellipsoid
  22745. */
  22746. static CreateSphere(options: {
  22747. segments?: number;
  22748. diameter?: number;
  22749. diameterX?: number;
  22750. diameterY?: number;
  22751. diameterZ?: number;
  22752. arc?: number;
  22753. slice?: number;
  22754. sideOrientation?: number;
  22755. frontUVs?: Vector4;
  22756. backUVs?: Vector4;
  22757. }): VertexData;
  22758. /**
  22759. * Creates the VertexData for a cylinder, cone or prism
  22760. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22761. * * height sets the height (y direction) of the cylinder, optional, default 2
  22762. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22763. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22764. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22765. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22766. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22767. * * 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
  22768. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22769. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22770. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22771. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the cylinder, cone or prism
  22776. */
  22777. static CreateCylinder(options: {
  22778. height?: number;
  22779. diameterTop?: number;
  22780. diameterBottom?: number;
  22781. diameter?: number;
  22782. tessellation?: number;
  22783. subdivisions?: number;
  22784. arc?: number;
  22785. faceColors?: Color4[];
  22786. faceUV?: Vector4[];
  22787. hasRings?: boolean;
  22788. enclose?: boolean;
  22789. sideOrientation?: number;
  22790. frontUVs?: Vector4;
  22791. backUVs?: Vector4;
  22792. }): VertexData;
  22793. /**
  22794. * Creates the VertexData for a torus
  22795. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22796. * * diameter the diameter of the torus, optional default 1
  22797. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22798. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22800. * * 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)
  22801. * * 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)
  22802. * @returns the VertexData of the torus
  22803. */
  22804. static CreateTorus(options: {
  22805. diameter?: number;
  22806. thickness?: number;
  22807. tessellation?: number;
  22808. sideOrientation?: number;
  22809. frontUVs?: Vector4;
  22810. backUVs?: Vector4;
  22811. }): VertexData;
  22812. /**
  22813. * Creates the VertexData of the LineSystem
  22814. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22815. * - lines an array of lines, each line being an array of successive Vector3
  22816. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22817. * @returns the VertexData of the LineSystem
  22818. */
  22819. static CreateLineSystem(options: {
  22820. lines: Vector3[][];
  22821. colors?: Nullable<Color4[][]>;
  22822. }): VertexData;
  22823. /**
  22824. * Create the VertexData for a DashedLines
  22825. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22826. * - points an array successive Vector3
  22827. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22828. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22829. * - dashNb the intended total number of dashes, optional, default 200
  22830. * @returns the VertexData for the DashedLines
  22831. */
  22832. static CreateDashedLines(options: {
  22833. points: Vector3[];
  22834. dashSize?: number;
  22835. gapSize?: number;
  22836. dashNb?: number;
  22837. }): VertexData;
  22838. /**
  22839. * Creates the VertexData for a Ground
  22840. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22841. * - width the width (x direction) of the ground, optional, default 1
  22842. * - height the height (z direction) of the ground, optional, default 1
  22843. * - subdivisions the number of subdivisions per side, optional, default 1
  22844. * @returns the VertexData of the Ground
  22845. */
  22846. static CreateGround(options: {
  22847. width?: number;
  22848. height?: number;
  22849. subdivisions?: number;
  22850. subdivisionsX?: number;
  22851. subdivisionsY?: number;
  22852. }): VertexData;
  22853. /**
  22854. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22855. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22856. * * xmin the ground minimum X coordinate, optional, default -1
  22857. * * zmin the ground minimum Z coordinate, optional, default -1
  22858. * * xmax the ground maximum X coordinate, optional, default 1
  22859. * * zmax the ground maximum Z coordinate, optional, default 1
  22860. * * 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}
  22861. * * 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}
  22862. * @returns the VertexData of the TiledGround
  22863. */
  22864. static CreateTiledGround(options: {
  22865. xmin: number;
  22866. zmin: number;
  22867. xmax: number;
  22868. zmax: number;
  22869. subdivisions?: {
  22870. w: number;
  22871. h: number;
  22872. };
  22873. precision?: {
  22874. w: number;
  22875. h: number;
  22876. };
  22877. }): VertexData;
  22878. /**
  22879. * Creates the VertexData of the Ground designed from a heightmap
  22880. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22881. * * width the width (x direction) of the ground
  22882. * * height the height (z direction) of the ground
  22883. * * subdivisions the number of subdivisions per side
  22884. * * minHeight the minimum altitude on the ground, optional, default 0
  22885. * * maxHeight the maximum altitude on the ground, optional default 1
  22886. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22887. * * buffer the array holding the image color data
  22888. * * bufferWidth the width of image
  22889. * * bufferHeight the height of image
  22890. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22891. * @returns the VertexData of the Ground designed from a heightmap
  22892. */
  22893. static CreateGroundFromHeightMap(options: {
  22894. width: number;
  22895. height: number;
  22896. subdivisions: number;
  22897. minHeight: number;
  22898. maxHeight: number;
  22899. colorFilter: Color3;
  22900. buffer: Uint8Array;
  22901. bufferWidth: number;
  22902. bufferHeight: number;
  22903. alphaFilter: number;
  22904. }): VertexData;
  22905. /**
  22906. * Creates the VertexData for a Plane
  22907. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22908. * * size sets the width and height of the plane to the value of size, optional default 1
  22909. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22910. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22912. * * 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)
  22913. * * 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)
  22914. * @returns the VertexData of the box
  22915. */
  22916. static CreatePlane(options: {
  22917. size?: number;
  22918. width?: number;
  22919. height?: number;
  22920. sideOrientation?: number;
  22921. frontUVs?: Vector4;
  22922. backUVs?: Vector4;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData of the Disc or regular Polygon
  22926. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22927. * * radius the radius of the disc, optional default 0.5
  22928. * * tessellation the number of polygon sides, optional, default 64
  22929. * * 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
  22930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22931. * * 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)
  22932. * * 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)
  22933. * @returns the VertexData of the box
  22934. */
  22935. static CreateDisc(options: {
  22936. radius?: number;
  22937. tessellation?: number;
  22938. arc?: number;
  22939. sideOrientation?: number;
  22940. frontUVs?: Vector4;
  22941. backUVs?: Vector4;
  22942. }): VertexData;
  22943. /**
  22944. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22945. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22946. * @param polygon a mesh built from polygonTriangulation.build()
  22947. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22948. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22949. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22950. * @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)
  22951. * @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)
  22952. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  22953. * @returns the VertexData of the Polygon
  22954. */
  22955. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  22956. /**
  22957. * Creates the VertexData of the IcoSphere
  22958. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22959. * * radius the radius of the IcoSphere, optional default 1
  22960. * * radiusX allows stretching in the x direction, optional, default radius
  22961. * * radiusY allows stretching in the y direction, optional, default radius
  22962. * * radiusZ allows stretching in the z direction, optional, default radius
  22963. * * flat when true creates a flat shaded mesh, optional, default true
  22964. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22966. * * 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)
  22967. * * 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)
  22968. * @returns the VertexData of the IcoSphere
  22969. */
  22970. static CreateIcoSphere(options: {
  22971. radius?: number;
  22972. radiusX?: number;
  22973. radiusY?: number;
  22974. radiusZ?: number;
  22975. flat?: boolean;
  22976. subdivisions?: number;
  22977. sideOrientation?: number;
  22978. frontUVs?: Vector4;
  22979. backUVs?: Vector4;
  22980. }): VertexData;
  22981. /**
  22982. * Creates the VertexData for a Polyhedron
  22983. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22984. * * type provided types are:
  22985. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22986. * * 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)
  22987. * * size the size of the IcoSphere, optional default 1
  22988. * * sizeX allows stretching in the x direction, optional, default size
  22989. * * sizeY allows stretching in the y direction, optional, default size
  22990. * * sizeZ allows stretching in the z direction, optional, default size
  22991. * * 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
  22992. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22993. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22994. * * flat when true creates a flat shaded mesh, optional, default true
  22995. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22997. * * 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)
  22998. * * 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)
  22999. * @returns the VertexData of the Polyhedron
  23000. */
  23001. static CreatePolyhedron(options: {
  23002. type?: number;
  23003. size?: number;
  23004. sizeX?: number;
  23005. sizeY?: number;
  23006. sizeZ?: number;
  23007. custom?: any;
  23008. faceUV?: Vector4[];
  23009. faceColors?: Color4[];
  23010. flat?: boolean;
  23011. sideOrientation?: number;
  23012. frontUVs?: Vector4;
  23013. backUVs?: Vector4;
  23014. }): VertexData;
  23015. /**
  23016. * Creates the VertexData for a TorusKnot
  23017. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23018. * * radius the radius of the torus knot, optional, default 2
  23019. * * tube the thickness of the tube, optional, default 0.5
  23020. * * radialSegments the number of sides on each tube segments, optional, default 32
  23021. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23022. * * p the number of windings around the z axis, optional, default 2
  23023. * * q the number of windings around the x axis, optional, default 3
  23024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23025. * * 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)
  23026. * * 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)
  23027. * @returns the VertexData of the Torus Knot
  23028. */
  23029. static CreateTorusKnot(options: {
  23030. radius?: number;
  23031. tube?: number;
  23032. radialSegments?: number;
  23033. tubularSegments?: number;
  23034. p?: number;
  23035. q?: number;
  23036. sideOrientation?: number;
  23037. frontUVs?: Vector4;
  23038. backUVs?: Vector4;
  23039. }): VertexData;
  23040. /**
  23041. * Compute normals for given positions and indices
  23042. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23043. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23044. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23045. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23046. * * facetNormals : optional array of facet normals (vector3)
  23047. * * facetPositions : optional array of facet positions (vector3)
  23048. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23049. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23050. * * bInfo : optional bounding info, required for facetPartitioning computation
  23051. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23052. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23053. * * useRightHandedSystem: optional boolean to for right handed system computation
  23054. * * depthSort : optional boolean to enable the facet depth sort computation
  23055. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23056. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23057. */
  23058. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23059. facetNormals?: any;
  23060. facetPositions?: any;
  23061. facetPartitioning?: any;
  23062. ratio?: number;
  23063. bInfo?: any;
  23064. bbSize?: Vector3;
  23065. subDiv?: any;
  23066. useRightHandedSystem?: boolean;
  23067. depthSort?: boolean;
  23068. distanceTo?: Vector3;
  23069. depthSortedFacets?: any;
  23070. }): void;
  23071. /** @hidden */
  23072. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23073. /**
  23074. * Applies VertexData created from the imported parameters to the geometry
  23075. * @param parsedVertexData the parsed data from an imported file
  23076. * @param geometry the geometry to apply the VertexData to
  23077. */
  23078. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23079. }
  23080. }
  23081. declare module BABYLON {
  23082. /**
  23083. * Defines a target to use with MorphTargetManager
  23084. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23085. */
  23086. export class MorphTarget implements IAnimatable {
  23087. /** defines the name of the target */
  23088. name: string;
  23089. /**
  23090. * Gets or sets the list of animations
  23091. */
  23092. animations: Animation[];
  23093. private _scene;
  23094. private _positions;
  23095. private _normals;
  23096. private _tangents;
  23097. private _uvs;
  23098. private _influence;
  23099. private _uniqueId;
  23100. /**
  23101. * Observable raised when the influence changes
  23102. */
  23103. onInfluenceChanged: Observable<boolean>;
  23104. /** @hidden */
  23105. _onDataLayoutChanged: Observable<void>;
  23106. /**
  23107. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23108. */
  23109. get influence(): number;
  23110. set influence(influence: number);
  23111. /**
  23112. * Gets or sets the id of the morph Target
  23113. */
  23114. id: string;
  23115. private _animationPropertiesOverride;
  23116. /**
  23117. * Gets or sets the animation properties override
  23118. */
  23119. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23120. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23121. /**
  23122. * Creates a new MorphTarget
  23123. * @param name defines the name of the target
  23124. * @param influence defines the influence to use
  23125. * @param scene defines the scene the morphtarget belongs to
  23126. */
  23127. constructor(
  23128. /** defines the name of the target */
  23129. name: string, influence?: number, scene?: Nullable<Scene>);
  23130. /**
  23131. * Gets the unique ID of this manager
  23132. */
  23133. get uniqueId(): number;
  23134. /**
  23135. * Gets a boolean defining if the target contains position data
  23136. */
  23137. get hasPositions(): boolean;
  23138. /**
  23139. * Gets a boolean defining if the target contains normal data
  23140. */
  23141. get hasNormals(): boolean;
  23142. /**
  23143. * Gets a boolean defining if the target contains tangent data
  23144. */
  23145. get hasTangents(): boolean;
  23146. /**
  23147. * Gets a boolean defining if the target contains texture coordinates data
  23148. */
  23149. get hasUVs(): boolean;
  23150. /**
  23151. * Affects position data to this target
  23152. * @param data defines the position data to use
  23153. */
  23154. setPositions(data: Nullable<FloatArray>): void;
  23155. /**
  23156. * Gets the position data stored in this target
  23157. * @returns a FloatArray containing the position data (or null if not present)
  23158. */
  23159. getPositions(): Nullable<FloatArray>;
  23160. /**
  23161. * Affects normal data to this target
  23162. * @param data defines the normal data to use
  23163. */
  23164. setNormals(data: Nullable<FloatArray>): void;
  23165. /**
  23166. * Gets the normal data stored in this target
  23167. * @returns a FloatArray containing the normal data (or null if not present)
  23168. */
  23169. getNormals(): Nullable<FloatArray>;
  23170. /**
  23171. * Affects tangent data to this target
  23172. * @param data defines the tangent data to use
  23173. */
  23174. setTangents(data: Nullable<FloatArray>): void;
  23175. /**
  23176. * Gets the tangent data stored in this target
  23177. * @returns a FloatArray containing the tangent data (or null if not present)
  23178. */
  23179. getTangents(): Nullable<FloatArray>;
  23180. /**
  23181. * Affects texture coordinates data to this target
  23182. * @param data defines the texture coordinates data to use
  23183. */
  23184. setUVs(data: Nullable<FloatArray>): void;
  23185. /**
  23186. * Gets the texture coordinates data stored in this target
  23187. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23188. */
  23189. getUVs(): Nullable<FloatArray>;
  23190. /**
  23191. * Clone the current target
  23192. * @returns a new MorphTarget
  23193. */
  23194. clone(): MorphTarget;
  23195. /**
  23196. * Serializes the current target into a Serialization object
  23197. * @returns the serialized object
  23198. */
  23199. serialize(): any;
  23200. /**
  23201. * Returns the string "MorphTarget"
  23202. * @returns "MorphTarget"
  23203. */
  23204. getClassName(): string;
  23205. /**
  23206. * Creates a new target from serialized data
  23207. * @param serializationObject defines the serialized data to use
  23208. * @returns a new MorphTarget
  23209. */
  23210. static Parse(serializationObject: any): MorphTarget;
  23211. /**
  23212. * Creates a MorphTarget from mesh data
  23213. * @param mesh defines the source mesh
  23214. * @param name defines the name to use for the new target
  23215. * @param influence defines the influence to attach to the target
  23216. * @returns a new MorphTarget
  23217. */
  23218. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23219. }
  23220. }
  23221. declare module BABYLON {
  23222. /**
  23223. * This class is used to deform meshes using morphing between different targets
  23224. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23225. */
  23226. export class MorphTargetManager {
  23227. private _targets;
  23228. private _targetInfluenceChangedObservers;
  23229. private _targetDataLayoutChangedObservers;
  23230. private _activeTargets;
  23231. private _scene;
  23232. private _influences;
  23233. private _supportsNormals;
  23234. private _supportsTangents;
  23235. private _supportsUVs;
  23236. private _vertexCount;
  23237. private _uniqueId;
  23238. private _tempInfluences;
  23239. /**
  23240. * Gets or sets a boolean indicating if normals must be morphed
  23241. */
  23242. enableNormalMorphing: boolean;
  23243. /**
  23244. * Gets or sets a boolean indicating if tangents must be morphed
  23245. */
  23246. enableTangentMorphing: boolean;
  23247. /**
  23248. * Gets or sets a boolean indicating if UV must be morphed
  23249. */
  23250. enableUVMorphing: boolean;
  23251. /**
  23252. * Creates a new MorphTargetManager
  23253. * @param scene defines the current scene
  23254. */
  23255. constructor(scene?: Nullable<Scene>);
  23256. /**
  23257. * Gets the unique ID of this manager
  23258. */
  23259. get uniqueId(): number;
  23260. /**
  23261. * Gets the number of vertices handled by this manager
  23262. */
  23263. get vertexCount(): number;
  23264. /**
  23265. * Gets a boolean indicating if this manager supports morphing of normals
  23266. */
  23267. get supportsNormals(): boolean;
  23268. /**
  23269. * Gets a boolean indicating if this manager supports morphing of tangents
  23270. */
  23271. get supportsTangents(): boolean;
  23272. /**
  23273. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23274. */
  23275. get supportsUVs(): boolean;
  23276. /**
  23277. * Gets the number of targets stored in this manager
  23278. */
  23279. get numTargets(): number;
  23280. /**
  23281. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23282. */
  23283. get numInfluencers(): number;
  23284. /**
  23285. * Gets the list of influences (one per target)
  23286. */
  23287. get influences(): Float32Array;
  23288. /**
  23289. * Gets the active target at specified index. An active target is a target with an influence > 0
  23290. * @param index defines the index to check
  23291. * @returns the requested target
  23292. */
  23293. getActiveTarget(index: number): MorphTarget;
  23294. /**
  23295. * Gets the target at specified index
  23296. * @param index defines the index to check
  23297. * @returns the requested target
  23298. */
  23299. getTarget(index: number): MorphTarget;
  23300. /**
  23301. * Add a new target to this manager
  23302. * @param target defines the target to add
  23303. */
  23304. addTarget(target: MorphTarget): void;
  23305. /**
  23306. * Removes a target from the manager
  23307. * @param target defines the target to remove
  23308. */
  23309. removeTarget(target: MorphTarget): void;
  23310. /**
  23311. * Clone the current manager
  23312. * @returns a new MorphTargetManager
  23313. */
  23314. clone(): MorphTargetManager;
  23315. /**
  23316. * Serializes the current manager into a Serialization object
  23317. * @returns the serialized object
  23318. */
  23319. serialize(): any;
  23320. private _syncActiveTargets;
  23321. /**
  23322. * Syncrhonize the targets with all the meshes using this morph target manager
  23323. */
  23324. synchronize(): void;
  23325. /**
  23326. * Creates a new MorphTargetManager from serialized data
  23327. * @param serializationObject defines the serialized data
  23328. * @param scene defines the hosting scene
  23329. * @returns the new MorphTargetManager
  23330. */
  23331. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23332. }
  23333. }
  23334. declare module BABYLON {
  23335. /**
  23336. * Class used to represent a specific level of detail of a mesh
  23337. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23338. */
  23339. export class MeshLODLevel {
  23340. /** Defines the distance where this level should start being displayed */
  23341. distance: number;
  23342. /** Defines the mesh to use to render this level */
  23343. mesh: Nullable<Mesh>;
  23344. /**
  23345. * Creates a new LOD level
  23346. * @param distance defines the distance where this level should star being displayed
  23347. * @param mesh defines the mesh to use to render this level
  23348. */
  23349. constructor(
  23350. /** Defines the distance where this level should start being displayed */
  23351. distance: number,
  23352. /** Defines the mesh to use to render this level */
  23353. mesh: Nullable<Mesh>);
  23354. }
  23355. }
  23356. declare module BABYLON {
  23357. /**
  23358. * Mesh representing the gorund
  23359. */
  23360. export class GroundMesh extends Mesh {
  23361. /** If octree should be generated */
  23362. generateOctree: boolean;
  23363. private _heightQuads;
  23364. /** @hidden */
  23365. _subdivisionsX: number;
  23366. /** @hidden */
  23367. _subdivisionsY: number;
  23368. /** @hidden */
  23369. _width: number;
  23370. /** @hidden */
  23371. _height: number;
  23372. /** @hidden */
  23373. _minX: number;
  23374. /** @hidden */
  23375. _maxX: number;
  23376. /** @hidden */
  23377. _minZ: number;
  23378. /** @hidden */
  23379. _maxZ: number;
  23380. constructor(name: string, scene: Scene);
  23381. /**
  23382. * "GroundMesh"
  23383. * @returns "GroundMesh"
  23384. */
  23385. getClassName(): string;
  23386. /**
  23387. * The minimum of x and y subdivisions
  23388. */
  23389. get subdivisions(): number;
  23390. /**
  23391. * X subdivisions
  23392. */
  23393. get subdivisionsX(): number;
  23394. /**
  23395. * Y subdivisions
  23396. */
  23397. get subdivisionsY(): number;
  23398. /**
  23399. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23400. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23401. * @param chunksCount the number of subdivisions for x and y
  23402. * @param octreeBlocksSize (Default: 32)
  23403. */
  23404. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23405. /**
  23406. * Returns a height (y) value in the Worl system :
  23407. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23408. * @param x x coordinate
  23409. * @param z z coordinate
  23410. * @returns the ground y position if (x, z) are outside the ground surface.
  23411. */
  23412. getHeightAtCoordinates(x: number, z: number): number;
  23413. /**
  23414. * Returns a normalized vector (Vector3) orthogonal to the ground
  23415. * at the ground coordinates (x, z) expressed in the World system.
  23416. * @param x x coordinate
  23417. * @param z z coordinate
  23418. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23419. */
  23420. getNormalAtCoordinates(x: number, z: number): Vector3;
  23421. /**
  23422. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23423. * at the ground coordinates (x, z) expressed in the World system.
  23424. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23425. * @param x x coordinate
  23426. * @param z z coordinate
  23427. * @param ref vector to store the result
  23428. * @returns the GroundMesh.
  23429. */
  23430. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23431. /**
  23432. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23433. * if the ground has been updated.
  23434. * This can be used in the render loop.
  23435. * @returns the GroundMesh.
  23436. */
  23437. updateCoordinateHeights(): GroundMesh;
  23438. private _getFacetAt;
  23439. private _initHeightQuads;
  23440. private _computeHeightQuads;
  23441. /**
  23442. * Serializes this ground mesh
  23443. * @param serializationObject object to write serialization to
  23444. */
  23445. serialize(serializationObject: any): void;
  23446. /**
  23447. * Parses a serialized ground mesh
  23448. * @param parsedMesh the serialized mesh
  23449. * @param scene the scene to create the ground mesh in
  23450. * @returns the created ground mesh
  23451. */
  23452. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23453. }
  23454. }
  23455. declare module BABYLON {
  23456. /**
  23457. * Interface for Physics-Joint data
  23458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23459. */
  23460. export interface PhysicsJointData {
  23461. /**
  23462. * The main pivot of the joint
  23463. */
  23464. mainPivot?: Vector3;
  23465. /**
  23466. * The connected pivot of the joint
  23467. */
  23468. connectedPivot?: Vector3;
  23469. /**
  23470. * The main axis of the joint
  23471. */
  23472. mainAxis?: Vector3;
  23473. /**
  23474. * The connected axis of the joint
  23475. */
  23476. connectedAxis?: Vector3;
  23477. /**
  23478. * The collision of the joint
  23479. */
  23480. collision?: boolean;
  23481. /**
  23482. * Native Oimo/Cannon/Energy data
  23483. */
  23484. nativeParams?: any;
  23485. }
  23486. /**
  23487. * This is a holder class for the physics joint created by the physics plugin
  23488. * It holds a set of functions to control the underlying joint
  23489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23490. */
  23491. export class PhysicsJoint {
  23492. /**
  23493. * The type of the physics joint
  23494. */
  23495. type: number;
  23496. /**
  23497. * The data for the physics joint
  23498. */
  23499. jointData: PhysicsJointData;
  23500. private _physicsJoint;
  23501. protected _physicsPlugin: IPhysicsEnginePlugin;
  23502. /**
  23503. * Initializes the physics joint
  23504. * @param type The type of the physics joint
  23505. * @param jointData The data for the physics joint
  23506. */
  23507. constructor(
  23508. /**
  23509. * The type of the physics joint
  23510. */
  23511. type: number,
  23512. /**
  23513. * The data for the physics joint
  23514. */
  23515. jointData: PhysicsJointData);
  23516. /**
  23517. * Gets the physics joint
  23518. */
  23519. get physicsJoint(): any;
  23520. /**
  23521. * Sets the physics joint
  23522. */
  23523. set physicsJoint(newJoint: any);
  23524. /**
  23525. * Sets the physics plugin
  23526. */
  23527. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23528. /**
  23529. * Execute a function that is physics-plugin specific.
  23530. * @param {Function} func the function that will be executed.
  23531. * It accepts two parameters: the physics world and the physics joint
  23532. */
  23533. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23534. /**
  23535. * Distance-Joint type
  23536. */
  23537. static DistanceJoint: number;
  23538. /**
  23539. * Hinge-Joint type
  23540. */
  23541. static HingeJoint: number;
  23542. /**
  23543. * Ball-and-Socket joint type
  23544. */
  23545. static BallAndSocketJoint: number;
  23546. /**
  23547. * Wheel-Joint type
  23548. */
  23549. static WheelJoint: number;
  23550. /**
  23551. * Slider-Joint type
  23552. */
  23553. static SliderJoint: number;
  23554. /**
  23555. * Prismatic-Joint type
  23556. */
  23557. static PrismaticJoint: number;
  23558. /**
  23559. * Universal-Joint type
  23560. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23561. */
  23562. static UniversalJoint: number;
  23563. /**
  23564. * Hinge-Joint 2 type
  23565. */
  23566. static Hinge2Joint: number;
  23567. /**
  23568. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23569. */
  23570. static PointToPointJoint: number;
  23571. /**
  23572. * Spring-Joint type
  23573. */
  23574. static SpringJoint: number;
  23575. /**
  23576. * Lock-Joint type
  23577. */
  23578. static LockJoint: number;
  23579. }
  23580. /**
  23581. * A class representing a physics distance joint
  23582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23583. */
  23584. export class DistanceJoint extends PhysicsJoint {
  23585. /**
  23586. *
  23587. * @param jointData The data for the Distance-Joint
  23588. */
  23589. constructor(jointData: DistanceJointData);
  23590. /**
  23591. * Update the predefined distance.
  23592. * @param maxDistance The maximum preferred distance
  23593. * @param minDistance The minimum preferred distance
  23594. */
  23595. updateDistance(maxDistance: number, minDistance?: number): void;
  23596. }
  23597. /**
  23598. * Represents a Motor-Enabled Joint
  23599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23600. */
  23601. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23602. /**
  23603. * Initializes the Motor-Enabled Joint
  23604. * @param type The type of the joint
  23605. * @param jointData The physica joint data for the joint
  23606. */
  23607. constructor(type: number, jointData: PhysicsJointData);
  23608. /**
  23609. * Set the motor values.
  23610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23611. * @param force the force to apply
  23612. * @param maxForce max force for this motor.
  23613. */
  23614. setMotor(force?: number, maxForce?: number): void;
  23615. /**
  23616. * Set the motor's limits.
  23617. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23618. * @param upperLimit The upper limit of the motor
  23619. * @param lowerLimit The lower limit of the motor
  23620. */
  23621. setLimit(upperLimit: number, lowerLimit?: number): void;
  23622. }
  23623. /**
  23624. * This class represents a single physics Hinge-Joint
  23625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23626. */
  23627. export class HingeJoint extends MotorEnabledJoint {
  23628. /**
  23629. * Initializes the Hinge-Joint
  23630. * @param jointData The joint data for the Hinge-Joint
  23631. */
  23632. constructor(jointData: PhysicsJointData);
  23633. /**
  23634. * Set the motor values.
  23635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23636. * @param {number} force the force to apply
  23637. * @param {number} maxForce max force for this motor.
  23638. */
  23639. setMotor(force?: number, maxForce?: number): void;
  23640. /**
  23641. * Set the motor's limits.
  23642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23643. * @param upperLimit The upper limit of the motor
  23644. * @param lowerLimit The lower limit of the motor
  23645. */
  23646. setLimit(upperLimit: number, lowerLimit?: number): void;
  23647. }
  23648. /**
  23649. * This class represents a dual hinge physics joint (same as wheel joint)
  23650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23651. */
  23652. export class Hinge2Joint extends MotorEnabledJoint {
  23653. /**
  23654. * Initializes the Hinge2-Joint
  23655. * @param jointData The joint data for the Hinge2-Joint
  23656. */
  23657. constructor(jointData: PhysicsJointData);
  23658. /**
  23659. * Set the motor values.
  23660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23661. * @param {number} targetSpeed the speed the motor is to reach
  23662. * @param {number} maxForce max force for this motor.
  23663. * @param {motorIndex} the motor's index, 0 or 1.
  23664. */
  23665. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23666. /**
  23667. * Set the motor limits.
  23668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23669. * @param {number} upperLimit the upper limit
  23670. * @param {number} lowerLimit lower limit
  23671. * @param {motorIndex} the motor's index, 0 or 1.
  23672. */
  23673. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23674. }
  23675. /**
  23676. * Interface for a motor enabled joint
  23677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23678. */
  23679. export interface IMotorEnabledJoint {
  23680. /**
  23681. * Physics joint
  23682. */
  23683. physicsJoint: any;
  23684. /**
  23685. * Sets the motor of the motor-enabled joint
  23686. * @param force The force of the motor
  23687. * @param maxForce The maximum force of the motor
  23688. * @param motorIndex The index of the motor
  23689. */
  23690. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23691. /**
  23692. * Sets the limit of the motor
  23693. * @param upperLimit The upper limit of the motor
  23694. * @param lowerLimit The lower limit of the motor
  23695. * @param motorIndex The index of the motor
  23696. */
  23697. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23698. }
  23699. /**
  23700. * Joint data for a Distance-Joint
  23701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23702. */
  23703. export interface DistanceJointData extends PhysicsJointData {
  23704. /**
  23705. * Max distance the 2 joint objects can be apart
  23706. */
  23707. maxDistance: number;
  23708. }
  23709. /**
  23710. * Joint data from a spring joint
  23711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23712. */
  23713. export interface SpringJointData extends PhysicsJointData {
  23714. /**
  23715. * Length of the spring
  23716. */
  23717. length: number;
  23718. /**
  23719. * Stiffness of the spring
  23720. */
  23721. stiffness: number;
  23722. /**
  23723. * Damping of the spring
  23724. */
  23725. damping: number;
  23726. /** this callback will be called when applying the force to the impostors. */
  23727. forceApplicationCallback: () => void;
  23728. }
  23729. }
  23730. declare module BABYLON {
  23731. /**
  23732. * Holds the data for the raycast result
  23733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23734. */
  23735. export class PhysicsRaycastResult {
  23736. private _hasHit;
  23737. private _hitDistance;
  23738. private _hitNormalWorld;
  23739. private _hitPointWorld;
  23740. private _rayFromWorld;
  23741. private _rayToWorld;
  23742. /**
  23743. * Gets if there was a hit
  23744. */
  23745. get hasHit(): boolean;
  23746. /**
  23747. * Gets the distance from the hit
  23748. */
  23749. get hitDistance(): number;
  23750. /**
  23751. * Gets the hit normal/direction in the world
  23752. */
  23753. get hitNormalWorld(): Vector3;
  23754. /**
  23755. * Gets the hit point in the world
  23756. */
  23757. get hitPointWorld(): Vector3;
  23758. /**
  23759. * Gets the ray "start point" of the ray in the world
  23760. */
  23761. get rayFromWorld(): Vector3;
  23762. /**
  23763. * Gets the ray "end point" of the ray in the world
  23764. */
  23765. get rayToWorld(): Vector3;
  23766. /**
  23767. * Sets the hit data (normal & point in world space)
  23768. * @param hitNormalWorld defines the normal in world space
  23769. * @param hitPointWorld defines the point in world space
  23770. */
  23771. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23772. /**
  23773. * Sets the distance from the start point to the hit point
  23774. * @param distance
  23775. */
  23776. setHitDistance(distance: number): void;
  23777. /**
  23778. * Calculates the distance manually
  23779. */
  23780. calculateHitDistance(): void;
  23781. /**
  23782. * Resets all the values to default
  23783. * @param from The from point on world space
  23784. * @param to The to point on world space
  23785. */
  23786. reset(from?: Vector3, to?: Vector3): void;
  23787. }
  23788. /**
  23789. * Interface for the size containing width and height
  23790. */
  23791. interface IXYZ {
  23792. /**
  23793. * X
  23794. */
  23795. x: number;
  23796. /**
  23797. * Y
  23798. */
  23799. y: number;
  23800. /**
  23801. * Z
  23802. */
  23803. z: number;
  23804. }
  23805. }
  23806. declare module BABYLON {
  23807. /**
  23808. * Interface used to describe a physics joint
  23809. */
  23810. export interface PhysicsImpostorJoint {
  23811. /** Defines the main impostor to which the joint is linked */
  23812. mainImpostor: PhysicsImpostor;
  23813. /** Defines the impostor that is connected to the main impostor using this joint */
  23814. connectedImpostor: PhysicsImpostor;
  23815. /** Defines the joint itself */
  23816. joint: PhysicsJoint;
  23817. }
  23818. /** @hidden */
  23819. export interface IPhysicsEnginePlugin {
  23820. world: any;
  23821. name: string;
  23822. setGravity(gravity: Vector3): void;
  23823. setTimeStep(timeStep: number): void;
  23824. getTimeStep(): number;
  23825. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23826. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23827. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23829. removePhysicsBody(impostor: PhysicsImpostor): void;
  23830. generateJoint(joint: PhysicsImpostorJoint): void;
  23831. removeJoint(joint: PhysicsImpostorJoint): void;
  23832. isSupported(): boolean;
  23833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23835. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23836. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23837. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23838. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23839. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23840. getBodyMass(impostor: PhysicsImpostor): number;
  23841. getBodyFriction(impostor: PhysicsImpostor): number;
  23842. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23843. getBodyRestitution(impostor: PhysicsImpostor): number;
  23844. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23845. getBodyPressure?(impostor: PhysicsImpostor): number;
  23846. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23847. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23848. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23849. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23850. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23851. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23852. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23853. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23854. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23855. sleepBody(impostor: PhysicsImpostor): void;
  23856. wakeUpBody(impostor: PhysicsImpostor): void;
  23857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23859. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23860. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23861. getRadius(impostor: PhysicsImpostor): number;
  23862. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23863. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23864. dispose(): void;
  23865. }
  23866. /**
  23867. * Interface used to define a physics engine
  23868. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23869. */
  23870. export interface IPhysicsEngine {
  23871. /**
  23872. * Gets the gravity vector used by the simulation
  23873. */
  23874. gravity: Vector3;
  23875. /**
  23876. * Sets the gravity vector used by the simulation
  23877. * @param gravity defines the gravity vector to use
  23878. */
  23879. setGravity(gravity: Vector3): void;
  23880. /**
  23881. * Set the time step of the physics engine.
  23882. * Default is 1/60.
  23883. * To slow it down, enter 1/600 for example.
  23884. * To speed it up, 1/30
  23885. * @param newTimeStep the new timestep to apply to this world.
  23886. */
  23887. setTimeStep(newTimeStep: number): void;
  23888. /**
  23889. * Get the time step of the physics engine.
  23890. * @returns the current time step
  23891. */
  23892. getTimeStep(): number;
  23893. /**
  23894. * Set the sub time step of the physics engine.
  23895. * Default is 0 meaning there is no sub steps
  23896. * To increase physics resolution precision, set a small value (like 1 ms)
  23897. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23898. */
  23899. setSubTimeStep(subTimeStep: number): void;
  23900. /**
  23901. * Get the sub time step of the physics engine.
  23902. * @returns the current sub time step
  23903. */
  23904. getSubTimeStep(): number;
  23905. /**
  23906. * Release all resources
  23907. */
  23908. dispose(): void;
  23909. /**
  23910. * Gets the name of the current physics plugin
  23911. * @returns the name of the plugin
  23912. */
  23913. getPhysicsPluginName(): string;
  23914. /**
  23915. * Adding a new impostor for the impostor tracking.
  23916. * This will be done by the impostor itself.
  23917. * @param impostor the impostor to add
  23918. */
  23919. addImpostor(impostor: PhysicsImpostor): void;
  23920. /**
  23921. * Remove an impostor from the engine.
  23922. * This impostor and its mesh will not longer be updated by the physics engine.
  23923. * @param impostor the impostor to remove
  23924. */
  23925. removeImpostor(impostor: PhysicsImpostor): void;
  23926. /**
  23927. * Add a joint to the physics engine
  23928. * @param mainImpostor defines the main impostor to which the joint is added.
  23929. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23930. * @param joint defines the joint that will connect both impostors.
  23931. */
  23932. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23933. /**
  23934. * Removes a joint from the simulation
  23935. * @param mainImpostor defines the impostor used with the joint
  23936. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23937. * @param joint defines the joint to remove
  23938. */
  23939. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23940. /**
  23941. * Gets the current plugin used to run the simulation
  23942. * @returns current plugin
  23943. */
  23944. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23945. /**
  23946. * Gets the list of physic impostors
  23947. * @returns an array of PhysicsImpostor
  23948. */
  23949. getImpostors(): Array<PhysicsImpostor>;
  23950. /**
  23951. * Gets the impostor for a physics enabled object
  23952. * @param object defines the object impersonated by the impostor
  23953. * @returns the PhysicsImpostor or null if not found
  23954. */
  23955. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23956. /**
  23957. * Gets the impostor for a physics body object
  23958. * @param body defines physics body used by the impostor
  23959. * @returns the PhysicsImpostor or null if not found
  23960. */
  23961. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23962. /**
  23963. * Does a raycast in the physics world
  23964. * @param from when should the ray start?
  23965. * @param to when should the ray end?
  23966. * @returns PhysicsRaycastResult
  23967. */
  23968. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23969. /**
  23970. * Called by the scene. No need to call it.
  23971. * @param delta defines the timespam between frames
  23972. */
  23973. _step(delta: number): void;
  23974. }
  23975. }
  23976. declare module BABYLON {
  23977. /**
  23978. * The interface for the physics imposter parameters
  23979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23980. */
  23981. export interface PhysicsImpostorParameters {
  23982. /**
  23983. * The mass of the physics imposter
  23984. */
  23985. mass: number;
  23986. /**
  23987. * The friction of the physics imposter
  23988. */
  23989. friction?: number;
  23990. /**
  23991. * The coefficient of restitution of the physics imposter
  23992. */
  23993. restitution?: number;
  23994. /**
  23995. * The native options of the physics imposter
  23996. */
  23997. nativeOptions?: any;
  23998. /**
  23999. * Specifies if the parent should be ignored
  24000. */
  24001. ignoreParent?: boolean;
  24002. /**
  24003. * Specifies if bi-directional transformations should be disabled
  24004. */
  24005. disableBidirectionalTransformation?: boolean;
  24006. /**
  24007. * The pressure inside the physics imposter, soft object only
  24008. */
  24009. pressure?: number;
  24010. /**
  24011. * The stiffness the physics imposter, soft object only
  24012. */
  24013. stiffness?: number;
  24014. /**
  24015. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24016. */
  24017. velocityIterations?: number;
  24018. /**
  24019. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24020. */
  24021. positionIterations?: number;
  24022. /**
  24023. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24024. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24025. * Add to fix multiple points
  24026. */
  24027. fixedPoints?: number;
  24028. /**
  24029. * The collision margin around a soft object
  24030. */
  24031. margin?: number;
  24032. /**
  24033. * The collision margin around a soft object
  24034. */
  24035. damping?: number;
  24036. /**
  24037. * The path for a rope based on an extrusion
  24038. */
  24039. path?: any;
  24040. /**
  24041. * The shape of an extrusion used for a rope based on an extrusion
  24042. */
  24043. shape?: any;
  24044. }
  24045. /**
  24046. * Interface for a physics-enabled object
  24047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24048. */
  24049. export interface IPhysicsEnabledObject {
  24050. /**
  24051. * The position of the physics-enabled object
  24052. */
  24053. position: Vector3;
  24054. /**
  24055. * The rotation of the physics-enabled object
  24056. */
  24057. rotationQuaternion: Nullable<Quaternion>;
  24058. /**
  24059. * The scale of the physics-enabled object
  24060. */
  24061. scaling: Vector3;
  24062. /**
  24063. * The rotation of the physics-enabled object
  24064. */
  24065. rotation?: Vector3;
  24066. /**
  24067. * The parent of the physics-enabled object
  24068. */
  24069. parent?: any;
  24070. /**
  24071. * The bounding info of the physics-enabled object
  24072. * @returns The bounding info of the physics-enabled object
  24073. */
  24074. getBoundingInfo(): BoundingInfo;
  24075. /**
  24076. * Computes the world matrix
  24077. * @param force Specifies if the world matrix should be computed by force
  24078. * @returns A world matrix
  24079. */
  24080. computeWorldMatrix(force: boolean): Matrix;
  24081. /**
  24082. * Gets the world matrix
  24083. * @returns A world matrix
  24084. */
  24085. getWorldMatrix?(): Matrix;
  24086. /**
  24087. * Gets the child meshes
  24088. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24089. * @returns An array of abstract meshes
  24090. */
  24091. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24092. /**
  24093. * Gets the vertex data
  24094. * @param kind The type of vertex data
  24095. * @returns A nullable array of numbers, or a float32 array
  24096. */
  24097. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24098. /**
  24099. * Gets the indices from the mesh
  24100. * @returns A nullable array of index arrays
  24101. */
  24102. getIndices?(): Nullable<IndicesArray>;
  24103. /**
  24104. * Gets the scene from the mesh
  24105. * @returns the indices array or null
  24106. */
  24107. getScene?(): Scene;
  24108. /**
  24109. * Gets the absolute position from the mesh
  24110. * @returns the absolute position
  24111. */
  24112. getAbsolutePosition(): Vector3;
  24113. /**
  24114. * Gets the absolute pivot point from the mesh
  24115. * @returns the absolute pivot point
  24116. */
  24117. getAbsolutePivotPoint(): Vector3;
  24118. /**
  24119. * Rotates the mesh
  24120. * @param axis The axis of rotation
  24121. * @param amount The amount of rotation
  24122. * @param space The space of the rotation
  24123. * @returns The rotation transform node
  24124. */
  24125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24126. /**
  24127. * Translates the mesh
  24128. * @param axis The axis of translation
  24129. * @param distance The distance of translation
  24130. * @param space The space of the translation
  24131. * @returns The transform node
  24132. */
  24133. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24134. /**
  24135. * Sets the absolute position of the mesh
  24136. * @param absolutePosition The absolute position of the mesh
  24137. * @returns The transform node
  24138. */
  24139. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24140. /**
  24141. * Gets the class name of the mesh
  24142. * @returns The class name
  24143. */
  24144. getClassName(): string;
  24145. }
  24146. /**
  24147. * Represents a physics imposter
  24148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24149. */
  24150. export class PhysicsImpostor {
  24151. /**
  24152. * The physics-enabled object used as the physics imposter
  24153. */
  24154. object: IPhysicsEnabledObject;
  24155. /**
  24156. * The type of the physics imposter
  24157. */
  24158. type: number;
  24159. private _options;
  24160. private _scene?;
  24161. /**
  24162. * The default object size of the imposter
  24163. */
  24164. static DEFAULT_OBJECT_SIZE: Vector3;
  24165. /**
  24166. * The identity quaternion of the imposter
  24167. */
  24168. static IDENTITY_QUATERNION: Quaternion;
  24169. /** @hidden */
  24170. _pluginData: any;
  24171. private _physicsEngine;
  24172. private _physicsBody;
  24173. private _bodyUpdateRequired;
  24174. private _onBeforePhysicsStepCallbacks;
  24175. private _onAfterPhysicsStepCallbacks;
  24176. /** @hidden */
  24177. _onPhysicsCollideCallbacks: Array<{
  24178. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24179. otherImpostors: Array<PhysicsImpostor>;
  24180. }>;
  24181. private _deltaPosition;
  24182. private _deltaRotation;
  24183. private _deltaRotationConjugated;
  24184. /** @hidden */
  24185. _isFromLine: boolean;
  24186. private _parent;
  24187. private _isDisposed;
  24188. private static _tmpVecs;
  24189. private static _tmpQuat;
  24190. /**
  24191. * Specifies if the physics imposter is disposed
  24192. */
  24193. get isDisposed(): boolean;
  24194. /**
  24195. * Gets the mass of the physics imposter
  24196. */
  24197. get mass(): number;
  24198. set mass(value: number);
  24199. /**
  24200. * Gets the coefficient of friction
  24201. */
  24202. get friction(): number;
  24203. /**
  24204. * Sets the coefficient of friction
  24205. */
  24206. set friction(value: number);
  24207. /**
  24208. * Gets the coefficient of restitution
  24209. */
  24210. get restitution(): number;
  24211. /**
  24212. * Sets the coefficient of restitution
  24213. */
  24214. set restitution(value: number);
  24215. /**
  24216. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24217. */
  24218. get pressure(): number;
  24219. /**
  24220. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24221. */
  24222. set pressure(value: number);
  24223. /**
  24224. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24225. */
  24226. get stiffness(): number;
  24227. /**
  24228. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24229. */
  24230. set stiffness(value: number);
  24231. /**
  24232. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24233. */
  24234. get velocityIterations(): number;
  24235. /**
  24236. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24237. */
  24238. set velocityIterations(value: number);
  24239. /**
  24240. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24241. */
  24242. get positionIterations(): number;
  24243. /**
  24244. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24245. */
  24246. set positionIterations(value: number);
  24247. /**
  24248. * The unique id of the physics imposter
  24249. * set by the physics engine when adding this impostor to the array
  24250. */
  24251. uniqueId: number;
  24252. /**
  24253. * @hidden
  24254. */
  24255. soft: boolean;
  24256. /**
  24257. * @hidden
  24258. */
  24259. segments: number;
  24260. private _joints;
  24261. /**
  24262. * Initializes the physics imposter
  24263. * @param object The physics-enabled object used as the physics imposter
  24264. * @param type The type of the physics imposter
  24265. * @param _options The options for the physics imposter
  24266. * @param _scene The Babylon scene
  24267. */
  24268. constructor(
  24269. /**
  24270. * The physics-enabled object used as the physics imposter
  24271. */
  24272. object: IPhysicsEnabledObject,
  24273. /**
  24274. * The type of the physics imposter
  24275. */
  24276. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24277. /**
  24278. * This function will completly initialize this impostor.
  24279. * It will create a new body - but only if this mesh has no parent.
  24280. * If it has, this impostor will not be used other than to define the impostor
  24281. * of the child mesh.
  24282. * @hidden
  24283. */
  24284. _init(): void;
  24285. private _getPhysicsParent;
  24286. /**
  24287. * Should a new body be generated.
  24288. * @returns boolean specifying if body initialization is required
  24289. */
  24290. isBodyInitRequired(): boolean;
  24291. /**
  24292. * Sets the updated scaling
  24293. * @param updated Specifies if the scaling is updated
  24294. */
  24295. setScalingUpdated(): void;
  24296. /**
  24297. * Force a regeneration of this or the parent's impostor's body.
  24298. * Use under cautious - This will remove all joints already implemented.
  24299. */
  24300. forceUpdate(): void;
  24301. /**
  24302. * Gets the body that holds this impostor. Either its own, or its parent.
  24303. */
  24304. get physicsBody(): any;
  24305. /**
  24306. * Get the parent of the physics imposter
  24307. * @returns Physics imposter or null
  24308. */
  24309. get parent(): Nullable<PhysicsImpostor>;
  24310. /**
  24311. * Sets the parent of the physics imposter
  24312. */
  24313. set parent(value: Nullable<PhysicsImpostor>);
  24314. /**
  24315. * Set the physics body. Used mainly by the physics engine/plugin
  24316. */
  24317. set physicsBody(physicsBody: any);
  24318. /**
  24319. * Resets the update flags
  24320. */
  24321. resetUpdateFlags(): void;
  24322. /**
  24323. * Gets the object extend size
  24324. * @returns the object extend size
  24325. */
  24326. getObjectExtendSize(): Vector3;
  24327. /**
  24328. * Gets the object center
  24329. * @returns The object center
  24330. */
  24331. getObjectCenter(): Vector3;
  24332. /**
  24333. * Get a specific parameter from the options parameters
  24334. * @param paramName The object parameter name
  24335. * @returns The object parameter
  24336. */
  24337. getParam(paramName: string): any;
  24338. /**
  24339. * Sets a specific parameter in the options given to the physics plugin
  24340. * @param paramName The parameter name
  24341. * @param value The value of the parameter
  24342. */
  24343. setParam(paramName: string, value: number): void;
  24344. /**
  24345. * Specifically change the body's mass option. Won't recreate the physics body object
  24346. * @param mass The mass of the physics imposter
  24347. */
  24348. setMass(mass: number): void;
  24349. /**
  24350. * Gets the linear velocity
  24351. * @returns linear velocity or null
  24352. */
  24353. getLinearVelocity(): Nullable<Vector3>;
  24354. /**
  24355. * Sets the linear velocity
  24356. * @param velocity linear velocity or null
  24357. */
  24358. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24359. /**
  24360. * Gets the angular velocity
  24361. * @returns angular velocity or null
  24362. */
  24363. getAngularVelocity(): Nullable<Vector3>;
  24364. /**
  24365. * Sets the angular velocity
  24366. * @param velocity The velocity or null
  24367. */
  24368. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24369. /**
  24370. * Execute a function with the physics plugin native code
  24371. * Provide a function the will have two variables - the world object and the physics body object
  24372. * @param func The function to execute with the physics plugin native code
  24373. */
  24374. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24375. /**
  24376. * Register a function that will be executed before the physics world is stepping forward
  24377. * @param func The function to execute before the physics world is stepped forward
  24378. */
  24379. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24380. /**
  24381. * Unregister a function that will be executed before the physics world is stepping forward
  24382. * @param func The function to execute before the physics world is stepped forward
  24383. */
  24384. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24385. /**
  24386. * Register a function that will be executed after the physics step
  24387. * @param func The function to execute after physics step
  24388. */
  24389. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24390. /**
  24391. * Unregisters a function that will be executed after the physics step
  24392. * @param func The function to execute after physics step
  24393. */
  24394. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24395. /**
  24396. * register a function that will be executed when this impostor collides against a different body
  24397. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24398. * @param func Callback that is executed on collision
  24399. */
  24400. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24401. /**
  24402. * Unregisters the physics imposter on contact
  24403. * @param collideAgainst The physics object to collide against
  24404. * @param func Callback to execute on collision
  24405. */
  24406. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24407. private _tmpQuat;
  24408. private _tmpQuat2;
  24409. /**
  24410. * Get the parent rotation
  24411. * @returns The parent rotation
  24412. */
  24413. getParentsRotation(): Quaternion;
  24414. /**
  24415. * this function is executed by the physics engine.
  24416. */
  24417. beforeStep: () => void;
  24418. /**
  24419. * this function is executed by the physics engine
  24420. */
  24421. afterStep: () => void;
  24422. /**
  24423. * Legacy collision detection event support
  24424. */
  24425. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24426. /**
  24427. * event and body object due to cannon's event-based architecture.
  24428. */
  24429. onCollide: (e: {
  24430. body: any;
  24431. }) => void;
  24432. /**
  24433. * Apply a force
  24434. * @param force The force to apply
  24435. * @param contactPoint The contact point for the force
  24436. * @returns The physics imposter
  24437. */
  24438. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24439. /**
  24440. * Apply an impulse
  24441. * @param force The impulse force
  24442. * @param contactPoint The contact point for the impulse force
  24443. * @returns The physics imposter
  24444. */
  24445. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24446. /**
  24447. * A help function to create a joint
  24448. * @param otherImpostor A physics imposter used to create a joint
  24449. * @param jointType The type of joint
  24450. * @param jointData The data for the joint
  24451. * @returns The physics imposter
  24452. */
  24453. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24454. /**
  24455. * Add a joint to this impostor with a different impostor
  24456. * @param otherImpostor A physics imposter used to add a joint
  24457. * @param joint The joint to add
  24458. * @returns The physics imposter
  24459. */
  24460. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24461. /**
  24462. * Add an anchor to a cloth impostor
  24463. * @param otherImpostor rigid impostor to anchor to
  24464. * @param width ratio across width from 0 to 1
  24465. * @param height ratio up height from 0 to 1
  24466. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24467. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24468. * @returns impostor the soft imposter
  24469. */
  24470. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24471. /**
  24472. * Add a hook to a rope impostor
  24473. * @param otherImpostor rigid impostor to anchor to
  24474. * @param length ratio across rope from 0 to 1
  24475. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24476. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24477. * @returns impostor the rope imposter
  24478. */
  24479. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24480. /**
  24481. * Will keep this body still, in a sleep mode.
  24482. * @returns the physics imposter
  24483. */
  24484. sleep(): PhysicsImpostor;
  24485. /**
  24486. * Wake the body up.
  24487. * @returns The physics imposter
  24488. */
  24489. wakeUp(): PhysicsImpostor;
  24490. /**
  24491. * Clones the physics imposter
  24492. * @param newObject The physics imposter clones to this physics-enabled object
  24493. * @returns A nullable physics imposter
  24494. */
  24495. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24496. /**
  24497. * Disposes the physics imposter
  24498. */
  24499. dispose(): void;
  24500. /**
  24501. * Sets the delta position
  24502. * @param position The delta position amount
  24503. */
  24504. setDeltaPosition(position: Vector3): void;
  24505. /**
  24506. * Sets the delta rotation
  24507. * @param rotation The delta rotation amount
  24508. */
  24509. setDeltaRotation(rotation: Quaternion): void;
  24510. /**
  24511. * Gets the box size of the physics imposter and stores the result in the input parameter
  24512. * @param result Stores the box size
  24513. * @returns The physics imposter
  24514. */
  24515. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24516. /**
  24517. * Gets the radius of the physics imposter
  24518. * @returns Radius of the physics imposter
  24519. */
  24520. getRadius(): number;
  24521. /**
  24522. * Sync a bone with this impostor
  24523. * @param bone The bone to sync to the impostor.
  24524. * @param boneMesh The mesh that the bone is influencing.
  24525. * @param jointPivot The pivot of the joint / bone in local space.
  24526. * @param distToJoint Optional distance from the impostor to the joint.
  24527. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24528. */
  24529. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24530. /**
  24531. * Sync impostor to a bone
  24532. * @param bone The bone that the impostor will be synced to.
  24533. * @param boneMesh The mesh that the bone is influencing.
  24534. * @param jointPivot The pivot of the joint / bone in local space.
  24535. * @param distToJoint Optional distance from the impostor to the joint.
  24536. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24537. * @param boneAxis Optional vector3 axis the bone is aligned with
  24538. */
  24539. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24540. /**
  24541. * No-Imposter type
  24542. */
  24543. static NoImpostor: number;
  24544. /**
  24545. * Sphere-Imposter type
  24546. */
  24547. static SphereImpostor: number;
  24548. /**
  24549. * Box-Imposter type
  24550. */
  24551. static BoxImpostor: number;
  24552. /**
  24553. * Plane-Imposter type
  24554. */
  24555. static PlaneImpostor: number;
  24556. /**
  24557. * Mesh-imposter type
  24558. */
  24559. static MeshImpostor: number;
  24560. /**
  24561. * Capsule-Impostor type (Ammo.js plugin only)
  24562. */
  24563. static CapsuleImpostor: number;
  24564. /**
  24565. * Cylinder-Imposter type
  24566. */
  24567. static CylinderImpostor: number;
  24568. /**
  24569. * Particle-Imposter type
  24570. */
  24571. static ParticleImpostor: number;
  24572. /**
  24573. * Heightmap-Imposter type
  24574. */
  24575. static HeightmapImpostor: number;
  24576. /**
  24577. * ConvexHull-Impostor type (Ammo.js plugin only)
  24578. */
  24579. static ConvexHullImpostor: number;
  24580. /**
  24581. * Custom-Imposter type (Ammo.js plugin only)
  24582. */
  24583. static CustomImpostor: number;
  24584. /**
  24585. * Rope-Imposter type
  24586. */
  24587. static RopeImpostor: number;
  24588. /**
  24589. * Cloth-Imposter type
  24590. */
  24591. static ClothImpostor: number;
  24592. /**
  24593. * Softbody-Imposter type
  24594. */
  24595. static SoftbodyImpostor: number;
  24596. }
  24597. }
  24598. declare module BABYLON {
  24599. /**
  24600. * @hidden
  24601. **/
  24602. export class _CreationDataStorage {
  24603. closePath?: boolean;
  24604. closeArray?: boolean;
  24605. idx: number[];
  24606. dashSize: number;
  24607. gapSize: number;
  24608. path3D: Path3D;
  24609. pathArray: Vector3[][];
  24610. arc: number;
  24611. radius: number;
  24612. cap: number;
  24613. tessellation: number;
  24614. }
  24615. /**
  24616. * @hidden
  24617. **/
  24618. class _InstanceDataStorage {
  24619. visibleInstances: any;
  24620. batchCache: _InstancesBatch;
  24621. instancesBufferSize: number;
  24622. instancesBuffer: Nullable<Buffer>;
  24623. instancesData: Float32Array;
  24624. overridenInstanceCount: number;
  24625. isFrozen: boolean;
  24626. previousBatch: Nullable<_InstancesBatch>;
  24627. hardwareInstancedRendering: boolean;
  24628. sideOrientation: number;
  24629. manualUpdate: boolean;
  24630. }
  24631. /**
  24632. * @hidden
  24633. **/
  24634. export class _InstancesBatch {
  24635. mustReturn: boolean;
  24636. visibleInstances: Nullable<InstancedMesh[]>[];
  24637. renderSelf: boolean[];
  24638. hardwareInstancedRendering: boolean[];
  24639. }
  24640. /**
  24641. * Class used to represent renderable models
  24642. */
  24643. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24644. /**
  24645. * Mesh side orientation : usually the external or front surface
  24646. */
  24647. static readonly FRONTSIDE: number;
  24648. /**
  24649. * Mesh side orientation : usually the internal or back surface
  24650. */
  24651. static readonly BACKSIDE: number;
  24652. /**
  24653. * Mesh side orientation : both internal and external or front and back surfaces
  24654. */
  24655. static readonly DOUBLESIDE: number;
  24656. /**
  24657. * Mesh side orientation : by default, `FRONTSIDE`
  24658. */
  24659. static readonly DEFAULTSIDE: number;
  24660. /**
  24661. * Mesh cap setting : no cap
  24662. */
  24663. static readonly NO_CAP: number;
  24664. /**
  24665. * Mesh cap setting : one cap at the beginning of the mesh
  24666. */
  24667. static readonly CAP_START: number;
  24668. /**
  24669. * Mesh cap setting : one cap at the end of the mesh
  24670. */
  24671. static readonly CAP_END: number;
  24672. /**
  24673. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24674. */
  24675. static readonly CAP_ALL: number;
  24676. /**
  24677. * Mesh pattern setting : no flip or rotate
  24678. */
  24679. static readonly NO_FLIP: number;
  24680. /**
  24681. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24682. */
  24683. static readonly FLIP_TILE: number;
  24684. /**
  24685. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24686. */
  24687. static readonly ROTATE_TILE: number;
  24688. /**
  24689. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24690. */
  24691. static readonly FLIP_ROW: number;
  24692. /**
  24693. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24694. */
  24695. static readonly ROTATE_ROW: number;
  24696. /**
  24697. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24698. */
  24699. static readonly FLIP_N_ROTATE_TILE: number;
  24700. /**
  24701. * Mesh pattern setting : rotate pattern and rotate
  24702. */
  24703. static readonly FLIP_N_ROTATE_ROW: number;
  24704. /**
  24705. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24706. */
  24707. static readonly CENTER: number;
  24708. /**
  24709. * Mesh tile positioning : part tiles on left
  24710. */
  24711. static readonly LEFT: number;
  24712. /**
  24713. * Mesh tile positioning : part tiles on right
  24714. */
  24715. static readonly RIGHT: number;
  24716. /**
  24717. * Mesh tile positioning : part tiles on top
  24718. */
  24719. static readonly TOP: number;
  24720. /**
  24721. * Mesh tile positioning : part tiles on bottom
  24722. */
  24723. static readonly BOTTOM: number;
  24724. /**
  24725. * Gets the default side orientation.
  24726. * @param orientation the orientation to value to attempt to get
  24727. * @returns the default orientation
  24728. * @hidden
  24729. */
  24730. static _GetDefaultSideOrientation(orientation?: number): number;
  24731. private _internalMeshDataInfo;
  24732. /**
  24733. * An event triggered before rendering the mesh
  24734. */
  24735. get onBeforeRenderObservable(): Observable<Mesh>;
  24736. /**
  24737. * An event triggered before binding the mesh
  24738. */
  24739. get onBeforeBindObservable(): Observable<Mesh>;
  24740. /**
  24741. * An event triggered after rendering the mesh
  24742. */
  24743. get onAfterRenderObservable(): Observable<Mesh>;
  24744. /**
  24745. * An event triggered before drawing the mesh
  24746. */
  24747. get onBeforeDrawObservable(): Observable<Mesh>;
  24748. private _onBeforeDrawObserver;
  24749. /**
  24750. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24751. */
  24752. set onBeforeDraw(callback: () => void);
  24753. get hasInstances(): boolean;
  24754. /**
  24755. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24756. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24757. */
  24758. delayLoadState: number;
  24759. /**
  24760. * Gets the list of instances created from this mesh
  24761. * it is not supposed to be modified manually.
  24762. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24763. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24764. */
  24765. instances: InstancedMesh[];
  24766. /**
  24767. * Gets the file containing delay loading data for this mesh
  24768. */
  24769. delayLoadingFile: string;
  24770. /** @hidden */
  24771. _binaryInfo: any;
  24772. /**
  24773. * User defined function used to change how LOD level selection is done
  24774. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24775. */
  24776. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24777. /**
  24778. * Gets or sets the morph target manager
  24779. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24780. */
  24781. get morphTargetManager(): Nullable<MorphTargetManager>;
  24782. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24783. /** @hidden */
  24784. _creationDataStorage: Nullable<_CreationDataStorage>;
  24785. /** @hidden */
  24786. _geometry: Nullable<Geometry>;
  24787. /** @hidden */
  24788. _delayInfo: Array<string>;
  24789. /** @hidden */
  24790. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24791. /** @hidden */
  24792. _instanceDataStorage: _InstanceDataStorage;
  24793. private _effectiveMaterial;
  24794. /** @hidden */
  24795. _shouldGenerateFlatShading: boolean;
  24796. /** @hidden */
  24797. _originalBuilderSideOrientation: number;
  24798. /**
  24799. * Use this property to change the original side orientation defined at construction time
  24800. */
  24801. overrideMaterialSideOrientation: Nullable<number>;
  24802. /**
  24803. * Gets the source mesh (the one used to clone this one from)
  24804. */
  24805. get source(): Nullable<Mesh>;
  24806. /**
  24807. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24808. */
  24809. get isUnIndexed(): boolean;
  24810. set isUnIndexed(value: boolean);
  24811. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24812. get worldMatrixInstancedBuffer(): Float32Array;
  24813. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24814. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24815. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24816. /**
  24817. * @constructor
  24818. * @param name The value used by scene.getMeshByName() to do a lookup.
  24819. * @param scene The scene to add this mesh to.
  24820. * @param parent The parent of this mesh, if it has one
  24821. * @param source An optional Mesh from which geometry is shared, cloned.
  24822. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24823. * When false, achieved by calling a clone(), also passing False.
  24824. * This will make creation of children, recursive.
  24825. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24826. */
  24827. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24828. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24829. doNotInstantiate: boolean;
  24830. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24831. /**
  24832. * Gets the class name
  24833. * @returns the string "Mesh".
  24834. */
  24835. getClassName(): string;
  24836. /** @hidden */
  24837. get _isMesh(): boolean;
  24838. /**
  24839. * Returns a description of this mesh
  24840. * @param fullDetails define if full details about this mesh must be used
  24841. * @returns a descriptive string representing this mesh
  24842. */
  24843. toString(fullDetails?: boolean): string;
  24844. /** @hidden */
  24845. _unBindEffect(): void;
  24846. /**
  24847. * Gets a boolean indicating if this mesh has LOD
  24848. */
  24849. get hasLODLevels(): boolean;
  24850. /**
  24851. * Gets the list of MeshLODLevel associated with the current mesh
  24852. * @returns an array of MeshLODLevel
  24853. */
  24854. getLODLevels(): MeshLODLevel[];
  24855. private _sortLODLevels;
  24856. /**
  24857. * Add a mesh as LOD level triggered at the given distance.
  24858. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24859. * @param distance The distance from the center of the object to show this level
  24860. * @param mesh The mesh to be added as LOD level (can be null)
  24861. * @return This mesh (for chaining)
  24862. */
  24863. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24864. /**
  24865. * Returns the LOD level mesh at the passed distance or null if not found.
  24866. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24867. * @param distance The distance from the center of the object to show this level
  24868. * @returns a Mesh or `null`
  24869. */
  24870. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24871. /**
  24872. * Remove a mesh from the LOD array
  24873. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24874. * @param mesh defines the mesh to be removed
  24875. * @return This mesh (for chaining)
  24876. */
  24877. removeLODLevel(mesh: Mesh): Mesh;
  24878. /**
  24879. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24880. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24881. * @param camera defines the camera to use to compute distance
  24882. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24883. * @return This mesh (for chaining)
  24884. */
  24885. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24886. /**
  24887. * Gets the mesh internal Geometry object
  24888. */
  24889. get geometry(): Nullable<Geometry>;
  24890. /**
  24891. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24892. * @returns the total number of vertices
  24893. */
  24894. getTotalVertices(): number;
  24895. /**
  24896. * Returns the content of an associated vertex buffer
  24897. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24898. * - VertexBuffer.PositionKind
  24899. * - VertexBuffer.UVKind
  24900. * - VertexBuffer.UV2Kind
  24901. * - VertexBuffer.UV3Kind
  24902. * - VertexBuffer.UV4Kind
  24903. * - VertexBuffer.UV5Kind
  24904. * - VertexBuffer.UV6Kind
  24905. * - VertexBuffer.ColorKind
  24906. * - VertexBuffer.MatricesIndicesKind
  24907. * - VertexBuffer.MatricesIndicesExtraKind
  24908. * - VertexBuffer.MatricesWeightsKind
  24909. * - VertexBuffer.MatricesWeightsExtraKind
  24910. * @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
  24911. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24912. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24913. */
  24914. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24915. /**
  24916. * Returns the mesh VertexBuffer object from the requested `kind`
  24917. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24918. * - VertexBuffer.PositionKind
  24919. * - VertexBuffer.NormalKind
  24920. * - VertexBuffer.UVKind
  24921. * - VertexBuffer.UV2Kind
  24922. * - VertexBuffer.UV3Kind
  24923. * - VertexBuffer.UV4Kind
  24924. * - VertexBuffer.UV5Kind
  24925. * - VertexBuffer.UV6Kind
  24926. * - VertexBuffer.ColorKind
  24927. * - VertexBuffer.MatricesIndicesKind
  24928. * - VertexBuffer.MatricesIndicesExtraKind
  24929. * - VertexBuffer.MatricesWeightsKind
  24930. * - VertexBuffer.MatricesWeightsExtraKind
  24931. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24932. */
  24933. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24934. /**
  24935. * Tests if a specific vertex buffer is associated with this mesh
  24936. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24937. * - VertexBuffer.PositionKind
  24938. * - VertexBuffer.NormalKind
  24939. * - VertexBuffer.UVKind
  24940. * - VertexBuffer.UV2Kind
  24941. * - VertexBuffer.UV3Kind
  24942. * - VertexBuffer.UV4Kind
  24943. * - VertexBuffer.UV5Kind
  24944. * - VertexBuffer.UV6Kind
  24945. * - VertexBuffer.ColorKind
  24946. * - VertexBuffer.MatricesIndicesKind
  24947. * - VertexBuffer.MatricesIndicesExtraKind
  24948. * - VertexBuffer.MatricesWeightsKind
  24949. * - VertexBuffer.MatricesWeightsExtraKind
  24950. * @returns a boolean
  24951. */
  24952. isVerticesDataPresent(kind: string): boolean;
  24953. /**
  24954. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24955. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24956. * - VertexBuffer.PositionKind
  24957. * - VertexBuffer.UVKind
  24958. * - VertexBuffer.UV2Kind
  24959. * - VertexBuffer.UV3Kind
  24960. * - VertexBuffer.UV4Kind
  24961. * - VertexBuffer.UV5Kind
  24962. * - VertexBuffer.UV6Kind
  24963. * - VertexBuffer.ColorKind
  24964. * - VertexBuffer.MatricesIndicesKind
  24965. * - VertexBuffer.MatricesIndicesExtraKind
  24966. * - VertexBuffer.MatricesWeightsKind
  24967. * - VertexBuffer.MatricesWeightsExtraKind
  24968. * @returns a boolean
  24969. */
  24970. isVertexBufferUpdatable(kind: string): boolean;
  24971. /**
  24972. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24973. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24974. * - VertexBuffer.PositionKind
  24975. * - VertexBuffer.NormalKind
  24976. * - VertexBuffer.UVKind
  24977. * - VertexBuffer.UV2Kind
  24978. * - VertexBuffer.UV3Kind
  24979. * - VertexBuffer.UV4Kind
  24980. * - VertexBuffer.UV5Kind
  24981. * - VertexBuffer.UV6Kind
  24982. * - VertexBuffer.ColorKind
  24983. * - VertexBuffer.MatricesIndicesKind
  24984. * - VertexBuffer.MatricesIndicesExtraKind
  24985. * - VertexBuffer.MatricesWeightsKind
  24986. * - VertexBuffer.MatricesWeightsExtraKind
  24987. * @returns an array of strings
  24988. */
  24989. getVerticesDataKinds(): string[];
  24990. /**
  24991. * Returns a positive integer : the total number of indices in this mesh geometry.
  24992. * @returns the numner of indices or zero if the mesh has no geometry.
  24993. */
  24994. getTotalIndices(): number;
  24995. /**
  24996. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24997. * @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.
  24998. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24999. * @returns the indices array or an empty array if the mesh has no geometry
  25000. */
  25001. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25002. get isBlocked(): boolean;
  25003. /**
  25004. * Determine if the current mesh is ready to be rendered
  25005. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25006. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25007. * @returns true if all associated assets are ready (material, textures, shaders)
  25008. */
  25009. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25010. /**
  25011. * 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.
  25012. */
  25013. get areNormalsFrozen(): boolean;
  25014. /**
  25015. * 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.
  25016. * @returns the current mesh
  25017. */
  25018. freezeNormals(): Mesh;
  25019. /**
  25020. * 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
  25021. * @returns the current mesh
  25022. */
  25023. unfreezeNormals(): Mesh;
  25024. /**
  25025. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25026. */
  25027. set overridenInstanceCount(count: number);
  25028. /** @hidden */
  25029. _preActivate(): Mesh;
  25030. /** @hidden */
  25031. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25032. /** @hidden */
  25033. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25034. /**
  25035. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25036. * This means the mesh underlying bounding box and sphere are recomputed.
  25037. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25038. * @returns the current mesh
  25039. */
  25040. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25041. /** @hidden */
  25042. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25043. /**
  25044. * This function will subdivide the mesh into multiple submeshes
  25045. * @param count defines the expected number of submeshes
  25046. */
  25047. subdivide(count: number): void;
  25048. /**
  25049. * Copy a FloatArray into a specific associated vertex buffer
  25050. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25051. * - VertexBuffer.PositionKind
  25052. * - VertexBuffer.UVKind
  25053. * - VertexBuffer.UV2Kind
  25054. * - VertexBuffer.UV3Kind
  25055. * - VertexBuffer.UV4Kind
  25056. * - VertexBuffer.UV5Kind
  25057. * - VertexBuffer.UV6Kind
  25058. * - VertexBuffer.ColorKind
  25059. * - VertexBuffer.MatricesIndicesKind
  25060. * - VertexBuffer.MatricesIndicesExtraKind
  25061. * - VertexBuffer.MatricesWeightsKind
  25062. * - VertexBuffer.MatricesWeightsExtraKind
  25063. * @param data defines the data source
  25064. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25065. * @param stride defines the data stride size (can be null)
  25066. * @returns the current mesh
  25067. */
  25068. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25069. /**
  25070. * Delete a vertex buffer associated with this mesh
  25071. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25072. * - VertexBuffer.PositionKind
  25073. * - VertexBuffer.UVKind
  25074. * - VertexBuffer.UV2Kind
  25075. * - VertexBuffer.UV3Kind
  25076. * - VertexBuffer.UV4Kind
  25077. * - VertexBuffer.UV5Kind
  25078. * - VertexBuffer.UV6Kind
  25079. * - VertexBuffer.ColorKind
  25080. * - VertexBuffer.MatricesIndicesKind
  25081. * - VertexBuffer.MatricesIndicesExtraKind
  25082. * - VertexBuffer.MatricesWeightsKind
  25083. * - VertexBuffer.MatricesWeightsExtraKind
  25084. */
  25085. removeVerticesData(kind: string): void;
  25086. /**
  25087. * Flags an associated vertex buffer as updatable
  25088. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25089. * - VertexBuffer.PositionKind
  25090. * - VertexBuffer.UVKind
  25091. * - VertexBuffer.UV2Kind
  25092. * - VertexBuffer.UV3Kind
  25093. * - VertexBuffer.UV4Kind
  25094. * - VertexBuffer.UV5Kind
  25095. * - VertexBuffer.UV6Kind
  25096. * - VertexBuffer.ColorKind
  25097. * - VertexBuffer.MatricesIndicesKind
  25098. * - VertexBuffer.MatricesIndicesExtraKind
  25099. * - VertexBuffer.MatricesWeightsKind
  25100. * - VertexBuffer.MatricesWeightsExtraKind
  25101. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25102. */
  25103. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25104. /**
  25105. * Sets the mesh global Vertex Buffer
  25106. * @param buffer defines the buffer to use
  25107. * @returns the current mesh
  25108. */
  25109. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25110. /**
  25111. * Update a specific associated vertex buffer
  25112. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25113. * - VertexBuffer.PositionKind
  25114. * - VertexBuffer.UVKind
  25115. * - VertexBuffer.UV2Kind
  25116. * - VertexBuffer.UV3Kind
  25117. * - VertexBuffer.UV4Kind
  25118. * - VertexBuffer.UV5Kind
  25119. * - VertexBuffer.UV6Kind
  25120. * - VertexBuffer.ColorKind
  25121. * - VertexBuffer.MatricesIndicesKind
  25122. * - VertexBuffer.MatricesIndicesExtraKind
  25123. * - VertexBuffer.MatricesWeightsKind
  25124. * - VertexBuffer.MatricesWeightsExtraKind
  25125. * @param data defines the data source
  25126. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25127. * @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)
  25128. * @returns the current mesh
  25129. */
  25130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25131. /**
  25132. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25133. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25134. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25135. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25136. * @returns the current mesh
  25137. */
  25138. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25139. /**
  25140. * Creates a un-shared specific occurence of the geometry for the mesh.
  25141. * @returns the current mesh
  25142. */
  25143. makeGeometryUnique(): Mesh;
  25144. /**
  25145. * Set the index buffer of this mesh
  25146. * @param indices defines the source data
  25147. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25148. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25149. * @returns the current mesh
  25150. */
  25151. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25152. /**
  25153. * Update the current index buffer
  25154. * @param indices defines the source data
  25155. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25156. * @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)
  25157. * @returns the current mesh
  25158. */
  25159. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25160. /**
  25161. * Invert the geometry to move from a right handed system to a left handed one.
  25162. * @returns the current mesh
  25163. */
  25164. toLeftHanded(): Mesh;
  25165. /** @hidden */
  25166. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25167. /** @hidden */
  25168. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25169. /**
  25170. * Registers for this mesh a javascript function called just before the rendering process
  25171. * @param func defines the function to call before rendering this mesh
  25172. * @returns the current mesh
  25173. */
  25174. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25175. /**
  25176. * Disposes a previously registered javascript function called before the rendering
  25177. * @param func defines the function to remove
  25178. * @returns the current mesh
  25179. */
  25180. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25181. /**
  25182. * Registers for this mesh a javascript function called just after the rendering is complete
  25183. * @param func defines the function to call after rendering this mesh
  25184. * @returns the current mesh
  25185. */
  25186. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25187. /**
  25188. * Disposes a previously registered javascript function called after the rendering.
  25189. * @param func defines the function to remove
  25190. * @returns the current mesh
  25191. */
  25192. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25193. /** @hidden */
  25194. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25195. /** @hidden */
  25196. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25197. /** @hidden */
  25198. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25199. /** @hidden */
  25200. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25201. /** @hidden */
  25202. _rebuild(): void;
  25203. /** @hidden */
  25204. _freeze(): void;
  25205. /** @hidden */
  25206. _unFreeze(): void;
  25207. /**
  25208. * 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
  25209. * @param subMesh defines the subMesh to render
  25210. * @param enableAlphaMode defines if alpha mode can be changed
  25211. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25212. * @returns the current mesh
  25213. */
  25214. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25215. private _onBeforeDraw;
  25216. /**
  25217. * Renormalize the mesh and patch it up if there are no weights
  25218. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25219. * However in the case of zero weights then we set just a single influence to 1.
  25220. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25221. */
  25222. cleanMatrixWeights(): void;
  25223. private normalizeSkinFourWeights;
  25224. private normalizeSkinWeightsAndExtra;
  25225. /**
  25226. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25227. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25228. * the user know there was an issue with importing the mesh
  25229. * @returns a validation object with skinned, valid and report string
  25230. */
  25231. validateSkinning(): {
  25232. skinned: boolean;
  25233. valid: boolean;
  25234. report: string;
  25235. };
  25236. /** @hidden */
  25237. _checkDelayState(): Mesh;
  25238. private _queueLoad;
  25239. /**
  25240. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25241. * A mesh is in the frustum if its bounding box intersects the frustum
  25242. * @param frustumPlanes defines the frustum to test
  25243. * @returns true if the mesh is in the frustum planes
  25244. */
  25245. isInFrustum(frustumPlanes: Plane[]): boolean;
  25246. /**
  25247. * Sets the mesh material by the material or multiMaterial `id` property
  25248. * @param id is a string identifying the material or the multiMaterial
  25249. * @returns the current mesh
  25250. */
  25251. setMaterialByID(id: string): Mesh;
  25252. /**
  25253. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25254. * @returns an array of IAnimatable
  25255. */
  25256. getAnimatables(): IAnimatable[];
  25257. /**
  25258. * Modifies the mesh geometry according to the passed transformation matrix.
  25259. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25260. * The mesh normals are modified using the same transformation.
  25261. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25262. * @param transform defines the transform matrix to use
  25263. * @see http://doc.babylonjs.com/resources/baking_transformations
  25264. * @returns the current mesh
  25265. */
  25266. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25267. /**
  25268. * Modifies the mesh geometry according to its own current World Matrix.
  25269. * The mesh World Matrix is then reset.
  25270. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25271. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25272. * @see http://doc.babylonjs.com/resources/baking_transformations
  25273. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25274. * @returns the current mesh
  25275. */
  25276. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25277. /** @hidden */
  25278. get _positions(): Nullable<Vector3[]>;
  25279. /** @hidden */
  25280. _resetPointsArrayCache(): Mesh;
  25281. /** @hidden */
  25282. _generatePointsArray(): boolean;
  25283. /**
  25284. * Returns a new Mesh object generated from the current mesh properties.
  25285. * This method must not get confused with createInstance()
  25286. * @param name is a string, the name given to the new mesh
  25287. * @param newParent can be any Node object (default `null`)
  25288. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25289. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25290. * @returns a new mesh
  25291. */
  25292. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25293. /**
  25294. * Releases resources associated with this mesh.
  25295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25297. */
  25298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25299. /** @hidden */
  25300. _disposeInstanceSpecificData(): void;
  25301. /**
  25302. * Modifies the mesh geometry according to a displacement map.
  25303. * 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.
  25304. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25305. * @param url is a string, the URL from the image file is to be downloaded.
  25306. * @param minHeight is the lower limit of the displacement.
  25307. * @param maxHeight is the upper limit of the displacement.
  25308. * @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.
  25309. * @param uvOffset is an optional vector2 used to offset UV.
  25310. * @param uvScale is an optional vector2 used to scale UV.
  25311. * @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.
  25312. * @returns the Mesh.
  25313. */
  25314. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25315. /**
  25316. * Modifies the mesh geometry according to a displacementMap buffer.
  25317. * 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.
  25318. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25319. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25320. * @param heightMapWidth is the width of the buffer image.
  25321. * @param heightMapHeight is the height of the buffer image.
  25322. * @param minHeight is the lower limit of the displacement.
  25323. * @param maxHeight is the upper limit of the displacement.
  25324. * @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.
  25325. * @param uvOffset is an optional vector2 used to offset UV.
  25326. * @param uvScale is an optional vector2 used to scale UV.
  25327. * @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.
  25328. * @returns the Mesh.
  25329. */
  25330. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25331. /**
  25332. * Modify the mesh to get a flat shading rendering.
  25333. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25334. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25335. * @returns current mesh
  25336. */
  25337. convertToFlatShadedMesh(): Mesh;
  25338. /**
  25339. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25340. * In other words, more vertices, no more indices and a single bigger VBO.
  25341. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25342. * @returns current mesh
  25343. */
  25344. convertToUnIndexedMesh(): Mesh;
  25345. /**
  25346. * Inverses facet orientations.
  25347. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25348. * @param flipNormals will also inverts the normals
  25349. * @returns current mesh
  25350. */
  25351. flipFaces(flipNormals?: boolean): Mesh;
  25352. /**
  25353. * Increase the number of facets and hence vertices in a mesh
  25354. * Vertex normals are interpolated from existing vertex normals
  25355. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25356. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25357. */
  25358. increaseVertices(numberPerEdge: number): void;
  25359. /**
  25360. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25361. * This will undo any application of covertToFlatShadedMesh
  25362. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25363. */
  25364. forceSharedVertices(): void;
  25365. /** @hidden */
  25366. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25367. /** @hidden */
  25368. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25369. /**
  25370. * Creates a new InstancedMesh object from the mesh model.
  25371. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25372. * @param name defines the name of the new instance
  25373. * @returns a new InstancedMesh
  25374. */
  25375. createInstance(name: string): InstancedMesh;
  25376. /**
  25377. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25378. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25379. * @returns the current mesh
  25380. */
  25381. synchronizeInstances(): Mesh;
  25382. /**
  25383. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25384. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25385. * This should be used together with the simplification to avoid disappearing triangles.
  25386. * @param successCallback an optional success callback to be called after the optimization finished.
  25387. * @returns the current mesh
  25388. */
  25389. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25390. /**
  25391. * Serialize current mesh
  25392. * @param serializationObject defines the object which will receive the serialization data
  25393. */
  25394. serialize(serializationObject: any): void;
  25395. /** @hidden */
  25396. _syncGeometryWithMorphTargetManager(): void;
  25397. /** @hidden */
  25398. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25399. /**
  25400. * Returns a new Mesh object parsed from the source provided.
  25401. * @param parsedMesh is the source
  25402. * @param scene defines the hosting scene
  25403. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25404. * @returns a new Mesh
  25405. */
  25406. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25407. /**
  25408. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25409. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25410. * @param name defines the name of the mesh to create
  25411. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25412. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25413. * @param closePath creates a seam between the first and the last points of each path of the path array
  25414. * @param offset is taken in account only if the `pathArray` is containing a single path
  25415. * @param scene defines the hosting scene
  25416. * @param updatable defines if the mesh must be flagged as updatable
  25417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25418. * @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)
  25419. * @returns a new Mesh
  25420. */
  25421. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25422. /**
  25423. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25424. * @param name defines the name of the mesh to create
  25425. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25426. * @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
  25427. * @param scene defines the hosting scene
  25428. * @param updatable defines if the mesh must be flagged as updatable
  25429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25430. * @returns a new Mesh
  25431. */
  25432. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25433. /**
  25434. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25435. * @param name defines the name of the mesh to create
  25436. * @param size sets the size (float) of each box side (default 1)
  25437. * @param scene defines the hosting scene
  25438. * @param updatable defines if the mesh must be flagged as updatable
  25439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25440. * @returns a new Mesh
  25441. */
  25442. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25443. /**
  25444. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25445. * @param name defines the name of the mesh to create
  25446. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25447. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25448. * @param scene defines the hosting scene
  25449. * @param updatable defines if the mesh must be flagged as updatable
  25450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25451. * @returns a new Mesh
  25452. */
  25453. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25454. /**
  25455. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25456. * @param name defines the name of the mesh to create
  25457. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25458. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25459. * @param scene defines the hosting scene
  25460. * @returns a new Mesh
  25461. */
  25462. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25463. /**
  25464. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25465. * @param name defines the name of the mesh to create
  25466. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25467. * @param diameterTop set the top cap diameter (floats, default 1)
  25468. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25469. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25470. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25471. * @param scene defines the hosting scene
  25472. * @param updatable defines if the mesh must be flagged as updatable
  25473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25477. /**
  25478. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25479. * @param name defines the name of the mesh to create
  25480. * @param diameter sets the diameter size (float) of the torus (default 1)
  25481. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25482. * @param tessellation sets the number of torus sides (postive integer, default 16)
  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. * @returns a new Mesh
  25487. */
  25488. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25489. /**
  25490. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25491. * @param name defines the name of the mesh to create
  25492. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25493. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25494. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25495. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25496. * @param p the number of windings on X axis (positive integers, default 2)
  25497. * @param q the number of windings on Y axis (positive integers, default 3)
  25498. * @param scene defines the hosting scene
  25499. * @param updatable defines if the mesh must be flagged as updatable
  25500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25501. * @returns a new Mesh
  25502. */
  25503. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25504. /**
  25505. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25506. * @param name defines the name of the mesh to create
  25507. * @param points is an array successive Vector3
  25508. * @param scene defines the hosting scene
  25509. * @param updatable defines if the mesh must be flagged as updatable
  25510. * @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).
  25511. * @returns a new Mesh
  25512. */
  25513. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25514. /**
  25515. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25516. * @param name defines the name of the mesh to create
  25517. * @param points is an array successive Vector3
  25518. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25519. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25520. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25521. * @param scene defines the hosting scene
  25522. * @param updatable defines if the mesh must be flagged as updatable
  25523. * @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)
  25524. * @returns a new Mesh
  25525. */
  25526. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25527. /**
  25528. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25529. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25530. * 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.
  25531. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25532. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25533. * Remember you can only change the shape positions, not their number when updating a polygon.
  25534. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25535. * @param name defines the name of the mesh to create
  25536. * @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
  25537. * @param scene defines the hosting scene
  25538. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25539. * @param updatable defines if the mesh must be flagged as updatable
  25540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25541. * @param earcutInjection can be used to inject your own earcut reference
  25542. * @returns a new Mesh
  25543. */
  25544. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25545. /**
  25546. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25547. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25548. * @param name defines the name of the mesh to create
  25549. * @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
  25550. * @param depth defines the height of extrusion
  25551. * @param scene defines the hosting scene
  25552. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25553. * @param updatable defines if the mesh must be flagged as updatable
  25554. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25555. * @param earcutInjection can be used to inject your own earcut reference
  25556. * @returns a new Mesh
  25557. */
  25558. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25559. /**
  25560. * Creates an extruded shape mesh.
  25561. * 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
  25562. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25563. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25564. * @param name defines the name of the mesh to create
  25565. * @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
  25566. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25567. * @param scale is the value to scale the shape
  25568. * @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
  25569. * @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
  25570. * @param scene defines the hosting scene
  25571. * @param updatable defines if the mesh must be flagged as updatable
  25572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25573. * @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)
  25574. * @returns a new Mesh
  25575. */
  25576. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25577. /**
  25578. * Creates an custom extruded shape mesh.
  25579. * The custom extrusion is a parametric shape.
  25580. * It has no predefined shape. Its final shape will depend on the input parameters.
  25581. * Please consider using the same method from the MeshBuilder class instead
  25582. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25583. * @param name defines the name of the mesh to create
  25584. * @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
  25585. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25586. * @param scaleFunction is a custom Javascript function called on each path point
  25587. * @param rotationFunction is a custom Javascript function called on each path point
  25588. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25589. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25590. * @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
  25591. * @param scene defines the hosting scene
  25592. * @param updatable defines if the mesh must be flagged as updatable
  25593. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25594. * @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)
  25595. * @returns a new Mesh
  25596. */
  25597. 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;
  25598. /**
  25599. * Creates lathe mesh.
  25600. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25601. * Please consider using the same method from the MeshBuilder class instead
  25602. * @param name defines the name of the mesh to create
  25603. * @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
  25604. * @param radius is the radius value of the lathe
  25605. * @param tessellation is the side number of the lathe.
  25606. * @param scene defines the hosting scene
  25607. * @param updatable defines if the mesh must be flagged as updatable
  25608. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25609. * @returns a new Mesh
  25610. */
  25611. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25612. /**
  25613. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25614. * @param name defines the name of the mesh to create
  25615. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25616. * @param scene defines the hosting scene
  25617. * @param updatable defines if the mesh must be flagged as updatable
  25618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25619. * @returns a new Mesh
  25620. */
  25621. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25622. /**
  25623. * Creates a ground mesh.
  25624. * Please consider using the same method from the MeshBuilder class instead
  25625. * @param name defines the name of the mesh to create
  25626. * @param width set the width of the ground
  25627. * @param height set the height of the ground
  25628. * @param subdivisions sets the number of subdivisions per side
  25629. * @param scene defines the hosting scene
  25630. * @param updatable defines if the mesh must be flagged as updatable
  25631. * @returns a new Mesh
  25632. */
  25633. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25634. /**
  25635. * Creates a tiled ground mesh.
  25636. * Please consider using the same method from the MeshBuilder class instead
  25637. * @param name defines the name of the mesh to create
  25638. * @param xmin set the ground minimum X coordinate
  25639. * @param zmin set the ground minimum Y coordinate
  25640. * @param xmax set the ground maximum X coordinate
  25641. * @param zmax set the ground maximum Z coordinate
  25642. * @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
  25643. * @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
  25644. * @param scene defines the hosting scene
  25645. * @param updatable defines if the mesh must be flagged as updatable
  25646. * @returns a new Mesh
  25647. */
  25648. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25649. w: number;
  25650. h: number;
  25651. }, precision: {
  25652. w: number;
  25653. h: number;
  25654. }, scene: Scene, updatable?: boolean): Mesh;
  25655. /**
  25656. * Creates a ground mesh from a height map.
  25657. * Please consider using the same method from the MeshBuilder class instead
  25658. * @see http://doc.babylonjs.com/babylon101/height_map
  25659. * @param name defines the name of the mesh to create
  25660. * @param url sets the URL of the height map image resource
  25661. * @param width set the ground width size
  25662. * @param height set the ground height size
  25663. * @param subdivisions sets the number of subdivision per side
  25664. * @param minHeight is the minimum altitude on the ground
  25665. * @param maxHeight is the maximum altitude on the ground
  25666. * @param scene defines the hosting scene
  25667. * @param updatable defines if the mesh must be flagged as updatable
  25668. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25669. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25670. * @returns a new Mesh
  25671. */
  25672. 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;
  25673. /**
  25674. * Creates a tube mesh.
  25675. * The tube is a parametric shape.
  25676. * It has no predefined shape. Its final shape will depend on the input parameters.
  25677. * Please consider using the same method from the MeshBuilder class instead
  25678. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25679. * @param name defines the name of the mesh to create
  25680. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25681. * @param radius sets the tube radius size
  25682. * @param tessellation is the number of sides on the tubular surface
  25683. * @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
  25684. * @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
  25685. * @param scene defines the hosting scene
  25686. * @param updatable defines if the mesh must be flagged as updatable
  25687. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25688. * @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)
  25689. * @returns a new Mesh
  25690. */
  25691. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25692. (i: number, distance: number): number;
  25693. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25694. /**
  25695. * Creates a polyhedron mesh.
  25696. * Please consider using the same method from the MeshBuilder class instead.
  25697. * * 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
  25698. * * The parameter `size` (positive float, default 1) sets the polygon size
  25699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25700. * * 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`
  25701. * * 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
  25702. * * 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)`)
  25703. * * 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
  25704. * * 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
  25705. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25706. * * 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
  25707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25708. * @param name defines the name of the mesh to create
  25709. * @param options defines the options used to create the mesh
  25710. * @param scene defines the hosting scene
  25711. * @returns a new Mesh
  25712. */
  25713. static CreatePolyhedron(name: string, options: {
  25714. type?: number;
  25715. size?: number;
  25716. sizeX?: number;
  25717. sizeY?: number;
  25718. sizeZ?: number;
  25719. custom?: any;
  25720. faceUV?: Vector4[];
  25721. faceColors?: Color4[];
  25722. updatable?: boolean;
  25723. sideOrientation?: number;
  25724. }, scene: Scene): Mesh;
  25725. /**
  25726. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25727. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25728. * * 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`)
  25729. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25730. * * 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
  25731. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25732. * * 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
  25733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25734. * @param name defines the name of the mesh
  25735. * @param options defines the options used to create the mesh
  25736. * @param scene defines the hosting scene
  25737. * @returns a new Mesh
  25738. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25739. */
  25740. static CreateIcoSphere(name: string, options: {
  25741. radius?: number;
  25742. flat?: boolean;
  25743. subdivisions?: number;
  25744. sideOrientation?: number;
  25745. updatable?: boolean;
  25746. }, scene: Scene): Mesh;
  25747. /**
  25748. * Creates a decal mesh.
  25749. * Please consider using the same method from the MeshBuilder class instead.
  25750. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25751. * @param name defines the name of the mesh
  25752. * @param sourceMesh defines the mesh receiving the decal
  25753. * @param position sets the position of the decal in world coordinates
  25754. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25755. * @param size sets the decal scaling
  25756. * @param angle sets the angle to rotate the decal
  25757. * @returns a new Mesh
  25758. */
  25759. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25760. /**
  25761. * Prepare internal position array for software CPU skinning
  25762. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25763. */
  25764. setPositionsForCPUSkinning(): Float32Array;
  25765. /**
  25766. * Prepare internal normal array for software CPU skinning
  25767. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25768. */
  25769. setNormalsForCPUSkinning(): Float32Array;
  25770. /**
  25771. * Updates the vertex buffer by applying transformation from the bones
  25772. * @param skeleton defines the skeleton to apply to current mesh
  25773. * @returns the current mesh
  25774. */
  25775. applySkeleton(skeleton: Skeleton): Mesh;
  25776. /**
  25777. * 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
  25778. * @param meshes defines the list of meshes to scan
  25779. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25780. */
  25781. static MinMax(meshes: AbstractMesh[]): {
  25782. min: Vector3;
  25783. max: Vector3;
  25784. };
  25785. /**
  25786. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25787. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25788. * @returns a vector3
  25789. */
  25790. static Center(meshesOrMinMaxVector: {
  25791. min: Vector3;
  25792. max: Vector3;
  25793. } | AbstractMesh[]): Vector3;
  25794. /**
  25795. * Merge the array of meshes into a single mesh for performance reasons.
  25796. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25797. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25798. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25799. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25800. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25801. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25802. * @returns a new mesh
  25803. */
  25804. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25805. /** @hidden */
  25806. addInstance(instance: InstancedMesh): void;
  25807. /** @hidden */
  25808. removeInstance(instance: InstancedMesh): void;
  25809. }
  25810. }
  25811. declare module BABYLON {
  25812. /**
  25813. * This is the base class of all the camera used in the application.
  25814. * @see http://doc.babylonjs.com/features/cameras
  25815. */
  25816. export class Camera extends Node {
  25817. /** @hidden */
  25818. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25819. /**
  25820. * This is the default projection mode used by the cameras.
  25821. * It helps recreating a feeling of perspective and better appreciate depth.
  25822. * This is the best way to simulate real life cameras.
  25823. */
  25824. static readonly PERSPECTIVE_CAMERA: number;
  25825. /**
  25826. * This helps creating camera with an orthographic mode.
  25827. * 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.
  25828. */
  25829. static readonly ORTHOGRAPHIC_CAMERA: number;
  25830. /**
  25831. * This is the default FOV mode for perspective cameras.
  25832. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25833. */
  25834. static readonly FOVMODE_VERTICAL_FIXED: number;
  25835. /**
  25836. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25837. */
  25838. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25839. /**
  25840. * This specifies ther is no need for a camera rig.
  25841. * Basically only one eye is rendered corresponding to the camera.
  25842. */
  25843. static readonly RIG_MODE_NONE: number;
  25844. /**
  25845. * Simulates a camera Rig with one blue eye and one red eye.
  25846. * This can be use with 3d blue and red glasses.
  25847. */
  25848. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25849. /**
  25850. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25851. */
  25852. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25853. /**
  25854. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25855. */
  25856. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25857. /**
  25858. * Defines that both eyes of the camera will be rendered over under each other.
  25859. */
  25860. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25861. /**
  25862. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25863. */
  25864. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25865. /**
  25866. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25867. */
  25868. static readonly RIG_MODE_VR: number;
  25869. /**
  25870. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25871. */
  25872. static readonly RIG_MODE_WEBVR: number;
  25873. /**
  25874. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25875. */
  25876. static readonly RIG_MODE_CUSTOM: number;
  25877. /**
  25878. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25879. */
  25880. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25881. /**
  25882. * Define the input manager associated with the camera.
  25883. */
  25884. inputs: CameraInputsManager<Camera>;
  25885. /** @hidden */
  25886. _position: Vector3;
  25887. /**
  25888. * Define the current local position of the camera in the scene
  25889. */
  25890. get position(): Vector3;
  25891. set position(newPosition: Vector3);
  25892. /**
  25893. * The vector the camera should consider as up.
  25894. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25895. */
  25896. upVector: Vector3;
  25897. /**
  25898. * Define the current limit on the left side for an orthographic camera
  25899. * In scene unit
  25900. */
  25901. orthoLeft: Nullable<number>;
  25902. /**
  25903. * Define the current limit on the right side for an orthographic camera
  25904. * In scene unit
  25905. */
  25906. orthoRight: Nullable<number>;
  25907. /**
  25908. * Define the current limit on the bottom side for an orthographic camera
  25909. * In scene unit
  25910. */
  25911. orthoBottom: Nullable<number>;
  25912. /**
  25913. * Define the current limit on the top side for an orthographic camera
  25914. * In scene unit
  25915. */
  25916. orthoTop: Nullable<number>;
  25917. /**
  25918. * Field Of View is set in Radians. (default is 0.8)
  25919. */
  25920. fov: number;
  25921. /**
  25922. * Define the minimum distance the camera can see from.
  25923. * This is important to note that the depth buffer are not infinite and the closer it starts
  25924. * the more your scene might encounter depth fighting issue.
  25925. */
  25926. minZ: number;
  25927. /**
  25928. * Define the maximum distance the camera can see to.
  25929. * This is important to note that the depth buffer are not infinite and the further it end
  25930. * the more your scene might encounter depth fighting issue.
  25931. */
  25932. maxZ: number;
  25933. /**
  25934. * Define the default inertia of the camera.
  25935. * This helps giving a smooth feeling to the camera movement.
  25936. */
  25937. inertia: number;
  25938. /**
  25939. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25940. */
  25941. mode: number;
  25942. /**
  25943. * Define whether the camera is intermediate.
  25944. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25945. */
  25946. isIntermediate: boolean;
  25947. /**
  25948. * Define the viewport of the camera.
  25949. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25950. */
  25951. viewport: Viewport;
  25952. /**
  25953. * Restricts the camera to viewing objects with the same layerMask.
  25954. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25955. */
  25956. layerMask: number;
  25957. /**
  25958. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25959. */
  25960. fovMode: number;
  25961. /**
  25962. * Rig mode of the camera.
  25963. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25964. * This is normally controlled byt the camera themselves as internal use.
  25965. */
  25966. cameraRigMode: number;
  25967. /**
  25968. * Defines the distance between both "eyes" in case of a RIG
  25969. */
  25970. interaxialDistance: number;
  25971. /**
  25972. * Defines if stereoscopic rendering is done side by side or over under.
  25973. */
  25974. isStereoscopicSideBySide: boolean;
  25975. /**
  25976. * 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
  25977. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25978. * else in the scene. (Eg. security camera)
  25979. *
  25980. * 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)
  25981. */
  25982. customRenderTargets: RenderTargetTexture[];
  25983. /**
  25984. * When set, the camera will render to this render target instead of the default canvas
  25985. *
  25986. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25987. */
  25988. outputRenderTarget: Nullable<RenderTargetTexture>;
  25989. /**
  25990. * Observable triggered when the camera view matrix has changed.
  25991. */
  25992. onViewMatrixChangedObservable: Observable<Camera>;
  25993. /**
  25994. * Observable triggered when the camera Projection matrix has changed.
  25995. */
  25996. onProjectionMatrixChangedObservable: Observable<Camera>;
  25997. /**
  25998. * Observable triggered when the inputs have been processed.
  25999. */
  26000. onAfterCheckInputsObservable: Observable<Camera>;
  26001. /**
  26002. * Observable triggered when reset has been called and applied to the camera.
  26003. */
  26004. onRestoreStateObservable: Observable<Camera>;
  26005. /**
  26006. * Is this camera a part of a rig system?
  26007. */
  26008. isRigCamera: boolean;
  26009. /**
  26010. * If isRigCamera set to true this will be set with the parent camera.
  26011. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26012. */
  26013. rigParent?: Camera;
  26014. /** @hidden */
  26015. _cameraRigParams: any;
  26016. /** @hidden */
  26017. _rigCameras: Camera[];
  26018. /** @hidden */
  26019. _rigPostProcess: Nullable<PostProcess>;
  26020. protected _webvrViewMatrix: Matrix;
  26021. /** @hidden */
  26022. _skipRendering: boolean;
  26023. /** @hidden */
  26024. _projectionMatrix: Matrix;
  26025. /** @hidden */
  26026. _postProcesses: Nullable<PostProcess>[];
  26027. /** @hidden */
  26028. _activeMeshes: SmartArray<AbstractMesh>;
  26029. protected _globalPosition: Vector3;
  26030. /** @hidden */
  26031. _computedViewMatrix: Matrix;
  26032. private _doNotComputeProjectionMatrix;
  26033. private _transformMatrix;
  26034. private _frustumPlanes;
  26035. private _refreshFrustumPlanes;
  26036. private _storedFov;
  26037. private _stateStored;
  26038. /**
  26039. * Instantiates a new camera object.
  26040. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26041. * @see http://doc.babylonjs.com/features/cameras
  26042. * @param name Defines the name of the camera in the scene
  26043. * @param position Defines the position of the camera
  26044. * @param scene Defines the scene the camera belongs too
  26045. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26046. */
  26047. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26048. /**
  26049. * Store current camera state (fov, position, etc..)
  26050. * @returns the camera
  26051. */
  26052. storeState(): Camera;
  26053. /**
  26054. * Restores the camera state values if it has been stored. You must call storeState() first
  26055. */
  26056. protected _restoreStateValues(): boolean;
  26057. /**
  26058. * Restored camera state. You must call storeState() first.
  26059. * @returns true if restored and false otherwise
  26060. */
  26061. restoreState(): boolean;
  26062. /**
  26063. * Gets the class name of the camera.
  26064. * @returns the class name
  26065. */
  26066. getClassName(): string;
  26067. /** @hidden */
  26068. readonly _isCamera: boolean;
  26069. /**
  26070. * Gets a string representation of the camera useful for debug purpose.
  26071. * @param fullDetails Defines that a more verboe level of logging is required
  26072. * @returns the string representation
  26073. */
  26074. toString(fullDetails?: boolean): string;
  26075. /**
  26076. * Gets the current world space position of the camera.
  26077. */
  26078. get globalPosition(): Vector3;
  26079. /**
  26080. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26081. * @returns the active meshe list
  26082. */
  26083. getActiveMeshes(): SmartArray<AbstractMesh>;
  26084. /**
  26085. * Check whether a mesh is part of the current active mesh list of the camera
  26086. * @param mesh Defines the mesh to check
  26087. * @returns true if active, false otherwise
  26088. */
  26089. isActiveMesh(mesh: Mesh): boolean;
  26090. /**
  26091. * Is this camera ready to be used/rendered
  26092. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26093. * @return true if the camera is ready
  26094. */
  26095. isReady(completeCheck?: boolean): boolean;
  26096. /** @hidden */
  26097. _initCache(): void;
  26098. /** @hidden */
  26099. _updateCache(ignoreParentClass?: boolean): void;
  26100. /** @hidden */
  26101. _isSynchronized(): boolean;
  26102. /** @hidden */
  26103. _isSynchronizedViewMatrix(): boolean;
  26104. /** @hidden */
  26105. _isSynchronizedProjectionMatrix(): boolean;
  26106. /**
  26107. * Attach the input controls to a specific dom element to get the input from.
  26108. * @param element Defines the element the controls should be listened from
  26109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26110. */
  26111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26112. /**
  26113. * Detach the current controls from the specified dom element.
  26114. * @param element Defines the element to stop listening the inputs from
  26115. */
  26116. detachControl(element: HTMLElement): void;
  26117. /**
  26118. * Update the camera state according to the different inputs gathered during the frame.
  26119. */
  26120. update(): void;
  26121. /** @hidden */
  26122. _checkInputs(): void;
  26123. /** @hidden */
  26124. get rigCameras(): Camera[];
  26125. /**
  26126. * Gets the post process used by the rig cameras
  26127. */
  26128. get rigPostProcess(): Nullable<PostProcess>;
  26129. /**
  26130. * Internal, gets the first post proces.
  26131. * @returns the first post process to be run on this camera.
  26132. */
  26133. _getFirstPostProcess(): Nullable<PostProcess>;
  26134. private _cascadePostProcessesToRigCams;
  26135. /**
  26136. * Attach a post process to the camera.
  26137. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26138. * @param postProcess The post process to attach to the camera
  26139. * @param insertAt The position of the post process in case several of them are in use in the scene
  26140. * @returns the position the post process has been inserted at
  26141. */
  26142. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26143. /**
  26144. * Detach a post process to the camera.
  26145. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26146. * @param postProcess The post process to detach from the camera
  26147. */
  26148. detachPostProcess(postProcess: PostProcess): void;
  26149. /**
  26150. * Gets the current world matrix of the camera
  26151. */
  26152. getWorldMatrix(): Matrix;
  26153. /** @hidden */
  26154. _getViewMatrix(): Matrix;
  26155. /**
  26156. * Gets the current view matrix of the camera.
  26157. * @param force forces the camera to recompute the matrix without looking at the cached state
  26158. * @returns the view matrix
  26159. */
  26160. getViewMatrix(force?: boolean): Matrix;
  26161. /**
  26162. * Freeze the projection matrix.
  26163. * It will prevent the cache check of the camera projection compute and can speed up perf
  26164. * if no parameter of the camera are meant to change
  26165. * @param projection Defines manually a projection if necessary
  26166. */
  26167. freezeProjectionMatrix(projection?: Matrix): void;
  26168. /**
  26169. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26170. */
  26171. unfreezeProjectionMatrix(): void;
  26172. /**
  26173. * Gets the current projection matrix of the camera.
  26174. * @param force forces the camera to recompute the matrix without looking at the cached state
  26175. * @returns the projection matrix
  26176. */
  26177. getProjectionMatrix(force?: boolean): Matrix;
  26178. /**
  26179. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26180. * @returns a Matrix
  26181. */
  26182. getTransformationMatrix(): Matrix;
  26183. private _updateFrustumPlanes;
  26184. /**
  26185. * Checks if a cullable object (mesh...) is in the camera frustum
  26186. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26187. * @param target The object to check
  26188. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26189. * @returns true if the object is in frustum otherwise false
  26190. */
  26191. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26192. /**
  26193. * Checks if a cullable object (mesh...) is in the camera frustum
  26194. * Unlike isInFrustum this cheks the full bounding box
  26195. * @param target The object to check
  26196. * @returns true if the object is in frustum otherwise false
  26197. */
  26198. isCompletelyInFrustum(target: ICullable): boolean;
  26199. /**
  26200. * Gets a ray in the forward direction from the camera.
  26201. * @param length Defines the length of the ray to create
  26202. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26203. * @param origin Defines the start point of the ray which defaults to the camera position
  26204. * @returns the forward ray
  26205. */
  26206. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26207. /**
  26208. * Releases resources associated with this node.
  26209. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26210. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26211. */
  26212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26213. /** @hidden */
  26214. _isLeftCamera: boolean;
  26215. /**
  26216. * Gets the left camera of a rig setup in case of Rigged Camera
  26217. */
  26218. get isLeftCamera(): boolean;
  26219. /** @hidden */
  26220. _isRightCamera: boolean;
  26221. /**
  26222. * Gets the right camera of a rig setup in case of Rigged Camera
  26223. */
  26224. get isRightCamera(): boolean;
  26225. /**
  26226. * Gets the left camera of a rig setup in case of Rigged Camera
  26227. */
  26228. get leftCamera(): Nullable<FreeCamera>;
  26229. /**
  26230. * Gets the right camera of a rig setup in case of Rigged Camera
  26231. */
  26232. get rightCamera(): Nullable<FreeCamera>;
  26233. /**
  26234. * Gets the left camera target of a rig setup in case of Rigged Camera
  26235. * @returns the target position
  26236. */
  26237. getLeftTarget(): Nullable<Vector3>;
  26238. /**
  26239. * Gets the right camera target of a rig setup in case of Rigged Camera
  26240. * @returns the target position
  26241. */
  26242. getRightTarget(): Nullable<Vector3>;
  26243. /**
  26244. * @hidden
  26245. */
  26246. setCameraRigMode(mode: number, rigParams: any): void;
  26247. /** @hidden */
  26248. static _setStereoscopicRigMode(camera: Camera): void;
  26249. /** @hidden */
  26250. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26251. /** @hidden */
  26252. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26253. /** @hidden */
  26254. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26255. /** @hidden */
  26256. _getVRProjectionMatrix(): Matrix;
  26257. protected _updateCameraRotationMatrix(): void;
  26258. protected _updateWebVRCameraRotationMatrix(): void;
  26259. /**
  26260. * This function MUST be overwritten by the different WebVR cameras available.
  26261. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26262. * @hidden
  26263. */
  26264. _getWebVRProjectionMatrix(): Matrix;
  26265. /**
  26266. * This function MUST be overwritten by the different WebVR cameras available.
  26267. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26268. * @hidden
  26269. */
  26270. _getWebVRViewMatrix(): Matrix;
  26271. /** @hidden */
  26272. setCameraRigParameter(name: string, value: any): void;
  26273. /**
  26274. * needs to be overridden by children so sub has required properties to be copied
  26275. * @hidden
  26276. */
  26277. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26278. /**
  26279. * May need to be overridden by children
  26280. * @hidden
  26281. */
  26282. _updateRigCameras(): void;
  26283. /** @hidden */
  26284. _setupInputs(): void;
  26285. /**
  26286. * Serialiaze the camera setup to a json represention
  26287. * @returns the JSON representation
  26288. */
  26289. serialize(): any;
  26290. /**
  26291. * Clones the current camera.
  26292. * @param name The cloned camera name
  26293. * @returns the cloned camera
  26294. */
  26295. clone(name: string): Camera;
  26296. /**
  26297. * Gets the direction of the camera relative to a given local axis.
  26298. * @param localAxis Defines the reference axis to provide a relative direction.
  26299. * @return the direction
  26300. */
  26301. getDirection(localAxis: Vector3): Vector3;
  26302. /**
  26303. * Returns the current camera absolute rotation
  26304. */
  26305. get absoluteRotation(): Quaternion;
  26306. /**
  26307. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26308. * @param localAxis Defines the reference axis to provide a relative direction.
  26309. * @param result Defines the vector to store the result in
  26310. */
  26311. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26312. /**
  26313. * Gets a camera constructor for a given camera type
  26314. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26315. * @param name The name of the camera the result will be able to instantiate
  26316. * @param scene The scene the result will construct the camera in
  26317. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26318. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26319. * @returns a factory method to construc the camera
  26320. */
  26321. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26322. /**
  26323. * Compute the world matrix of the camera.
  26324. * @returns the camera world matrix
  26325. */
  26326. computeWorldMatrix(): Matrix;
  26327. /**
  26328. * Parse a JSON and creates the camera from the parsed information
  26329. * @param parsedCamera The JSON to parse
  26330. * @param scene The scene to instantiate the camera in
  26331. * @returns the newly constructed camera
  26332. */
  26333. static Parse(parsedCamera: any, scene: Scene): Camera;
  26334. }
  26335. }
  26336. declare module BABYLON {
  26337. /**
  26338. * Class containing static functions to help procedurally build meshes
  26339. */
  26340. export class DiscBuilder {
  26341. /**
  26342. * Creates a plane polygonal mesh. By default, this is a disc
  26343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26344. * * 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
  26345. * * 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
  26346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26347. * * 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
  26348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26349. * @param name defines the name of the mesh
  26350. * @param options defines the options used to create the mesh
  26351. * @param scene defines the hosting scene
  26352. * @returns the plane polygonal mesh
  26353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26354. */
  26355. static CreateDisc(name: string, options: {
  26356. radius?: number;
  26357. tessellation?: number;
  26358. arc?: number;
  26359. updatable?: boolean;
  26360. sideOrientation?: number;
  26361. frontUVs?: Vector4;
  26362. backUVs?: Vector4;
  26363. }, scene?: Nullable<Scene>): Mesh;
  26364. }
  26365. }
  26366. declare module BABYLON {
  26367. /**
  26368. * Options to be used when creating a FresnelParameters.
  26369. */
  26370. export type IFresnelParametersCreationOptions = {
  26371. /**
  26372. * Define the color used on edges (grazing angle)
  26373. */
  26374. leftColor?: Color3;
  26375. /**
  26376. * Define the color used on center
  26377. */
  26378. rightColor?: Color3;
  26379. /**
  26380. * Define bias applied to computed fresnel term
  26381. */
  26382. bias?: number;
  26383. /**
  26384. * Defined the power exponent applied to fresnel term
  26385. */
  26386. power?: number;
  26387. /**
  26388. * Define if the fresnel effect is enable or not.
  26389. */
  26390. isEnabled?: boolean;
  26391. };
  26392. /**
  26393. * Serialized format for FresnelParameters.
  26394. */
  26395. export type IFresnelParametersSerialized = {
  26396. /**
  26397. * Define the color used on edges (grazing angle) [as an array]
  26398. */
  26399. leftColor: number[];
  26400. /**
  26401. * Define the color used on center [as an array]
  26402. */
  26403. rightColor: number[];
  26404. /**
  26405. * Define bias applied to computed fresnel term
  26406. */
  26407. bias: number;
  26408. /**
  26409. * Defined the power exponent applied to fresnel term
  26410. */
  26411. power?: number;
  26412. /**
  26413. * Define if the fresnel effect is enable or not.
  26414. */
  26415. isEnabled: boolean;
  26416. };
  26417. /**
  26418. * This represents all the required information to add a fresnel effect on a material:
  26419. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26420. */
  26421. export class FresnelParameters {
  26422. private _isEnabled;
  26423. /**
  26424. * Define if the fresnel effect is enable or not.
  26425. */
  26426. get isEnabled(): boolean;
  26427. set isEnabled(value: boolean);
  26428. /**
  26429. * Define the color used on edges (grazing angle)
  26430. */
  26431. leftColor: Color3;
  26432. /**
  26433. * Define the color used on center
  26434. */
  26435. rightColor: Color3;
  26436. /**
  26437. * Define bias applied to computed fresnel term
  26438. */
  26439. bias: number;
  26440. /**
  26441. * Defined the power exponent applied to fresnel term
  26442. */
  26443. power: number;
  26444. /**
  26445. * Creates a new FresnelParameters object.
  26446. *
  26447. * @param options provide your own settings to optionally to override defaults
  26448. */
  26449. constructor(options?: IFresnelParametersCreationOptions);
  26450. /**
  26451. * Clones the current fresnel and its valuues
  26452. * @returns a clone fresnel configuration
  26453. */
  26454. clone(): FresnelParameters;
  26455. /**
  26456. * Determines equality between FresnelParameters objects
  26457. * @param otherFresnelParameters defines the second operand
  26458. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26459. */
  26460. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26461. /**
  26462. * Serializes the current fresnel parameters to a JSON representation.
  26463. * @return the JSON serialization
  26464. */
  26465. serialize(): IFresnelParametersSerialized;
  26466. /**
  26467. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26468. * @param parsedFresnelParameters Define the JSON representation
  26469. * @returns the parsed parameters
  26470. */
  26471. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26472. }
  26473. }
  26474. declare module BABYLON {
  26475. /**
  26476. * Base class of materials working in push mode in babylon JS
  26477. * @hidden
  26478. */
  26479. export class PushMaterial extends Material {
  26480. protected _activeEffect: Effect;
  26481. protected _normalMatrix: Matrix;
  26482. /**
  26483. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26484. * This means that the material can keep using a previous shader while a new one is being compiled.
  26485. * This is mostly used when shader parallel compilation is supported (true by default)
  26486. */
  26487. allowShaderHotSwapping: boolean;
  26488. constructor(name: string, scene: Scene);
  26489. getEffect(): Effect;
  26490. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26491. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26492. /**
  26493. * Binds the given world matrix to the active effect
  26494. *
  26495. * @param world the matrix to bind
  26496. */
  26497. bindOnlyWorldMatrix(world: Matrix): void;
  26498. /**
  26499. * Binds the given normal matrix to the active effect
  26500. *
  26501. * @param normalMatrix the matrix to bind
  26502. */
  26503. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26504. bind(world: Matrix, mesh?: Mesh): void;
  26505. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26506. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26507. }
  26508. }
  26509. declare module BABYLON {
  26510. /**
  26511. * This groups all the flags used to control the materials channel.
  26512. */
  26513. export class MaterialFlags {
  26514. private static _DiffuseTextureEnabled;
  26515. /**
  26516. * Are diffuse textures enabled in the application.
  26517. */
  26518. static get DiffuseTextureEnabled(): boolean;
  26519. static set DiffuseTextureEnabled(value: boolean);
  26520. private static _AmbientTextureEnabled;
  26521. /**
  26522. * Are ambient textures enabled in the application.
  26523. */
  26524. static get AmbientTextureEnabled(): boolean;
  26525. static set AmbientTextureEnabled(value: boolean);
  26526. private static _OpacityTextureEnabled;
  26527. /**
  26528. * Are opacity textures enabled in the application.
  26529. */
  26530. static get OpacityTextureEnabled(): boolean;
  26531. static set OpacityTextureEnabled(value: boolean);
  26532. private static _ReflectionTextureEnabled;
  26533. /**
  26534. * Are reflection textures enabled in the application.
  26535. */
  26536. static get ReflectionTextureEnabled(): boolean;
  26537. static set ReflectionTextureEnabled(value: boolean);
  26538. private static _EmissiveTextureEnabled;
  26539. /**
  26540. * Are emissive textures enabled in the application.
  26541. */
  26542. static get EmissiveTextureEnabled(): boolean;
  26543. static set EmissiveTextureEnabled(value: boolean);
  26544. private static _SpecularTextureEnabled;
  26545. /**
  26546. * Are specular textures enabled in the application.
  26547. */
  26548. static get SpecularTextureEnabled(): boolean;
  26549. static set SpecularTextureEnabled(value: boolean);
  26550. private static _BumpTextureEnabled;
  26551. /**
  26552. * Are bump textures enabled in the application.
  26553. */
  26554. static get BumpTextureEnabled(): boolean;
  26555. static set BumpTextureEnabled(value: boolean);
  26556. private static _LightmapTextureEnabled;
  26557. /**
  26558. * Are lightmap textures enabled in the application.
  26559. */
  26560. static get LightmapTextureEnabled(): boolean;
  26561. static set LightmapTextureEnabled(value: boolean);
  26562. private static _RefractionTextureEnabled;
  26563. /**
  26564. * Are refraction textures enabled in the application.
  26565. */
  26566. static get RefractionTextureEnabled(): boolean;
  26567. static set RefractionTextureEnabled(value: boolean);
  26568. private static _ColorGradingTextureEnabled;
  26569. /**
  26570. * Are color grading textures enabled in the application.
  26571. */
  26572. static get ColorGradingTextureEnabled(): boolean;
  26573. static set ColorGradingTextureEnabled(value: boolean);
  26574. private static _FresnelEnabled;
  26575. /**
  26576. * Are fresnels enabled in the application.
  26577. */
  26578. static get FresnelEnabled(): boolean;
  26579. static set FresnelEnabled(value: boolean);
  26580. private static _ClearCoatTextureEnabled;
  26581. /**
  26582. * Are clear coat textures enabled in the application.
  26583. */
  26584. static get ClearCoatTextureEnabled(): boolean;
  26585. static set ClearCoatTextureEnabled(value: boolean);
  26586. private static _ClearCoatBumpTextureEnabled;
  26587. /**
  26588. * Are clear coat bump textures enabled in the application.
  26589. */
  26590. static get ClearCoatBumpTextureEnabled(): boolean;
  26591. static set ClearCoatBumpTextureEnabled(value: boolean);
  26592. private static _ClearCoatTintTextureEnabled;
  26593. /**
  26594. * Are clear coat tint textures enabled in the application.
  26595. */
  26596. static get ClearCoatTintTextureEnabled(): boolean;
  26597. static set ClearCoatTintTextureEnabled(value: boolean);
  26598. private static _SheenTextureEnabled;
  26599. /**
  26600. * Are sheen textures enabled in the application.
  26601. */
  26602. static get SheenTextureEnabled(): boolean;
  26603. static set SheenTextureEnabled(value: boolean);
  26604. private static _AnisotropicTextureEnabled;
  26605. /**
  26606. * Are anisotropic textures enabled in the application.
  26607. */
  26608. static get AnisotropicTextureEnabled(): boolean;
  26609. static set AnisotropicTextureEnabled(value: boolean);
  26610. private static _ThicknessTextureEnabled;
  26611. /**
  26612. * Are thickness textures enabled in the application.
  26613. */
  26614. static get ThicknessTextureEnabled(): boolean;
  26615. static set ThicknessTextureEnabled(value: boolean);
  26616. }
  26617. }
  26618. declare module BABYLON {
  26619. /** @hidden */
  26620. export var defaultFragmentDeclaration: {
  26621. name: string;
  26622. shader: string;
  26623. };
  26624. }
  26625. declare module BABYLON {
  26626. /** @hidden */
  26627. export var defaultUboDeclaration: {
  26628. name: string;
  26629. shader: string;
  26630. };
  26631. }
  26632. declare module BABYLON {
  26633. /** @hidden */
  26634. export var lightFragmentDeclaration: {
  26635. name: string;
  26636. shader: string;
  26637. };
  26638. }
  26639. declare module BABYLON {
  26640. /** @hidden */
  26641. export var lightUboDeclaration: {
  26642. name: string;
  26643. shader: string;
  26644. };
  26645. }
  26646. declare module BABYLON {
  26647. /** @hidden */
  26648. export var lightsFragmentFunctions: {
  26649. name: string;
  26650. shader: string;
  26651. };
  26652. }
  26653. declare module BABYLON {
  26654. /** @hidden */
  26655. export var shadowsFragmentFunctions: {
  26656. name: string;
  26657. shader: string;
  26658. };
  26659. }
  26660. declare module BABYLON {
  26661. /** @hidden */
  26662. export var fresnelFunction: {
  26663. name: string;
  26664. shader: string;
  26665. };
  26666. }
  26667. declare module BABYLON {
  26668. /** @hidden */
  26669. export var reflectionFunction: {
  26670. name: string;
  26671. shader: string;
  26672. };
  26673. }
  26674. declare module BABYLON {
  26675. /** @hidden */
  26676. export var bumpFragmentMainFunctions: {
  26677. name: string;
  26678. shader: string;
  26679. };
  26680. }
  26681. declare module BABYLON {
  26682. /** @hidden */
  26683. export var bumpFragmentFunctions: {
  26684. name: string;
  26685. shader: string;
  26686. };
  26687. }
  26688. declare module BABYLON {
  26689. /** @hidden */
  26690. export var logDepthDeclaration: {
  26691. name: string;
  26692. shader: string;
  26693. };
  26694. }
  26695. declare module BABYLON {
  26696. /** @hidden */
  26697. export var bumpFragment: {
  26698. name: string;
  26699. shader: string;
  26700. };
  26701. }
  26702. declare module BABYLON {
  26703. /** @hidden */
  26704. export var depthPrePass: {
  26705. name: string;
  26706. shader: string;
  26707. };
  26708. }
  26709. declare module BABYLON {
  26710. /** @hidden */
  26711. export var lightFragment: {
  26712. name: string;
  26713. shader: string;
  26714. };
  26715. }
  26716. declare module BABYLON {
  26717. /** @hidden */
  26718. export var logDepthFragment: {
  26719. name: string;
  26720. shader: string;
  26721. };
  26722. }
  26723. declare module BABYLON {
  26724. /** @hidden */
  26725. export var defaultPixelShader: {
  26726. name: string;
  26727. shader: string;
  26728. };
  26729. }
  26730. declare module BABYLON {
  26731. /** @hidden */
  26732. export var defaultVertexDeclaration: {
  26733. name: string;
  26734. shader: string;
  26735. };
  26736. }
  26737. declare module BABYLON {
  26738. /** @hidden */
  26739. export var bumpVertexDeclaration: {
  26740. name: string;
  26741. shader: string;
  26742. };
  26743. }
  26744. declare module BABYLON {
  26745. /** @hidden */
  26746. export var bumpVertex: {
  26747. name: string;
  26748. shader: string;
  26749. };
  26750. }
  26751. declare module BABYLON {
  26752. /** @hidden */
  26753. export var fogVertex: {
  26754. name: string;
  26755. shader: string;
  26756. };
  26757. }
  26758. declare module BABYLON {
  26759. /** @hidden */
  26760. export var shadowsVertex: {
  26761. name: string;
  26762. shader: string;
  26763. };
  26764. }
  26765. declare module BABYLON {
  26766. /** @hidden */
  26767. export var pointCloudVertex: {
  26768. name: string;
  26769. shader: string;
  26770. };
  26771. }
  26772. declare module BABYLON {
  26773. /** @hidden */
  26774. export var logDepthVertex: {
  26775. name: string;
  26776. shader: string;
  26777. };
  26778. }
  26779. declare module BABYLON {
  26780. /** @hidden */
  26781. export var defaultVertexShader: {
  26782. name: string;
  26783. shader: string;
  26784. };
  26785. }
  26786. declare module BABYLON {
  26787. /** @hidden */
  26788. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26789. MAINUV1: boolean;
  26790. MAINUV2: boolean;
  26791. DIFFUSE: boolean;
  26792. DIFFUSEDIRECTUV: number;
  26793. AMBIENT: boolean;
  26794. AMBIENTDIRECTUV: number;
  26795. OPACITY: boolean;
  26796. OPACITYDIRECTUV: number;
  26797. OPACITYRGB: boolean;
  26798. REFLECTION: boolean;
  26799. EMISSIVE: boolean;
  26800. EMISSIVEDIRECTUV: number;
  26801. SPECULAR: boolean;
  26802. SPECULARDIRECTUV: number;
  26803. BUMP: boolean;
  26804. BUMPDIRECTUV: number;
  26805. PARALLAX: boolean;
  26806. PARALLAXOCCLUSION: boolean;
  26807. SPECULAROVERALPHA: boolean;
  26808. CLIPPLANE: boolean;
  26809. CLIPPLANE2: boolean;
  26810. CLIPPLANE3: boolean;
  26811. CLIPPLANE4: boolean;
  26812. CLIPPLANE5: boolean;
  26813. CLIPPLANE6: boolean;
  26814. ALPHATEST: boolean;
  26815. DEPTHPREPASS: boolean;
  26816. ALPHAFROMDIFFUSE: boolean;
  26817. POINTSIZE: boolean;
  26818. FOG: boolean;
  26819. SPECULARTERM: boolean;
  26820. DIFFUSEFRESNEL: boolean;
  26821. OPACITYFRESNEL: boolean;
  26822. REFLECTIONFRESNEL: boolean;
  26823. REFRACTIONFRESNEL: boolean;
  26824. EMISSIVEFRESNEL: boolean;
  26825. FRESNEL: boolean;
  26826. NORMAL: boolean;
  26827. UV1: boolean;
  26828. UV2: boolean;
  26829. VERTEXCOLOR: boolean;
  26830. VERTEXALPHA: boolean;
  26831. NUM_BONE_INFLUENCERS: number;
  26832. BonesPerMesh: number;
  26833. BONETEXTURE: boolean;
  26834. INSTANCES: boolean;
  26835. GLOSSINESS: boolean;
  26836. ROUGHNESS: boolean;
  26837. EMISSIVEASILLUMINATION: boolean;
  26838. LINKEMISSIVEWITHDIFFUSE: boolean;
  26839. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26840. LIGHTMAP: boolean;
  26841. LIGHTMAPDIRECTUV: number;
  26842. OBJECTSPACE_NORMALMAP: boolean;
  26843. USELIGHTMAPASSHADOWMAP: boolean;
  26844. REFLECTIONMAP_3D: boolean;
  26845. REFLECTIONMAP_SPHERICAL: boolean;
  26846. REFLECTIONMAP_PLANAR: boolean;
  26847. REFLECTIONMAP_CUBIC: boolean;
  26848. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26849. REFLECTIONMAP_PROJECTION: boolean;
  26850. REFLECTIONMAP_SKYBOX: boolean;
  26851. REFLECTIONMAP_EXPLICIT: boolean;
  26852. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26853. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26854. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26855. INVERTCUBICMAP: boolean;
  26856. LOGARITHMICDEPTH: boolean;
  26857. REFRACTION: boolean;
  26858. REFRACTIONMAP_3D: boolean;
  26859. REFLECTIONOVERALPHA: boolean;
  26860. TWOSIDEDLIGHTING: boolean;
  26861. SHADOWFLOAT: boolean;
  26862. MORPHTARGETS: boolean;
  26863. MORPHTARGETS_NORMAL: boolean;
  26864. MORPHTARGETS_TANGENT: boolean;
  26865. MORPHTARGETS_UV: boolean;
  26866. NUM_MORPH_INFLUENCERS: number;
  26867. NONUNIFORMSCALING: boolean;
  26868. PREMULTIPLYALPHA: boolean;
  26869. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26870. ALPHABLEND: boolean;
  26871. IMAGEPROCESSING: boolean;
  26872. VIGNETTE: boolean;
  26873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26874. VIGNETTEBLENDMODEOPAQUE: boolean;
  26875. TONEMAPPING: boolean;
  26876. TONEMAPPING_ACES: boolean;
  26877. CONTRAST: boolean;
  26878. COLORCURVES: boolean;
  26879. COLORGRADING: boolean;
  26880. COLORGRADING3D: boolean;
  26881. SAMPLER3DGREENDEPTH: boolean;
  26882. SAMPLER3DBGRMAP: boolean;
  26883. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26884. MULTIVIEW: boolean;
  26885. /**
  26886. * If the reflection texture on this material is in linear color space
  26887. * @hidden
  26888. */
  26889. IS_REFLECTION_LINEAR: boolean;
  26890. /**
  26891. * If the refraction texture on this material is in linear color space
  26892. * @hidden
  26893. */
  26894. IS_REFRACTION_LINEAR: boolean;
  26895. EXPOSURE: boolean;
  26896. constructor();
  26897. setReflectionMode(modeToEnable: string): void;
  26898. }
  26899. /**
  26900. * This is the default material used in Babylon. It is the best trade off between quality
  26901. * and performances.
  26902. * @see http://doc.babylonjs.com/babylon101/materials
  26903. */
  26904. export class StandardMaterial extends PushMaterial {
  26905. private _diffuseTexture;
  26906. /**
  26907. * The basic texture of the material as viewed under a light.
  26908. */
  26909. diffuseTexture: Nullable<BaseTexture>;
  26910. private _ambientTexture;
  26911. /**
  26912. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26913. */
  26914. ambientTexture: Nullable<BaseTexture>;
  26915. private _opacityTexture;
  26916. /**
  26917. * Define the transparency of the material from a texture.
  26918. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26919. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26920. */
  26921. opacityTexture: Nullable<BaseTexture>;
  26922. private _reflectionTexture;
  26923. /**
  26924. * Define the texture used to display the reflection.
  26925. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26926. */
  26927. reflectionTexture: Nullable<BaseTexture>;
  26928. private _emissiveTexture;
  26929. /**
  26930. * Define texture of the material as if self lit.
  26931. * This will be mixed in the final result even in the absence of light.
  26932. */
  26933. emissiveTexture: Nullable<BaseTexture>;
  26934. private _specularTexture;
  26935. /**
  26936. * Define how the color and intensity of the highlight given by the light in the material.
  26937. */
  26938. specularTexture: Nullable<BaseTexture>;
  26939. private _bumpTexture;
  26940. /**
  26941. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26942. * 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.
  26943. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26944. */
  26945. bumpTexture: Nullable<BaseTexture>;
  26946. private _lightmapTexture;
  26947. /**
  26948. * Complex lighting can be computationally expensive to compute at runtime.
  26949. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26950. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26951. */
  26952. lightmapTexture: Nullable<BaseTexture>;
  26953. private _refractionTexture;
  26954. /**
  26955. * Define the texture used to display the refraction.
  26956. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26957. */
  26958. refractionTexture: Nullable<BaseTexture>;
  26959. /**
  26960. * The color of the material lit by the environmental background lighting.
  26961. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26962. */
  26963. ambientColor: Color3;
  26964. /**
  26965. * The basic color of the material as viewed under a light.
  26966. */
  26967. diffuseColor: Color3;
  26968. /**
  26969. * Define how the color and intensity of the highlight given by the light in the material.
  26970. */
  26971. specularColor: Color3;
  26972. /**
  26973. * Define the color of the material as if self lit.
  26974. * This will be mixed in the final result even in the absence of light.
  26975. */
  26976. emissiveColor: Color3;
  26977. /**
  26978. * Defines how sharp are the highlights in the material.
  26979. * The bigger the value the sharper giving a more glossy feeling to the result.
  26980. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26981. */
  26982. specularPower: number;
  26983. private _useAlphaFromDiffuseTexture;
  26984. /**
  26985. * Does the transparency come from the diffuse texture alpha channel.
  26986. */
  26987. useAlphaFromDiffuseTexture: boolean;
  26988. private _useEmissiveAsIllumination;
  26989. /**
  26990. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26991. */
  26992. useEmissiveAsIllumination: boolean;
  26993. private _linkEmissiveWithDiffuse;
  26994. /**
  26995. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26996. * the emissive level when the final color is close to one.
  26997. */
  26998. linkEmissiveWithDiffuse: boolean;
  26999. private _useSpecularOverAlpha;
  27000. /**
  27001. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27002. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27003. */
  27004. useSpecularOverAlpha: boolean;
  27005. private _useReflectionOverAlpha;
  27006. /**
  27007. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27008. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27009. */
  27010. useReflectionOverAlpha: boolean;
  27011. private _disableLighting;
  27012. /**
  27013. * Does lights from the scene impacts this material.
  27014. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27015. */
  27016. disableLighting: boolean;
  27017. private _useObjectSpaceNormalMap;
  27018. /**
  27019. * Allows using an object space normal map (instead of tangent space).
  27020. */
  27021. useObjectSpaceNormalMap: boolean;
  27022. private _useParallax;
  27023. /**
  27024. * Is parallax enabled or not.
  27025. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27026. */
  27027. useParallax: boolean;
  27028. private _useParallaxOcclusion;
  27029. /**
  27030. * Is parallax occlusion enabled or not.
  27031. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27032. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27033. */
  27034. useParallaxOcclusion: boolean;
  27035. /**
  27036. * 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.
  27037. */
  27038. parallaxScaleBias: number;
  27039. private _roughness;
  27040. /**
  27041. * Helps to define how blurry the reflections should appears in the material.
  27042. */
  27043. roughness: number;
  27044. /**
  27045. * In case of refraction, define the value of the index of refraction.
  27046. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27047. */
  27048. indexOfRefraction: number;
  27049. /**
  27050. * Invert the refraction texture alongside the y axis.
  27051. * It can be useful with procedural textures or probe for instance.
  27052. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27053. */
  27054. invertRefractionY: boolean;
  27055. /**
  27056. * Defines the alpha limits in alpha test mode.
  27057. */
  27058. alphaCutOff: number;
  27059. private _useLightmapAsShadowmap;
  27060. /**
  27061. * In case of light mapping, define whether the map contains light or shadow informations.
  27062. */
  27063. useLightmapAsShadowmap: boolean;
  27064. private _diffuseFresnelParameters;
  27065. /**
  27066. * Define the diffuse fresnel parameters of the material.
  27067. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27068. */
  27069. diffuseFresnelParameters: FresnelParameters;
  27070. private _opacityFresnelParameters;
  27071. /**
  27072. * Define the opacity fresnel parameters of the material.
  27073. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27074. */
  27075. opacityFresnelParameters: FresnelParameters;
  27076. private _reflectionFresnelParameters;
  27077. /**
  27078. * Define the reflection fresnel parameters of the material.
  27079. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27080. */
  27081. reflectionFresnelParameters: FresnelParameters;
  27082. private _refractionFresnelParameters;
  27083. /**
  27084. * Define the refraction fresnel parameters of the material.
  27085. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27086. */
  27087. refractionFresnelParameters: FresnelParameters;
  27088. private _emissiveFresnelParameters;
  27089. /**
  27090. * Define the emissive fresnel parameters of the material.
  27091. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27092. */
  27093. emissiveFresnelParameters: FresnelParameters;
  27094. private _useReflectionFresnelFromSpecular;
  27095. /**
  27096. * If true automatically deducts the fresnels values from the material specularity.
  27097. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27098. */
  27099. useReflectionFresnelFromSpecular: boolean;
  27100. private _useGlossinessFromSpecularMapAlpha;
  27101. /**
  27102. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27103. */
  27104. useGlossinessFromSpecularMapAlpha: boolean;
  27105. private _maxSimultaneousLights;
  27106. /**
  27107. * Defines the maximum number of lights that can be used in the material
  27108. */
  27109. maxSimultaneousLights: number;
  27110. private _invertNormalMapX;
  27111. /**
  27112. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27113. */
  27114. invertNormalMapX: boolean;
  27115. private _invertNormalMapY;
  27116. /**
  27117. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27118. */
  27119. invertNormalMapY: boolean;
  27120. private _twoSidedLighting;
  27121. /**
  27122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27123. */
  27124. twoSidedLighting: boolean;
  27125. /**
  27126. * Default configuration related to image processing available in the standard Material.
  27127. */
  27128. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27129. /**
  27130. * Gets the image processing configuration used either in this material.
  27131. */
  27132. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27133. /**
  27134. * Sets the Default image processing configuration used either in the this material.
  27135. *
  27136. * If sets to null, the scene one is in use.
  27137. */
  27138. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27139. /**
  27140. * Keep track of the image processing observer to allow dispose and replace.
  27141. */
  27142. private _imageProcessingObserver;
  27143. /**
  27144. * Attaches a new image processing configuration to the Standard Material.
  27145. * @param configuration
  27146. */
  27147. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27148. /**
  27149. * Gets wether the color curves effect is enabled.
  27150. */
  27151. get cameraColorCurvesEnabled(): boolean;
  27152. /**
  27153. * Sets wether the color curves effect is enabled.
  27154. */
  27155. set cameraColorCurvesEnabled(value: boolean);
  27156. /**
  27157. * Gets wether the color grading effect is enabled.
  27158. */
  27159. get cameraColorGradingEnabled(): boolean;
  27160. /**
  27161. * Gets wether the color grading effect is enabled.
  27162. */
  27163. set cameraColorGradingEnabled(value: boolean);
  27164. /**
  27165. * Gets wether tonemapping is enabled or not.
  27166. */
  27167. get cameraToneMappingEnabled(): boolean;
  27168. /**
  27169. * Sets wether tonemapping is enabled or not
  27170. */
  27171. set cameraToneMappingEnabled(value: boolean);
  27172. /**
  27173. * The camera exposure used on this material.
  27174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27175. * This corresponds to a photographic exposure.
  27176. */
  27177. get cameraExposure(): number;
  27178. /**
  27179. * The camera exposure used on this material.
  27180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27181. * This corresponds to a photographic exposure.
  27182. */
  27183. set cameraExposure(value: number);
  27184. /**
  27185. * Gets The camera contrast used on this material.
  27186. */
  27187. get cameraContrast(): number;
  27188. /**
  27189. * Sets The camera contrast used on this material.
  27190. */
  27191. set cameraContrast(value: number);
  27192. /**
  27193. * Gets the Color Grading 2D Lookup Texture.
  27194. */
  27195. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27196. /**
  27197. * Sets the Color Grading 2D Lookup Texture.
  27198. */
  27199. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27200. /**
  27201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27203. * 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;
  27204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27205. */
  27206. get cameraColorCurves(): Nullable<ColorCurves>;
  27207. /**
  27208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27210. * 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;
  27211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27212. */
  27213. set cameraColorCurves(value: Nullable<ColorCurves>);
  27214. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27215. protected _worldViewProjectionMatrix: Matrix;
  27216. protected _globalAmbientColor: Color3;
  27217. protected _useLogarithmicDepth: boolean;
  27218. protected _rebuildInParallel: boolean;
  27219. /**
  27220. * Instantiates a new standard material.
  27221. * This is the default material used in Babylon. It is the best trade off between quality
  27222. * and performances.
  27223. * @see http://doc.babylonjs.com/babylon101/materials
  27224. * @param name Define the name of the material in the scene
  27225. * @param scene Define the scene the material belong to
  27226. */
  27227. constructor(name: string, scene: Scene);
  27228. /**
  27229. * Gets a boolean indicating that current material needs to register RTT
  27230. */
  27231. get hasRenderTargetTextures(): boolean;
  27232. /**
  27233. * Gets the current class name of the material e.g. "StandardMaterial"
  27234. * Mainly use in serialization.
  27235. * @returns the class name
  27236. */
  27237. getClassName(): string;
  27238. /**
  27239. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27240. * You can try switching to logarithmic depth.
  27241. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27242. */
  27243. get useLogarithmicDepth(): boolean;
  27244. set useLogarithmicDepth(value: boolean);
  27245. /**
  27246. * Specifies if the material will require alpha blending
  27247. * @returns a boolean specifying if alpha blending is needed
  27248. */
  27249. needAlphaBlending(): boolean;
  27250. /**
  27251. * Specifies if this material should be rendered in alpha test mode
  27252. * @returns a boolean specifying if an alpha test is needed.
  27253. */
  27254. needAlphaTesting(): boolean;
  27255. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27256. /**
  27257. * Get the texture used for alpha test purpose.
  27258. * @returns the diffuse texture in case of the standard material.
  27259. */
  27260. getAlphaTestTexture(): Nullable<BaseTexture>;
  27261. /**
  27262. * Get if the submesh is ready to be used and all its information available.
  27263. * Child classes can use it to update shaders
  27264. * @param mesh defines the mesh to check
  27265. * @param subMesh defines which submesh to check
  27266. * @param useInstances specifies that instances should be used
  27267. * @returns a boolean indicating that the submesh is ready or not
  27268. */
  27269. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27270. /**
  27271. * Builds the material UBO layouts.
  27272. * Used internally during the effect preparation.
  27273. */
  27274. buildUniformLayout(): void;
  27275. /**
  27276. * Unbinds the material from the mesh
  27277. */
  27278. unbind(): void;
  27279. /**
  27280. * Binds the submesh to this material by preparing the effect and shader to draw
  27281. * @param world defines the world transformation matrix
  27282. * @param mesh defines the mesh containing the submesh
  27283. * @param subMesh defines the submesh to bind the material to
  27284. */
  27285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27286. /**
  27287. * Get the list of animatables in the material.
  27288. * @returns the list of animatables object used in the material
  27289. */
  27290. getAnimatables(): IAnimatable[];
  27291. /**
  27292. * Gets the active textures from the material
  27293. * @returns an array of textures
  27294. */
  27295. getActiveTextures(): BaseTexture[];
  27296. /**
  27297. * Specifies if the material uses a texture
  27298. * @param texture defines the texture to check against the material
  27299. * @returns a boolean specifying if the material uses the texture
  27300. */
  27301. hasTexture(texture: BaseTexture): boolean;
  27302. /**
  27303. * Disposes the material
  27304. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27305. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27306. */
  27307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27308. /**
  27309. * Makes a duplicate of the material, and gives it a new name
  27310. * @param name defines the new name for the duplicated material
  27311. * @returns the cloned material
  27312. */
  27313. clone(name: string): StandardMaterial;
  27314. /**
  27315. * Serializes this material in a JSON representation
  27316. * @returns the serialized material object
  27317. */
  27318. serialize(): any;
  27319. /**
  27320. * Creates a standard material from parsed material data
  27321. * @param source defines the JSON representation of the material
  27322. * @param scene defines the hosting scene
  27323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27324. * @returns a new standard material
  27325. */
  27326. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27327. /**
  27328. * Are diffuse textures enabled in the application.
  27329. */
  27330. static get DiffuseTextureEnabled(): boolean;
  27331. static set DiffuseTextureEnabled(value: boolean);
  27332. /**
  27333. * Are ambient textures enabled in the application.
  27334. */
  27335. static get AmbientTextureEnabled(): boolean;
  27336. static set AmbientTextureEnabled(value: boolean);
  27337. /**
  27338. * Are opacity textures enabled in the application.
  27339. */
  27340. static get OpacityTextureEnabled(): boolean;
  27341. static set OpacityTextureEnabled(value: boolean);
  27342. /**
  27343. * Are reflection textures enabled in the application.
  27344. */
  27345. static get ReflectionTextureEnabled(): boolean;
  27346. static set ReflectionTextureEnabled(value: boolean);
  27347. /**
  27348. * Are emissive textures enabled in the application.
  27349. */
  27350. static get EmissiveTextureEnabled(): boolean;
  27351. static set EmissiveTextureEnabled(value: boolean);
  27352. /**
  27353. * Are specular textures enabled in the application.
  27354. */
  27355. static get SpecularTextureEnabled(): boolean;
  27356. static set SpecularTextureEnabled(value: boolean);
  27357. /**
  27358. * Are bump textures enabled in the application.
  27359. */
  27360. static get BumpTextureEnabled(): boolean;
  27361. static set BumpTextureEnabled(value: boolean);
  27362. /**
  27363. * Are lightmap textures enabled in the application.
  27364. */
  27365. static get LightmapTextureEnabled(): boolean;
  27366. static set LightmapTextureEnabled(value: boolean);
  27367. /**
  27368. * Are refraction textures enabled in the application.
  27369. */
  27370. static get RefractionTextureEnabled(): boolean;
  27371. static set RefractionTextureEnabled(value: boolean);
  27372. /**
  27373. * Are color grading textures enabled in the application.
  27374. */
  27375. static get ColorGradingTextureEnabled(): boolean;
  27376. static set ColorGradingTextureEnabled(value: boolean);
  27377. /**
  27378. * Are fresnels enabled in the application.
  27379. */
  27380. static get FresnelEnabled(): boolean;
  27381. static set FresnelEnabled(value: boolean);
  27382. }
  27383. }
  27384. declare module BABYLON {
  27385. /**
  27386. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27387. *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.
  27388. * The SPS is also a particle system. It provides some methods to manage the particles.
  27389. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27390. *
  27391. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27392. */
  27393. export class SolidParticleSystem implements IDisposable {
  27394. /**
  27395. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27396. * Example : var p = SPS.particles[i];
  27397. */
  27398. particles: SolidParticle[];
  27399. /**
  27400. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27401. */
  27402. nbParticles: number;
  27403. /**
  27404. * If the particles must ever face the camera (default false). Useful for planar particles.
  27405. */
  27406. billboard: boolean;
  27407. /**
  27408. * Recompute normals when adding a shape
  27409. */
  27410. recomputeNormals: boolean;
  27411. /**
  27412. * This a counter ofr your own usage. It's not set by any SPS functions.
  27413. */
  27414. counter: number;
  27415. /**
  27416. * The SPS name. This name is also given to the underlying mesh.
  27417. */
  27418. name: string;
  27419. /**
  27420. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27421. */
  27422. mesh: Mesh;
  27423. /**
  27424. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27425. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27426. */
  27427. vars: any;
  27428. /**
  27429. * This array is populated when the SPS is set as 'pickable'.
  27430. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27431. * Each element of this array is an object `{idx: int, faceId: int}`.
  27432. * `idx` is the picked particle index in the `SPS.particles` array
  27433. * `faceId` is the picked face index counted within this particle.
  27434. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27435. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27436. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27437. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27438. */
  27439. pickedParticles: {
  27440. idx: number;
  27441. faceId: number;
  27442. }[];
  27443. /**
  27444. * This array is populated when the SPS is set as 'pickable'
  27445. * Each key of this array is a submesh index.
  27446. * Each element of this array is a second array defined like this :
  27447. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27448. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27449. * `idx` is the picked particle index in the `SPS.particles` array
  27450. * `faceId` is the picked face index counted within this particle.
  27451. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27452. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27453. */
  27454. pickedBySubMesh: {
  27455. idx: number;
  27456. faceId: number;
  27457. }[][];
  27458. /**
  27459. * This array is populated when `enableDepthSort` is set to true.
  27460. * Each element of this array is an instance of the class DepthSortedParticle.
  27461. */
  27462. depthSortedParticles: DepthSortedParticle[];
  27463. /**
  27464. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27465. * @hidden
  27466. */
  27467. _bSphereOnly: boolean;
  27468. /**
  27469. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27470. * @hidden
  27471. */
  27472. _bSphereRadiusFactor: number;
  27473. private _scene;
  27474. private _positions;
  27475. private _indices;
  27476. private _normals;
  27477. private _colors;
  27478. private _uvs;
  27479. private _indices32;
  27480. private _positions32;
  27481. private _normals32;
  27482. private _fixedNormal32;
  27483. private _colors32;
  27484. private _uvs32;
  27485. private _index;
  27486. private _updatable;
  27487. private _pickable;
  27488. private _isVisibilityBoxLocked;
  27489. private _alwaysVisible;
  27490. private _depthSort;
  27491. private _expandable;
  27492. private _shapeCounter;
  27493. private _copy;
  27494. private _color;
  27495. private _computeParticleColor;
  27496. private _computeParticleTexture;
  27497. private _computeParticleRotation;
  27498. private _computeParticleVertex;
  27499. private _computeBoundingBox;
  27500. private _depthSortParticles;
  27501. private _camera;
  27502. private _mustUnrotateFixedNormals;
  27503. private _particlesIntersect;
  27504. private _needs32Bits;
  27505. private _isNotBuilt;
  27506. private _lastParticleId;
  27507. private _idxOfId;
  27508. private _multimaterialEnabled;
  27509. private _useModelMaterial;
  27510. private _indicesByMaterial;
  27511. private _materialIndexes;
  27512. private _depthSortFunction;
  27513. private _materialSortFunction;
  27514. private _materials;
  27515. private _multimaterial;
  27516. private _materialIndexesById;
  27517. private _defaultMaterial;
  27518. private _autoUpdateSubMeshes;
  27519. private _tmpVertex;
  27520. /**
  27521. * Creates a SPS (Solid Particle System) object.
  27522. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27523. * @param scene (Scene) is the scene in which the SPS is added.
  27524. * @param options defines the options of the sps e.g.
  27525. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27526. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27527. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27528. * * 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.
  27529. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27530. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27531. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27532. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27533. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27534. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27535. */
  27536. constructor(name: string, scene: Scene, options?: {
  27537. updatable?: boolean;
  27538. isPickable?: boolean;
  27539. enableDepthSort?: boolean;
  27540. particleIntersection?: boolean;
  27541. boundingSphereOnly?: boolean;
  27542. bSphereRadiusFactor?: number;
  27543. expandable?: boolean;
  27544. useModelMaterial?: boolean;
  27545. enableMultiMaterial?: boolean;
  27546. });
  27547. /**
  27548. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27549. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27550. * @returns the created mesh
  27551. */
  27552. buildMesh(): Mesh;
  27553. /**
  27554. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27555. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27556. * Thus the particles generated from `digest()` have their property `position` set yet.
  27557. * @param mesh ( Mesh ) is the mesh to be digested
  27558. * @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
  27559. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27560. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27561. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27562. * @returns the current SPS
  27563. */
  27564. digest(mesh: Mesh, options?: {
  27565. facetNb?: number;
  27566. number?: number;
  27567. delta?: number;
  27568. storage?: [];
  27569. }): SolidParticleSystem;
  27570. /**
  27571. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27572. * @hidden
  27573. */
  27574. private _unrotateFixedNormals;
  27575. /**
  27576. * Resets the temporary working copy particle
  27577. * @hidden
  27578. */
  27579. private _resetCopy;
  27580. /**
  27581. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27582. * @param p the current index in the positions array to be updated
  27583. * @param ind the current index in the indices array
  27584. * @param shape a Vector3 array, the shape geometry
  27585. * @param positions the positions array to be updated
  27586. * @param meshInd the shape indices array
  27587. * @param indices the indices array to be updated
  27588. * @param meshUV the shape uv array
  27589. * @param uvs the uv array to be updated
  27590. * @param meshCol the shape color array
  27591. * @param colors the color array to be updated
  27592. * @param meshNor the shape normals array
  27593. * @param normals the normals array to be updated
  27594. * @param idx the particle index
  27595. * @param idxInShape the particle index in its shape
  27596. * @param options the addShape() method passed options
  27597. * @model the particle model
  27598. * @hidden
  27599. */
  27600. private _meshBuilder;
  27601. /**
  27602. * Returns a shape Vector3 array from positions float array
  27603. * @param positions float array
  27604. * @returns a vector3 array
  27605. * @hidden
  27606. */
  27607. private _posToShape;
  27608. /**
  27609. * Returns a shapeUV array from a float uvs (array deep copy)
  27610. * @param uvs as a float array
  27611. * @returns a shapeUV array
  27612. * @hidden
  27613. */
  27614. private _uvsToShapeUV;
  27615. /**
  27616. * Adds a new particle object in the particles array
  27617. * @param idx particle index in particles array
  27618. * @param id particle id
  27619. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27620. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27621. * @param model particle ModelShape object
  27622. * @param shapeId model shape identifier
  27623. * @param idxInShape index of the particle in the current model
  27624. * @param bInfo model bounding info object
  27625. * @param storage target storage array, if any
  27626. * @hidden
  27627. */
  27628. private _addParticle;
  27629. /**
  27630. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27631. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27632. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27633. * @param nb (positive integer) the number of particles to be created from this model
  27634. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27635. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27636. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27637. * @returns the number of shapes in the system
  27638. */
  27639. addShape(mesh: Mesh, nb: number, options?: {
  27640. positionFunction?: any;
  27641. vertexFunction?: any;
  27642. storage?: [];
  27643. }): number;
  27644. /**
  27645. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27646. * @hidden
  27647. */
  27648. private _rebuildParticle;
  27649. /**
  27650. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27651. * @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.
  27652. * @returns the SPS.
  27653. */
  27654. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27655. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27656. * Returns an array with the removed particles.
  27657. * 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.
  27658. * The SPS can't be empty so at least one particle needs to remain in place.
  27659. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27660. * @param start index of the first particle to remove
  27661. * @param end index of the last particle to remove (included)
  27662. * @returns an array populated with the removed particles
  27663. */
  27664. removeParticles(start: number, end: number): SolidParticle[];
  27665. /**
  27666. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27667. * @param solidParticleArray an array populated with Solid Particles objects
  27668. * @returns the SPS
  27669. */
  27670. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27671. /**
  27672. * Creates a new particle and modifies the SPS mesh geometry :
  27673. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27674. * - calls _addParticle() to populate the particle array
  27675. * factorized code from addShape() and insertParticlesFromArray()
  27676. * @param idx particle index in the particles array
  27677. * @param i particle index in its shape
  27678. * @param modelShape particle ModelShape object
  27679. * @param shape shape vertex array
  27680. * @param meshInd shape indices array
  27681. * @param meshUV shape uv array
  27682. * @param meshCol shape color array
  27683. * @param meshNor shape normals array
  27684. * @param bbInfo shape bounding info
  27685. * @param storage target particle storage
  27686. * @options addShape() passed options
  27687. * @hidden
  27688. */
  27689. private _insertNewParticle;
  27690. /**
  27691. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27692. * This method calls `updateParticle()` for each particle of the SPS.
  27693. * For an animated SPS, it is usually called within the render loop.
  27694. * 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.
  27695. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27696. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27697. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27698. * @returns the SPS.
  27699. */
  27700. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27701. /**
  27702. * Disposes the SPS.
  27703. */
  27704. dispose(): void;
  27705. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27706. * idx is the particle index in the SPS
  27707. * faceId is the picked face index counted within this particle.
  27708. * Returns null if the pickInfo can't identify a picked particle.
  27709. * @param pickingInfo (PickingInfo object)
  27710. * @returns {idx: number, faceId: number} or null
  27711. */
  27712. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27713. idx: number;
  27714. faceId: number;
  27715. }>;
  27716. /**
  27717. * Returns a SolidParticle object from its identifier : particle.id
  27718. * @param id (integer) the particle Id
  27719. * @returns the searched particle or null if not found in the SPS.
  27720. */
  27721. getParticleById(id: number): Nullable<SolidParticle>;
  27722. /**
  27723. * Returns a new array populated with the particles having the passed shapeId.
  27724. * @param shapeId (integer) the shape identifier
  27725. * @returns a new solid particle array
  27726. */
  27727. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27728. /**
  27729. * Populates the passed array "ref" with the particles having the passed shapeId.
  27730. * @param shapeId the shape identifier
  27731. * @returns the SPS
  27732. * @param ref
  27733. */
  27734. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27735. /**
  27736. * Computes the required SubMeshes according the materials assigned to the particles.
  27737. * @returns the solid particle system.
  27738. * Does nothing if called before the SPS mesh is built.
  27739. */
  27740. computeSubMeshes(): SolidParticleSystem;
  27741. /**
  27742. * Sorts the solid particles by material when MultiMaterial is enabled.
  27743. * Updates the indices32 array.
  27744. * Updates the indicesByMaterial array.
  27745. * Updates the mesh indices array.
  27746. * @returns the SPS
  27747. * @hidden
  27748. */
  27749. private _sortParticlesByMaterial;
  27750. /**
  27751. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27752. * @hidden
  27753. */
  27754. private _setMaterialIndexesById;
  27755. /**
  27756. * Returns an array with unique values of Materials from the passed array
  27757. * @param array the material array to be checked and filtered
  27758. * @hidden
  27759. */
  27760. private _filterUniqueMaterialId;
  27761. /**
  27762. * Sets a new Standard Material as _defaultMaterial if not already set.
  27763. * @hidden
  27764. */
  27765. private _setDefaultMaterial;
  27766. /**
  27767. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27769. * @returns the SPS.
  27770. */
  27771. refreshVisibleSize(): SolidParticleSystem;
  27772. /**
  27773. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27774. * @param size the size (float) of the visibility box
  27775. * note : this doesn't lock the SPS mesh bounding box.
  27776. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27777. */
  27778. setVisibilityBox(size: number): void;
  27779. /**
  27780. * Gets whether the SPS as always visible or not
  27781. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27782. */
  27783. get isAlwaysVisible(): boolean;
  27784. /**
  27785. * Sets the SPS as always visible or not
  27786. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27787. */
  27788. set isAlwaysVisible(val: boolean);
  27789. /**
  27790. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27792. */
  27793. set isVisibilityBoxLocked(val: boolean);
  27794. /**
  27795. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27796. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27797. */
  27798. get isVisibilityBoxLocked(): boolean;
  27799. /**
  27800. * Tells to `setParticles()` to compute the particle rotations or not.
  27801. * Default value : true. The SPS is faster when it's set to false.
  27802. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27803. */
  27804. set computeParticleRotation(val: boolean);
  27805. /**
  27806. * Tells to `setParticles()` to compute the particle colors or not.
  27807. * Default value : true. The SPS is faster when it's set to false.
  27808. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27809. */
  27810. set computeParticleColor(val: boolean);
  27811. set computeParticleTexture(val: boolean);
  27812. /**
  27813. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27814. * Default value : false. The SPS is faster when it's set to false.
  27815. * Note : the particle custom vertex positions aren't stored values.
  27816. */
  27817. set computeParticleVertex(val: boolean);
  27818. /**
  27819. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27820. */
  27821. set computeBoundingBox(val: boolean);
  27822. /**
  27823. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27824. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27825. * Default : `true`
  27826. */
  27827. set depthSortParticles(val: boolean);
  27828. /**
  27829. * Gets if `setParticles()` computes the particle rotations or not.
  27830. * Default value : true. The SPS is faster when it's set to false.
  27831. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27832. */
  27833. get computeParticleRotation(): boolean;
  27834. /**
  27835. * Gets if `setParticles()` computes the particle colors or not.
  27836. * Default value : true. The SPS is faster when it's set to false.
  27837. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27838. */
  27839. get computeParticleColor(): boolean;
  27840. /**
  27841. * Gets if `setParticles()` computes the particle textures or not.
  27842. * Default value : true. The SPS is faster when it's set to false.
  27843. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27844. */
  27845. get computeParticleTexture(): boolean;
  27846. /**
  27847. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27848. * Default value : false. The SPS is faster when it's set to false.
  27849. * Note : the particle custom vertex positions aren't stored values.
  27850. */
  27851. get computeParticleVertex(): boolean;
  27852. /**
  27853. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27854. */
  27855. get computeBoundingBox(): boolean;
  27856. /**
  27857. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27858. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27859. * Default : `true`
  27860. */
  27861. get depthSortParticles(): boolean;
  27862. /**
  27863. * Gets if the SPS is created as expandable at construction time.
  27864. * Default : `false`
  27865. */
  27866. get expandable(): boolean;
  27867. /**
  27868. * Gets if the SPS supports the Multi Materials
  27869. */
  27870. get multimaterialEnabled(): boolean;
  27871. /**
  27872. * Gets if the SPS uses the model materials for its own multimaterial.
  27873. */
  27874. get useModelMaterial(): boolean;
  27875. /**
  27876. * The SPS used material array.
  27877. */
  27878. get materials(): Material[];
  27879. /**
  27880. * Sets the SPS MultiMaterial from the passed materials.
  27881. * Note : the passed array is internally copied and not used then by reference.
  27882. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27883. */
  27884. setMultiMaterial(materials: Material[]): void;
  27885. /**
  27886. * The SPS computed multimaterial object
  27887. */
  27888. get multimaterial(): MultiMaterial;
  27889. set multimaterial(mm: MultiMaterial);
  27890. /**
  27891. * If the subMeshes must be updated on the next call to setParticles()
  27892. */
  27893. get autoUpdateSubMeshes(): boolean;
  27894. set autoUpdateSubMeshes(val: boolean);
  27895. /**
  27896. * This function does nothing. It may be overwritten to set all the particle first values.
  27897. * The SPS doesn't call this function, you may have to call it by your own.
  27898. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27899. */
  27900. initParticles(): void;
  27901. /**
  27902. * This function does nothing. It may be overwritten to recycle a particle.
  27903. * The SPS doesn't call this function, you may have to call it by your own.
  27904. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27905. * @param particle The particle to recycle
  27906. * @returns the recycled particle
  27907. */
  27908. recycleParticle(particle: SolidParticle): SolidParticle;
  27909. /**
  27910. * Updates a particle : this function should be overwritten by the user.
  27911. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27912. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27913. * @example : just set a particle position or velocity and recycle conditions
  27914. * @param particle The particle to update
  27915. * @returns the updated particle
  27916. */
  27917. updateParticle(particle: SolidParticle): SolidParticle;
  27918. /**
  27919. * Updates a vertex of a particle : it can be overwritten by the user.
  27920. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27921. * @param particle the current particle
  27922. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  27923. * @param pt the index of the current vertex in the particle shape
  27924. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27925. * @example : just set a vertex particle position or color
  27926. * @returns the sps
  27927. */
  27928. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  27929. /**
  27930. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27931. * This does nothing and may be overwritten by the user.
  27932. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27933. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27934. * @param update the boolean update value actually passed to setParticles()
  27935. */
  27936. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27937. /**
  27938. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27939. * This will be passed three parameters.
  27940. * This does nothing and may be overwritten by the user.
  27941. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27942. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27943. * @param update the boolean update value actually passed to setParticles()
  27944. */
  27945. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27946. }
  27947. }
  27948. declare module BABYLON {
  27949. /**
  27950. * Represents one particle of a solid particle system.
  27951. */
  27952. export class SolidParticle {
  27953. /**
  27954. * particle global index
  27955. */
  27956. idx: number;
  27957. /**
  27958. * particle identifier
  27959. */
  27960. id: number;
  27961. /**
  27962. * The color of the particle
  27963. */
  27964. color: Nullable<Color4>;
  27965. /**
  27966. * The world space position of the particle.
  27967. */
  27968. position: Vector3;
  27969. /**
  27970. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27971. */
  27972. rotation: Vector3;
  27973. /**
  27974. * The world space rotation quaternion of the particle.
  27975. */
  27976. rotationQuaternion: Nullable<Quaternion>;
  27977. /**
  27978. * The scaling of the particle.
  27979. */
  27980. scaling: Vector3;
  27981. /**
  27982. * The uvs of the particle.
  27983. */
  27984. uvs: Vector4;
  27985. /**
  27986. * The current speed of the particle.
  27987. */
  27988. velocity: Vector3;
  27989. /**
  27990. * The pivot point in the particle local space.
  27991. */
  27992. pivot: Vector3;
  27993. /**
  27994. * Must the particle be translated from its pivot point in its local space ?
  27995. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27996. * Default : false
  27997. */
  27998. translateFromPivot: boolean;
  27999. /**
  28000. * Is the particle active or not ?
  28001. */
  28002. alive: boolean;
  28003. /**
  28004. * Is the particle visible or not ?
  28005. */
  28006. isVisible: boolean;
  28007. /**
  28008. * Index of this particle in the global "positions" array (Internal use)
  28009. * @hidden
  28010. */
  28011. _pos: number;
  28012. /**
  28013. * @hidden Index of this particle in the global "indices" array (Internal use)
  28014. */
  28015. _ind: number;
  28016. /**
  28017. * @hidden ModelShape of this particle (Internal use)
  28018. */
  28019. _model: ModelShape;
  28020. /**
  28021. * ModelShape id of this particle
  28022. */
  28023. shapeId: number;
  28024. /**
  28025. * Index of the particle in its shape id
  28026. */
  28027. idxInShape: number;
  28028. /**
  28029. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28030. */
  28031. _modelBoundingInfo: BoundingInfo;
  28032. /**
  28033. * @hidden Particle BoundingInfo object (Internal use)
  28034. */
  28035. _boundingInfo: BoundingInfo;
  28036. /**
  28037. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28038. */
  28039. _sps: SolidParticleSystem;
  28040. /**
  28041. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28042. */
  28043. _stillInvisible: boolean;
  28044. /**
  28045. * @hidden Last computed particle rotation matrix
  28046. */
  28047. _rotationMatrix: number[];
  28048. /**
  28049. * Parent particle Id, if any.
  28050. * Default null.
  28051. */
  28052. parentId: Nullable<number>;
  28053. /**
  28054. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28055. */
  28056. materialIndex: Nullable<number>;
  28057. /**
  28058. * Custom object or properties.
  28059. */
  28060. props: Nullable<any>;
  28061. /**
  28062. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28063. * The possible values are :
  28064. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28065. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28066. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28067. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28068. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28069. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28070. * */
  28071. cullingStrategy: number;
  28072. /**
  28073. * @hidden Internal global position in the SPS.
  28074. */
  28075. _globalPosition: Vector3;
  28076. /**
  28077. * Creates a Solid Particle object.
  28078. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28079. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28080. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28081. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28082. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28083. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28084. * @param shapeId (integer) is the model shape identifier in the SPS.
  28085. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28086. * @param sps defines the sps it is associated to
  28087. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28088. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28089. */
  28090. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28091. /**
  28092. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28093. * @param target the particle target
  28094. * @returns the current particle
  28095. */
  28096. copyToRef(target: SolidParticle): SolidParticle;
  28097. /**
  28098. * Legacy support, changed scale to scaling
  28099. */
  28100. get scale(): Vector3;
  28101. /**
  28102. * Legacy support, changed scale to scaling
  28103. */
  28104. set scale(scale: Vector3);
  28105. /**
  28106. * Legacy support, changed quaternion to rotationQuaternion
  28107. */
  28108. get quaternion(): Nullable<Quaternion>;
  28109. /**
  28110. * Legacy support, changed quaternion to rotationQuaternion
  28111. */
  28112. set quaternion(q: Nullable<Quaternion>);
  28113. /**
  28114. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28115. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28116. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28117. * @returns true if it intersects
  28118. */
  28119. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28120. /**
  28121. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28122. * A particle is in the frustum if its bounding box intersects the frustum
  28123. * @param frustumPlanes defines the frustum to test
  28124. * @returns true if the particle is in the frustum planes
  28125. */
  28126. isInFrustum(frustumPlanes: Plane[]): boolean;
  28127. /**
  28128. * get the rotation matrix of the particle
  28129. * @hidden
  28130. */
  28131. getRotationMatrix(m: Matrix): void;
  28132. }
  28133. /**
  28134. * Represents the shape of the model used by one particle of a solid particle system.
  28135. * SPS internal tool, don't use it manually.
  28136. */
  28137. export class ModelShape {
  28138. /**
  28139. * The shape id
  28140. * @hidden
  28141. */
  28142. shapeID: number;
  28143. /**
  28144. * flat array of model positions (internal use)
  28145. * @hidden
  28146. */
  28147. _shape: Vector3[];
  28148. /**
  28149. * flat array of model UVs (internal use)
  28150. * @hidden
  28151. */
  28152. _shapeUV: number[];
  28153. /**
  28154. * color array of the model
  28155. * @hidden
  28156. */
  28157. _shapeColors: number[];
  28158. /**
  28159. * indices array of the model
  28160. * @hidden
  28161. */
  28162. _indices: number[];
  28163. /**
  28164. * normals array of the model
  28165. * @hidden
  28166. */
  28167. _normals: number[];
  28168. /**
  28169. * length of the shape in the model indices array (internal use)
  28170. * @hidden
  28171. */
  28172. _indicesLength: number;
  28173. /**
  28174. * Custom position function (internal use)
  28175. * @hidden
  28176. */
  28177. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28178. /**
  28179. * Custom vertex function (internal use)
  28180. * @hidden
  28181. */
  28182. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28183. /**
  28184. * Model material (internal use)
  28185. * @hidden
  28186. */
  28187. _material: Nullable<Material>;
  28188. /**
  28189. * 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.
  28190. * SPS internal tool, don't use it manually.
  28191. * @hidden
  28192. */
  28193. 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>);
  28194. }
  28195. /**
  28196. * Represents a Depth Sorted Particle in the solid particle system.
  28197. * @hidden
  28198. */
  28199. export class DepthSortedParticle {
  28200. /**
  28201. * Particle index
  28202. */
  28203. idx: number;
  28204. /**
  28205. * Index of the particle in the "indices" array
  28206. */
  28207. ind: number;
  28208. /**
  28209. * Length of the particle shape in the "indices" array
  28210. */
  28211. indicesLength: number;
  28212. /**
  28213. * Squared distance from the particle to the camera
  28214. */
  28215. sqDistance: number;
  28216. /**
  28217. * Material index when used with MultiMaterials
  28218. */
  28219. materialIndex: number;
  28220. /**
  28221. * Creates a new sorted particle
  28222. * @param materialIndex
  28223. */
  28224. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28225. }
  28226. /**
  28227. * Represents a solid particle vertex
  28228. */
  28229. export class SolidParticleVertex {
  28230. /**
  28231. * Vertex position
  28232. */
  28233. position: Vector3;
  28234. /**
  28235. * Vertex color
  28236. */
  28237. color: Color4;
  28238. /**
  28239. * Vertex UV
  28240. */
  28241. uv: Vector2;
  28242. /**
  28243. * Creates a new solid particle vertex
  28244. */
  28245. constructor();
  28246. /** Vertex x coordinate */
  28247. get x(): number;
  28248. set x(val: number);
  28249. /** Vertex y coordinate */
  28250. get y(): number;
  28251. set y(val: number);
  28252. /** Vertex z coordinate */
  28253. get z(): number;
  28254. set z(val: number);
  28255. }
  28256. }
  28257. declare module BABYLON {
  28258. /**
  28259. * @hidden
  28260. */
  28261. export class _MeshCollisionData {
  28262. _checkCollisions: boolean;
  28263. _collisionMask: number;
  28264. _collisionGroup: number;
  28265. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28266. _collider: Nullable<Collider>;
  28267. _oldPositionForCollisions: Vector3;
  28268. _diffPositionForCollisions: Vector3;
  28269. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28270. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28271. }
  28272. }
  28273. declare module BABYLON {
  28274. /** @hidden */
  28275. class _FacetDataStorage {
  28276. facetPositions: Vector3[];
  28277. facetNormals: Vector3[];
  28278. facetPartitioning: number[][];
  28279. facetNb: number;
  28280. partitioningSubdivisions: number;
  28281. partitioningBBoxRatio: number;
  28282. facetDataEnabled: boolean;
  28283. facetParameters: any;
  28284. bbSize: Vector3;
  28285. subDiv: {
  28286. max: number;
  28287. X: number;
  28288. Y: number;
  28289. Z: number;
  28290. };
  28291. facetDepthSort: boolean;
  28292. facetDepthSortEnabled: boolean;
  28293. depthSortedIndices: IndicesArray;
  28294. depthSortedFacets: {
  28295. ind: number;
  28296. sqDistance: number;
  28297. }[];
  28298. facetDepthSortFunction: (f1: {
  28299. ind: number;
  28300. sqDistance: number;
  28301. }, f2: {
  28302. ind: number;
  28303. sqDistance: number;
  28304. }) => number;
  28305. facetDepthSortFrom: Vector3;
  28306. facetDepthSortOrigin: Vector3;
  28307. invertedMatrix: Matrix;
  28308. }
  28309. /**
  28310. * @hidden
  28311. **/
  28312. class _InternalAbstractMeshDataInfo {
  28313. _hasVertexAlpha: boolean;
  28314. _useVertexColors: boolean;
  28315. _numBoneInfluencers: number;
  28316. _applyFog: boolean;
  28317. _receiveShadows: boolean;
  28318. _facetData: _FacetDataStorage;
  28319. _visibility: number;
  28320. _skeleton: Nullable<Skeleton>;
  28321. _layerMask: number;
  28322. _computeBonesUsingShaders: boolean;
  28323. _isActive: boolean;
  28324. _onlyForInstances: boolean;
  28325. _isActiveIntermediate: boolean;
  28326. _onlyForInstancesIntermediate: boolean;
  28327. _actAsRegularMesh: boolean;
  28328. }
  28329. /**
  28330. * Class used to store all common mesh properties
  28331. */
  28332. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28333. /** No occlusion */
  28334. static OCCLUSION_TYPE_NONE: number;
  28335. /** Occlusion set to optimisitic */
  28336. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28337. /** Occlusion set to strict */
  28338. static OCCLUSION_TYPE_STRICT: number;
  28339. /** Use an accurante occlusion algorithm */
  28340. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28341. /** Use a conservative occlusion algorithm */
  28342. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28343. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28344. * Test order :
  28345. * Is the bounding sphere outside the frustum ?
  28346. * If not, are the bounding box vertices outside the frustum ?
  28347. * It not, then the cullable object is in the frustum.
  28348. */
  28349. static readonly CULLINGSTRATEGY_STANDARD: number;
  28350. /** Culling strategy : Bounding Sphere Only.
  28351. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28352. * It's also less accurate than the standard because some not visible objects can still be selected.
  28353. * Test : is the bounding sphere outside the frustum ?
  28354. * If not, then the cullable object is in the frustum.
  28355. */
  28356. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28357. /** Culling strategy : Optimistic Inclusion.
  28358. * This in an inclusion test first, then the standard exclusion test.
  28359. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28360. * 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.
  28361. * Anyway, it's as accurate as the standard strategy.
  28362. * Test :
  28363. * Is the cullable object bounding sphere center in the frustum ?
  28364. * If not, apply the default culling strategy.
  28365. */
  28366. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28367. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28368. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28369. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28370. * 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.
  28371. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28372. * Test :
  28373. * Is the cullable object bounding sphere center in the frustum ?
  28374. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28375. */
  28376. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28377. /**
  28378. * No billboard
  28379. */
  28380. static get BILLBOARDMODE_NONE(): number;
  28381. /** Billboard on X axis */
  28382. static get BILLBOARDMODE_X(): number;
  28383. /** Billboard on Y axis */
  28384. static get BILLBOARDMODE_Y(): number;
  28385. /** Billboard on Z axis */
  28386. static get BILLBOARDMODE_Z(): number;
  28387. /** Billboard on all axes */
  28388. static get BILLBOARDMODE_ALL(): number;
  28389. /** Billboard on using position instead of orientation */
  28390. static get BILLBOARDMODE_USE_POSITION(): number;
  28391. /** @hidden */
  28392. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28393. /**
  28394. * The culling strategy to use to check whether the mesh must be rendered or not.
  28395. * This value can be changed at any time and will be used on the next render mesh selection.
  28396. * The possible values are :
  28397. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28398. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28399. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28400. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28401. * Please read each static variable documentation to get details about the culling process.
  28402. * */
  28403. cullingStrategy: number;
  28404. /**
  28405. * Gets the number of facets in the mesh
  28406. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28407. */
  28408. get facetNb(): number;
  28409. /**
  28410. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28412. */
  28413. get partitioningSubdivisions(): number;
  28414. set partitioningSubdivisions(nb: number);
  28415. /**
  28416. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28417. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28419. */
  28420. get partitioningBBoxRatio(): number;
  28421. set partitioningBBoxRatio(ratio: number);
  28422. /**
  28423. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28424. * Works only for updatable meshes.
  28425. * Doesn't work with multi-materials
  28426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28427. */
  28428. get mustDepthSortFacets(): boolean;
  28429. set mustDepthSortFacets(sort: boolean);
  28430. /**
  28431. * The location (Vector3) where the facet depth sort must be computed from.
  28432. * By default, the active camera position.
  28433. * Used only when facet depth sort is enabled
  28434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28435. */
  28436. get facetDepthSortFrom(): Vector3;
  28437. set facetDepthSortFrom(location: Vector3);
  28438. /**
  28439. * gets a boolean indicating if facetData is enabled
  28440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28441. */
  28442. get isFacetDataEnabled(): boolean;
  28443. /** @hidden */
  28444. _updateNonUniformScalingState(value: boolean): boolean;
  28445. /**
  28446. * An event triggered when this mesh collides with another one
  28447. */
  28448. onCollideObservable: Observable<AbstractMesh>;
  28449. /** Set a function to call when this mesh collides with another one */
  28450. set onCollide(callback: () => void);
  28451. /**
  28452. * An event triggered when the collision's position changes
  28453. */
  28454. onCollisionPositionChangeObservable: Observable<Vector3>;
  28455. /** Set a function to call when the collision's position changes */
  28456. set onCollisionPositionChange(callback: () => void);
  28457. /**
  28458. * An event triggered when material is changed
  28459. */
  28460. onMaterialChangedObservable: Observable<AbstractMesh>;
  28461. /**
  28462. * Gets or sets the orientation for POV movement & rotation
  28463. */
  28464. definedFacingForward: boolean;
  28465. /** @hidden */
  28466. _occlusionQuery: Nullable<WebGLQuery>;
  28467. /** @hidden */
  28468. _renderingGroup: Nullable<RenderingGroup>;
  28469. /**
  28470. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28471. */
  28472. get visibility(): number;
  28473. /**
  28474. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28475. */
  28476. set visibility(value: number);
  28477. /** Gets or sets the alpha index used to sort transparent meshes
  28478. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28479. */
  28480. alphaIndex: number;
  28481. /**
  28482. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28483. */
  28484. isVisible: boolean;
  28485. /**
  28486. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28487. */
  28488. isPickable: boolean;
  28489. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28490. showSubMeshesBoundingBox: boolean;
  28491. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28492. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28493. */
  28494. isBlocker: boolean;
  28495. /**
  28496. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28497. */
  28498. enablePointerMoveEvents: boolean;
  28499. /**
  28500. * Specifies the rendering group id for this mesh (0 by default)
  28501. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28502. */
  28503. renderingGroupId: number;
  28504. private _material;
  28505. /** Gets or sets current material */
  28506. get material(): Nullable<Material>;
  28507. set material(value: Nullable<Material>);
  28508. /**
  28509. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28510. * @see http://doc.babylonjs.com/babylon101/shadows
  28511. */
  28512. get receiveShadows(): boolean;
  28513. set receiveShadows(value: boolean);
  28514. /** Defines color to use when rendering outline */
  28515. outlineColor: Color3;
  28516. /** Define width to use when rendering outline */
  28517. outlineWidth: number;
  28518. /** Defines color to use when rendering overlay */
  28519. overlayColor: Color3;
  28520. /** Defines alpha to use when rendering overlay */
  28521. overlayAlpha: number;
  28522. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28523. get hasVertexAlpha(): boolean;
  28524. set hasVertexAlpha(value: boolean);
  28525. /** 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) */
  28526. get useVertexColors(): boolean;
  28527. set useVertexColors(value: boolean);
  28528. /**
  28529. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28530. */
  28531. get computeBonesUsingShaders(): boolean;
  28532. set computeBonesUsingShaders(value: boolean);
  28533. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28534. get numBoneInfluencers(): number;
  28535. set numBoneInfluencers(value: number);
  28536. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28537. get applyFog(): boolean;
  28538. set applyFog(value: boolean);
  28539. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28540. useOctreeForRenderingSelection: boolean;
  28541. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28542. useOctreeForPicking: boolean;
  28543. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28544. useOctreeForCollisions: boolean;
  28545. /**
  28546. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28547. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28548. */
  28549. get layerMask(): number;
  28550. set layerMask(value: number);
  28551. /**
  28552. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28553. */
  28554. alwaysSelectAsActiveMesh: boolean;
  28555. /**
  28556. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28557. */
  28558. doNotSyncBoundingInfo: boolean;
  28559. /**
  28560. * Gets or sets the current action manager
  28561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28562. */
  28563. actionManager: Nullable<AbstractActionManager>;
  28564. private _meshCollisionData;
  28565. /**
  28566. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28568. */
  28569. ellipsoid: Vector3;
  28570. /**
  28571. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28573. */
  28574. ellipsoidOffset: Vector3;
  28575. /**
  28576. * Gets or sets a collision mask used to mask collisions (default is -1).
  28577. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28578. */
  28579. get collisionMask(): number;
  28580. set collisionMask(mask: number);
  28581. /**
  28582. * Gets or sets the current collision group mask (-1 by default).
  28583. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28584. */
  28585. get collisionGroup(): number;
  28586. set collisionGroup(mask: number);
  28587. /**
  28588. * Gets or sets current surrounding meshes (null by default).
  28589. *
  28590. * By default collision detection is tested against every mesh in the scene.
  28591. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28592. * meshes will be tested for the collision.
  28593. *
  28594. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28595. */
  28596. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28597. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28598. /**
  28599. * Defines edge width used when edgesRenderer is enabled
  28600. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28601. */
  28602. edgesWidth: number;
  28603. /**
  28604. * Defines edge color used when edgesRenderer is enabled
  28605. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28606. */
  28607. edgesColor: Color4;
  28608. /** @hidden */
  28609. _edgesRenderer: Nullable<IEdgesRenderer>;
  28610. /** @hidden */
  28611. _masterMesh: Nullable<AbstractMesh>;
  28612. /** @hidden */
  28613. _boundingInfo: Nullable<BoundingInfo>;
  28614. /** @hidden */
  28615. _renderId: number;
  28616. /**
  28617. * Gets or sets the list of subMeshes
  28618. * @see http://doc.babylonjs.com/how_to/multi_materials
  28619. */
  28620. subMeshes: SubMesh[];
  28621. /** @hidden */
  28622. _intersectionsInProgress: AbstractMesh[];
  28623. /** @hidden */
  28624. _unIndexed: boolean;
  28625. /** @hidden */
  28626. _lightSources: Light[];
  28627. /** Gets the list of lights affecting that mesh */
  28628. get lightSources(): Light[];
  28629. /** @hidden */
  28630. get _positions(): Nullable<Vector3[]>;
  28631. /** @hidden */
  28632. _waitingData: {
  28633. lods: Nullable<any>;
  28634. actions: Nullable<any>;
  28635. freezeWorldMatrix: Nullable<boolean>;
  28636. };
  28637. /** @hidden */
  28638. _bonesTransformMatrices: Nullable<Float32Array>;
  28639. /** @hidden */
  28640. _transformMatrixTexture: Nullable<RawTexture>;
  28641. /**
  28642. * Gets or sets a skeleton to apply skining transformations
  28643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28644. */
  28645. set skeleton(value: Nullable<Skeleton>);
  28646. get skeleton(): Nullable<Skeleton>;
  28647. /**
  28648. * An event triggered when the mesh is rebuilt.
  28649. */
  28650. onRebuildObservable: Observable<AbstractMesh>;
  28651. /**
  28652. * Creates a new AbstractMesh
  28653. * @param name defines the name of the mesh
  28654. * @param scene defines the hosting scene
  28655. */
  28656. constructor(name: string, scene?: Nullable<Scene>);
  28657. /**
  28658. * Returns the string "AbstractMesh"
  28659. * @returns "AbstractMesh"
  28660. */
  28661. getClassName(): string;
  28662. /**
  28663. * Gets a string representation of the current mesh
  28664. * @param fullDetails defines a boolean indicating if full details must be included
  28665. * @returns a string representation of the current mesh
  28666. */
  28667. toString(fullDetails?: boolean): string;
  28668. /**
  28669. * @hidden
  28670. */
  28671. protected _getEffectiveParent(): Nullable<Node>;
  28672. /** @hidden */
  28673. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28674. /** @hidden */
  28675. _rebuild(): void;
  28676. /** @hidden */
  28677. _resyncLightSources(): void;
  28678. /** @hidden */
  28679. _resyncLightSource(light: Light): void;
  28680. /** @hidden */
  28681. _unBindEffect(): void;
  28682. /** @hidden */
  28683. _removeLightSource(light: Light, dispose: boolean): void;
  28684. private _markSubMeshesAsDirty;
  28685. /** @hidden */
  28686. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28687. /** @hidden */
  28688. _markSubMeshesAsAttributesDirty(): void;
  28689. /** @hidden */
  28690. _markSubMeshesAsMiscDirty(): void;
  28691. /**
  28692. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28693. */
  28694. get scaling(): Vector3;
  28695. set scaling(newScaling: Vector3);
  28696. /**
  28697. * Returns true if the mesh is blocked. Implemented by child classes
  28698. */
  28699. get isBlocked(): boolean;
  28700. /**
  28701. * Returns the mesh itself by default. Implemented by child classes
  28702. * @param camera defines the camera to use to pick the right LOD level
  28703. * @returns the currentAbstractMesh
  28704. */
  28705. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28706. /**
  28707. * Returns 0 by default. Implemented by child classes
  28708. * @returns an integer
  28709. */
  28710. getTotalVertices(): number;
  28711. /**
  28712. * Returns a positive integer : the total number of indices in this mesh geometry.
  28713. * @returns the numner of indices or zero if the mesh has no geometry.
  28714. */
  28715. getTotalIndices(): number;
  28716. /**
  28717. * Returns null by default. Implemented by child classes
  28718. * @returns null
  28719. */
  28720. getIndices(): Nullable<IndicesArray>;
  28721. /**
  28722. * Returns the array of the requested vertex data kind. Implemented by child classes
  28723. * @param kind defines the vertex data kind to use
  28724. * @returns null
  28725. */
  28726. getVerticesData(kind: string): Nullable<FloatArray>;
  28727. /**
  28728. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28729. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28730. * Note that a new underlying VertexBuffer object is created each call.
  28731. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28732. * @param kind defines vertex data kind:
  28733. * * VertexBuffer.PositionKind
  28734. * * VertexBuffer.UVKind
  28735. * * VertexBuffer.UV2Kind
  28736. * * VertexBuffer.UV3Kind
  28737. * * VertexBuffer.UV4Kind
  28738. * * VertexBuffer.UV5Kind
  28739. * * VertexBuffer.UV6Kind
  28740. * * VertexBuffer.ColorKind
  28741. * * VertexBuffer.MatricesIndicesKind
  28742. * * VertexBuffer.MatricesIndicesExtraKind
  28743. * * VertexBuffer.MatricesWeightsKind
  28744. * * VertexBuffer.MatricesWeightsExtraKind
  28745. * @param data defines the data source
  28746. * @param updatable defines if the data must be flagged as updatable (or static)
  28747. * @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
  28748. * @returns the current mesh
  28749. */
  28750. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28751. /**
  28752. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28753. * If the mesh has no geometry, it is simply returned as it is.
  28754. * @param kind defines vertex data kind:
  28755. * * VertexBuffer.PositionKind
  28756. * * VertexBuffer.UVKind
  28757. * * VertexBuffer.UV2Kind
  28758. * * VertexBuffer.UV3Kind
  28759. * * VertexBuffer.UV4Kind
  28760. * * VertexBuffer.UV5Kind
  28761. * * VertexBuffer.UV6Kind
  28762. * * VertexBuffer.ColorKind
  28763. * * VertexBuffer.MatricesIndicesKind
  28764. * * VertexBuffer.MatricesIndicesExtraKind
  28765. * * VertexBuffer.MatricesWeightsKind
  28766. * * VertexBuffer.MatricesWeightsExtraKind
  28767. * @param data defines the data source
  28768. * @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
  28769. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28770. * @returns the current mesh
  28771. */
  28772. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28773. /**
  28774. * Sets the mesh indices,
  28775. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28776. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28777. * @param totalVertices Defines the total number of vertices
  28778. * @returns the current mesh
  28779. */
  28780. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28781. /**
  28782. * Gets a boolean indicating if specific vertex data is present
  28783. * @param kind defines the vertex data kind to use
  28784. * @returns true is data kind is present
  28785. */
  28786. isVerticesDataPresent(kind: string): boolean;
  28787. /**
  28788. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28789. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28790. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28791. * @returns a BoundingInfo
  28792. */
  28793. getBoundingInfo(): BoundingInfo;
  28794. /**
  28795. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28796. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28797. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28798. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28799. * @returns the current mesh
  28800. */
  28801. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28802. /**
  28803. * Overwrite the current bounding info
  28804. * @param boundingInfo defines the new bounding info
  28805. * @returns the current mesh
  28806. */
  28807. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28808. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28809. get useBones(): boolean;
  28810. /** @hidden */
  28811. _preActivate(): void;
  28812. /** @hidden */
  28813. _preActivateForIntermediateRendering(renderId: number): void;
  28814. /** @hidden */
  28815. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28816. /** @hidden */
  28817. _postActivate(): void;
  28818. /** @hidden */
  28819. _freeze(): void;
  28820. /** @hidden */
  28821. _unFreeze(): void;
  28822. /**
  28823. * Gets the current world matrix
  28824. * @returns a Matrix
  28825. */
  28826. getWorldMatrix(): Matrix;
  28827. /** @hidden */
  28828. _getWorldMatrixDeterminant(): number;
  28829. /**
  28830. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28831. */
  28832. get isAnInstance(): boolean;
  28833. /**
  28834. * Gets a boolean indicating if this mesh has instances
  28835. */
  28836. get hasInstances(): boolean;
  28837. /**
  28838. * Perform relative position change from the point of view of behind the front of the mesh.
  28839. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28840. * Supports definition of mesh facing forward or backward
  28841. * @param amountRight defines the distance on the right axis
  28842. * @param amountUp defines the distance on the up axis
  28843. * @param amountForward defines the distance on the forward axis
  28844. * @returns the current mesh
  28845. */
  28846. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28847. /**
  28848. * Calculate relative position change from the point of view of behind the front of the mesh.
  28849. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28850. * Supports definition of mesh facing forward or backward
  28851. * @param amountRight defines the distance on the right axis
  28852. * @param amountUp defines the distance on the up axis
  28853. * @param amountForward defines the distance on the forward axis
  28854. * @returns the new displacement vector
  28855. */
  28856. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28857. /**
  28858. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28859. * Supports definition of mesh facing forward or backward
  28860. * @param flipBack defines the flip
  28861. * @param twirlClockwise defines the twirl
  28862. * @param tiltRight defines the tilt
  28863. * @returns the current mesh
  28864. */
  28865. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28866. /**
  28867. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28868. * Supports definition of mesh facing forward or backward.
  28869. * @param flipBack defines the flip
  28870. * @param twirlClockwise defines the twirl
  28871. * @param tiltRight defines the tilt
  28872. * @returns the new rotation vector
  28873. */
  28874. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28875. /**
  28876. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28877. * This means the mesh underlying bounding box and sphere are recomputed.
  28878. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28879. * @returns the current mesh
  28880. */
  28881. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28882. /** @hidden */
  28883. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28884. /** @hidden */
  28885. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28886. /** @hidden */
  28887. _updateBoundingInfo(): AbstractMesh;
  28888. /** @hidden */
  28889. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28890. /** @hidden */
  28891. protected _afterComputeWorldMatrix(): void;
  28892. /** @hidden */
  28893. get _effectiveMesh(): AbstractMesh;
  28894. /**
  28895. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28896. * A mesh is in the frustum if its bounding box intersects the frustum
  28897. * @param frustumPlanes defines the frustum to test
  28898. * @returns true if the mesh is in the frustum planes
  28899. */
  28900. isInFrustum(frustumPlanes: Plane[]): boolean;
  28901. /**
  28902. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28903. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28904. * @param frustumPlanes defines the frustum to test
  28905. * @returns true if the mesh is completely in the frustum planes
  28906. */
  28907. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28908. /**
  28909. * True if the mesh intersects another mesh or a SolidParticle object
  28910. * @param mesh defines a target mesh or SolidParticle to test
  28911. * @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)
  28912. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28913. * @returns true if there is an intersection
  28914. */
  28915. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28916. /**
  28917. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28918. * @param point defines the point to test
  28919. * @returns true if there is an intersection
  28920. */
  28921. intersectsPoint(point: Vector3): boolean;
  28922. /**
  28923. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28924. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28925. */
  28926. get checkCollisions(): boolean;
  28927. set checkCollisions(collisionEnabled: boolean);
  28928. /**
  28929. * Gets Collider object used to compute collisions (not physics)
  28930. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28931. */
  28932. get collider(): Nullable<Collider>;
  28933. /**
  28934. * Move the mesh using collision engine
  28935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28936. * @param displacement defines the requested displacement vector
  28937. * @returns the current mesh
  28938. */
  28939. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28940. private _onCollisionPositionChange;
  28941. /** @hidden */
  28942. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28943. /** @hidden */
  28944. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28945. /** @hidden */
  28946. _checkCollision(collider: Collider): AbstractMesh;
  28947. /** @hidden */
  28948. _generatePointsArray(): boolean;
  28949. /**
  28950. * Checks if the passed Ray intersects with the mesh
  28951. * @param ray defines the ray to use
  28952. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28953. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28954. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28955. * @returns the picking info
  28956. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28957. */
  28958. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28959. /**
  28960. * Clones the current mesh
  28961. * @param name defines the mesh name
  28962. * @param newParent defines the new mesh parent
  28963. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28964. * @returns the new mesh
  28965. */
  28966. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28967. /**
  28968. * Disposes all the submeshes of the current meshnp
  28969. * @returns the current mesh
  28970. */
  28971. releaseSubMeshes(): AbstractMesh;
  28972. /**
  28973. * Releases resources associated with this abstract mesh.
  28974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28976. */
  28977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28978. /**
  28979. * Adds the passed mesh as a child to the current mesh
  28980. * @param mesh defines the child mesh
  28981. * @returns the current mesh
  28982. */
  28983. addChild(mesh: AbstractMesh): AbstractMesh;
  28984. /**
  28985. * Removes the passed mesh from the current mesh children list
  28986. * @param mesh defines the child mesh
  28987. * @returns the current mesh
  28988. */
  28989. removeChild(mesh: AbstractMesh): AbstractMesh;
  28990. /** @hidden */
  28991. private _initFacetData;
  28992. /**
  28993. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28994. * This method can be called within the render loop.
  28995. * 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
  28996. * @returns the current mesh
  28997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28998. */
  28999. updateFacetData(): AbstractMesh;
  29000. /**
  29001. * Returns the facetLocalNormals array.
  29002. * The normals are expressed in the mesh local spac
  29003. * @returns an array of Vector3
  29004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29005. */
  29006. getFacetLocalNormals(): Vector3[];
  29007. /**
  29008. * Returns the facetLocalPositions array.
  29009. * The facet positions are expressed in the mesh local space
  29010. * @returns an array of Vector3
  29011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29012. */
  29013. getFacetLocalPositions(): Vector3[];
  29014. /**
  29015. * Returns the facetLocalPartioning array
  29016. * @returns an array of array of numbers
  29017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29018. */
  29019. getFacetLocalPartitioning(): number[][];
  29020. /**
  29021. * Returns the i-th facet position in the world system.
  29022. * This method allocates a new Vector3 per call
  29023. * @param i defines the facet index
  29024. * @returns a new Vector3
  29025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29026. */
  29027. getFacetPosition(i: number): Vector3;
  29028. /**
  29029. * Sets the reference Vector3 with the i-th facet position in the world system
  29030. * @param i defines the facet index
  29031. * @param ref defines the target vector
  29032. * @returns the current mesh
  29033. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29034. */
  29035. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29036. /**
  29037. * Returns the i-th facet normal in the world system.
  29038. * This method allocates a new Vector3 per call
  29039. * @param i defines the facet index
  29040. * @returns a new Vector3
  29041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29042. */
  29043. getFacetNormal(i: number): Vector3;
  29044. /**
  29045. * Sets the reference Vector3 with the i-th facet normal in the world system
  29046. * @param i defines the facet index
  29047. * @param ref defines the target vector
  29048. * @returns the current mesh
  29049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29050. */
  29051. getFacetNormalToRef(i: number, ref: Vector3): this;
  29052. /**
  29053. * 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)
  29054. * @param x defines x coordinate
  29055. * @param y defines y coordinate
  29056. * @param z defines z coordinate
  29057. * @returns the array of facet indexes
  29058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29059. */
  29060. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29061. /**
  29062. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29063. * @param projected sets as the (x,y,z) world projection on the facet
  29064. * @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
  29065. * @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
  29066. * @param x defines x coordinate
  29067. * @param y defines y coordinate
  29068. * @param z defines z coordinate
  29069. * @returns the face index if found (or null instead)
  29070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29071. */
  29072. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29073. /**
  29074. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29075. * @param projected sets as the (x,y,z) local projection on the facet
  29076. * @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
  29077. * @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
  29078. * @param x defines x coordinate
  29079. * @param y defines y coordinate
  29080. * @param z defines z coordinate
  29081. * @returns the face index if found (or null instead)
  29082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29083. */
  29084. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29085. /**
  29086. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29087. * @returns the parameters
  29088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29089. */
  29090. getFacetDataParameters(): any;
  29091. /**
  29092. * Disables the feature FacetData and frees the related memory
  29093. * @returns the current mesh
  29094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29095. */
  29096. disableFacetData(): AbstractMesh;
  29097. /**
  29098. * Updates the AbstractMesh indices array
  29099. * @param indices defines the data source
  29100. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29101. * @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)
  29102. * @returns the current mesh
  29103. */
  29104. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29105. /**
  29106. * Creates new normals data for the mesh
  29107. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29108. * @returns the current mesh
  29109. */
  29110. createNormals(updatable: boolean): AbstractMesh;
  29111. /**
  29112. * Align the mesh with a normal
  29113. * @param normal defines the normal to use
  29114. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29115. * @returns the current mesh
  29116. */
  29117. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29118. /** @hidden */
  29119. _checkOcclusionQuery(): boolean;
  29120. /**
  29121. * Disables the mesh edge rendering mode
  29122. * @returns the currentAbstractMesh
  29123. */
  29124. disableEdgesRendering(): AbstractMesh;
  29125. /**
  29126. * Enables the edge rendering mode on the mesh.
  29127. * This mode makes the mesh edges visible
  29128. * @param epsilon defines the maximal distance between two angles to detect a face
  29129. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29130. * @returns the currentAbstractMesh
  29131. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29132. */
  29133. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29134. }
  29135. }
  29136. declare module BABYLON {
  29137. /**
  29138. * Interface used to define ActionEvent
  29139. */
  29140. export interface IActionEvent {
  29141. /** The mesh or sprite that triggered the action */
  29142. source: any;
  29143. /** The X mouse cursor position at the time of the event */
  29144. pointerX: number;
  29145. /** The Y mouse cursor position at the time of the event */
  29146. pointerY: number;
  29147. /** The mesh that is currently pointed at (can be null) */
  29148. meshUnderPointer: Nullable<AbstractMesh>;
  29149. /** the original (browser) event that triggered the ActionEvent */
  29150. sourceEvent?: any;
  29151. /** additional data for the event */
  29152. additionalData?: any;
  29153. }
  29154. /**
  29155. * ActionEvent is the event being sent when an action is triggered.
  29156. */
  29157. export class ActionEvent implements IActionEvent {
  29158. /** The mesh or sprite that triggered the action */
  29159. source: any;
  29160. /** The X mouse cursor position at the time of the event */
  29161. pointerX: number;
  29162. /** The Y mouse cursor position at the time of the event */
  29163. pointerY: number;
  29164. /** The mesh that is currently pointed at (can be null) */
  29165. meshUnderPointer: Nullable<AbstractMesh>;
  29166. /** the original (browser) event that triggered the ActionEvent */
  29167. sourceEvent?: any;
  29168. /** additional data for the event */
  29169. additionalData?: any;
  29170. /**
  29171. * Creates a new ActionEvent
  29172. * @param source The mesh or sprite that triggered the action
  29173. * @param pointerX The X mouse cursor position at the time of the event
  29174. * @param pointerY The Y mouse cursor position at the time of the event
  29175. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29176. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29177. * @param additionalData additional data for the event
  29178. */
  29179. constructor(
  29180. /** The mesh or sprite that triggered the action */
  29181. source: any,
  29182. /** The X mouse cursor position at the time of the event */
  29183. pointerX: number,
  29184. /** The Y mouse cursor position at the time of the event */
  29185. pointerY: number,
  29186. /** The mesh that is currently pointed at (can be null) */
  29187. meshUnderPointer: Nullable<AbstractMesh>,
  29188. /** the original (browser) event that triggered the ActionEvent */
  29189. sourceEvent?: any,
  29190. /** additional data for the event */
  29191. additionalData?: any);
  29192. /**
  29193. * Helper function to auto-create an ActionEvent from a source mesh.
  29194. * @param source The source mesh that triggered the event
  29195. * @param evt The original (browser) event
  29196. * @param additionalData additional data for the event
  29197. * @returns the new ActionEvent
  29198. */
  29199. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29200. /**
  29201. * Helper function to auto-create an ActionEvent from a source sprite
  29202. * @param source The source sprite that triggered the event
  29203. * @param scene Scene associated with the sprite
  29204. * @param evt The original (browser) event
  29205. * @param additionalData additional data for the event
  29206. * @returns the new ActionEvent
  29207. */
  29208. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29209. /**
  29210. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29211. * @param scene the scene where the event occurred
  29212. * @param evt The original (browser) event
  29213. * @returns the new ActionEvent
  29214. */
  29215. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29216. /**
  29217. * Helper function to auto-create an ActionEvent from a primitive
  29218. * @param prim defines the target primitive
  29219. * @param pointerPos defines the pointer position
  29220. * @param evt The original (browser) event
  29221. * @param additionalData additional data for the event
  29222. * @returns the new ActionEvent
  29223. */
  29224. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29225. }
  29226. }
  29227. declare module BABYLON {
  29228. /**
  29229. * Abstract class used to decouple action Manager from scene and meshes.
  29230. * Do not instantiate.
  29231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29232. */
  29233. export abstract class AbstractActionManager implements IDisposable {
  29234. /** Gets the list of active triggers */
  29235. static Triggers: {
  29236. [key: string]: number;
  29237. };
  29238. /** Gets the cursor to use when hovering items */
  29239. hoverCursor: string;
  29240. /** Gets the list of actions */
  29241. actions: IAction[];
  29242. /**
  29243. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29244. */
  29245. isRecursive: boolean;
  29246. /**
  29247. * Releases all associated resources
  29248. */
  29249. abstract dispose(): void;
  29250. /**
  29251. * Does this action manager has pointer triggers
  29252. */
  29253. abstract get hasPointerTriggers(): boolean;
  29254. /**
  29255. * Does this action manager has pick triggers
  29256. */
  29257. abstract get hasPickTriggers(): boolean;
  29258. /**
  29259. * Process a specific trigger
  29260. * @param trigger defines the trigger to process
  29261. * @param evt defines the event details to be processed
  29262. */
  29263. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29264. /**
  29265. * Does this action manager handles actions of any of the given triggers
  29266. * @param triggers defines the triggers to be tested
  29267. * @return a boolean indicating whether one (or more) of the triggers is handled
  29268. */
  29269. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29270. /**
  29271. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29272. * speed.
  29273. * @param triggerA defines the trigger to be tested
  29274. * @param triggerB defines the trigger to be tested
  29275. * @return a boolean indicating whether one (or more) of the triggers is handled
  29276. */
  29277. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29278. /**
  29279. * Does this action manager handles actions of a given trigger
  29280. * @param trigger defines the trigger to be tested
  29281. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29282. * @return whether the trigger is handled
  29283. */
  29284. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29285. /**
  29286. * Serialize this manager to a JSON object
  29287. * @param name defines the property name to store this manager
  29288. * @returns a JSON representation of this manager
  29289. */
  29290. abstract serialize(name: string): any;
  29291. /**
  29292. * Registers an action to this action manager
  29293. * @param action defines the action to be registered
  29294. * @return the action amended (prepared) after registration
  29295. */
  29296. abstract registerAction(action: IAction): Nullable<IAction>;
  29297. /**
  29298. * Unregisters an action to this action manager
  29299. * @param action defines the action to be unregistered
  29300. * @return a boolean indicating whether the action has been unregistered
  29301. */
  29302. abstract unregisterAction(action: IAction): Boolean;
  29303. /**
  29304. * Does exist one action manager with at least one trigger
  29305. **/
  29306. static get HasTriggers(): boolean;
  29307. /**
  29308. * Does exist one action manager with at least one pick trigger
  29309. **/
  29310. static get HasPickTriggers(): boolean;
  29311. /**
  29312. * Does exist one action manager that handles actions of a given trigger
  29313. * @param trigger defines the trigger to be tested
  29314. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29315. **/
  29316. static HasSpecificTrigger(trigger: number): boolean;
  29317. }
  29318. }
  29319. declare module BABYLON {
  29320. /**
  29321. * Defines how a node can be built from a string name.
  29322. */
  29323. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29324. /**
  29325. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29326. */
  29327. export class Node implements IBehaviorAware<Node> {
  29328. /** @hidden */
  29329. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29330. private static _NodeConstructors;
  29331. /**
  29332. * Add a new node constructor
  29333. * @param type defines the type name of the node to construct
  29334. * @param constructorFunc defines the constructor function
  29335. */
  29336. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29337. /**
  29338. * Returns a node constructor based on type name
  29339. * @param type defines the type name
  29340. * @param name defines the new node name
  29341. * @param scene defines the hosting scene
  29342. * @param options defines optional options to transmit to constructors
  29343. * @returns the new constructor or null
  29344. */
  29345. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29346. /**
  29347. * Gets or sets the name of the node
  29348. */
  29349. name: string;
  29350. /**
  29351. * Gets or sets the id of the node
  29352. */
  29353. id: string;
  29354. /**
  29355. * Gets or sets the unique id of the node
  29356. */
  29357. uniqueId: number;
  29358. /**
  29359. * Gets or sets a string used to store user defined state for the node
  29360. */
  29361. state: string;
  29362. /**
  29363. * Gets or sets an object used to store user defined information for the node
  29364. */
  29365. metadata: any;
  29366. /**
  29367. * For internal use only. Please do not use.
  29368. */
  29369. reservedDataStore: any;
  29370. /**
  29371. * List of inspectable custom properties (used by the Inspector)
  29372. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29373. */
  29374. inspectableCustomProperties: IInspectable[];
  29375. private _doNotSerialize;
  29376. /**
  29377. * Gets or sets a boolean used to define if the node must be serialized
  29378. */
  29379. get doNotSerialize(): boolean;
  29380. set doNotSerialize(value: boolean);
  29381. /** @hidden */
  29382. _isDisposed: boolean;
  29383. /**
  29384. * Gets a list of Animations associated with the node
  29385. */
  29386. animations: Animation[];
  29387. protected _ranges: {
  29388. [name: string]: Nullable<AnimationRange>;
  29389. };
  29390. /**
  29391. * Callback raised when the node is ready to be used
  29392. */
  29393. onReady: Nullable<(node: Node) => void>;
  29394. private _isEnabled;
  29395. private _isParentEnabled;
  29396. private _isReady;
  29397. /** @hidden */
  29398. _currentRenderId: number;
  29399. private _parentUpdateId;
  29400. /** @hidden */
  29401. _childUpdateId: number;
  29402. /** @hidden */
  29403. _waitingParentId: Nullable<string>;
  29404. /** @hidden */
  29405. _scene: Scene;
  29406. /** @hidden */
  29407. _cache: any;
  29408. private _parentNode;
  29409. private _children;
  29410. /** @hidden */
  29411. _worldMatrix: Matrix;
  29412. /** @hidden */
  29413. _worldMatrixDeterminant: number;
  29414. /** @hidden */
  29415. _worldMatrixDeterminantIsDirty: boolean;
  29416. /** @hidden */
  29417. private _sceneRootNodesIndex;
  29418. /**
  29419. * Gets a boolean indicating if the node has been disposed
  29420. * @returns true if the node was disposed
  29421. */
  29422. isDisposed(): boolean;
  29423. /**
  29424. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29425. * @see https://doc.babylonjs.com/how_to/parenting
  29426. */
  29427. set parent(parent: Nullable<Node>);
  29428. get parent(): Nullable<Node>;
  29429. /** @hidden */
  29430. _addToSceneRootNodes(): void;
  29431. /** @hidden */
  29432. _removeFromSceneRootNodes(): void;
  29433. private _animationPropertiesOverride;
  29434. /**
  29435. * Gets or sets the animation properties override
  29436. */
  29437. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29438. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29439. /**
  29440. * Gets a string idenfifying the name of the class
  29441. * @returns "Node" string
  29442. */
  29443. getClassName(): string;
  29444. /** @hidden */
  29445. readonly _isNode: boolean;
  29446. /**
  29447. * An event triggered when the mesh is disposed
  29448. */
  29449. onDisposeObservable: Observable<Node>;
  29450. private _onDisposeObserver;
  29451. /**
  29452. * Sets a callback that will be raised when the node will be disposed
  29453. */
  29454. set onDispose(callback: () => void);
  29455. /**
  29456. * Creates a new Node
  29457. * @param name the name and id to be given to this node
  29458. * @param scene the scene this node will be added to
  29459. */
  29460. constructor(name: string, scene?: Nullable<Scene>);
  29461. /**
  29462. * Gets the scene of the node
  29463. * @returns a scene
  29464. */
  29465. getScene(): Scene;
  29466. /**
  29467. * Gets the engine of the node
  29468. * @returns a Engine
  29469. */
  29470. getEngine(): Engine;
  29471. private _behaviors;
  29472. /**
  29473. * Attach a behavior to the node
  29474. * @see http://doc.babylonjs.com/features/behaviour
  29475. * @param behavior defines the behavior to attach
  29476. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29477. * @returns the current Node
  29478. */
  29479. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29480. /**
  29481. * Remove an attached behavior
  29482. * @see http://doc.babylonjs.com/features/behaviour
  29483. * @param behavior defines the behavior to attach
  29484. * @returns the current Node
  29485. */
  29486. removeBehavior(behavior: Behavior<Node>): Node;
  29487. /**
  29488. * Gets the list of attached behaviors
  29489. * @see http://doc.babylonjs.com/features/behaviour
  29490. */
  29491. get behaviors(): Behavior<Node>[];
  29492. /**
  29493. * Gets an attached behavior by name
  29494. * @param name defines the name of the behavior to look for
  29495. * @see http://doc.babylonjs.com/features/behaviour
  29496. * @returns null if behavior was not found else the requested behavior
  29497. */
  29498. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29499. /**
  29500. * Returns the latest update of the World matrix
  29501. * @returns a Matrix
  29502. */
  29503. getWorldMatrix(): Matrix;
  29504. /** @hidden */
  29505. _getWorldMatrixDeterminant(): number;
  29506. /**
  29507. * Returns directly the latest state of the mesh World matrix.
  29508. * A Matrix is returned.
  29509. */
  29510. get worldMatrixFromCache(): Matrix;
  29511. /** @hidden */
  29512. _initCache(): void;
  29513. /** @hidden */
  29514. updateCache(force?: boolean): void;
  29515. /** @hidden */
  29516. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29517. /** @hidden */
  29518. _updateCache(ignoreParentClass?: boolean): void;
  29519. /** @hidden */
  29520. _isSynchronized(): boolean;
  29521. /** @hidden */
  29522. _markSyncedWithParent(): void;
  29523. /** @hidden */
  29524. isSynchronizedWithParent(): boolean;
  29525. /** @hidden */
  29526. isSynchronized(): boolean;
  29527. /**
  29528. * Is this node ready to be used/rendered
  29529. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29530. * @return true if the node is ready
  29531. */
  29532. isReady(completeCheck?: boolean): boolean;
  29533. /**
  29534. * Is this node enabled?
  29535. * 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
  29536. * @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
  29537. * @return whether this node (and its parent) is enabled
  29538. */
  29539. isEnabled(checkAncestors?: boolean): boolean;
  29540. /** @hidden */
  29541. protected _syncParentEnabledState(): void;
  29542. /**
  29543. * Set the enabled state of this node
  29544. * @param value defines the new enabled state
  29545. */
  29546. setEnabled(value: boolean): void;
  29547. /**
  29548. * Is this node a descendant of the given node?
  29549. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29550. * @param ancestor defines the parent node to inspect
  29551. * @returns a boolean indicating if this node is a descendant of the given node
  29552. */
  29553. isDescendantOf(ancestor: Node): boolean;
  29554. /** @hidden */
  29555. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29556. /**
  29557. * Will return all nodes that have this node as ascendant
  29558. * @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
  29559. * @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
  29560. * @return all children nodes of all types
  29561. */
  29562. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29563. /**
  29564. * Get all child-meshes of this node
  29565. * @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)
  29566. * @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
  29567. * @returns an array of AbstractMesh
  29568. */
  29569. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29570. /**
  29571. * Get all direct children of this node
  29572. * @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
  29573. * @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)
  29574. * @returns an array of Node
  29575. */
  29576. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29577. /** @hidden */
  29578. _setReady(state: boolean): void;
  29579. /**
  29580. * Get an animation by name
  29581. * @param name defines the name of the animation to look for
  29582. * @returns null if not found else the requested animation
  29583. */
  29584. getAnimationByName(name: string): Nullable<Animation>;
  29585. /**
  29586. * Creates an animation range for this node
  29587. * @param name defines the name of the range
  29588. * @param from defines the starting key
  29589. * @param to defines the end key
  29590. */
  29591. createAnimationRange(name: string, from: number, to: number): void;
  29592. /**
  29593. * Delete a specific animation range
  29594. * @param name defines the name of the range to delete
  29595. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29596. */
  29597. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29598. /**
  29599. * Get an animation range by name
  29600. * @param name defines the name of the animation range to look for
  29601. * @returns null if not found else the requested animation range
  29602. */
  29603. getAnimationRange(name: string): Nullable<AnimationRange>;
  29604. /**
  29605. * Gets the list of all animation ranges defined on this node
  29606. * @returns an array
  29607. */
  29608. getAnimationRanges(): Nullable<AnimationRange>[];
  29609. /**
  29610. * Will start the animation sequence
  29611. * @param name defines the range frames for animation sequence
  29612. * @param loop defines if the animation should loop (false by default)
  29613. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29614. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29615. * @returns the object created for this animation. If range does not exist, it will return null
  29616. */
  29617. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29618. /**
  29619. * Serialize animation ranges into a JSON compatible object
  29620. * @returns serialization object
  29621. */
  29622. serializeAnimationRanges(): any;
  29623. /**
  29624. * Computes the world matrix of the node
  29625. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29626. * @returns the world matrix
  29627. */
  29628. computeWorldMatrix(force?: boolean): Matrix;
  29629. /**
  29630. * Releases resources associated with this node.
  29631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29633. */
  29634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29635. /**
  29636. * Parse animation range data from a serialization object and store them into a given node
  29637. * @param node defines where to store the animation ranges
  29638. * @param parsedNode defines the serialization object to read data from
  29639. * @param scene defines the hosting scene
  29640. */
  29641. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29642. /**
  29643. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29644. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29645. * @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
  29646. * @returns the new bounding vectors
  29647. */
  29648. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29649. min: Vector3;
  29650. max: Vector3;
  29651. };
  29652. }
  29653. }
  29654. declare module BABYLON {
  29655. /**
  29656. * @hidden
  29657. */
  29658. export class _IAnimationState {
  29659. key: number;
  29660. repeatCount: number;
  29661. workValue?: any;
  29662. loopMode?: number;
  29663. offsetValue?: any;
  29664. highLimitValue?: any;
  29665. }
  29666. /**
  29667. * Class used to store any kind of animation
  29668. */
  29669. export class Animation {
  29670. /**Name of the animation */
  29671. name: string;
  29672. /**Property to animate */
  29673. targetProperty: string;
  29674. /**The frames per second of the animation */
  29675. framePerSecond: number;
  29676. /**The data type of the animation */
  29677. dataType: number;
  29678. /**The loop mode of the animation */
  29679. loopMode?: number | undefined;
  29680. /**Specifies if blending should be enabled */
  29681. enableBlending?: boolean | undefined;
  29682. /**
  29683. * Use matrix interpolation instead of using direct key value when animating matrices
  29684. */
  29685. static AllowMatricesInterpolation: boolean;
  29686. /**
  29687. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29688. */
  29689. static AllowMatrixDecomposeForInterpolation: boolean;
  29690. /**
  29691. * Stores the key frames of the animation
  29692. */
  29693. private _keys;
  29694. /**
  29695. * Stores the easing function of the animation
  29696. */
  29697. private _easingFunction;
  29698. /**
  29699. * @hidden Internal use only
  29700. */
  29701. _runtimeAnimations: RuntimeAnimation[];
  29702. /**
  29703. * The set of event that will be linked to this animation
  29704. */
  29705. private _events;
  29706. /**
  29707. * Stores an array of target property paths
  29708. */
  29709. targetPropertyPath: string[];
  29710. /**
  29711. * Stores the blending speed of the animation
  29712. */
  29713. blendingSpeed: number;
  29714. /**
  29715. * Stores the animation ranges for the animation
  29716. */
  29717. private _ranges;
  29718. /**
  29719. * @hidden Internal use
  29720. */
  29721. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29722. /**
  29723. * Sets up an animation
  29724. * @param property The property to animate
  29725. * @param animationType The animation type to apply
  29726. * @param framePerSecond The frames per second of the animation
  29727. * @param easingFunction The easing function used in the animation
  29728. * @returns The created animation
  29729. */
  29730. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29731. /**
  29732. * Create and start an animation on a node
  29733. * @param name defines the name of the global animation that will be run on all nodes
  29734. * @param node defines the root node where the animation will take place
  29735. * @param targetProperty defines property to animate
  29736. * @param framePerSecond defines the number of frame per second yo use
  29737. * @param totalFrame defines the number of frames in total
  29738. * @param from defines the initial value
  29739. * @param to defines the final value
  29740. * @param loopMode defines which loop mode you want to use (off by default)
  29741. * @param easingFunction defines the easing function to use (linear by default)
  29742. * @param onAnimationEnd defines the callback to call when animation end
  29743. * @returns the animatable created for this animation
  29744. */
  29745. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29746. /**
  29747. * Create and start an animation on a node and its descendants
  29748. * @param name defines the name of the global animation that will be run on all nodes
  29749. * @param node defines the root node where the animation will take place
  29750. * @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
  29751. * @param targetProperty defines property to animate
  29752. * @param framePerSecond defines the number of frame per second to use
  29753. * @param totalFrame defines the number of frames in total
  29754. * @param from defines the initial value
  29755. * @param to defines the final value
  29756. * @param loopMode defines which loop mode you want to use (off by default)
  29757. * @param easingFunction defines the easing function to use (linear by default)
  29758. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29759. * @returns the list of animatables created for all nodes
  29760. * @example https://www.babylonjs-playground.com/#MH0VLI
  29761. */
  29762. 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[]>;
  29763. /**
  29764. * Creates a new animation, merges it with the existing animations and starts it
  29765. * @param name Name of the animation
  29766. * @param node Node which contains the scene that begins the animations
  29767. * @param targetProperty Specifies which property to animate
  29768. * @param framePerSecond The frames per second of the animation
  29769. * @param totalFrame The total number of frames
  29770. * @param from The frame at the beginning of the animation
  29771. * @param to The frame at the end of the animation
  29772. * @param loopMode Specifies the loop mode of the animation
  29773. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29774. * @param onAnimationEnd Callback to run once the animation is complete
  29775. * @returns Nullable animation
  29776. */
  29777. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29778. /**
  29779. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29780. * @param sourceAnimation defines the Animation containing keyframes to convert
  29781. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29782. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29783. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29784. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29785. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29786. */
  29787. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29788. /**
  29789. * Transition property of an host to the target Value
  29790. * @param property The property to transition
  29791. * @param targetValue The target Value of the property
  29792. * @param host The object where the property to animate belongs
  29793. * @param scene Scene used to run the animation
  29794. * @param frameRate Framerate (in frame/s) to use
  29795. * @param transition The transition type we want to use
  29796. * @param duration The duration of the animation, in milliseconds
  29797. * @param onAnimationEnd Callback trigger at the end of the animation
  29798. * @returns Nullable animation
  29799. */
  29800. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29801. /**
  29802. * Return the array of runtime animations currently using this animation
  29803. */
  29804. get runtimeAnimations(): RuntimeAnimation[];
  29805. /**
  29806. * Specifies if any of the runtime animations are currently running
  29807. */
  29808. get hasRunningRuntimeAnimations(): boolean;
  29809. /**
  29810. * Initializes the animation
  29811. * @param name Name of the animation
  29812. * @param targetProperty Property to animate
  29813. * @param framePerSecond The frames per second of the animation
  29814. * @param dataType The data type of the animation
  29815. * @param loopMode The loop mode of the animation
  29816. * @param enableBlending Specifies if blending should be enabled
  29817. */
  29818. constructor(
  29819. /**Name of the animation */
  29820. name: string,
  29821. /**Property to animate */
  29822. targetProperty: string,
  29823. /**The frames per second of the animation */
  29824. framePerSecond: number,
  29825. /**The data type of the animation */
  29826. dataType: number,
  29827. /**The loop mode of the animation */
  29828. loopMode?: number | undefined,
  29829. /**Specifies if blending should be enabled */
  29830. enableBlending?: boolean | undefined);
  29831. /**
  29832. * Converts the animation to a string
  29833. * @param fullDetails support for multiple levels of logging within scene loading
  29834. * @returns String form of the animation
  29835. */
  29836. toString(fullDetails?: boolean): string;
  29837. /**
  29838. * Add an event to this animation
  29839. * @param event Event to add
  29840. */
  29841. addEvent(event: AnimationEvent): void;
  29842. /**
  29843. * Remove all events found at the given frame
  29844. * @param frame The frame to remove events from
  29845. */
  29846. removeEvents(frame: number): void;
  29847. /**
  29848. * Retrieves all the events from the animation
  29849. * @returns Events from the animation
  29850. */
  29851. getEvents(): AnimationEvent[];
  29852. /**
  29853. * Creates an animation range
  29854. * @param name Name of the animation range
  29855. * @param from Starting frame of the animation range
  29856. * @param to Ending frame of the animation
  29857. */
  29858. createRange(name: string, from: number, to: number): void;
  29859. /**
  29860. * Deletes an animation range by name
  29861. * @param name Name of the animation range to delete
  29862. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29863. */
  29864. deleteRange(name: string, deleteFrames?: boolean): void;
  29865. /**
  29866. * Gets the animation range by name, or null if not defined
  29867. * @param name Name of the animation range
  29868. * @returns Nullable animation range
  29869. */
  29870. getRange(name: string): Nullable<AnimationRange>;
  29871. /**
  29872. * Gets the key frames from the animation
  29873. * @returns The key frames of the animation
  29874. */
  29875. getKeys(): Array<IAnimationKey>;
  29876. /**
  29877. * Gets the highest frame rate of the animation
  29878. * @returns Highest frame rate of the animation
  29879. */
  29880. getHighestFrame(): number;
  29881. /**
  29882. * Gets the easing function of the animation
  29883. * @returns Easing function of the animation
  29884. */
  29885. getEasingFunction(): IEasingFunction;
  29886. /**
  29887. * Sets the easing function of the animation
  29888. * @param easingFunction A custom mathematical formula for animation
  29889. */
  29890. setEasingFunction(easingFunction: EasingFunction): void;
  29891. /**
  29892. * Interpolates a scalar linearly
  29893. * @param startValue Start value of the animation curve
  29894. * @param endValue End value of the animation curve
  29895. * @param gradient Scalar amount to interpolate
  29896. * @returns Interpolated scalar value
  29897. */
  29898. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29899. /**
  29900. * Interpolates a scalar cubically
  29901. * @param startValue Start value of the animation curve
  29902. * @param outTangent End tangent of the animation
  29903. * @param endValue End value of the animation curve
  29904. * @param inTangent Start tangent of the animation curve
  29905. * @param gradient Scalar amount to interpolate
  29906. * @returns Interpolated scalar value
  29907. */
  29908. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29909. /**
  29910. * Interpolates a quaternion using a spherical linear interpolation
  29911. * @param startValue Start value of the animation curve
  29912. * @param endValue End value of the animation curve
  29913. * @param gradient Scalar amount to interpolate
  29914. * @returns Interpolated quaternion value
  29915. */
  29916. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29917. /**
  29918. * Interpolates a quaternion cubically
  29919. * @param startValue Start value of the animation curve
  29920. * @param outTangent End tangent of the animation curve
  29921. * @param endValue End value of the animation curve
  29922. * @param inTangent Start tangent of the animation curve
  29923. * @param gradient Scalar amount to interpolate
  29924. * @returns Interpolated quaternion value
  29925. */
  29926. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29927. /**
  29928. * Interpolates a Vector3 linearl
  29929. * @param startValue Start value of the animation curve
  29930. * @param endValue End value of the animation curve
  29931. * @param gradient Scalar amount to interpolate
  29932. * @returns Interpolated scalar value
  29933. */
  29934. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29935. /**
  29936. * Interpolates a Vector3 cubically
  29937. * @param startValue Start value of the animation curve
  29938. * @param outTangent End tangent of the animation
  29939. * @param endValue End value of the animation curve
  29940. * @param inTangent Start tangent of the animation curve
  29941. * @param gradient Scalar amount to interpolate
  29942. * @returns InterpolatedVector3 value
  29943. */
  29944. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29945. /**
  29946. * Interpolates a Vector2 linearly
  29947. * @param startValue Start value of the animation curve
  29948. * @param endValue End value of the animation curve
  29949. * @param gradient Scalar amount to interpolate
  29950. * @returns Interpolated Vector2 value
  29951. */
  29952. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29953. /**
  29954. * Interpolates a Vector2 cubically
  29955. * @param startValue Start value of the animation curve
  29956. * @param outTangent End tangent of the animation
  29957. * @param endValue End value of the animation curve
  29958. * @param inTangent Start tangent of the animation curve
  29959. * @param gradient Scalar amount to interpolate
  29960. * @returns Interpolated Vector2 value
  29961. */
  29962. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29963. /**
  29964. * Interpolates a size linearly
  29965. * @param startValue Start value of the animation curve
  29966. * @param endValue End value of the animation curve
  29967. * @param gradient Scalar amount to interpolate
  29968. * @returns Interpolated Size value
  29969. */
  29970. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29971. /**
  29972. * Interpolates a Color3 linearly
  29973. * @param startValue Start value of the animation curve
  29974. * @param endValue End value of the animation curve
  29975. * @param gradient Scalar amount to interpolate
  29976. * @returns Interpolated Color3 value
  29977. */
  29978. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29979. /**
  29980. * Interpolates a Color4 linearly
  29981. * @param startValue Start value of the animation curve
  29982. * @param endValue End value of the animation curve
  29983. * @param gradient Scalar amount to interpolate
  29984. * @returns Interpolated Color3 value
  29985. */
  29986. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29987. /**
  29988. * @hidden Internal use only
  29989. */
  29990. _getKeyValue(value: any): any;
  29991. /**
  29992. * @hidden Internal use only
  29993. */
  29994. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29995. /**
  29996. * Defines the function to use to interpolate matrices
  29997. * @param startValue defines the start matrix
  29998. * @param endValue defines the end matrix
  29999. * @param gradient defines the gradient between both matrices
  30000. * @param result defines an optional target matrix where to store the interpolation
  30001. * @returns the interpolated matrix
  30002. */
  30003. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30004. /**
  30005. * Makes a copy of the animation
  30006. * @returns Cloned animation
  30007. */
  30008. clone(): Animation;
  30009. /**
  30010. * Sets the key frames of the animation
  30011. * @param values The animation key frames to set
  30012. */
  30013. setKeys(values: Array<IAnimationKey>): void;
  30014. /**
  30015. * Serializes the animation to an object
  30016. * @returns Serialized object
  30017. */
  30018. serialize(): any;
  30019. /**
  30020. * Float animation type
  30021. */
  30022. static readonly ANIMATIONTYPE_FLOAT: number;
  30023. /**
  30024. * Vector3 animation type
  30025. */
  30026. static readonly ANIMATIONTYPE_VECTOR3: number;
  30027. /**
  30028. * Quaternion animation type
  30029. */
  30030. static readonly ANIMATIONTYPE_QUATERNION: number;
  30031. /**
  30032. * Matrix animation type
  30033. */
  30034. static readonly ANIMATIONTYPE_MATRIX: number;
  30035. /**
  30036. * Color3 animation type
  30037. */
  30038. static readonly ANIMATIONTYPE_COLOR3: number;
  30039. /**
  30040. * Color3 animation type
  30041. */
  30042. static readonly ANIMATIONTYPE_COLOR4: number;
  30043. /**
  30044. * Vector2 animation type
  30045. */
  30046. static readonly ANIMATIONTYPE_VECTOR2: number;
  30047. /**
  30048. * Size animation type
  30049. */
  30050. static readonly ANIMATIONTYPE_SIZE: number;
  30051. /**
  30052. * Relative Loop Mode
  30053. */
  30054. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30055. /**
  30056. * Cycle Loop Mode
  30057. */
  30058. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30059. /**
  30060. * Constant Loop Mode
  30061. */
  30062. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30063. /** @hidden */
  30064. static _UniversalLerp(left: any, right: any, amount: number): any;
  30065. /**
  30066. * Parses an animation object and creates an animation
  30067. * @param parsedAnimation Parsed animation object
  30068. * @returns Animation object
  30069. */
  30070. static Parse(parsedAnimation: any): Animation;
  30071. /**
  30072. * Appends the serialized animations from the source animations
  30073. * @param source Source containing the animations
  30074. * @param destination Target to store the animations
  30075. */
  30076. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30077. }
  30078. }
  30079. declare module BABYLON {
  30080. /**
  30081. * Interface containing an array of animations
  30082. */
  30083. export interface IAnimatable {
  30084. /**
  30085. * Array of animations
  30086. */
  30087. animations: Nullable<Array<Animation>>;
  30088. }
  30089. }
  30090. declare module BABYLON {
  30091. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30092. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30093. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30094. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30095. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30096. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30097. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30098. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30099. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30100. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30101. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30102. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30103. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30104. /**
  30105. * Decorator used to define property that can be serialized as reference to a camera
  30106. * @param sourceName defines the name of the property to decorate
  30107. */
  30108. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30109. /**
  30110. * Class used to help serialization objects
  30111. */
  30112. export class SerializationHelper {
  30113. /** @hidden */
  30114. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30115. /** @hidden */
  30116. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30117. /** @hidden */
  30118. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30119. /** @hidden */
  30120. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30121. /**
  30122. * Appends the serialized animations from the source animations
  30123. * @param source Source containing the animations
  30124. * @param destination Target to store the animations
  30125. */
  30126. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30127. /**
  30128. * Static function used to serialized a specific entity
  30129. * @param entity defines the entity to serialize
  30130. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30131. * @returns a JSON compatible object representing the serialization of the entity
  30132. */
  30133. static Serialize<T>(entity: T, serializationObject?: any): any;
  30134. /**
  30135. * Creates a new entity from a serialization data object
  30136. * @param creationFunction defines a function used to instanciated the new entity
  30137. * @param source defines the source serialization data
  30138. * @param scene defines the hosting scene
  30139. * @param rootUrl defines the root url for resources
  30140. * @returns a new entity
  30141. */
  30142. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30143. /**
  30144. * Clones an object
  30145. * @param creationFunction defines the function used to instanciate the new object
  30146. * @param source defines the source object
  30147. * @returns the cloned object
  30148. */
  30149. static Clone<T>(creationFunction: () => T, source: T): T;
  30150. /**
  30151. * Instanciates a new object based on a source one (some data will be shared between both object)
  30152. * @param creationFunction defines the function used to instanciate the new object
  30153. * @param source defines the source object
  30154. * @returns the new object
  30155. */
  30156. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30157. }
  30158. }
  30159. declare module BABYLON {
  30160. /**
  30161. * Base class of all the textures in babylon.
  30162. * It groups all the common properties the materials, post process, lights... might need
  30163. * in order to make a correct use of the texture.
  30164. */
  30165. export class BaseTexture implements IAnimatable {
  30166. /**
  30167. * Default anisotropic filtering level for the application.
  30168. * It is set to 4 as a good tradeoff between perf and quality.
  30169. */
  30170. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30171. /**
  30172. * Gets or sets the unique id of the texture
  30173. */
  30174. uniqueId: number;
  30175. /**
  30176. * Define the name of the texture.
  30177. */
  30178. name: string;
  30179. /**
  30180. * Gets or sets an object used to store user defined information.
  30181. */
  30182. metadata: any;
  30183. /**
  30184. * For internal use only. Please do not use.
  30185. */
  30186. reservedDataStore: any;
  30187. private _hasAlpha;
  30188. /**
  30189. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30190. */
  30191. set hasAlpha(value: boolean);
  30192. get hasAlpha(): boolean;
  30193. /**
  30194. * Defines if the alpha value should be determined via the rgb values.
  30195. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30196. */
  30197. getAlphaFromRGB: boolean;
  30198. /**
  30199. * Intensity or strength of the texture.
  30200. * It is commonly used by materials to fine tune the intensity of the texture
  30201. */
  30202. level: number;
  30203. /**
  30204. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30205. * This is part of the texture as textures usually maps to one uv set.
  30206. */
  30207. coordinatesIndex: number;
  30208. private _coordinatesMode;
  30209. /**
  30210. * How a texture is mapped.
  30211. *
  30212. * | Value | Type | Description |
  30213. * | ----- | ----------------------------------- | ----------- |
  30214. * | 0 | EXPLICIT_MODE | |
  30215. * | 1 | SPHERICAL_MODE | |
  30216. * | 2 | PLANAR_MODE | |
  30217. * | 3 | CUBIC_MODE | |
  30218. * | 4 | PROJECTION_MODE | |
  30219. * | 5 | SKYBOX_MODE | |
  30220. * | 6 | INVCUBIC_MODE | |
  30221. * | 7 | EQUIRECTANGULAR_MODE | |
  30222. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30223. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30224. */
  30225. set coordinatesMode(value: number);
  30226. get coordinatesMode(): number;
  30227. /**
  30228. * | Value | Type | Description |
  30229. * | ----- | ------------------ | ----------- |
  30230. * | 0 | CLAMP_ADDRESSMODE | |
  30231. * | 1 | WRAP_ADDRESSMODE | |
  30232. * | 2 | MIRROR_ADDRESSMODE | |
  30233. */
  30234. wrapU: number;
  30235. /**
  30236. * | Value | Type | Description |
  30237. * | ----- | ------------------ | ----------- |
  30238. * | 0 | CLAMP_ADDRESSMODE | |
  30239. * | 1 | WRAP_ADDRESSMODE | |
  30240. * | 2 | MIRROR_ADDRESSMODE | |
  30241. */
  30242. wrapV: number;
  30243. /**
  30244. * | Value | Type | Description |
  30245. * | ----- | ------------------ | ----------- |
  30246. * | 0 | CLAMP_ADDRESSMODE | |
  30247. * | 1 | WRAP_ADDRESSMODE | |
  30248. * | 2 | MIRROR_ADDRESSMODE | |
  30249. */
  30250. wrapR: number;
  30251. /**
  30252. * With compliant hardware and browser (supporting anisotropic filtering)
  30253. * this defines the level of anisotropic filtering in the texture.
  30254. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30255. */
  30256. anisotropicFilteringLevel: number;
  30257. /**
  30258. * Define if the texture is a cube texture or if false a 2d texture.
  30259. */
  30260. get isCube(): boolean;
  30261. set isCube(value: boolean);
  30262. /**
  30263. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30264. */
  30265. get is3D(): boolean;
  30266. set is3D(value: boolean);
  30267. /**
  30268. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30269. */
  30270. get is2DArray(): boolean;
  30271. set is2DArray(value: boolean);
  30272. /**
  30273. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30274. * HDR texture are usually stored in linear space.
  30275. * This only impacts the PBR and Background materials
  30276. */
  30277. gammaSpace: boolean;
  30278. /**
  30279. * Gets or sets whether or not the texture contains RGBD data.
  30280. */
  30281. get isRGBD(): boolean;
  30282. set isRGBD(value: boolean);
  30283. /**
  30284. * Is Z inverted in the texture (useful in a cube texture).
  30285. */
  30286. invertZ: boolean;
  30287. /**
  30288. * Are mip maps generated for this texture or not.
  30289. */
  30290. get noMipmap(): boolean;
  30291. /**
  30292. * @hidden
  30293. */
  30294. lodLevelInAlpha: boolean;
  30295. /**
  30296. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30297. */
  30298. get lodGenerationOffset(): number;
  30299. set lodGenerationOffset(value: number);
  30300. /**
  30301. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30302. */
  30303. get lodGenerationScale(): number;
  30304. set lodGenerationScale(value: number);
  30305. /**
  30306. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30307. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30308. * average roughness values.
  30309. */
  30310. get linearSpecularLOD(): boolean;
  30311. set linearSpecularLOD(value: boolean);
  30312. /**
  30313. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30314. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30315. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30316. */
  30317. get irradianceTexture(): Nullable<BaseTexture>;
  30318. set irradianceTexture(value: Nullable<BaseTexture>);
  30319. /**
  30320. * Define if the texture is a render target.
  30321. */
  30322. isRenderTarget: boolean;
  30323. /**
  30324. * Define the unique id of the texture in the scene.
  30325. */
  30326. get uid(): string;
  30327. /**
  30328. * Return a string representation of the texture.
  30329. * @returns the texture as a string
  30330. */
  30331. toString(): string;
  30332. /**
  30333. * Get the class name of the texture.
  30334. * @returns "BaseTexture"
  30335. */
  30336. getClassName(): string;
  30337. /**
  30338. * Define the list of animation attached to the texture.
  30339. */
  30340. animations: Animation[];
  30341. /**
  30342. * An event triggered when the texture is disposed.
  30343. */
  30344. onDisposeObservable: Observable<BaseTexture>;
  30345. private _onDisposeObserver;
  30346. /**
  30347. * Callback triggered when the texture has been disposed.
  30348. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30349. */
  30350. set onDispose(callback: () => void);
  30351. /**
  30352. * Define the current state of the loading sequence when in delayed load mode.
  30353. */
  30354. delayLoadState: number;
  30355. private _scene;
  30356. /** @hidden */
  30357. _texture: Nullable<InternalTexture>;
  30358. private _uid;
  30359. /**
  30360. * Define if the texture is preventinga material to render or not.
  30361. * If not and the texture is not ready, the engine will use a default black texture instead.
  30362. */
  30363. get isBlocking(): boolean;
  30364. /**
  30365. * Instantiates a new BaseTexture.
  30366. * Base class of all the textures in babylon.
  30367. * It groups all the common properties the materials, post process, lights... might need
  30368. * in order to make a correct use of the texture.
  30369. * @param scene Define the scene the texture blongs to
  30370. */
  30371. constructor(scene: Nullable<Scene>);
  30372. /**
  30373. * Get the scene the texture belongs to.
  30374. * @returns the scene or null if undefined
  30375. */
  30376. getScene(): Nullable<Scene>;
  30377. /**
  30378. * Get the texture transform matrix used to offset tile the texture for istance.
  30379. * @returns the transformation matrix
  30380. */
  30381. getTextureMatrix(): Matrix;
  30382. /**
  30383. * Get the texture reflection matrix used to rotate/transform the reflection.
  30384. * @returns the reflection matrix
  30385. */
  30386. getReflectionTextureMatrix(): Matrix;
  30387. /**
  30388. * Get the underlying lower level texture from Babylon.
  30389. * @returns the insternal texture
  30390. */
  30391. getInternalTexture(): Nullable<InternalTexture>;
  30392. /**
  30393. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30394. * @returns true if ready or not blocking
  30395. */
  30396. isReadyOrNotBlocking(): boolean;
  30397. /**
  30398. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30399. * @returns true if fully ready
  30400. */
  30401. isReady(): boolean;
  30402. private _cachedSize;
  30403. /**
  30404. * Get the size of the texture.
  30405. * @returns the texture size.
  30406. */
  30407. getSize(): ISize;
  30408. /**
  30409. * Get the base size of the texture.
  30410. * It can be different from the size if the texture has been resized for POT for instance
  30411. * @returns the base size
  30412. */
  30413. getBaseSize(): ISize;
  30414. /**
  30415. * Update the sampling mode of the texture.
  30416. * Default is Trilinear mode.
  30417. *
  30418. * | Value | Type | Description |
  30419. * | ----- | ------------------ | ----------- |
  30420. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30421. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30422. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30423. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30424. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30425. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30426. * | 7 | NEAREST_LINEAR | |
  30427. * | 8 | NEAREST_NEAREST | |
  30428. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30429. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30430. * | 11 | LINEAR_LINEAR | |
  30431. * | 12 | LINEAR_NEAREST | |
  30432. *
  30433. * > _mag_: magnification filter (close to the viewer)
  30434. * > _min_: minification filter (far from the viewer)
  30435. * > _mip_: filter used between mip map levels
  30436. *@param samplingMode Define the new sampling mode of the texture
  30437. */
  30438. updateSamplingMode(samplingMode: number): void;
  30439. /**
  30440. * Scales the texture if is `canRescale()`
  30441. * @param ratio the resize factor we want to use to rescale
  30442. */
  30443. scale(ratio: number): void;
  30444. /**
  30445. * Get if the texture can rescale.
  30446. */
  30447. get canRescale(): boolean;
  30448. /** @hidden */
  30449. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30450. /** @hidden */
  30451. _rebuild(): void;
  30452. /**
  30453. * Triggers the load sequence in delayed load mode.
  30454. */
  30455. delayLoad(): void;
  30456. /**
  30457. * Clones the texture.
  30458. * @returns the cloned texture
  30459. */
  30460. clone(): Nullable<BaseTexture>;
  30461. /**
  30462. * Get the texture underlying type (INT, FLOAT...)
  30463. */
  30464. get textureType(): number;
  30465. /**
  30466. * Get the texture underlying format (RGB, RGBA...)
  30467. */
  30468. get textureFormat(): number;
  30469. /**
  30470. * Indicates that textures need to be re-calculated for all materials
  30471. */
  30472. protected _markAllSubMeshesAsTexturesDirty(): void;
  30473. /**
  30474. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30475. * This will returns an RGBA array buffer containing either in values (0-255) or
  30476. * float values (0-1) depending of the underlying buffer type.
  30477. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30478. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30479. * @param buffer defines a user defined buffer to fill with data (can be null)
  30480. * @returns The Array buffer containing the pixels data.
  30481. */
  30482. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30483. /**
  30484. * Release and destroy the underlying lower level texture aka internalTexture.
  30485. */
  30486. releaseInternalTexture(): void;
  30487. /** @hidden */
  30488. get _lodTextureHigh(): Nullable<BaseTexture>;
  30489. /** @hidden */
  30490. get _lodTextureMid(): Nullable<BaseTexture>;
  30491. /** @hidden */
  30492. get _lodTextureLow(): Nullable<BaseTexture>;
  30493. /**
  30494. * Dispose the texture and release its associated resources.
  30495. */
  30496. dispose(): void;
  30497. /**
  30498. * Serialize the texture into a JSON representation that can be parsed later on.
  30499. * @returns the JSON representation of the texture
  30500. */
  30501. serialize(): any;
  30502. /**
  30503. * Helper function to be called back once a list of texture contains only ready textures.
  30504. * @param textures Define the list of textures to wait for
  30505. * @param callback Define the callback triggered once the entire list will be ready
  30506. */
  30507. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30508. }
  30509. }
  30510. declare module BABYLON {
  30511. /**
  30512. * Options to be used when creating an effect.
  30513. */
  30514. export interface IEffectCreationOptions {
  30515. /**
  30516. * Atrributes that will be used in the shader.
  30517. */
  30518. attributes: string[];
  30519. /**
  30520. * Uniform varible names that will be set in the shader.
  30521. */
  30522. uniformsNames: string[];
  30523. /**
  30524. * Uniform buffer variable names that will be set in the shader.
  30525. */
  30526. uniformBuffersNames: string[];
  30527. /**
  30528. * Sampler texture variable names that will be set in the shader.
  30529. */
  30530. samplers: string[];
  30531. /**
  30532. * Define statements that will be set in the shader.
  30533. */
  30534. defines: any;
  30535. /**
  30536. * Possible fallbacks for this effect to improve performance when needed.
  30537. */
  30538. fallbacks: Nullable<IEffectFallbacks>;
  30539. /**
  30540. * Callback that will be called when the shader is compiled.
  30541. */
  30542. onCompiled: Nullable<(effect: Effect) => void>;
  30543. /**
  30544. * Callback that will be called if an error occurs during shader compilation.
  30545. */
  30546. onError: Nullable<(effect: Effect, errors: string) => void>;
  30547. /**
  30548. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30549. */
  30550. indexParameters?: any;
  30551. /**
  30552. * Max number of lights that can be used in the shader.
  30553. */
  30554. maxSimultaneousLights?: number;
  30555. /**
  30556. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30557. */
  30558. transformFeedbackVaryings?: Nullable<string[]>;
  30559. }
  30560. /**
  30561. * Effect containing vertex and fragment shader that can be executed on an object.
  30562. */
  30563. export class Effect implements IDisposable {
  30564. /**
  30565. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30566. */
  30567. static ShadersRepository: string;
  30568. /**
  30569. * Enable logging of the shader code when a compilation error occurs
  30570. */
  30571. static LogShaderCodeOnCompilationError: boolean;
  30572. /**
  30573. * Name of the effect.
  30574. */
  30575. name: any;
  30576. /**
  30577. * String container all the define statements that should be set on the shader.
  30578. */
  30579. defines: string;
  30580. /**
  30581. * Callback that will be called when the shader is compiled.
  30582. */
  30583. onCompiled: Nullable<(effect: Effect) => void>;
  30584. /**
  30585. * Callback that will be called if an error occurs during shader compilation.
  30586. */
  30587. onError: Nullable<(effect: Effect, errors: string) => void>;
  30588. /**
  30589. * Callback that will be called when effect is bound.
  30590. */
  30591. onBind: Nullable<(effect: Effect) => void>;
  30592. /**
  30593. * Unique ID of the effect.
  30594. */
  30595. uniqueId: number;
  30596. /**
  30597. * Observable that will be called when the shader is compiled.
  30598. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30599. */
  30600. onCompileObservable: Observable<Effect>;
  30601. /**
  30602. * Observable that will be called if an error occurs during shader compilation.
  30603. */
  30604. onErrorObservable: Observable<Effect>;
  30605. /** @hidden */
  30606. _onBindObservable: Nullable<Observable<Effect>>;
  30607. /**
  30608. * @hidden
  30609. * Specifies if the effect was previously ready
  30610. */
  30611. _wasPreviouslyReady: boolean;
  30612. /**
  30613. * Observable that will be called when effect is bound.
  30614. */
  30615. get onBindObservable(): Observable<Effect>;
  30616. /** @hidden */
  30617. _bonesComputationForcedToCPU: boolean;
  30618. private static _uniqueIdSeed;
  30619. private _engine;
  30620. private _uniformBuffersNames;
  30621. private _uniformBuffersNamesList;
  30622. private _uniformsNames;
  30623. private _samplerList;
  30624. private _samplers;
  30625. private _isReady;
  30626. private _compilationError;
  30627. private _allFallbacksProcessed;
  30628. private _attributesNames;
  30629. private _attributes;
  30630. private _attributeLocationByName;
  30631. private _uniforms;
  30632. /**
  30633. * Key for the effect.
  30634. * @hidden
  30635. */
  30636. _key: string;
  30637. private _indexParameters;
  30638. private _fallbacks;
  30639. private _vertexSourceCode;
  30640. private _fragmentSourceCode;
  30641. private _vertexSourceCodeOverride;
  30642. private _fragmentSourceCodeOverride;
  30643. private _transformFeedbackVaryings;
  30644. /**
  30645. * Compiled shader to webGL program.
  30646. * @hidden
  30647. */
  30648. _pipelineContext: Nullable<IPipelineContext>;
  30649. private _valueCache;
  30650. private static _baseCache;
  30651. /**
  30652. * Instantiates an effect.
  30653. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30654. * @param baseName Name of the effect.
  30655. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30656. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30657. * @param samplers List of sampler variables that will be passed to the shader.
  30658. * @param engine Engine to be used to render the effect
  30659. * @param defines Define statements to be added to the shader.
  30660. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30661. * @param onCompiled Callback that will be called when the shader is compiled.
  30662. * @param onError Callback that will be called if an error occurs during shader compilation.
  30663. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30664. */
  30665. 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);
  30666. private _useFinalCode;
  30667. /**
  30668. * Unique key for this effect
  30669. */
  30670. get key(): string;
  30671. /**
  30672. * If the effect has been compiled and prepared.
  30673. * @returns if the effect is compiled and prepared.
  30674. */
  30675. isReady(): boolean;
  30676. private _isReadyInternal;
  30677. /**
  30678. * The engine the effect was initialized with.
  30679. * @returns the engine.
  30680. */
  30681. getEngine(): Engine;
  30682. /**
  30683. * The pipeline context for this effect
  30684. * @returns the associated pipeline context
  30685. */
  30686. getPipelineContext(): Nullable<IPipelineContext>;
  30687. /**
  30688. * The set of names of attribute variables for the shader.
  30689. * @returns An array of attribute names.
  30690. */
  30691. getAttributesNames(): string[];
  30692. /**
  30693. * Returns the attribute at the given index.
  30694. * @param index The index of the attribute.
  30695. * @returns The location of the attribute.
  30696. */
  30697. getAttributeLocation(index: number): number;
  30698. /**
  30699. * Returns the attribute based on the name of the variable.
  30700. * @param name of the attribute to look up.
  30701. * @returns the attribute location.
  30702. */
  30703. getAttributeLocationByName(name: string): number;
  30704. /**
  30705. * The number of attributes.
  30706. * @returns the numnber of attributes.
  30707. */
  30708. getAttributesCount(): number;
  30709. /**
  30710. * Gets the index of a uniform variable.
  30711. * @param uniformName of the uniform to look up.
  30712. * @returns the index.
  30713. */
  30714. getUniformIndex(uniformName: string): number;
  30715. /**
  30716. * Returns the attribute based on the name of the variable.
  30717. * @param uniformName of the uniform to look up.
  30718. * @returns the location of the uniform.
  30719. */
  30720. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30721. /**
  30722. * Returns an array of sampler variable names
  30723. * @returns The array of sampler variable names.
  30724. */
  30725. getSamplers(): string[];
  30726. /**
  30727. * Returns an array of uniform variable names
  30728. * @returns The array of uniform variable names.
  30729. */
  30730. getUniformNames(): string[];
  30731. /**
  30732. * Returns an array of uniform buffer variable names
  30733. * @returns The array of uniform buffer variable names.
  30734. */
  30735. getUniformBuffersNames(): string[];
  30736. /**
  30737. * Returns the index parameters used to create the effect
  30738. * @returns The index parameters object
  30739. */
  30740. getIndexParameters(): any;
  30741. /**
  30742. * The error from the last compilation.
  30743. * @returns the error string.
  30744. */
  30745. getCompilationError(): string;
  30746. /**
  30747. * Gets a boolean indicating that all fallbacks were used during compilation
  30748. * @returns true if all fallbacks were used
  30749. */
  30750. allFallbacksProcessed(): boolean;
  30751. /**
  30752. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30753. * @param func The callback to be used.
  30754. */
  30755. executeWhenCompiled(func: (effect: Effect) => void): void;
  30756. private _checkIsReady;
  30757. private _loadShader;
  30758. /**
  30759. * Gets the vertex shader source code of this effect
  30760. */
  30761. get vertexSourceCode(): string;
  30762. /**
  30763. * Gets the fragment shader source code of this effect
  30764. */
  30765. get fragmentSourceCode(): string;
  30766. /**
  30767. * Recompiles the webGL program
  30768. * @param vertexSourceCode The source code for the vertex shader.
  30769. * @param fragmentSourceCode The source code for the fragment shader.
  30770. * @param onCompiled Callback called when completed.
  30771. * @param onError Callback called on error.
  30772. * @hidden
  30773. */
  30774. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30775. /**
  30776. * Prepares the effect
  30777. * @hidden
  30778. */
  30779. _prepareEffect(): void;
  30780. private _getShaderCodeAndErrorLine;
  30781. private _processCompilationErrors;
  30782. /**
  30783. * Checks if the effect is supported. (Must be called after compilation)
  30784. */
  30785. get isSupported(): boolean;
  30786. /**
  30787. * Binds a texture to the engine to be used as output of the shader.
  30788. * @param channel Name of the output variable.
  30789. * @param texture Texture to bind.
  30790. * @hidden
  30791. */
  30792. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30793. /**
  30794. * Sets a texture on the engine to be used in the shader.
  30795. * @param channel Name of the sampler variable.
  30796. * @param texture Texture to set.
  30797. */
  30798. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30799. /**
  30800. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30801. * @param channel Name of the sampler variable.
  30802. * @param texture Texture to set.
  30803. */
  30804. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30805. /**
  30806. * Sets an array of textures on the engine to be used in the shader.
  30807. * @param channel Name of the variable.
  30808. * @param textures Textures to set.
  30809. */
  30810. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30811. /**
  30812. * 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)
  30813. * @param channel Name of the sampler variable.
  30814. * @param postProcess Post process to get the input texture from.
  30815. */
  30816. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30817. /**
  30818. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30819. * 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)
  30820. * @param channel Name of the sampler variable.
  30821. * @param postProcess Post process to get the output texture from.
  30822. */
  30823. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30824. /** @hidden */
  30825. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30826. /** @hidden */
  30827. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30828. /** @hidden */
  30829. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30830. /** @hidden */
  30831. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30832. /**
  30833. * Binds a buffer to a uniform.
  30834. * @param buffer Buffer to bind.
  30835. * @param name Name of the uniform variable to bind to.
  30836. */
  30837. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30838. /**
  30839. * Binds block to a uniform.
  30840. * @param blockName Name of the block to bind.
  30841. * @param index Index to bind.
  30842. */
  30843. bindUniformBlock(blockName: string, index: number): void;
  30844. /**
  30845. * Sets an interger value on a uniform variable.
  30846. * @param uniformName Name of the variable.
  30847. * @param value Value to be set.
  30848. * @returns this effect.
  30849. */
  30850. setInt(uniformName: string, value: number): Effect;
  30851. /**
  30852. * Sets an int array on a uniform variable.
  30853. * @param uniformName Name of the variable.
  30854. * @param array array to be set.
  30855. * @returns this effect.
  30856. */
  30857. setIntArray(uniformName: string, array: Int32Array): Effect;
  30858. /**
  30859. * 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)
  30860. * @param uniformName Name of the variable.
  30861. * @param array array to be set.
  30862. * @returns this effect.
  30863. */
  30864. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30865. /**
  30866. * 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)
  30867. * @param uniformName Name of the variable.
  30868. * @param array array to be set.
  30869. * @returns this effect.
  30870. */
  30871. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30872. /**
  30873. * 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)
  30874. * @param uniformName Name of the variable.
  30875. * @param array array to be set.
  30876. * @returns this effect.
  30877. */
  30878. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30879. /**
  30880. * Sets an float array on a uniform variable.
  30881. * @param uniformName Name of the variable.
  30882. * @param array array to be set.
  30883. * @returns this effect.
  30884. */
  30885. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30886. /**
  30887. * 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)
  30888. * @param uniformName Name of the variable.
  30889. * @param array array to be set.
  30890. * @returns this effect.
  30891. */
  30892. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30893. /**
  30894. * 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)
  30895. * @param uniformName Name of the variable.
  30896. * @param array array to be set.
  30897. * @returns this effect.
  30898. */
  30899. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30900. /**
  30901. * 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)
  30902. * @param uniformName Name of the variable.
  30903. * @param array array to be set.
  30904. * @returns this effect.
  30905. */
  30906. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30907. /**
  30908. * Sets an array on a uniform variable.
  30909. * @param uniformName Name of the variable.
  30910. * @param array array to be set.
  30911. * @returns this effect.
  30912. */
  30913. setArray(uniformName: string, array: number[]): Effect;
  30914. /**
  30915. * 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)
  30916. * @param uniformName Name of the variable.
  30917. * @param array array to be set.
  30918. * @returns this effect.
  30919. */
  30920. setArray2(uniformName: string, array: number[]): Effect;
  30921. /**
  30922. * 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)
  30923. * @param uniformName Name of the variable.
  30924. * @param array array to be set.
  30925. * @returns this effect.
  30926. */
  30927. setArray3(uniformName: string, array: number[]): Effect;
  30928. /**
  30929. * 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)
  30930. * @param uniformName Name of the variable.
  30931. * @param array array to be set.
  30932. * @returns this effect.
  30933. */
  30934. setArray4(uniformName: string, array: number[]): Effect;
  30935. /**
  30936. * Sets matrices on a uniform variable.
  30937. * @param uniformName Name of the variable.
  30938. * @param matrices matrices to be set.
  30939. * @returns this effect.
  30940. */
  30941. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30942. /**
  30943. * Sets matrix on a uniform variable.
  30944. * @param uniformName Name of the variable.
  30945. * @param matrix matrix to be set.
  30946. * @returns this effect.
  30947. */
  30948. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30949. /**
  30950. * 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)
  30951. * @param uniformName Name of the variable.
  30952. * @param matrix matrix to be set.
  30953. * @returns this effect.
  30954. */
  30955. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30956. /**
  30957. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30958. * @param uniformName Name of the variable.
  30959. * @param matrix matrix to be set.
  30960. * @returns this effect.
  30961. */
  30962. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30963. /**
  30964. * Sets a float on a uniform variable.
  30965. * @param uniformName Name of the variable.
  30966. * @param value value to be set.
  30967. * @returns this effect.
  30968. */
  30969. setFloat(uniformName: string, value: number): Effect;
  30970. /**
  30971. * Sets a boolean on a uniform variable.
  30972. * @param uniformName Name of the variable.
  30973. * @param bool value to be set.
  30974. * @returns this effect.
  30975. */
  30976. setBool(uniformName: string, bool: boolean): Effect;
  30977. /**
  30978. * Sets a Vector2 on a uniform variable.
  30979. * @param uniformName Name of the variable.
  30980. * @param vector2 vector2 to be set.
  30981. * @returns this effect.
  30982. */
  30983. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30984. /**
  30985. * Sets a float2 on a uniform variable.
  30986. * @param uniformName Name of the variable.
  30987. * @param x First float in float2.
  30988. * @param y Second float in float2.
  30989. * @returns this effect.
  30990. */
  30991. setFloat2(uniformName: string, x: number, y: number): Effect;
  30992. /**
  30993. * Sets a Vector3 on a uniform variable.
  30994. * @param uniformName Name of the variable.
  30995. * @param vector3 Value to be set.
  30996. * @returns this effect.
  30997. */
  30998. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30999. /**
  31000. * Sets a float3 on a uniform variable.
  31001. * @param uniformName Name of the variable.
  31002. * @param x First float in float3.
  31003. * @param y Second float in float3.
  31004. * @param z Third float in float3.
  31005. * @returns this effect.
  31006. */
  31007. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31008. /**
  31009. * Sets a Vector4 on a uniform variable.
  31010. * @param uniformName Name of the variable.
  31011. * @param vector4 Value to be set.
  31012. * @returns this effect.
  31013. */
  31014. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31015. /**
  31016. * Sets a float4 on a uniform variable.
  31017. * @param uniformName Name of the variable.
  31018. * @param x First float in float4.
  31019. * @param y Second float in float4.
  31020. * @param z Third float in float4.
  31021. * @param w Fourth float in float4.
  31022. * @returns this effect.
  31023. */
  31024. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31025. /**
  31026. * Sets a Color3 on a uniform variable.
  31027. * @param uniformName Name of the variable.
  31028. * @param color3 Value to be set.
  31029. * @returns this effect.
  31030. */
  31031. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31032. /**
  31033. * Sets a Color4 on a uniform variable.
  31034. * @param uniformName Name of the variable.
  31035. * @param color3 Value to be set.
  31036. * @param alpha Alpha value to be set.
  31037. * @returns this effect.
  31038. */
  31039. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31040. /**
  31041. * Sets a Color4 on a uniform variable
  31042. * @param uniformName defines the name of the variable
  31043. * @param color4 defines the value to be set
  31044. * @returns this effect.
  31045. */
  31046. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31047. /** Release all associated resources */
  31048. dispose(): void;
  31049. /**
  31050. * This function will add a new shader to the shader store
  31051. * @param name the name of the shader
  31052. * @param pixelShader optional pixel shader content
  31053. * @param vertexShader optional vertex shader content
  31054. */
  31055. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31056. /**
  31057. * Store of each shader (The can be looked up using effect.key)
  31058. */
  31059. static ShadersStore: {
  31060. [key: string]: string;
  31061. };
  31062. /**
  31063. * Store of each included file for a shader (The can be looked up using effect.key)
  31064. */
  31065. static IncludesShadersStore: {
  31066. [key: string]: string;
  31067. };
  31068. /**
  31069. * Resets the cache of effects.
  31070. */
  31071. static ResetCache(): void;
  31072. }
  31073. }
  31074. declare module BABYLON {
  31075. /**
  31076. * Interface used to describe the capabilities of the engine relatively to the current browser
  31077. */
  31078. export interface EngineCapabilities {
  31079. /** Maximum textures units per fragment shader */
  31080. maxTexturesImageUnits: number;
  31081. /** Maximum texture units per vertex shader */
  31082. maxVertexTextureImageUnits: number;
  31083. /** Maximum textures units in the entire pipeline */
  31084. maxCombinedTexturesImageUnits: number;
  31085. /** Maximum texture size */
  31086. maxTextureSize: number;
  31087. /** Maximum texture samples */
  31088. maxSamples?: number;
  31089. /** Maximum cube texture size */
  31090. maxCubemapTextureSize: number;
  31091. /** Maximum render texture size */
  31092. maxRenderTextureSize: number;
  31093. /** Maximum number of vertex attributes */
  31094. maxVertexAttribs: number;
  31095. /** Maximum number of varyings */
  31096. maxVaryingVectors: number;
  31097. /** Maximum number of uniforms per vertex shader */
  31098. maxVertexUniformVectors: number;
  31099. /** Maximum number of uniforms per fragment shader */
  31100. maxFragmentUniformVectors: number;
  31101. /** Defines if standard derivates (dx/dy) are supported */
  31102. standardDerivatives: boolean;
  31103. /** Defines if s3tc texture compression is supported */
  31104. s3tc?: WEBGL_compressed_texture_s3tc;
  31105. /** Defines if pvrtc texture compression is supported */
  31106. pvrtc: any;
  31107. /** Defines if etc1 texture compression is supported */
  31108. etc1: any;
  31109. /** Defines if etc2 texture compression is supported */
  31110. etc2: any;
  31111. /** Defines if astc texture compression is supported */
  31112. astc: any;
  31113. /** Defines if float textures are supported */
  31114. textureFloat: boolean;
  31115. /** Defines if vertex array objects are supported */
  31116. vertexArrayObject: boolean;
  31117. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31118. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31119. /** Gets the maximum level of anisotropy supported */
  31120. maxAnisotropy: number;
  31121. /** Defines if instancing is supported */
  31122. instancedArrays: boolean;
  31123. /** Defines if 32 bits indices are supported */
  31124. uintIndices: boolean;
  31125. /** Defines if high precision shaders are supported */
  31126. highPrecisionShaderSupported: boolean;
  31127. /** Defines if depth reading in the fragment shader is supported */
  31128. fragmentDepthSupported: boolean;
  31129. /** Defines if float texture linear filtering is supported*/
  31130. textureFloatLinearFiltering: boolean;
  31131. /** Defines if rendering to float textures is supported */
  31132. textureFloatRender: boolean;
  31133. /** Defines if half float textures are supported*/
  31134. textureHalfFloat: boolean;
  31135. /** Defines if half float texture linear filtering is supported*/
  31136. textureHalfFloatLinearFiltering: boolean;
  31137. /** Defines if rendering to half float textures is supported */
  31138. textureHalfFloatRender: boolean;
  31139. /** Defines if textureLOD shader command is supported */
  31140. textureLOD: boolean;
  31141. /** Defines if draw buffers extension is supported */
  31142. drawBuffersExtension: boolean;
  31143. /** Defines if depth textures are supported */
  31144. depthTextureExtension: boolean;
  31145. /** Defines if float color buffer are supported */
  31146. colorBufferFloat: boolean;
  31147. /** Gets disjoint timer query extension (null if not supported) */
  31148. timerQuery?: EXT_disjoint_timer_query;
  31149. /** Defines if timestamp can be used with timer query */
  31150. canUseTimestampForTimerQuery: boolean;
  31151. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31152. multiview?: any;
  31153. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31154. oculusMultiview?: any;
  31155. /** Function used to let the system compiles shaders in background */
  31156. parallelShaderCompile?: {
  31157. COMPLETION_STATUS_KHR: number;
  31158. };
  31159. /** Max number of texture samples for MSAA */
  31160. maxMSAASamples: number;
  31161. /** Defines if the blend min max extension is supported */
  31162. blendMinMax: boolean;
  31163. }
  31164. }
  31165. declare module BABYLON {
  31166. /**
  31167. * @hidden
  31168. **/
  31169. export class DepthCullingState {
  31170. private _isDepthTestDirty;
  31171. private _isDepthMaskDirty;
  31172. private _isDepthFuncDirty;
  31173. private _isCullFaceDirty;
  31174. private _isCullDirty;
  31175. private _isZOffsetDirty;
  31176. private _isFrontFaceDirty;
  31177. private _depthTest;
  31178. private _depthMask;
  31179. private _depthFunc;
  31180. private _cull;
  31181. private _cullFace;
  31182. private _zOffset;
  31183. private _frontFace;
  31184. /**
  31185. * Initializes the state.
  31186. */
  31187. constructor();
  31188. get isDirty(): boolean;
  31189. get zOffset(): number;
  31190. set zOffset(value: number);
  31191. get cullFace(): Nullable<number>;
  31192. set cullFace(value: Nullable<number>);
  31193. get cull(): Nullable<boolean>;
  31194. set cull(value: Nullable<boolean>);
  31195. get depthFunc(): Nullable<number>;
  31196. set depthFunc(value: Nullable<number>);
  31197. get depthMask(): boolean;
  31198. set depthMask(value: boolean);
  31199. get depthTest(): boolean;
  31200. set depthTest(value: boolean);
  31201. get frontFace(): Nullable<number>;
  31202. set frontFace(value: Nullable<number>);
  31203. reset(): void;
  31204. apply(gl: WebGLRenderingContext): void;
  31205. }
  31206. }
  31207. declare module BABYLON {
  31208. /**
  31209. * @hidden
  31210. **/
  31211. export class StencilState {
  31212. /** 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 */
  31213. static readonly ALWAYS: number;
  31214. /** Passed to stencilOperation to specify that stencil value must be kept */
  31215. static readonly KEEP: number;
  31216. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31217. static readonly REPLACE: number;
  31218. private _isStencilTestDirty;
  31219. private _isStencilMaskDirty;
  31220. private _isStencilFuncDirty;
  31221. private _isStencilOpDirty;
  31222. private _stencilTest;
  31223. private _stencilMask;
  31224. private _stencilFunc;
  31225. private _stencilFuncRef;
  31226. private _stencilFuncMask;
  31227. private _stencilOpStencilFail;
  31228. private _stencilOpDepthFail;
  31229. private _stencilOpStencilDepthPass;
  31230. get isDirty(): boolean;
  31231. get stencilFunc(): number;
  31232. set stencilFunc(value: number);
  31233. get stencilFuncRef(): number;
  31234. set stencilFuncRef(value: number);
  31235. get stencilFuncMask(): number;
  31236. set stencilFuncMask(value: number);
  31237. get stencilOpStencilFail(): number;
  31238. set stencilOpStencilFail(value: number);
  31239. get stencilOpDepthFail(): number;
  31240. set stencilOpDepthFail(value: number);
  31241. get stencilOpStencilDepthPass(): number;
  31242. set stencilOpStencilDepthPass(value: number);
  31243. get stencilMask(): number;
  31244. set stencilMask(value: number);
  31245. get stencilTest(): boolean;
  31246. set stencilTest(value: boolean);
  31247. constructor();
  31248. reset(): void;
  31249. apply(gl: WebGLRenderingContext): void;
  31250. }
  31251. }
  31252. declare module BABYLON {
  31253. /**
  31254. * @hidden
  31255. **/
  31256. export class AlphaState {
  31257. private _isAlphaBlendDirty;
  31258. private _isBlendFunctionParametersDirty;
  31259. private _isBlendEquationParametersDirty;
  31260. private _isBlendConstantsDirty;
  31261. private _alphaBlend;
  31262. private _blendFunctionParameters;
  31263. private _blendEquationParameters;
  31264. private _blendConstants;
  31265. /**
  31266. * Initializes the state.
  31267. */
  31268. constructor();
  31269. get isDirty(): boolean;
  31270. get alphaBlend(): boolean;
  31271. set alphaBlend(value: boolean);
  31272. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31273. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31274. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31275. reset(): void;
  31276. apply(gl: WebGLRenderingContext): void;
  31277. }
  31278. }
  31279. declare module BABYLON {
  31280. /** @hidden */
  31281. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31282. attributeProcessor(attribute: string): string;
  31283. varyingProcessor(varying: string, isFragment: boolean): string;
  31284. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31285. }
  31286. }
  31287. declare module BABYLON {
  31288. /**
  31289. * Interface for attribute information associated with buffer instanciation
  31290. */
  31291. export interface InstancingAttributeInfo {
  31292. /**
  31293. * Name of the GLSL attribute
  31294. * if attribute index is not specified, this is used to retrieve the index from the effect
  31295. */
  31296. attributeName: string;
  31297. /**
  31298. * Index/offset of the attribute in the vertex shader
  31299. * if not specified, this will be computes from the name.
  31300. */
  31301. index?: number;
  31302. /**
  31303. * size of the attribute, 1, 2, 3 or 4
  31304. */
  31305. attributeSize: number;
  31306. /**
  31307. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31308. */
  31309. offset: number;
  31310. /**
  31311. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31312. * default to 1
  31313. */
  31314. divisor?: number;
  31315. /**
  31316. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31317. * default is FLOAT
  31318. */
  31319. attributeType?: number;
  31320. /**
  31321. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31322. */
  31323. normalized?: boolean;
  31324. }
  31325. }
  31326. declare module BABYLON {
  31327. interface ThinEngine {
  31328. /**
  31329. * Update a video texture
  31330. * @param texture defines the texture to update
  31331. * @param video defines the video element to use
  31332. * @param invertY defines if data must be stored with Y axis inverted
  31333. */
  31334. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31335. }
  31336. }
  31337. declare module BABYLON {
  31338. /**
  31339. * Settings for finer control over video usage
  31340. */
  31341. export interface VideoTextureSettings {
  31342. /**
  31343. * Applies `autoplay` to video, if specified
  31344. */
  31345. autoPlay?: boolean;
  31346. /**
  31347. * Applies `loop` to video, if specified
  31348. */
  31349. loop?: boolean;
  31350. /**
  31351. * Automatically updates internal texture from video at every frame in the render loop
  31352. */
  31353. autoUpdateTexture: boolean;
  31354. /**
  31355. * Image src displayed during the video loading or until the user interacts with the video.
  31356. */
  31357. poster?: string;
  31358. }
  31359. /**
  31360. * If you want to display a video in your scene, this is the special texture for that.
  31361. * This special texture works similar to other textures, with the exception of a few parameters.
  31362. * @see https://doc.babylonjs.com/how_to/video_texture
  31363. */
  31364. export class VideoTexture extends Texture {
  31365. /**
  31366. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31367. */
  31368. readonly autoUpdateTexture: boolean;
  31369. /**
  31370. * The video instance used by the texture internally
  31371. */
  31372. readonly video: HTMLVideoElement;
  31373. private _onUserActionRequestedObservable;
  31374. /**
  31375. * Event triggerd when a dom action is required by the user to play the video.
  31376. * This happens due to recent changes in browser policies preventing video to auto start.
  31377. */
  31378. get onUserActionRequestedObservable(): Observable<Texture>;
  31379. private _generateMipMaps;
  31380. private _engine;
  31381. private _stillImageCaptured;
  31382. private _displayingPosterTexture;
  31383. private _settings;
  31384. private _createInternalTextureOnEvent;
  31385. private _frameId;
  31386. private _currentSrc;
  31387. /**
  31388. * Creates a video texture.
  31389. * If you want to display a video in your scene, this is the special texture for that.
  31390. * This special texture works similar to other textures, with the exception of a few parameters.
  31391. * @see https://doc.babylonjs.com/how_to/video_texture
  31392. * @param name optional name, will detect from video source, if not defined
  31393. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31394. * @param scene is obviously the current scene.
  31395. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31396. * @param invertY is false by default but can be used to invert video on Y axis
  31397. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31398. * @param settings allows finer control over video usage
  31399. */
  31400. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31401. private _getName;
  31402. private _getVideo;
  31403. private _createInternalTexture;
  31404. private reset;
  31405. /**
  31406. * @hidden Internal method to initiate `update`.
  31407. */
  31408. _rebuild(): void;
  31409. /**
  31410. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31411. */
  31412. update(): void;
  31413. /**
  31414. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31415. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31416. */
  31417. updateTexture(isVisible: boolean): void;
  31418. protected _updateInternalTexture: () => void;
  31419. /**
  31420. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31421. * @param url New url.
  31422. */
  31423. updateURL(url: string): void;
  31424. /**
  31425. * Clones the texture.
  31426. * @returns the cloned texture
  31427. */
  31428. clone(): VideoTexture;
  31429. /**
  31430. * Dispose the texture and release its associated resources.
  31431. */
  31432. dispose(): void;
  31433. /**
  31434. * Creates a video texture straight from a stream.
  31435. * @param scene Define the scene the texture should be created in
  31436. * @param stream Define the stream the texture should be created from
  31437. * @returns The created video texture as a promise
  31438. */
  31439. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31440. /**
  31441. * Creates a video texture straight from your WebCam video feed.
  31442. * @param scene Define the scene the texture should be created in
  31443. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31444. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31445. * @returns The created video texture as a promise
  31446. */
  31447. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31448. minWidth: number;
  31449. maxWidth: number;
  31450. minHeight: number;
  31451. maxHeight: number;
  31452. deviceId: string;
  31453. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31454. /**
  31455. * Creates a video texture straight from your WebCam video feed.
  31456. * @param scene Define the scene the texture should be created in
  31457. * @param onReady Define a callback to triggered once the texture will be ready
  31458. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31459. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31460. */
  31461. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31462. minWidth: number;
  31463. maxWidth: number;
  31464. minHeight: number;
  31465. maxHeight: number;
  31466. deviceId: string;
  31467. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31468. }
  31469. }
  31470. declare module BABYLON {
  31471. /**
  31472. * Defines the interface used by objects working like Scene
  31473. * @hidden
  31474. */
  31475. export interface ISceneLike {
  31476. _addPendingData(data: any): void;
  31477. _removePendingData(data: any): void;
  31478. offlineProvider: IOfflineProvider;
  31479. }
  31480. /** Interface defining initialization parameters for Engine class */
  31481. export interface EngineOptions extends WebGLContextAttributes {
  31482. /**
  31483. * Defines if the engine should no exceed a specified device ratio
  31484. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31485. */
  31486. limitDeviceRatio?: number;
  31487. /**
  31488. * Defines if webvr should be enabled automatically
  31489. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31490. */
  31491. autoEnableWebVR?: boolean;
  31492. /**
  31493. * Defines if webgl2 should be turned off even if supported
  31494. * @see http://doc.babylonjs.com/features/webgl2
  31495. */
  31496. disableWebGL2Support?: boolean;
  31497. /**
  31498. * Defines if webaudio should be initialized as well
  31499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31500. */
  31501. audioEngine?: boolean;
  31502. /**
  31503. * Defines if animations should run using a deterministic lock step
  31504. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31505. */
  31506. deterministicLockstep?: boolean;
  31507. /** Defines the maximum steps to use with deterministic lock step mode */
  31508. lockstepMaxSteps?: number;
  31509. /** Defines the seconds between each deterministic lock step */
  31510. timeStep?: number;
  31511. /**
  31512. * Defines that engine should ignore context lost events
  31513. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31514. */
  31515. doNotHandleContextLost?: boolean;
  31516. /**
  31517. * Defines that engine should ignore modifying touch action attribute and style
  31518. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31519. */
  31520. doNotHandleTouchAction?: boolean;
  31521. /**
  31522. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31523. */
  31524. useHighPrecisionFloats?: boolean;
  31525. }
  31526. /**
  31527. * The base engine class (root of all engines)
  31528. */
  31529. export class ThinEngine {
  31530. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31531. static ExceptionList: ({
  31532. key: string;
  31533. capture: string;
  31534. captureConstraint: number;
  31535. targets: string[];
  31536. } | {
  31537. key: string;
  31538. capture: null;
  31539. captureConstraint: null;
  31540. targets: string[];
  31541. })[];
  31542. /** @hidden */
  31543. static _TextureLoaders: IInternalTextureLoader[];
  31544. /**
  31545. * Returns the current npm package of the sdk
  31546. */
  31547. static get NpmPackage(): string;
  31548. /**
  31549. * Returns the current version of the framework
  31550. */
  31551. static get Version(): string;
  31552. /**
  31553. * Returns a string describing the current engine
  31554. */
  31555. get description(): string;
  31556. /**
  31557. * Gets or sets the epsilon value used by collision engine
  31558. */
  31559. static CollisionsEpsilon: number;
  31560. /**
  31561. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31562. */
  31563. static get ShadersRepository(): string;
  31564. static set ShadersRepository(value: string);
  31565. /** @hidden */
  31566. _shaderProcessor: IShaderProcessor;
  31567. /**
  31568. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31569. */
  31570. forcePOTTextures: boolean;
  31571. /**
  31572. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31573. */
  31574. isFullscreen: boolean;
  31575. /**
  31576. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31577. */
  31578. cullBackFaces: boolean;
  31579. /**
  31580. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31581. */
  31582. renderEvenInBackground: boolean;
  31583. /**
  31584. * Gets or sets a boolean indicating that cache can be kept between frames
  31585. */
  31586. preventCacheWipeBetweenFrames: boolean;
  31587. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31588. validateShaderPrograms: boolean;
  31589. /**
  31590. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31591. * This can provide greater z depth for distant objects.
  31592. */
  31593. useReverseDepthBuffer: boolean;
  31594. /**
  31595. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31596. */
  31597. disableUniformBuffers: boolean;
  31598. /** @hidden */
  31599. _uniformBuffers: UniformBuffer[];
  31600. /**
  31601. * Gets a boolean indicating that the engine supports uniform buffers
  31602. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31603. */
  31604. get supportsUniformBuffers(): boolean;
  31605. /** @hidden */
  31606. _gl: WebGLRenderingContext;
  31607. /** @hidden */
  31608. _webGLVersion: number;
  31609. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31610. protected _windowIsBackground: boolean;
  31611. protected _creationOptions: EngineOptions;
  31612. protected _highPrecisionShadersAllowed: boolean;
  31613. /** @hidden */
  31614. get _shouldUseHighPrecisionShader(): boolean;
  31615. /**
  31616. * Gets a boolean indicating that only power of 2 textures are supported
  31617. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31618. */
  31619. get needPOTTextures(): boolean;
  31620. /** @hidden */
  31621. _badOS: boolean;
  31622. /** @hidden */
  31623. _badDesktopOS: boolean;
  31624. private _hardwareScalingLevel;
  31625. /** @hidden */
  31626. _caps: EngineCapabilities;
  31627. private _isStencilEnable;
  31628. private _glVersion;
  31629. private _glRenderer;
  31630. private _glVendor;
  31631. /** @hidden */
  31632. _videoTextureSupported: boolean;
  31633. protected _renderingQueueLaunched: boolean;
  31634. protected _activeRenderLoops: (() => void)[];
  31635. /**
  31636. * Observable signaled when a context lost event is raised
  31637. */
  31638. onContextLostObservable: Observable<ThinEngine>;
  31639. /**
  31640. * Observable signaled when a context restored event is raised
  31641. */
  31642. onContextRestoredObservable: Observable<ThinEngine>;
  31643. private _onContextLost;
  31644. private _onContextRestored;
  31645. protected _contextWasLost: boolean;
  31646. /** @hidden */
  31647. _doNotHandleContextLost: boolean;
  31648. /**
  31649. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31651. */
  31652. get doNotHandleContextLost(): boolean;
  31653. set doNotHandleContextLost(value: boolean);
  31654. /**
  31655. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31656. */
  31657. disableVertexArrayObjects: boolean;
  31658. /** @hidden */
  31659. protected _colorWrite: boolean;
  31660. /** @hidden */
  31661. protected _colorWriteChanged: boolean;
  31662. /** @hidden */
  31663. protected _depthCullingState: DepthCullingState;
  31664. /** @hidden */
  31665. protected _stencilState: StencilState;
  31666. /** @hidden */
  31667. _alphaState: AlphaState;
  31668. /** @hidden */
  31669. _alphaMode: number;
  31670. /** @hidden */
  31671. _alphaEquation: number;
  31672. /** @hidden */
  31673. _internalTexturesCache: InternalTexture[];
  31674. /** @hidden */
  31675. protected _activeChannel: number;
  31676. private _currentTextureChannel;
  31677. /** @hidden */
  31678. protected _boundTexturesCache: {
  31679. [key: string]: Nullable<InternalTexture>;
  31680. };
  31681. /** @hidden */
  31682. protected _currentEffect: Nullable<Effect>;
  31683. /** @hidden */
  31684. protected _currentProgram: Nullable<WebGLProgram>;
  31685. private _compiledEffects;
  31686. private _vertexAttribArraysEnabled;
  31687. /** @hidden */
  31688. protected _cachedViewport: Nullable<IViewportLike>;
  31689. private _cachedVertexArrayObject;
  31690. /** @hidden */
  31691. protected _cachedVertexBuffers: any;
  31692. /** @hidden */
  31693. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31694. /** @hidden */
  31695. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31696. /** @hidden */
  31697. _currentRenderTarget: Nullable<InternalTexture>;
  31698. private _uintIndicesCurrentlySet;
  31699. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31700. /** @hidden */
  31701. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31702. private _currentBufferPointers;
  31703. private _currentInstanceLocations;
  31704. private _currentInstanceBuffers;
  31705. private _textureUnits;
  31706. /** @hidden */
  31707. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31708. /** @hidden */
  31709. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31710. /** @hidden */
  31711. _boundRenderFunction: any;
  31712. private _vaoRecordInProgress;
  31713. private _mustWipeVertexAttributes;
  31714. private _emptyTexture;
  31715. private _emptyCubeTexture;
  31716. private _emptyTexture3D;
  31717. private _emptyTexture2DArray;
  31718. /** @hidden */
  31719. _frameHandler: number;
  31720. private _nextFreeTextureSlots;
  31721. private _maxSimultaneousTextures;
  31722. private _activeRequests;
  31723. /** @hidden */
  31724. _transformTextureUrl: Nullable<(url: string) => string>;
  31725. protected get _supportsHardwareTextureRescaling(): boolean;
  31726. private _framebufferDimensionsObject;
  31727. /**
  31728. * sets the object from which width and height will be taken from when getting render width and height
  31729. * Will fallback to the gl object
  31730. * @param dimensions the framebuffer width and height that will be used.
  31731. */
  31732. set framebufferDimensionsObject(dimensions: Nullable<{
  31733. framebufferWidth: number;
  31734. framebufferHeight: number;
  31735. }>);
  31736. /**
  31737. * Gets the current viewport
  31738. */
  31739. get currentViewport(): Nullable<IViewportLike>;
  31740. /**
  31741. * Gets the default empty texture
  31742. */
  31743. get emptyTexture(): InternalTexture;
  31744. /**
  31745. * Gets the default empty 3D texture
  31746. */
  31747. get emptyTexture3D(): InternalTexture;
  31748. /**
  31749. * Gets the default empty 2D array texture
  31750. */
  31751. get emptyTexture2DArray(): InternalTexture;
  31752. /**
  31753. * Gets the default empty cube texture
  31754. */
  31755. get emptyCubeTexture(): InternalTexture;
  31756. /**
  31757. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31758. */
  31759. readonly premultipliedAlpha: boolean;
  31760. /**
  31761. * Observable event triggered before each texture is initialized
  31762. */
  31763. onBeforeTextureInitObservable: Observable<Texture>;
  31764. /**
  31765. * Creates a new engine
  31766. * @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
  31767. * @param antialias defines enable antialiasing (default: false)
  31768. * @param options defines further options to be sent to the getContext() function
  31769. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31770. */
  31771. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31772. private _rebuildInternalTextures;
  31773. private _rebuildEffects;
  31774. /**
  31775. * Gets a boolean indicating if all created effects are ready
  31776. * @returns true if all effects are ready
  31777. */
  31778. areAllEffectsReady(): boolean;
  31779. protected _rebuildBuffers(): void;
  31780. protected _initGLContext(): void;
  31781. /**
  31782. * Gets version of the current webGL context
  31783. */
  31784. get webGLVersion(): number;
  31785. /**
  31786. * Gets a string idenfifying the name of the class
  31787. * @returns "Engine" string
  31788. */
  31789. getClassName(): string;
  31790. /**
  31791. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31792. */
  31793. get isStencilEnable(): boolean;
  31794. /** @hidden */
  31795. _prepareWorkingCanvas(): void;
  31796. /**
  31797. * Reset the texture cache to empty state
  31798. */
  31799. resetTextureCache(): void;
  31800. /**
  31801. * Gets an object containing information about the current webGL context
  31802. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31803. */
  31804. getGlInfo(): {
  31805. vendor: string;
  31806. renderer: string;
  31807. version: string;
  31808. };
  31809. /**
  31810. * Defines the hardware scaling level.
  31811. * By default the hardware scaling level is computed from the window device ratio.
  31812. * 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.
  31813. * @param level defines the level to use
  31814. */
  31815. setHardwareScalingLevel(level: number): void;
  31816. /**
  31817. * Gets the current hardware scaling level.
  31818. * By default the hardware scaling level is computed from the window device ratio.
  31819. * 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.
  31820. * @returns a number indicating the current hardware scaling level
  31821. */
  31822. getHardwareScalingLevel(): number;
  31823. /**
  31824. * Gets the list of loaded textures
  31825. * @returns an array containing all loaded textures
  31826. */
  31827. getLoadedTexturesCache(): InternalTexture[];
  31828. /**
  31829. * Gets the object containing all engine capabilities
  31830. * @returns the EngineCapabilities object
  31831. */
  31832. getCaps(): EngineCapabilities;
  31833. /**
  31834. * stop executing a render loop function and remove it from the execution array
  31835. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31836. */
  31837. stopRenderLoop(renderFunction?: () => void): void;
  31838. /** @hidden */
  31839. _renderLoop(): void;
  31840. /**
  31841. * Gets the HTML canvas attached with the current webGL context
  31842. * @returns a HTML canvas
  31843. */
  31844. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31845. /**
  31846. * Gets host window
  31847. * @returns the host window object
  31848. */
  31849. getHostWindow(): Nullable<Window>;
  31850. /**
  31851. * Gets the current render width
  31852. * @param useScreen defines if screen size must be used (or the current render target if any)
  31853. * @returns a number defining the current render width
  31854. */
  31855. getRenderWidth(useScreen?: boolean): number;
  31856. /**
  31857. * Gets the current render height
  31858. * @param useScreen defines if screen size must be used (or the current render target if any)
  31859. * @returns a number defining the current render height
  31860. */
  31861. getRenderHeight(useScreen?: boolean): number;
  31862. /**
  31863. * Can be used to override the current requestAnimationFrame requester.
  31864. * @hidden
  31865. */
  31866. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31867. /**
  31868. * Register and execute a render loop. The engine can have more than one render function
  31869. * @param renderFunction defines the function to continuously execute
  31870. */
  31871. runRenderLoop(renderFunction: () => void): void;
  31872. /**
  31873. * Clear the current render buffer or the current render target (if any is set up)
  31874. * @param color defines the color to use
  31875. * @param backBuffer defines if the back buffer must be cleared
  31876. * @param depth defines if the depth buffer must be cleared
  31877. * @param stencil defines if the stencil buffer must be cleared
  31878. */
  31879. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31880. private _viewportCached;
  31881. /** @hidden */
  31882. _viewport(x: number, y: number, width: number, height: number): void;
  31883. /**
  31884. * Set the WebGL's viewport
  31885. * @param viewport defines the viewport element to be used
  31886. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31887. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31888. */
  31889. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31890. /**
  31891. * Begin a new frame
  31892. */
  31893. beginFrame(): void;
  31894. /**
  31895. * Enf the current frame
  31896. */
  31897. endFrame(): void;
  31898. /**
  31899. * Resize the view according to the canvas' size
  31900. */
  31901. resize(): void;
  31902. /**
  31903. * Force a specific size of the canvas
  31904. * @param width defines the new canvas' width
  31905. * @param height defines the new canvas' height
  31906. */
  31907. setSize(width: number, height: number): void;
  31908. /**
  31909. * Binds the frame buffer to the specified texture.
  31910. * @param texture The texture to render to or null for the default canvas
  31911. * @param faceIndex The face of the texture to render to in case of cube texture
  31912. * @param requiredWidth The width of the target to render to
  31913. * @param requiredHeight The height of the target to render to
  31914. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31915. * @param lodLevel defines the lod level to bind to the frame buffer
  31916. * @param layer defines the 2d array index to bind to frame buffer to
  31917. */
  31918. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31919. /** @hidden */
  31920. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31921. /**
  31922. * Unbind the current render target texture from the webGL context
  31923. * @param texture defines the render target texture to unbind
  31924. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31925. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31926. */
  31927. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31928. /**
  31929. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31930. */
  31931. flushFramebuffer(): void;
  31932. /**
  31933. * Unbind the current render target and bind the default framebuffer
  31934. */
  31935. restoreDefaultFramebuffer(): void;
  31936. /** @hidden */
  31937. protected _resetVertexBufferBinding(): void;
  31938. /**
  31939. * Creates a vertex buffer
  31940. * @param data the data for the vertex buffer
  31941. * @returns the new WebGL static buffer
  31942. */
  31943. createVertexBuffer(data: DataArray): DataBuffer;
  31944. private _createVertexBuffer;
  31945. /**
  31946. * Creates a dynamic vertex buffer
  31947. * @param data the data for the dynamic vertex buffer
  31948. * @returns the new WebGL dynamic buffer
  31949. */
  31950. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31951. protected _resetIndexBufferBinding(): void;
  31952. /**
  31953. * Creates a new index buffer
  31954. * @param indices defines the content of the index buffer
  31955. * @param updatable defines if the index buffer must be updatable
  31956. * @returns a new webGL buffer
  31957. */
  31958. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31959. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31960. /**
  31961. * Bind a webGL buffer to the webGL context
  31962. * @param buffer defines the buffer to bind
  31963. */
  31964. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31965. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31966. private bindBuffer;
  31967. /**
  31968. * update the bound buffer with the given data
  31969. * @param data defines the data to update
  31970. */
  31971. updateArrayBuffer(data: Float32Array): void;
  31972. private _vertexAttribPointer;
  31973. /** @hidden */
  31974. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31975. private _bindVertexBuffersAttributes;
  31976. /**
  31977. * Records a vertex array object
  31978. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31979. * @param vertexBuffers defines the list of vertex buffers to store
  31980. * @param indexBuffer defines the index buffer to store
  31981. * @param effect defines the effect to store
  31982. * @returns the new vertex array object
  31983. */
  31984. recordVertexArrayObject(vertexBuffers: {
  31985. [key: string]: VertexBuffer;
  31986. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31987. /**
  31988. * Bind a specific vertex array object
  31989. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31990. * @param vertexArrayObject defines the vertex array object to bind
  31991. * @param indexBuffer defines the index buffer to bind
  31992. */
  31993. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31994. /**
  31995. * Bind webGl buffers directly to the webGL context
  31996. * @param vertexBuffer defines the vertex buffer to bind
  31997. * @param indexBuffer defines the index buffer to bind
  31998. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31999. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32000. * @param effect defines the effect associated with the vertex buffer
  32001. */
  32002. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32003. private _unbindVertexArrayObject;
  32004. /**
  32005. * Bind a list of vertex buffers to the webGL context
  32006. * @param vertexBuffers defines the list of vertex buffers to bind
  32007. * @param indexBuffer defines the index buffer to bind
  32008. * @param effect defines the effect associated with the vertex buffers
  32009. */
  32010. bindBuffers(vertexBuffers: {
  32011. [key: string]: Nullable<VertexBuffer>;
  32012. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32013. /**
  32014. * Unbind all instance attributes
  32015. */
  32016. unbindInstanceAttributes(): void;
  32017. /**
  32018. * Release and free the memory of a vertex array object
  32019. * @param vao defines the vertex array object to delete
  32020. */
  32021. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32022. /** @hidden */
  32023. _releaseBuffer(buffer: DataBuffer): boolean;
  32024. protected _deleteBuffer(buffer: DataBuffer): void;
  32025. /**
  32026. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32027. * @param instancesBuffer defines the webGL buffer to update and bind
  32028. * @param data defines the data to store in the buffer
  32029. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32030. */
  32031. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32032. /**
  32033. * Bind the content of a webGL buffer used with instantiation
  32034. * @param instancesBuffer defines the webGL buffer to bind
  32035. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32036. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32037. */
  32038. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32039. /**
  32040. * Disable the instance attribute corresponding to the name in parameter
  32041. * @param name defines the name of the attribute to disable
  32042. */
  32043. disableInstanceAttributeByName(name: string): void;
  32044. /**
  32045. * Disable the instance attribute corresponding to the location in parameter
  32046. * @param attributeLocation defines the attribute location of the attribute to disable
  32047. */
  32048. disableInstanceAttribute(attributeLocation: number): void;
  32049. /**
  32050. * Disable the attribute corresponding to the location in parameter
  32051. * @param attributeLocation defines the attribute location of the attribute to disable
  32052. */
  32053. disableAttributeByIndex(attributeLocation: number): void;
  32054. /**
  32055. * Send a draw order
  32056. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32057. * @param indexStart defines the starting index
  32058. * @param indexCount defines the number of index to draw
  32059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32060. */
  32061. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32062. /**
  32063. * Draw a list of points
  32064. * @param verticesStart defines the index of first vertex to draw
  32065. * @param verticesCount defines the count of vertices to draw
  32066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32067. */
  32068. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32069. /**
  32070. * Draw a list of unindexed primitives
  32071. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32072. * @param verticesStart defines the index of first vertex to draw
  32073. * @param verticesCount defines the count of vertices to draw
  32074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32075. */
  32076. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32077. /**
  32078. * Draw a list of indexed primitives
  32079. * @param fillMode defines the primitive to use
  32080. * @param indexStart defines the starting index
  32081. * @param indexCount defines the number of index to draw
  32082. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32083. */
  32084. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32085. /**
  32086. * Draw a list of unindexed primitives
  32087. * @param fillMode defines the primitive to use
  32088. * @param verticesStart defines the index of first vertex to draw
  32089. * @param verticesCount defines the count of vertices to draw
  32090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32091. */
  32092. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32093. private _drawMode;
  32094. /** @hidden */
  32095. protected _reportDrawCall(): void;
  32096. /** @hidden */
  32097. _releaseEffect(effect: Effect): void;
  32098. /** @hidden */
  32099. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32100. /**
  32101. * Create a new effect (used to store vertex/fragment shaders)
  32102. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32103. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32104. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32105. * @param samplers defines an array of string used to represent textures
  32106. * @param defines defines the string containing the defines to use to compile the shaders
  32107. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32108. * @param onCompiled defines a function to call when the effect creation is successful
  32109. * @param onError defines a function to call when the effect creation has failed
  32110. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32111. * @returns the new Effect
  32112. */
  32113. 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;
  32114. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32115. private _compileShader;
  32116. private _compileRawShader;
  32117. /** @hidden */
  32118. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32119. /**
  32120. * Directly creates a webGL program
  32121. * @param pipelineContext defines the pipeline context to attach to
  32122. * @param vertexCode defines the vertex shader code to use
  32123. * @param fragmentCode defines the fragment shader code to use
  32124. * @param context defines the webGL context to use (if not set, the current one will be used)
  32125. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32126. * @returns the new webGL program
  32127. */
  32128. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32129. /**
  32130. * Creates a webGL program
  32131. * @param pipelineContext defines the pipeline context to attach to
  32132. * @param vertexCode defines the vertex shader code to use
  32133. * @param fragmentCode defines the fragment shader code to use
  32134. * @param defines defines the string containing the defines to use to compile the shaders
  32135. * @param context defines the webGL context to use (if not set, the current one will be used)
  32136. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32137. * @returns the new webGL program
  32138. */
  32139. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32140. /**
  32141. * Creates a new pipeline context
  32142. * @returns the new pipeline
  32143. */
  32144. createPipelineContext(): IPipelineContext;
  32145. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32146. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32147. /** @hidden */
  32148. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32149. /** @hidden */
  32150. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32151. /** @hidden */
  32152. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32153. /**
  32154. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32155. * @param pipelineContext defines the pipeline context to use
  32156. * @param uniformsNames defines the list of uniform names
  32157. * @returns an array of webGL uniform locations
  32158. */
  32159. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32160. /**
  32161. * Gets the lsit of active attributes for a given webGL program
  32162. * @param pipelineContext defines the pipeline context to use
  32163. * @param attributesNames defines the list of attribute names to get
  32164. * @returns an array of indices indicating the offset of each attribute
  32165. */
  32166. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32167. /**
  32168. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32169. * @param effect defines the effect to activate
  32170. */
  32171. enableEffect(effect: Nullable<Effect>): void;
  32172. /**
  32173. * Set the value of an uniform to a number (int)
  32174. * @param uniform defines the webGL uniform location where to store the value
  32175. * @param value defines the int number to store
  32176. */
  32177. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32178. /**
  32179. * Set the value of an uniform to an array of int32
  32180. * @param uniform defines the webGL uniform location where to store the value
  32181. * @param array defines the array of int32 to store
  32182. */
  32183. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32184. /**
  32185. * Set the value of an uniform to an array of int32 (stored as vec2)
  32186. * @param uniform defines the webGL uniform location where to store the value
  32187. * @param array defines the array of int32 to store
  32188. */
  32189. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32190. /**
  32191. * Set the value of an uniform to an array of int32 (stored as vec3)
  32192. * @param uniform defines the webGL uniform location where to store the value
  32193. * @param array defines the array of int32 to store
  32194. */
  32195. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32196. /**
  32197. * Set the value of an uniform to an array of int32 (stored as vec4)
  32198. * @param uniform defines the webGL uniform location where to store the value
  32199. * @param array defines the array of int32 to store
  32200. */
  32201. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32202. /**
  32203. * Set the value of an uniform to an array of number
  32204. * @param uniform defines the webGL uniform location where to store the value
  32205. * @param array defines the array of number to store
  32206. */
  32207. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32208. /**
  32209. * Set the value of an uniform to an array of number (stored as vec2)
  32210. * @param uniform defines the webGL uniform location where to store the value
  32211. * @param array defines the array of number to store
  32212. */
  32213. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32214. /**
  32215. * Set the value of an uniform to an array of number (stored as vec3)
  32216. * @param uniform defines the webGL uniform location where to store the value
  32217. * @param array defines the array of number to store
  32218. */
  32219. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32220. /**
  32221. * Set the value of an uniform to an array of number (stored as vec4)
  32222. * @param uniform defines the webGL uniform location where to store the value
  32223. * @param array defines the array of number to store
  32224. */
  32225. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32226. /**
  32227. * Set the value of an uniform to an array of float32 (stored as matrices)
  32228. * @param uniform defines the webGL uniform location where to store the value
  32229. * @param matrices defines the array of float32 to store
  32230. */
  32231. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32232. /**
  32233. * Set the value of an uniform to a matrix (3x3)
  32234. * @param uniform defines the webGL uniform location where to store the value
  32235. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32236. */
  32237. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32238. /**
  32239. * Set the value of an uniform to a matrix (2x2)
  32240. * @param uniform defines the webGL uniform location where to store the value
  32241. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32242. */
  32243. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32244. /**
  32245. * Set the value of an uniform to a number (float)
  32246. * @param uniform defines the webGL uniform location where to store the value
  32247. * @param value defines the float number to store
  32248. */
  32249. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32250. /**
  32251. * Set the value of an uniform to a vec2
  32252. * @param uniform defines the webGL uniform location where to store the value
  32253. * @param x defines the 1st component of the value
  32254. * @param y defines the 2nd component of the value
  32255. */
  32256. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32257. /**
  32258. * Set the value of an uniform to a vec3
  32259. * @param uniform defines the webGL uniform location where to store the value
  32260. * @param x defines the 1st component of the value
  32261. * @param y defines the 2nd component of the value
  32262. * @param z defines the 3rd component of the value
  32263. */
  32264. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32265. /**
  32266. * Set the value of an uniform to a vec4
  32267. * @param uniform defines the webGL uniform location where to store the value
  32268. * @param x defines the 1st component of the value
  32269. * @param y defines the 2nd component of the value
  32270. * @param z defines the 3rd component of the value
  32271. * @param w defines the 4th component of the value
  32272. */
  32273. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32274. /**
  32275. * Apply all cached states (depth, culling, stencil and alpha)
  32276. */
  32277. applyStates(): void;
  32278. /**
  32279. * Enable or disable color writing
  32280. * @param enable defines the state to set
  32281. */
  32282. setColorWrite(enable: boolean): void;
  32283. /**
  32284. * Gets a boolean indicating if color writing is enabled
  32285. * @returns the current color writing state
  32286. */
  32287. getColorWrite(): boolean;
  32288. /**
  32289. * Gets the depth culling state manager
  32290. */
  32291. get depthCullingState(): DepthCullingState;
  32292. /**
  32293. * Gets the alpha state manager
  32294. */
  32295. get alphaState(): AlphaState;
  32296. /**
  32297. * Gets the stencil state manager
  32298. */
  32299. get stencilState(): StencilState;
  32300. /**
  32301. * Clears the list of texture accessible through engine.
  32302. * This can help preventing texture load conflict due to name collision.
  32303. */
  32304. clearInternalTexturesCache(): void;
  32305. /**
  32306. * Force the entire cache to be cleared
  32307. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32308. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32309. */
  32310. wipeCaches(bruteForce?: boolean): void;
  32311. /** @hidden */
  32312. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32313. min: number;
  32314. mag: number;
  32315. };
  32316. /** @hidden */
  32317. _createTexture(): WebGLTexture;
  32318. /**
  32319. * Usually called from Texture.ts.
  32320. * Passed information to create a WebGLTexture
  32321. * @param url defines a value which contains one of the following:
  32322. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32323. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32324. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32325. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32326. * @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)
  32327. * @param scene needed for loading to the correct scene
  32328. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32329. * @param onLoad optional callback to be called upon successful completion
  32330. * @param onError optional callback to be called upon failure
  32331. * @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
  32332. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32333. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32334. * @param forcedExtension defines the extension to use to pick the right loader
  32335. * @param mimeType defines an optional mime type
  32336. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32337. */
  32338. 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;
  32339. /**
  32340. * Loads an image as an HTMLImageElement.
  32341. * @param input url string, ArrayBuffer, or Blob to load
  32342. * @param onLoad callback called when the image successfully loads
  32343. * @param onError callback called when the image fails to load
  32344. * @param offlineProvider offline provider for caching
  32345. * @param mimeType optional mime type
  32346. * @returns the HTMLImageElement of the loaded image
  32347. * @hidden
  32348. */
  32349. 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>;
  32350. /**
  32351. * @hidden
  32352. */
  32353. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32354. private _unpackFlipYCached;
  32355. /**
  32356. * In case you are sharing the context with other applications, it might
  32357. * be interested to not cache the unpack flip y state to ensure a consistent
  32358. * value would be set.
  32359. */
  32360. enableUnpackFlipYCached: boolean;
  32361. /** @hidden */
  32362. _unpackFlipY(value: boolean): void;
  32363. /** @hidden */
  32364. _getUnpackAlignement(): number;
  32365. private _getTextureTarget;
  32366. /**
  32367. * Update the sampling mode of a given texture
  32368. * @param samplingMode defines the required sampling mode
  32369. * @param texture defines the texture to update
  32370. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32371. */
  32372. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32373. /**
  32374. * Update the sampling mode of a given texture
  32375. * @param texture defines the texture to update
  32376. * @param wrapU defines the texture wrap mode of the u coordinates
  32377. * @param wrapV defines the texture wrap mode of the v coordinates
  32378. * @param wrapR defines the texture wrap mode of the r coordinates
  32379. */
  32380. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32381. /** @hidden */
  32382. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32383. width: number;
  32384. height: number;
  32385. layers?: number;
  32386. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32387. /** @hidden */
  32388. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32389. /** @hidden */
  32390. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32391. /**
  32392. * Update a portion of an internal texture
  32393. * @param texture defines the texture to update
  32394. * @param imageData defines the data to store into the texture
  32395. * @param xOffset defines the x coordinates of the update rectangle
  32396. * @param yOffset defines the y coordinates of the update rectangle
  32397. * @param width defines the width of the update rectangle
  32398. * @param height defines the height of the update rectangle
  32399. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32400. * @param lod defines the lod level to update (0 by default)
  32401. */
  32402. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32403. /** @hidden */
  32404. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32405. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32406. private _prepareWebGLTexture;
  32407. /** @hidden */
  32408. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32409. private _getDepthStencilBuffer;
  32410. /** @hidden */
  32411. _releaseFramebufferObjects(texture: InternalTexture): void;
  32412. /** @hidden */
  32413. _releaseTexture(texture: InternalTexture): void;
  32414. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32415. protected _setProgram(program: WebGLProgram): void;
  32416. protected _boundUniforms: {
  32417. [key: number]: WebGLUniformLocation;
  32418. };
  32419. /**
  32420. * Binds an effect to the webGL context
  32421. * @param effect defines the effect to bind
  32422. */
  32423. bindSamplers(effect: Effect): void;
  32424. private _activateCurrentTexture;
  32425. /** @hidden */
  32426. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32427. /** @hidden */
  32428. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32429. /**
  32430. * Unbind all textures from the webGL context
  32431. */
  32432. unbindAllTextures(): void;
  32433. /**
  32434. * Sets a texture to the according uniform.
  32435. * @param channel The texture channel
  32436. * @param uniform The uniform to set
  32437. * @param texture The texture to apply
  32438. */
  32439. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32440. private _bindSamplerUniformToChannel;
  32441. private _getTextureWrapMode;
  32442. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32443. /**
  32444. * Sets an array of texture to the webGL context
  32445. * @param channel defines the channel where the texture array must be set
  32446. * @param uniform defines the associated uniform location
  32447. * @param textures defines the array of textures to bind
  32448. */
  32449. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32450. /** @hidden */
  32451. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32452. private _setTextureParameterFloat;
  32453. private _setTextureParameterInteger;
  32454. /**
  32455. * Unbind all vertex attributes from the webGL context
  32456. */
  32457. unbindAllAttributes(): void;
  32458. /**
  32459. * 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
  32460. */
  32461. releaseEffects(): void;
  32462. /**
  32463. * Dispose and release all associated resources
  32464. */
  32465. dispose(): void;
  32466. /**
  32467. * Attach a new callback raised when context lost event is fired
  32468. * @param callback defines the callback to call
  32469. */
  32470. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32471. /**
  32472. * Attach a new callback raised when context restored event is fired
  32473. * @param callback defines the callback to call
  32474. */
  32475. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32476. /**
  32477. * Get the current error code of the webGL context
  32478. * @returns the error code
  32479. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32480. */
  32481. getError(): number;
  32482. private _canRenderToFloatFramebuffer;
  32483. private _canRenderToHalfFloatFramebuffer;
  32484. private _canRenderToFramebuffer;
  32485. /** @hidden */
  32486. _getWebGLTextureType(type: number): number;
  32487. /** @hidden */
  32488. _getInternalFormat(format: number): number;
  32489. /** @hidden */
  32490. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32491. /** @hidden */
  32492. _getRGBAMultiSampleBufferFormat(type: number): number;
  32493. /** @hidden */
  32494. _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;
  32495. /**
  32496. * Loads a file from a url
  32497. * @param url url to load
  32498. * @param onSuccess callback called when the file successfully loads
  32499. * @param onProgress callback called while file is loading (if the server supports this mode)
  32500. * @param offlineProvider defines the offline provider for caching
  32501. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32502. * @param onError callback called when the file fails to load
  32503. * @returns a file request object
  32504. * @hidden
  32505. */
  32506. 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;
  32507. /**
  32508. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32509. * @param x defines the x coordinate of the rectangle where pixels must be read
  32510. * @param y defines the y coordinate of the rectangle where pixels must be read
  32511. * @param width defines the width of the rectangle where pixels must be read
  32512. * @param height defines the height of the rectangle where pixels must be read
  32513. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32514. * @returns a Uint8Array containing RGBA colors
  32515. */
  32516. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32517. private static _isSupported;
  32518. /**
  32519. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32520. * @returns true if the engine can be created
  32521. * @ignorenaming
  32522. */
  32523. static isSupported(): boolean;
  32524. /**
  32525. * Find the next highest power of two.
  32526. * @param x Number to start search from.
  32527. * @return Next highest power of two.
  32528. */
  32529. static CeilingPOT(x: number): number;
  32530. /**
  32531. * Find the next lowest power of two.
  32532. * @param x Number to start search from.
  32533. * @return Next lowest power of two.
  32534. */
  32535. static FloorPOT(x: number): number;
  32536. /**
  32537. * Find the nearest power of two.
  32538. * @param x Number to start search from.
  32539. * @return Next nearest power of two.
  32540. */
  32541. static NearestPOT(x: number): number;
  32542. /**
  32543. * Get the closest exponent of two
  32544. * @param value defines the value to approximate
  32545. * @param max defines the maximum value to return
  32546. * @param mode defines how to define the closest value
  32547. * @returns closest exponent of two of the given value
  32548. */
  32549. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32550. /**
  32551. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32552. * @param func - the function to be called
  32553. * @param requester - the object that will request the next frame. Falls back to window.
  32554. * @returns frame number
  32555. */
  32556. static QueueNewFrame(func: () => void, requester?: any): number;
  32557. /**
  32558. * Gets host document
  32559. * @returns the host document object
  32560. */
  32561. getHostDocument(): Nullable<Document>;
  32562. }
  32563. }
  32564. declare module BABYLON {
  32565. /**
  32566. * Class representing spherical harmonics coefficients to the 3rd degree
  32567. */
  32568. export class SphericalHarmonics {
  32569. /**
  32570. * Defines whether or not the harmonics have been prescaled for rendering.
  32571. */
  32572. preScaled: boolean;
  32573. /**
  32574. * The l0,0 coefficients of the spherical harmonics
  32575. */
  32576. l00: Vector3;
  32577. /**
  32578. * The l1,-1 coefficients of the spherical harmonics
  32579. */
  32580. l1_1: Vector3;
  32581. /**
  32582. * The l1,0 coefficients of the spherical harmonics
  32583. */
  32584. l10: Vector3;
  32585. /**
  32586. * The l1,1 coefficients of the spherical harmonics
  32587. */
  32588. l11: Vector3;
  32589. /**
  32590. * The l2,-2 coefficients of the spherical harmonics
  32591. */
  32592. l2_2: Vector3;
  32593. /**
  32594. * The l2,-1 coefficients of the spherical harmonics
  32595. */
  32596. l2_1: Vector3;
  32597. /**
  32598. * The l2,0 coefficients of the spherical harmonics
  32599. */
  32600. l20: Vector3;
  32601. /**
  32602. * The l2,1 coefficients of the spherical harmonics
  32603. */
  32604. l21: Vector3;
  32605. /**
  32606. * The l2,2 coefficients of the spherical harmonics
  32607. */
  32608. l22: Vector3;
  32609. /**
  32610. * Adds a light to the spherical harmonics
  32611. * @param direction the direction of the light
  32612. * @param color the color of the light
  32613. * @param deltaSolidAngle the delta solid angle of the light
  32614. */
  32615. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32616. /**
  32617. * Scales the spherical harmonics by the given amount
  32618. * @param scale the amount to scale
  32619. */
  32620. scaleInPlace(scale: number): void;
  32621. /**
  32622. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32623. *
  32624. * ```
  32625. * E_lm = A_l * L_lm
  32626. * ```
  32627. *
  32628. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32629. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32630. * the scaling factors are given in equation 9.
  32631. */
  32632. convertIncidentRadianceToIrradiance(): void;
  32633. /**
  32634. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32635. *
  32636. * ```
  32637. * L = (1/pi) * E * rho
  32638. * ```
  32639. *
  32640. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32641. */
  32642. convertIrradianceToLambertianRadiance(): void;
  32643. /**
  32644. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32645. * required operations at run time.
  32646. *
  32647. * This is simply done by scaling back the SH with Ylm constants parameter.
  32648. * The trigonometric part being applied by the shader at run time.
  32649. */
  32650. preScaleForRendering(): void;
  32651. /**
  32652. * Constructs a spherical harmonics from an array.
  32653. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32654. * @returns the spherical harmonics
  32655. */
  32656. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32657. /**
  32658. * Gets the spherical harmonics from polynomial
  32659. * @param polynomial the spherical polynomial
  32660. * @returns the spherical harmonics
  32661. */
  32662. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32663. }
  32664. /**
  32665. * Class representing spherical polynomial coefficients to the 3rd degree
  32666. */
  32667. export class SphericalPolynomial {
  32668. private _harmonics;
  32669. /**
  32670. * The spherical harmonics used to create the polynomials.
  32671. */
  32672. get preScaledHarmonics(): SphericalHarmonics;
  32673. /**
  32674. * The x coefficients of the spherical polynomial
  32675. */
  32676. x: Vector3;
  32677. /**
  32678. * The y coefficients of the spherical polynomial
  32679. */
  32680. y: Vector3;
  32681. /**
  32682. * The z coefficients of the spherical polynomial
  32683. */
  32684. z: Vector3;
  32685. /**
  32686. * The xx coefficients of the spherical polynomial
  32687. */
  32688. xx: Vector3;
  32689. /**
  32690. * The yy coefficients of the spherical polynomial
  32691. */
  32692. yy: Vector3;
  32693. /**
  32694. * The zz coefficients of the spherical polynomial
  32695. */
  32696. zz: Vector3;
  32697. /**
  32698. * The xy coefficients of the spherical polynomial
  32699. */
  32700. xy: Vector3;
  32701. /**
  32702. * The yz coefficients of the spherical polynomial
  32703. */
  32704. yz: Vector3;
  32705. /**
  32706. * The zx coefficients of the spherical polynomial
  32707. */
  32708. zx: Vector3;
  32709. /**
  32710. * Adds an ambient color to the spherical polynomial
  32711. * @param color the color to add
  32712. */
  32713. addAmbient(color: Color3): void;
  32714. /**
  32715. * Scales the spherical polynomial by the given amount
  32716. * @param scale the amount to scale
  32717. */
  32718. scaleInPlace(scale: number): void;
  32719. /**
  32720. * Gets the spherical polynomial from harmonics
  32721. * @param harmonics the spherical harmonics
  32722. * @returns the spherical polynomial
  32723. */
  32724. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32725. /**
  32726. * Constructs a spherical polynomial from an array.
  32727. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32728. * @returns the spherical polynomial
  32729. */
  32730. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32731. }
  32732. }
  32733. declare module BABYLON {
  32734. /**
  32735. * Defines the source of the internal texture
  32736. */
  32737. export enum InternalTextureSource {
  32738. /**
  32739. * The source of the texture data is unknown
  32740. */
  32741. Unknown = 0,
  32742. /**
  32743. * Texture data comes from an URL
  32744. */
  32745. Url = 1,
  32746. /**
  32747. * Texture data is only used for temporary storage
  32748. */
  32749. Temp = 2,
  32750. /**
  32751. * Texture data comes from raw data (ArrayBuffer)
  32752. */
  32753. Raw = 3,
  32754. /**
  32755. * Texture content is dynamic (video or dynamic texture)
  32756. */
  32757. Dynamic = 4,
  32758. /**
  32759. * Texture content is generated by rendering to it
  32760. */
  32761. RenderTarget = 5,
  32762. /**
  32763. * Texture content is part of a multi render target process
  32764. */
  32765. MultiRenderTarget = 6,
  32766. /**
  32767. * Texture data comes from a cube data file
  32768. */
  32769. Cube = 7,
  32770. /**
  32771. * Texture data comes from a raw cube data
  32772. */
  32773. CubeRaw = 8,
  32774. /**
  32775. * Texture data come from a prefiltered cube data file
  32776. */
  32777. CubePrefiltered = 9,
  32778. /**
  32779. * Texture content is raw 3D data
  32780. */
  32781. Raw3D = 10,
  32782. /**
  32783. * Texture content is raw 2D array data
  32784. */
  32785. Raw2DArray = 11,
  32786. /**
  32787. * Texture content is a depth texture
  32788. */
  32789. Depth = 12,
  32790. /**
  32791. * Texture data comes from a raw cube data encoded with RGBD
  32792. */
  32793. CubeRawRGBD = 13
  32794. }
  32795. /**
  32796. * Class used to store data associated with WebGL texture data for the engine
  32797. * This class should not be used directly
  32798. */
  32799. export class InternalTexture {
  32800. /** @hidden */
  32801. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32802. /**
  32803. * Defines if the texture is ready
  32804. */
  32805. isReady: boolean;
  32806. /**
  32807. * Defines if the texture is a cube texture
  32808. */
  32809. isCube: boolean;
  32810. /**
  32811. * Defines if the texture contains 3D data
  32812. */
  32813. is3D: boolean;
  32814. /**
  32815. * Defines if the texture contains 2D array data
  32816. */
  32817. is2DArray: boolean;
  32818. /**
  32819. * Defines if the texture contains multiview data
  32820. */
  32821. isMultiview: boolean;
  32822. /**
  32823. * Gets the URL used to load this texture
  32824. */
  32825. url: string;
  32826. /**
  32827. * Gets the sampling mode of the texture
  32828. */
  32829. samplingMode: number;
  32830. /**
  32831. * Gets a boolean indicating if the texture needs mipmaps generation
  32832. */
  32833. generateMipMaps: boolean;
  32834. /**
  32835. * Gets the number of samples used by the texture (WebGL2+ only)
  32836. */
  32837. samples: number;
  32838. /**
  32839. * Gets the type of the texture (int, float...)
  32840. */
  32841. type: number;
  32842. /**
  32843. * Gets the format of the texture (RGB, RGBA...)
  32844. */
  32845. format: number;
  32846. /**
  32847. * Observable called when the texture is loaded
  32848. */
  32849. onLoadedObservable: Observable<InternalTexture>;
  32850. /**
  32851. * Gets the width of the texture
  32852. */
  32853. width: number;
  32854. /**
  32855. * Gets the height of the texture
  32856. */
  32857. height: number;
  32858. /**
  32859. * Gets the depth of the texture
  32860. */
  32861. depth: number;
  32862. /**
  32863. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32864. */
  32865. baseWidth: number;
  32866. /**
  32867. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32868. */
  32869. baseHeight: number;
  32870. /**
  32871. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32872. */
  32873. baseDepth: number;
  32874. /**
  32875. * Gets a boolean indicating if the texture is inverted on Y axis
  32876. */
  32877. invertY: boolean;
  32878. /** @hidden */
  32879. _invertVScale: boolean;
  32880. /** @hidden */
  32881. _associatedChannel: number;
  32882. /** @hidden */
  32883. _source: InternalTextureSource;
  32884. /** @hidden */
  32885. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32886. /** @hidden */
  32887. _bufferView: Nullable<ArrayBufferView>;
  32888. /** @hidden */
  32889. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32890. /** @hidden */
  32891. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32892. /** @hidden */
  32893. _size: number;
  32894. /** @hidden */
  32895. _extension: string;
  32896. /** @hidden */
  32897. _files: Nullable<string[]>;
  32898. /** @hidden */
  32899. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32900. /** @hidden */
  32901. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32902. /** @hidden */
  32903. _framebuffer: Nullable<WebGLFramebuffer>;
  32904. /** @hidden */
  32905. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32906. /** @hidden */
  32907. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32908. /** @hidden */
  32909. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32910. /** @hidden */
  32911. _attachments: Nullable<number[]>;
  32912. /** @hidden */
  32913. _cachedCoordinatesMode: Nullable<number>;
  32914. /** @hidden */
  32915. _cachedWrapU: Nullable<number>;
  32916. /** @hidden */
  32917. _cachedWrapV: Nullable<number>;
  32918. /** @hidden */
  32919. _cachedWrapR: Nullable<number>;
  32920. /** @hidden */
  32921. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32922. /** @hidden */
  32923. _isDisabled: boolean;
  32924. /** @hidden */
  32925. _compression: Nullable<string>;
  32926. /** @hidden */
  32927. _generateStencilBuffer: boolean;
  32928. /** @hidden */
  32929. _generateDepthBuffer: boolean;
  32930. /** @hidden */
  32931. _comparisonFunction: number;
  32932. /** @hidden */
  32933. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32934. /** @hidden */
  32935. _lodGenerationScale: number;
  32936. /** @hidden */
  32937. _lodGenerationOffset: number;
  32938. /** @hidden */
  32939. _depthStencilTexture: Nullable<InternalTexture>;
  32940. /** @hidden */
  32941. _colorTextureArray: Nullable<WebGLTexture>;
  32942. /** @hidden */
  32943. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32944. /** @hidden */
  32945. _lodTextureHigh: Nullable<BaseTexture>;
  32946. /** @hidden */
  32947. _lodTextureMid: Nullable<BaseTexture>;
  32948. /** @hidden */
  32949. _lodTextureLow: Nullable<BaseTexture>;
  32950. /** @hidden */
  32951. _isRGBD: boolean;
  32952. /** @hidden */
  32953. _linearSpecularLOD: boolean;
  32954. /** @hidden */
  32955. _irradianceTexture: Nullable<BaseTexture>;
  32956. /** @hidden */
  32957. _webGLTexture: Nullable<WebGLTexture>;
  32958. /** @hidden */
  32959. _references: number;
  32960. private _engine;
  32961. /**
  32962. * Gets the Engine the texture belongs to.
  32963. * @returns The babylon engine
  32964. */
  32965. getEngine(): ThinEngine;
  32966. /**
  32967. * Gets the data source type of the texture
  32968. */
  32969. get source(): InternalTextureSource;
  32970. /**
  32971. * Creates a new InternalTexture
  32972. * @param engine defines the engine to use
  32973. * @param source defines the type of data that will be used
  32974. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32975. */
  32976. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32977. /**
  32978. * Increments the number of references (ie. the number of Texture that point to it)
  32979. */
  32980. incrementReferences(): void;
  32981. /**
  32982. * Change the size of the texture (not the size of the content)
  32983. * @param width defines the new width
  32984. * @param height defines the new height
  32985. * @param depth defines the new depth (1 by default)
  32986. */
  32987. updateSize(width: int, height: int, depth?: int): void;
  32988. /** @hidden */
  32989. _rebuild(): void;
  32990. /** @hidden */
  32991. _swapAndDie(target: InternalTexture): void;
  32992. /**
  32993. * Dispose the current allocated resources
  32994. */
  32995. dispose(): void;
  32996. }
  32997. }
  32998. declare module BABYLON {
  32999. /**
  33000. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33002. */
  33003. export class Analyser {
  33004. /**
  33005. * Gets or sets the smoothing
  33006. * @ignorenaming
  33007. */
  33008. SMOOTHING: number;
  33009. /**
  33010. * Gets or sets the FFT table size
  33011. * @ignorenaming
  33012. */
  33013. FFT_SIZE: number;
  33014. /**
  33015. * Gets or sets the bar graph amplitude
  33016. * @ignorenaming
  33017. */
  33018. BARGRAPHAMPLITUDE: number;
  33019. /**
  33020. * Gets or sets the position of the debug canvas
  33021. * @ignorenaming
  33022. */
  33023. DEBUGCANVASPOS: {
  33024. x: number;
  33025. y: number;
  33026. };
  33027. /**
  33028. * Gets or sets the debug canvas size
  33029. * @ignorenaming
  33030. */
  33031. DEBUGCANVASSIZE: {
  33032. width: number;
  33033. height: number;
  33034. };
  33035. private _byteFreqs;
  33036. private _byteTime;
  33037. private _floatFreqs;
  33038. private _webAudioAnalyser;
  33039. private _debugCanvas;
  33040. private _debugCanvasContext;
  33041. private _scene;
  33042. private _registerFunc;
  33043. private _audioEngine;
  33044. /**
  33045. * Creates a new analyser
  33046. * @param scene defines hosting scene
  33047. */
  33048. constructor(scene: Scene);
  33049. /**
  33050. * Get the number of data values you will have to play with for the visualization
  33051. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33052. * @returns a number
  33053. */
  33054. getFrequencyBinCount(): number;
  33055. /**
  33056. * Gets the current frequency data as a byte array
  33057. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33058. * @returns a Uint8Array
  33059. */
  33060. getByteFrequencyData(): Uint8Array;
  33061. /**
  33062. * Gets the current waveform as a byte array
  33063. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33064. * @returns a Uint8Array
  33065. */
  33066. getByteTimeDomainData(): Uint8Array;
  33067. /**
  33068. * Gets the current frequency data as a float array
  33069. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33070. * @returns a Float32Array
  33071. */
  33072. getFloatFrequencyData(): Float32Array;
  33073. /**
  33074. * Renders the debug canvas
  33075. */
  33076. drawDebugCanvas(): void;
  33077. /**
  33078. * Stops rendering the debug canvas and removes it
  33079. */
  33080. stopDebugCanvas(): void;
  33081. /**
  33082. * Connects two audio nodes
  33083. * @param inputAudioNode defines first node to connect
  33084. * @param outputAudioNode defines second node to connect
  33085. */
  33086. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33087. /**
  33088. * Releases all associated resources
  33089. */
  33090. dispose(): void;
  33091. }
  33092. }
  33093. declare module BABYLON {
  33094. /**
  33095. * This represents an audio engine and it is responsible
  33096. * to play, synchronize and analyse sounds throughout the application.
  33097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33098. */
  33099. export interface IAudioEngine extends IDisposable {
  33100. /**
  33101. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33102. */
  33103. readonly canUseWebAudio: boolean;
  33104. /**
  33105. * Gets the current AudioContext if available.
  33106. */
  33107. readonly audioContext: Nullable<AudioContext>;
  33108. /**
  33109. * The master gain node defines the global audio volume of your audio engine.
  33110. */
  33111. readonly masterGain: GainNode;
  33112. /**
  33113. * Gets whether or not mp3 are supported by your browser.
  33114. */
  33115. readonly isMP3supported: boolean;
  33116. /**
  33117. * Gets whether or not ogg are supported by your browser.
  33118. */
  33119. readonly isOGGsupported: boolean;
  33120. /**
  33121. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33122. * @ignoreNaming
  33123. */
  33124. WarnedWebAudioUnsupported: boolean;
  33125. /**
  33126. * Defines if the audio engine relies on a custom unlocked button.
  33127. * In this case, the embedded button will not be displayed.
  33128. */
  33129. useCustomUnlockedButton: boolean;
  33130. /**
  33131. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33132. */
  33133. readonly unlocked: boolean;
  33134. /**
  33135. * Event raised when audio has been unlocked on the browser.
  33136. */
  33137. onAudioUnlockedObservable: Observable<AudioEngine>;
  33138. /**
  33139. * Event raised when audio has been locked on the browser.
  33140. */
  33141. onAudioLockedObservable: Observable<AudioEngine>;
  33142. /**
  33143. * Flags the audio engine in Locked state.
  33144. * This happens due to new browser policies preventing audio to autoplay.
  33145. */
  33146. lock(): void;
  33147. /**
  33148. * Unlocks the audio engine once a user action has been done on the dom.
  33149. * This is helpful to resume play once browser policies have been satisfied.
  33150. */
  33151. unlock(): void;
  33152. /**
  33153. * Gets the global volume sets on the master gain.
  33154. * @returns the global volume if set or -1 otherwise
  33155. */
  33156. getGlobalVolume(): number;
  33157. /**
  33158. * Sets the global volume of your experience (sets on the master gain).
  33159. * @param newVolume Defines the new global volume of the application
  33160. */
  33161. setGlobalVolume(newVolume: number): void;
  33162. /**
  33163. * Connect the audio engine to an audio analyser allowing some amazing
  33164. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33166. * @param analyser The analyser to connect to the engine
  33167. */
  33168. connectToAnalyser(analyser: Analyser): void;
  33169. }
  33170. /**
  33171. * This represents the default audio engine used in babylon.
  33172. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33174. */
  33175. export class AudioEngine implements IAudioEngine {
  33176. private _audioContext;
  33177. private _audioContextInitialized;
  33178. private _muteButton;
  33179. private _hostElement;
  33180. /**
  33181. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33182. */
  33183. canUseWebAudio: boolean;
  33184. /**
  33185. * The master gain node defines the global audio volume of your audio engine.
  33186. */
  33187. masterGain: GainNode;
  33188. /**
  33189. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33190. * @ignoreNaming
  33191. */
  33192. WarnedWebAudioUnsupported: boolean;
  33193. /**
  33194. * Gets whether or not mp3 are supported by your browser.
  33195. */
  33196. isMP3supported: boolean;
  33197. /**
  33198. * Gets whether or not ogg are supported by your browser.
  33199. */
  33200. isOGGsupported: boolean;
  33201. /**
  33202. * Gets whether audio has been unlocked on the device.
  33203. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33204. * a user interaction has happened.
  33205. */
  33206. unlocked: boolean;
  33207. /**
  33208. * Defines if the audio engine relies on a custom unlocked button.
  33209. * In this case, the embedded button will not be displayed.
  33210. */
  33211. useCustomUnlockedButton: boolean;
  33212. /**
  33213. * Event raised when audio has been unlocked on the browser.
  33214. */
  33215. onAudioUnlockedObservable: Observable<AudioEngine>;
  33216. /**
  33217. * Event raised when audio has been locked on the browser.
  33218. */
  33219. onAudioLockedObservable: Observable<AudioEngine>;
  33220. /**
  33221. * Gets the current AudioContext if available.
  33222. */
  33223. get audioContext(): Nullable<AudioContext>;
  33224. private _connectedAnalyser;
  33225. /**
  33226. * Instantiates a new audio engine.
  33227. *
  33228. * There should be only one per page as some browsers restrict the number
  33229. * of audio contexts you can create.
  33230. * @param hostElement defines the host element where to display the mute icon if necessary
  33231. */
  33232. constructor(hostElement?: Nullable<HTMLElement>);
  33233. /**
  33234. * Flags the audio engine in Locked state.
  33235. * This happens due to new browser policies preventing audio to autoplay.
  33236. */
  33237. lock(): void;
  33238. /**
  33239. * Unlocks the audio engine once a user action has been done on the dom.
  33240. * This is helpful to resume play once browser policies have been satisfied.
  33241. */
  33242. unlock(): void;
  33243. private _resumeAudioContext;
  33244. private _initializeAudioContext;
  33245. private _tryToRun;
  33246. private _triggerRunningState;
  33247. private _triggerSuspendedState;
  33248. private _displayMuteButton;
  33249. private _moveButtonToTopLeft;
  33250. private _onResize;
  33251. private _hideMuteButton;
  33252. /**
  33253. * Destroy and release the resources associated with the audio ccontext.
  33254. */
  33255. dispose(): void;
  33256. /**
  33257. * Gets the global volume sets on the master gain.
  33258. * @returns the global volume if set or -1 otherwise
  33259. */
  33260. getGlobalVolume(): number;
  33261. /**
  33262. * Sets the global volume of your experience (sets on the master gain).
  33263. * @param newVolume Defines the new global volume of the application
  33264. */
  33265. setGlobalVolume(newVolume: number): void;
  33266. /**
  33267. * Connect the audio engine to an audio analyser allowing some amazing
  33268. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33270. * @param analyser The analyser to connect to the engine
  33271. */
  33272. connectToAnalyser(analyser: Analyser): void;
  33273. }
  33274. }
  33275. declare module BABYLON {
  33276. /**
  33277. * Interface used to present a loading screen while loading a scene
  33278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33279. */
  33280. export interface ILoadingScreen {
  33281. /**
  33282. * Function called to display the loading screen
  33283. */
  33284. displayLoadingUI: () => void;
  33285. /**
  33286. * Function called to hide the loading screen
  33287. */
  33288. hideLoadingUI: () => void;
  33289. /**
  33290. * Gets or sets the color to use for the background
  33291. */
  33292. loadingUIBackgroundColor: string;
  33293. /**
  33294. * Gets or sets the text to display while loading
  33295. */
  33296. loadingUIText: string;
  33297. }
  33298. /**
  33299. * Class used for the default loading screen
  33300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33301. */
  33302. export class DefaultLoadingScreen implements ILoadingScreen {
  33303. private _renderingCanvas;
  33304. private _loadingText;
  33305. private _loadingDivBackgroundColor;
  33306. private _loadingDiv;
  33307. private _loadingTextDiv;
  33308. /** Gets or sets the logo url to use for the default loading screen */
  33309. static DefaultLogoUrl: string;
  33310. /** Gets or sets the spinner url to use for the default loading screen */
  33311. static DefaultSpinnerUrl: string;
  33312. /**
  33313. * Creates a new default loading screen
  33314. * @param _renderingCanvas defines the canvas used to render the scene
  33315. * @param _loadingText defines the default text to display
  33316. * @param _loadingDivBackgroundColor defines the default background color
  33317. */
  33318. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33319. /**
  33320. * Function called to display the loading screen
  33321. */
  33322. displayLoadingUI(): void;
  33323. /**
  33324. * Function called to hide the loading screen
  33325. */
  33326. hideLoadingUI(): void;
  33327. /**
  33328. * Gets or sets the text to display while loading
  33329. */
  33330. set loadingUIText(text: string);
  33331. get loadingUIText(): string;
  33332. /**
  33333. * Gets or sets the color to use for the background
  33334. */
  33335. get loadingUIBackgroundColor(): string;
  33336. set loadingUIBackgroundColor(color: string);
  33337. private _resizeLoadingUI;
  33338. }
  33339. }
  33340. declare module BABYLON {
  33341. /**
  33342. * Interface for any object that can request an animation frame
  33343. */
  33344. export interface ICustomAnimationFrameRequester {
  33345. /**
  33346. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33347. */
  33348. renderFunction?: Function;
  33349. /**
  33350. * Called to request the next frame to render to
  33351. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33352. */
  33353. requestAnimationFrame: Function;
  33354. /**
  33355. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33356. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33357. */
  33358. requestID?: number;
  33359. }
  33360. }
  33361. declare module BABYLON {
  33362. /**
  33363. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33364. */
  33365. export class PerformanceMonitor {
  33366. private _enabled;
  33367. private _rollingFrameTime;
  33368. private _lastFrameTimeMs;
  33369. /**
  33370. * constructor
  33371. * @param frameSampleSize The number of samples required to saturate the sliding window
  33372. */
  33373. constructor(frameSampleSize?: number);
  33374. /**
  33375. * Samples current frame
  33376. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33377. */
  33378. sampleFrame(timeMs?: number): void;
  33379. /**
  33380. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33381. */
  33382. get averageFrameTime(): number;
  33383. /**
  33384. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33385. */
  33386. get averageFrameTimeVariance(): number;
  33387. /**
  33388. * Returns the frame time of the most recent frame
  33389. */
  33390. get instantaneousFrameTime(): number;
  33391. /**
  33392. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33393. */
  33394. get averageFPS(): number;
  33395. /**
  33396. * Returns the average framerate in frames per second using the most recent frame time
  33397. */
  33398. get instantaneousFPS(): number;
  33399. /**
  33400. * Returns true if enough samples have been taken to completely fill the sliding window
  33401. */
  33402. get isSaturated(): boolean;
  33403. /**
  33404. * Enables contributions to the sliding window sample set
  33405. */
  33406. enable(): void;
  33407. /**
  33408. * Disables contributions to the sliding window sample set
  33409. * Samples will not be interpolated over the disabled period
  33410. */
  33411. disable(): void;
  33412. /**
  33413. * Returns true if sampling is enabled
  33414. */
  33415. get isEnabled(): boolean;
  33416. /**
  33417. * Resets performance monitor
  33418. */
  33419. reset(): void;
  33420. }
  33421. /**
  33422. * RollingAverage
  33423. *
  33424. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33425. */
  33426. export class RollingAverage {
  33427. /**
  33428. * Current average
  33429. */
  33430. average: number;
  33431. /**
  33432. * Current variance
  33433. */
  33434. variance: number;
  33435. protected _samples: Array<number>;
  33436. protected _sampleCount: number;
  33437. protected _pos: number;
  33438. protected _m2: number;
  33439. /**
  33440. * constructor
  33441. * @param length The number of samples required to saturate the sliding window
  33442. */
  33443. constructor(length: number);
  33444. /**
  33445. * Adds a sample to the sample set
  33446. * @param v The sample value
  33447. */
  33448. add(v: number): void;
  33449. /**
  33450. * Returns previously added values or null if outside of history or outside the sliding window domain
  33451. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33452. * @return Value previously recorded with add() or null if outside of range
  33453. */
  33454. history(i: number): number;
  33455. /**
  33456. * Returns true if enough samples have been taken to completely fill the sliding window
  33457. * @return true if sample-set saturated
  33458. */
  33459. isSaturated(): boolean;
  33460. /**
  33461. * Resets the rolling average (equivalent to 0 samples taken so far)
  33462. */
  33463. reset(): void;
  33464. /**
  33465. * Wraps a value around the sample range boundaries
  33466. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33467. * @return Wrapped position in sample range
  33468. */
  33469. protected _wrapPosition(i: number): number;
  33470. }
  33471. }
  33472. declare module BABYLON {
  33473. /**
  33474. * This class is used to track a performance counter which is number based.
  33475. * The user has access to many properties which give statistics of different nature.
  33476. *
  33477. * The implementer can track two kinds of Performance Counter: time and count.
  33478. * 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.
  33479. * 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.
  33480. */
  33481. export class PerfCounter {
  33482. /**
  33483. * Gets or sets a global boolean to turn on and off all the counters
  33484. */
  33485. static Enabled: boolean;
  33486. /**
  33487. * Returns the smallest value ever
  33488. */
  33489. get min(): number;
  33490. /**
  33491. * Returns the biggest value ever
  33492. */
  33493. get max(): number;
  33494. /**
  33495. * Returns the average value since the performance counter is running
  33496. */
  33497. get average(): number;
  33498. /**
  33499. * Returns the average value of the last second the counter was monitored
  33500. */
  33501. get lastSecAverage(): number;
  33502. /**
  33503. * Returns the current value
  33504. */
  33505. get current(): number;
  33506. /**
  33507. * Gets the accumulated total
  33508. */
  33509. get total(): number;
  33510. /**
  33511. * Gets the total value count
  33512. */
  33513. get count(): number;
  33514. /**
  33515. * Creates a new counter
  33516. */
  33517. constructor();
  33518. /**
  33519. * Call this method to start monitoring a new frame.
  33520. * 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.
  33521. */
  33522. fetchNewFrame(): void;
  33523. /**
  33524. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33525. * @param newCount the count value to add to the monitored count
  33526. * @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.
  33527. */
  33528. addCount(newCount: number, fetchResult: boolean): void;
  33529. /**
  33530. * Start monitoring this performance counter
  33531. */
  33532. beginMonitoring(): void;
  33533. /**
  33534. * Compute the time lapsed since the previous beginMonitoring() call.
  33535. * @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
  33536. */
  33537. endMonitoring(newFrame?: boolean): void;
  33538. private _fetchResult;
  33539. private _startMonitoringTime;
  33540. private _min;
  33541. private _max;
  33542. private _average;
  33543. private _current;
  33544. private _totalValueCount;
  33545. private _totalAccumulated;
  33546. private _lastSecAverage;
  33547. private _lastSecAccumulated;
  33548. private _lastSecTime;
  33549. private _lastSecValueCount;
  33550. }
  33551. }
  33552. declare module BABYLON {
  33553. interface ThinEngine {
  33554. /**
  33555. * Sets alpha constants used by some alpha blending modes
  33556. * @param r defines the red component
  33557. * @param g defines the green component
  33558. * @param b defines the blue component
  33559. * @param a defines the alpha component
  33560. */
  33561. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33562. /**
  33563. * Sets the current alpha mode
  33564. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33565. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33567. */
  33568. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33569. /**
  33570. * Gets the current alpha mode
  33571. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33572. * @returns the current alpha mode
  33573. */
  33574. getAlphaMode(): number;
  33575. /**
  33576. * Sets the current alpha equation
  33577. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33578. */
  33579. setAlphaEquation(equation: number): void;
  33580. /**
  33581. * Gets the current alpha equation.
  33582. * @returns the current alpha equation
  33583. */
  33584. getAlphaEquation(): number;
  33585. }
  33586. }
  33587. declare module BABYLON {
  33588. /**
  33589. * Defines the interface used by display changed events
  33590. */
  33591. export interface IDisplayChangedEventArgs {
  33592. /** Gets the vrDisplay object (if any) */
  33593. vrDisplay: Nullable<any>;
  33594. /** Gets a boolean indicating if webVR is supported */
  33595. vrSupported: boolean;
  33596. }
  33597. /**
  33598. * Defines the interface used by objects containing a viewport (like a camera)
  33599. */
  33600. interface IViewportOwnerLike {
  33601. /**
  33602. * Gets or sets the viewport
  33603. */
  33604. viewport: IViewportLike;
  33605. }
  33606. /**
  33607. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33608. */
  33609. export class Engine extends ThinEngine {
  33610. /** Defines that alpha blending is disabled */
  33611. static readonly ALPHA_DISABLE: number;
  33612. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33613. static readonly ALPHA_ADD: number;
  33614. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33615. static readonly ALPHA_COMBINE: number;
  33616. /** Defines that alpha blending to DEST - SRC * DEST */
  33617. static readonly ALPHA_SUBTRACT: number;
  33618. /** Defines that alpha blending to SRC * DEST */
  33619. static readonly ALPHA_MULTIPLY: number;
  33620. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33621. static readonly ALPHA_MAXIMIZED: number;
  33622. /** Defines that alpha blending to SRC + DEST */
  33623. static readonly ALPHA_ONEONE: number;
  33624. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33625. static readonly ALPHA_PREMULTIPLIED: number;
  33626. /**
  33627. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33628. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33629. */
  33630. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33631. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33632. static readonly ALPHA_INTERPOLATE: number;
  33633. /**
  33634. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33635. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33636. */
  33637. static readonly ALPHA_SCREENMODE: number;
  33638. /** Defines that the ressource is not delayed*/
  33639. static readonly DELAYLOADSTATE_NONE: number;
  33640. /** Defines that the ressource was successfully delay loaded */
  33641. static readonly DELAYLOADSTATE_LOADED: number;
  33642. /** Defines that the ressource is currently delay loading */
  33643. static readonly DELAYLOADSTATE_LOADING: number;
  33644. /** Defines that the ressource is delayed and has not started loading */
  33645. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33646. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33647. static readonly NEVER: number;
  33648. /** 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 */
  33649. static readonly ALWAYS: number;
  33650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33651. static readonly LESS: number;
  33652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33653. static readonly EQUAL: number;
  33654. /** 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 */
  33655. static readonly LEQUAL: number;
  33656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33657. static readonly GREATER: number;
  33658. /** 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 */
  33659. static readonly GEQUAL: number;
  33660. /** 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 */
  33661. static readonly NOTEQUAL: number;
  33662. /** Passed to stencilOperation to specify that stencil value must be kept */
  33663. static readonly KEEP: number;
  33664. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33665. static readonly REPLACE: number;
  33666. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33667. static readonly INCR: number;
  33668. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33669. static readonly DECR: number;
  33670. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33671. static readonly INVERT: number;
  33672. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33673. static readonly INCR_WRAP: number;
  33674. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33675. static readonly DECR_WRAP: number;
  33676. /** Texture is not repeating outside of 0..1 UVs */
  33677. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33678. /** Texture is repeating outside of 0..1 UVs */
  33679. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33680. /** Texture is repeating and mirrored */
  33681. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33682. /** ALPHA */
  33683. static readonly TEXTUREFORMAT_ALPHA: number;
  33684. /** LUMINANCE */
  33685. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33686. /** LUMINANCE_ALPHA */
  33687. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33688. /** RGB */
  33689. static readonly TEXTUREFORMAT_RGB: number;
  33690. /** RGBA */
  33691. static readonly TEXTUREFORMAT_RGBA: number;
  33692. /** RED */
  33693. static readonly TEXTUREFORMAT_RED: number;
  33694. /** RED (2nd reference) */
  33695. static readonly TEXTUREFORMAT_R: number;
  33696. /** RG */
  33697. static readonly TEXTUREFORMAT_RG: number;
  33698. /** RED_INTEGER */
  33699. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33700. /** RED_INTEGER (2nd reference) */
  33701. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33702. /** RG_INTEGER */
  33703. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33704. /** RGB_INTEGER */
  33705. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33706. /** RGBA_INTEGER */
  33707. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33708. /** UNSIGNED_BYTE */
  33709. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33710. /** UNSIGNED_BYTE (2nd reference) */
  33711. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33712. /** FLOAT */
  33713. static readonly TEXTURETYPE_FLOAT: number;
  33714. /** HALF_FLOAT */
  33715. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33716. /** BYTE */
  33717. static readonly TEXTURETYPE_BYTE: number;
  33718. /** SHORT */
  33719. static readonly TEXTURETYPE_SHORT: number;
  33720. /** UNSIGNED_SHORT */
  33721. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33722. /** INT */
  33723. static readonly TEXTURETYPE_INT: number;
  33724. /** UNSIGNED_INT */
  33725. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33726. /** UNSIGNED_SHORT_4_4_4_4 */
  33727. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33728. /** UNSIGNED_SHORT_5_5_5_1 */
  33729. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33730. /** UNSIGNED_SHORT_5_6_5 */
  33731. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33732. /** UNSIGNED_INT_2_10_10_10_REV */
  33733. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33734. /** UNSIGNED_INT_24_8 */
  33735. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33736. /** UNSIGNED_INT_10F_11F_11F_REV */
  33737. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33738. /** UNSIGNED_INT_5_9_9_9_REV */
  33739. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33740. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33741. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33742. /** nearest is mag = nearest and min = nearest and mip = linear */
  33743. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33744. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33745. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33746. /** Trilinear is mag = linear and min = linear and mip = linear */
  33747. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33748. /** nearest is mag = nearest and min = nearest and mip = linear */
  33749. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33751. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33752. /** Trilinear is mag = linear and min = linear and mip = linear */
  33753. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33754. /** mag = nearest and min = nearest and mip = nearest */
  33755. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33756. /** mag = nearest and min = linear and mip = nearest */
  33757. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33758. /** mag = nearest and min = linear and mip = linear */
  33759. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33760. /** mag = nearest and min = linear and mip = none */
  33761. static readonly TEXTURE_NEAREST_LINEAR: number;
  33762. /** mag = nearest and min = nearest and mip = none */
  33763. static readonly TEXTURE_NEAREST_NEAREST: number;
  33764. /** mag = linear and min = nearest and mip = nearest */
  33765. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33766. /** mag = linear and min = nearest and mip = linear */
  33767. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33768. /** mag = linear and min = linear and mip = none */
  33769. static readonly TEXTURE_LINEAR_LINEAR: number;
  33770. /** mag = linear and min = nearest and mip = none */
  33771. static readonly TEXTURE_LINEAR_NEAREST: number;
  33772. /** Explicit coordinates mode */
  33773. static readonly TEXTURE_EXPLICIT_MODE: number;
  33774. /** Spherical coordinates mode */
  33775. static readonly TEXTURE_SPHERICAL_MODE: number;
  33776. /** Planar coordinates mode */
  33777. static readonly TEXTURE_PLANAR_MODE: number;
  33778. /** Cubic coordinates mode */
  33779. static readonly TEXTURE_CUBIC_MODE: number;
  33780. /** Projection coordinates mode */
  33781. static readonly TEXTURE_PROJECTION_MODE: number;
  33782. /** Skybox coordinates mode */
  33783. static readonly TEXTURE_SKYBOX_MODE: number;
  33784. /** Inverse Cubic coordinates mode */
  33785. static readonly TEXTURE_INVCUBIC_MODE: number;
  33786. /** Equirectangular coordinates mode */
  33787. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33788. /** Equirectangular Fixed coordinates mode */
  33789. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33790. /** Equirectangular Fixed Mirrored coordinates mode */
  33791. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33792. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33793. static readonly SCALEMODE_FLOOR: number;
  33794. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33795. static readonly SCALEMODE_NEAREST: number;
  33796. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33797. static readonly SCALEMODE_CEILING: number;
  33798. /**
  33799. * Returns the current npm package of the sdk
  33800. */
  33801. static get NpmPackage(): string;
  33802. /**
  33803. * Returns the current version of the framework
  33804. */
  33805. static get Version(): string;
  33806. /** Gets the list of created engines */
  33807. static get Instances(): Engine[];
  33808. /**
  33809. * Gets the latest created engine
  33810. */
  33811. static get LastCreatedEngine(): Nullable<Engine>;
  33812. /**
  33813. * Gets the latest created scene
  33814. */
  33815. static get LastCreatedScene(): Nullable<Scene>;
  33816. /**
  33817. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33818. * @param flag defines which part of the materials must be marked as dirty
  33819. * @param predicate defines a predicate used to filter which materials should be affected
  33820. */
  33821. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33822. /**
  33823. * Method called to create the default loading screen.
  33824. * This can be overriden in your own app.
  33825. * @param canvas The rendering canvas element
  33826. * @returns The loading screen
  33827. */
  33828. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33829. /**
  33830. * Method called to create the default rescale post process on each engine.
  33831. */
  33832. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33833. /**
  33834. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33835. **/
  33836. enableOfflineSupport: boolean;
  33837. /**
  33838. * 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)
  33839. **/
  33840. disableManifestCheck: boolean;
  33841. /**
  33842. * Gets the list of created scenes
  33843. */
  33844. scenes: Scene[];
  33845. /**
  33846. * Event raised when a new scene is created
  33847. */
  33848. onNewSceneAddedObservable: Observable<Scene>;
  33849. /**
  33850. * Gets the list of created postprocesses
  33851. */
  33852. postProcesses: PostProcess[];
  33853. /**
  33854. * Gets a boolean indicating if the pointer is currently locked
  33855. */
  33856. isPointerLock: boolean;
  33857. /**
  33858. * Observable event triggered each time the rendering canvas is resized
  33859. */
  33860. onResizeObservable: Observable<Engine>;
  33861. /**
  33862. * Observable event triggered each time the canvas loses focus
  33863. */
  33864. onCanvasBlurObservable: Observable<Engine>;
  33865. /**
  33866. * Observable event triggered each time the canvas gains focus
  33867. */
  33868. onCanvasFocusObservable: Observable<Engine>;
  33869. /**
  33870. * Observable event triggered each time the canvas receives pointerout event
  33871. */
  33872. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33873. /**
  33874. * Observable raised when the engine begins a new frame
  33875. */
  33876. onBeginFrameObservable: Observable<Engine>;
  33877. /**
  33878. * If set, will be used to request the next animation frame for the render loop
  33879. */
  33880. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33881. /**
  33882. * Observable raised when the engine ends the current frame
  33883. */
  33884. onEndFrameObservable: Observable<Engine>;
  33885. /**
  33886. * Observable raised when the engine is about to compile a shader
  33887. */
  33888. onBeforeShaderCompilationObservable: Observable<Engine>;
  33889. /**
  33890. * Observable raised when the engine has jsut compiled a shader
  33891. */
  33892. onAfterShaderCompilationObservable: Observable<Engine>;
  33893. /**
  33894. * Gets the audio engine
  33895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33896. * @ignorenaming
  33897. */
  33898. static audioEngine: IAudioEngine;
  33899. /**
  33900. * Default AudioEngine factory responsible of creating the Audio Engine.
  33901. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33902. */
  33903. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33904. /**
  33905. * Default offline support factory responsible of creating a tool used to store data locally.
  33906. * By default, this will create a Database object if the workload has been embedded.
  33907. */
  33908. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33909. private _loadingScreen;
  33910. private _pointerLockRequested;
  33911. private _dummyFramebuffer;
  33912. private _rescalePostProcess;
  33913. private _deterministicLockstep;
  33914. private _lockstepMaxSteps;
  33915. private _timeStep;
  33916. protected get _supportsHardwareTextureRescaling(): boolean;
  33917. private _fps;
  33918. private _deltaTime;
  33919. /** @hidden */
  33920. _drawCalls: PerfCounter;
  33921. /** 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 */
  33922. canvasTabIndex: number;
  33923. /**
  33924. * Turn this value on if you want to pause FPS computation when in background
  33925. */
  33926. disablePerformanceMonitorInBackground: boolean;
  33927. private _performanceMonitor;
  33928. /**
  33929. * Gets the performance monitor attached to this engine
  33930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33931. */
  33932. get performanceMonitor(): PerformanceMonitor;
  33933. private _onFocus;
  33934. private _onBlur;
  33935. private _onCanvasPointerOut;
  33936. private _onCanvasBlur;
  33937. private _onCanvasFocus;
  33938. private _onFullscreenChange;
  33939. private _onPointerLockChange;
  33940. /**
  33941. * Gets the HTML element used to attach event listeners
  33942. * @returns a HTML element
  33943. */
  33944. getInputElement(): Nullable<HTMLElement>;
  33945. /**
  33946. * Creates a new engine
  33947. * @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
  33948. * @param antialias defines enable antialiasing (default: false)
  33949. * @param options defines further options to be sent to the getContext() function
  33950. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33951. */
  33952. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33953. /**
  33954. * Gets current aspect ratio
  33955. * @param viewportOwner defines the camera to use to get the aspect ratio
  33956. * @param useScreen defines if screen size must be used (or the current render target if any)
  33957. * @returns a number defining the aspect ratio
  33958. */
  33959. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33960. /**
  33961. * Gets current screen aspect ratio
  33962. * @returns a number defining the aspect ratio
  33963. */
  33964. getScreenAspectRatio(): number;
  33965. /**
  33966. * Gets the client rect of the HTML canvas attached with the current webGL context
  33967. * @returns a client rectanglee
  33968. */
  33969. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33970. /**
  33971. * Gets the client rect of the HTML element used for events
  33972. * @returns a client rectanglee
  33973. */
  33974. getInputElementClientRect(): Nullable<ClientRect>;
  33975. /**
  33976. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33977. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33978. * @returns true if engine is in deterministic lock step mode
  33979. */
  33980. isDeterministicLockStep(): boolean;
  33981. /**
  33982. * Gets the max steps when engine is running in deterministic lock step
  33983. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33984. * @returns the max steps
  33985. */
  33986. getLockstepMaxSteps(): number;
  33987. /**
  33988. * Returns the time in ms between steps when using deterministic lock step.
  33989. * @returns time step in (ms)
  33990. */
  33991. getTimeStep(): number;
  33992. /**
  33993. * Force the mipmap generation for the given render target texture
  33994. * @param texture defines the render target texture to use
  33995. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33996. */
  33997. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33998. /** States */
  33999. /**
  34000. * Set various states to the webGL context
  34001. * @param culling defines backface culling state
  34002. * @param zOffset defines the value to apply to zOffset (0 by default)
  34003. * @param force defines if states must be applied even if cache is up to date
  34004. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34005. */
  34006. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34007. /**
  34008. * Set the z offset to apply to current rendering
  34009. * @param value defines the offset to apply
  34010. */
  34011. setZOffset(value: number): void;
  34012. /**
  34013. * Gets the current value of the zOffset
  34014. * @returns the current zOffset state
  34015. */
  34016. getZOffset(): number;
  34017. /**
  34018. * Enable or disable depth buffering
  34019. * @param enable defines the state to set
  34020. */
  34021. setDepthBuffer(enable: boolean): void;
  34022. /**
  34023. * Gets a boolean indicating if depth writing is enabled
  34024. * @returns the current depth writing state
  34025. */
  34026. getDepthWrite(): boolean;
  34027. /**
  34028. * Enable or disable depth writing
  34029. * @param enable defines the state to set
  34030. */
  34031. setDepthWrite(enable: boolean): void;
  34032. /**
  34033. * Gets a boolean indicating if stencil buffer is enabled
  34034. * @returns the current stencil buffer state
  34035. */
  34036. getStencilBuffer(): boolean;
  34037. /**
  34038. * Enable or disable the stencil buffer
  34039. * @param enable defines if the stencil buffer must be enabled or disabled
  34040. */
  34041. setStencilBuffer(enable: boolean): void;
  34042. /**
  34043. * Gets the current stencil mask
  34044. * @returns a number defining the new stencil mask to use
  34045. */
  34046. getStencilMask(): number;
  34047. /**
  34048. * Sets the current stencil mask
  34049. * @param mask defines the new stencil mask to use
  34050. */
  34051. setStencilMask(mask: number): void;
  34052. /**
  34053. * Gets the current stencil function
  34054. * @returns a number defining the stencil function to use
  34055. */
  34056. getStencilFunction(): number;
  34057. /**
  34058. * Gets the current stencil reference value
  34059. * @returns a number defining the stencil reference value to use
  34060. */
  34061. getStencilFunctionReference(): number;
  34062. /**
  34063. * Gets the current stencil mask
  34064. * @returns a number defining the stencil mask to use
  34065. */
  34066. getStencilFunctionMask(): number;
  34067. /**
  34068. * Sets the current stencil function
  34069. * @param stencilFunc defines the new stencil function to use
  34070. */
  34071. setStencilFunction(stencilFunc: number): void;
  34072. /**
  34073. * Sets the current stencil reference
  34074. * @param reference defines the new stencil reference to use
  34075. */
  34076. setStencilFunctionReference(reference: number): void;
  34077. /**
  34078. * Sets the current stencil mask
  34079. * @param mask defines the new stencil mask to use
  34080. */
  34081. setStencilFunctionMask(mask: number): void;
  34082. /**
  34083. * Gets the current stencil operation when stencil fails
  34084. * @returns a number defining stencil operation to use when stencil fails
  34085. */
  34086. getStencilOperationFail(): number;
  34087. /**
  34088. * Gets the current stencil operation when depth fails
  34089. * @returns a number defining stencil operation to use when depth fails
  34090. */
  34091. getStencilOperationDepthFail(): number;
  34092. /**
  34093. * Gets the current stencil operation when stencil passes
  34094. * @returns a number defining stencil operation to use when stencil passes
  34095. */
  34096. getStencilOperationPass(): number;
  34097. /**
  34098. * Sets the stencil operation to use when stencil fails
  34099. * @param operation defines the stencil operation to use when stencil fails
  34100. */
  34101. setStencilOperationFail(operation: number): void;
  34102. /**
  34103. * Sets the stencil operation to use when depth fails
  34104. * @param operation defines the stencil operation to use when depth fails
  34105. */
  34106. setStencilOperationDepthFail(operation: number): void;
  34107. /**
  34108. * Sets the stencil operation to use when stencil passes
  34109. * @param operation defines the stencil operation to use when stencil passes
  34110. */
  34111. setStencilOperationPass(operation: number): void;
  34112. /**
  34113. * Sets a boolean indicating if the dithering state is enabled or disabled
  34114. * @param value defines the dithering state
  34115. */
  34116. setDitheringState(value: boolean): void;
  34117. /**
  34118. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34119. * @param value defines the rasterizer state
  34120. */
  34121. setRasterizerState(value: boolean): void;
  34122. /**
  34123. * Gets the current depth function
  34124. * @returns a number defining the depth function
  34125. */
  34126. getDepthFunction(): Nullable<number>;
  34127. /**
  34128. * Sets the current depth function
  34129. * @param depthFunc defines the function to use
  34130. */
  34131. setDepthFunction(depthFunc: number): void;
  34132. /**
  34133. * Sets the current depth function to GREATER
  34134. */
  34135. setDepthFunctionToGreater(): void;
  34136. /**
  34137. * Sets the current depth function to GEQUAL
  34138. */
  34139. setDepthFunctionToGreaterOrEqual(): void;
  34140. /**
  34141. * Sets the current depth function to LESS
  34142. */
  34143. setDepthFunctionToLess(): void;
  34144. /**
  34145. * Sets the current depth function to LEQUAL
  34146. */
  34147. setDepthFunctionToLessOrEqual(): void;
  34148. private _cachedStencilBuffer;
  34149. private _cachedStencilFunction;
  34150. private _cachedStencilMask;
  34151. private _cachedStencilOperationPass;
  34152. private _cachedStencilOperationFail;
  34153. private _cachedStencilOperationDepthFail;
  34154. private _cachedStencilReference;
  34155. /**
  34156. * Caches the the state of the stencil buffer
  34157. */
  34158. cacheStencilState(): void;
  34159. /**
  34160. * Restores the state of the stencil buffer
  34161. */
  34162. restoreStencilState(): void;
  34163. /**
  34164. * Directly set the WebGL Viewport
  34165. * @param x defines the x coordinate of the viewport (in screen space)
  34166. * @param y defines the y coordinate of the viewport (in screen space)
  34167. * @param width defines the width of the viewport (in screen space)
  34168. * @param height defines the height of the viewport (in screen space)
  34169. * @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
  34170. */
  34171. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34172. /**
  34173. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34174. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34175. * @param y defines the y-coordinate of the corner of the clear rectangle
  34176. * @param width defines the width of the clear rectangle
  34177. * @param height defines the height of the clear rectangle
  34178. * @param clearColor defines the clear color
  34179. */
  34180. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34181. /**
  34182. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34183. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34184. * @param y defines the y-coordinate of the corner of the clear rectangle
  34185. * @param width defines the width of the clear rectangle
  34186. * @param height defines the height of the clear rectangle
  34187. */
  34188. enableScissor(x: number, y: number, width: number, height: number): void;
  34189. /**
  34190. * Disable previously set scissor test rectangle
  34191. */
  34192. disableScissor(): void;
  34193. protected _reportDrawCall(): void;
  34194. /**
  34195. * Initializes a webVR display and starts listening to display change events
  34196. * The onVRDisplayChangedObservable will be notified upon these changes
  34197. * @returns The onVRDisplayChangedObservable
  34198. */
  34199. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34200. /** @hidden */
  34201. _prepareVRComponent(): void;
  34202. /** @hidden */
  34203. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34204. /** @hidden */
  34205. _submitVRFrame(): void;
  34206. /**
  34207. * Call this function to leave webVR mode
  34208. * Will do nothing if webVR is not supported or if there is no webVR device
  34209. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34210. */
  34211. disableVR(): void;
  34212. /**
  34213. * Gets a boolean indicating that the system is in VR mode and is presenting
  34214. * @returns true if VR mode is engaged
  34215. */
  34216. isVRPresenting(): boolean;
  34217. /** @hidden */
  34218. _requestVRFrame(): void;
  34219. /** @hidden */
  34220. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34221. /**
  34222. * Gets the source code of the vertex shader associated with a specific webGL program
  34223. * @param program defines the program to use
  34224. * @returns a string containing the source code of the vertex shader associated with the program
  34225. */
  34226. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34227. /**
  34228. * Gets the source code of the fragment shader associated with a specific webGL program
  34229. * @param program defines the program to use
  34230. * @returns a string containing the source code of the fragment shader associated with the program
  34231. */
  34232. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34233. /**
  34234. * Sets a depth stencil texture from a render target to the according uniform.
  34235. * @param channel The texture channel
  34236. * @param uniform The uniform to set
  34237. * @param texture The render target texture containing the depth stencil texture to apply
  34238. */
  34239. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34240. /**
  34241. * Sets a texture to the webGL context from a postprocess
  34242. * @param channel defines the channel to use
  34243. * @param postProcess defines the source postprocess
  34244. */
  34245. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34246. /**
  34247. * Binds the output of the passed in post process to the texture channel specified
  34248. * @param channel The channel the texture should be bound to
  34249. * @param postProcess The post process which's output should be bound
  34250. */
  34251. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34252. protected _rebuildBuffers(): void;
  34253. /** @hidden */
  34254. _renderFrame(): void;
  34255. _renderLoop(): void;
  34256. /** @hidden */
  34257. _renderViews(): boolean;
  34258. /**
  34259. * Toggle full screen mode
  34260. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34261. */
  34262. switchFullscreen(requestPointerLock: boolean): void;
  34263. /**
  34264. * Enters full screen mode
  34265. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34266. */
  34267. enterFullscreen(requestPointerLock: boolean): void;
  34268. /**
  34269. * Exits full screen mode
  34270. */
  34271. exitFullscreen(): void;
  34272. /**
  34273. * Enters Pointerlock mode
  34274. */
  34275. enterPointerlock(): void;
  34276. /**
  34277. * Exits Pointerlock mode
  34278. */
  34279. exitPointerlock(): void;
  34280. /**
  34281. * Begin a new frame
  34282. */
  34283. beginFrame(): void;
  34284. /**
  34285. * Enf the current frame
  34286. */
  34287. endFrame(): void;
  34288. resize(): void;
  34289. /**
  34290. * Force a specific size of the canvas
  34291. * @param width defines the new canvas' width
  34292. * @param height defines the new canvas' height
  34293. */
  34294. setSize(width: number, height: number): void;
  34295. /**
  34296. * Updates a dynamic vertex buffer.
  34297. * @param vertexBuffer the vertex buffer to update
  34298. * @param data the data used to update the vertex buffer
  34299. * @param byteOffset the byte offset of the data
  34300. * @param byteLength the byte length of the data
  34301. */
  34302. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34303. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34304. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34305. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34306. _releaseTexture(texture: InternalTexture): void;
  34307. /**
  34308. * @hidden
  34309. * Rescales a texture
  34310. * @param source input texutre
  34311. * @param destination destination texture
  34312. * @param scene scene to use to render the resize
  34313. * @param internalFormat format to use when resizing
  34314. * @param onComplete callback to be called when resize has completed
  34315. */
  34316. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34317. /**
  34318. * Gets the current framerate
  34319. * @returns a number representing the framerate
  34320. */
  34321. getFps(): number;
  34322. /**
  34323. * Gets the time spent between current and previous frame
  34324. * @returns a number representing the delta time in ms
  34325. */
  34326. getDeltaTime(): number;
  34327. private _measureFps;
  34328. /** @hidden */
  34329. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34330. /**
  34331. * Update a dynamic index buffer
  34332. * @param indexBuffer defines the target index buffer
  34333. * @param indices defines the data to update
  34334. * @param offset defines the offset in the target index buffer where update should start
  34335. */
  34336. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34337. /**
  34338. * Updates the sample count of a render target texture
  34339. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34340. * @param texture defines the texture to update
  34341. * @param samples defines the sample count to set
  34342. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34343. */
  34344. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34345. /**
  34346. * Updates a depth texture Comparison Mode and Function.
  34347. * If the comparison Function is equal to 0, the mode will be set to none.
  34348. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34349. * @param texture The texture to set the comparison function for
  34350. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34351. */
  34352. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34353. /**
  34354. * Creates a webGL buffer to use with instanciation
  34355. * @param capacity defines the size of the buffer
  34356. * @returns the webGL buffer
  34357. */
  34358. createInstancesBuffer(capacity: number): DataBuffer;
  34359. /**
  34360. * Delete a webGL buffer used with instanciation
  34361. * @param buffer defines the webGL buffer to delete
  34362. */
  34363. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34364. private _clientWaitAsync;
  34365. /** @hidden */
  34366. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34367. /** @hidden */
  34368. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34369. dispose(): void;
  34370. private _disableTouchAction;
  34371. /**
  34372. * Display the loading screen
  34373. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34374. */
  34375. displayLoadingUI(): void;
  34376. /**
  34377. * Hide the loading screen
  34378. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34379. */
  34380. hideLoadingUI(): void;
  34381. /**
  34382. * Gets the current loading screen object
  34383. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34384. */
  34385. get loadingScreen(): ILoadingScreen;
  34386. /**
  34387. * Sets the current loading screen object
  34388. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34389. */
  34390. set loadingScreen(loadingScreen: ILoadingScreen);
  34391. /**
  34392. * Sets the current loading screen text
  34393. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34394. */
  34395. set loadingUIText(text: string);
  34396. /**
  34397. * Sets the current loading screen background color
  34398. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34399. */
  34400. set loadingUIBackgroundColor(color: string);
  34401. /** Pointerlock and fullscreen */
  34402. /**
  34403. * Ask the browser to promote the current element to pointerlock mode
  34404. * @param element defines the DOM element to promote
  34405. */
  34406. static _RequestPointerlock(element: HTMLElement): void;
  34407. /**
  34408. * Asks the browser to exit pointerlock mode
  34409. */
  34410. static _ExitPointerlock(): void;
  34411. /**
  34412. * Ask the browser to promote the current element to fullscreen rendering mode
  34413. * @param element defines the DOM element to promote
  34414. */
  34415. static _RequestFullscreen(element: HTMLElement): void;
  34416. /**
  34417. * Asks the browser to exit fullscreen mode
  34418. */
  34419. static _ExitFullscreen(): void;
  34420. }
  34421. }
  34422. declare module BABYLON {
  34423. /**
  34424. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34425. * during the life time of the application.
  34426. */
  34427. export class EngineStore {
  34428. /** Gets the list of created engines */
  34429. static Instances: Engine[];
  34430. /** @hidden */
  34431. static _LastCreatedScene: Nullable<Scene>;
  34432. /**
  34433. * Gets the latest created engine
  34434. */
  34435. static get LastCreatedEngine(): Nullable<Engine>;
  34436. /**
  34437. * Gets the latest created scene
  34438. */
  34439. static get LastCreatedScene(): Nullable<Scene>;
  34440. /**
  34441. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34442. * @ignorenaming
  34443. */
  34444. static UseFallbackTexture: boolean;
  34445. /**
  34446. * Texture content used if a texture cannot loaded
  34447. * @ignorenaming
  34448. */
  34449. static FallbackTexture: string;
  34450. }
  34451. }
  34452. declare module BABYLON {
  34453. /**
  34454. * Helper class that provides a small promise polyfill
  34455. */
  34456. export class PromisePolyfill {
  34457. /**
  34458. * Static function used to check if the polyfill is required
  34459. * If this is the case then the function will inject the polyfill to window.Promise
  34460. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34461. */
  34462. static Apply(force?: boolean): void;
  34463. }
  34464. }
  34465. declare module BABYLON {
  34466. /**
  34467. * Interface for screenshot methods with describe argument called `size` as object with options
  34468. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34469. */
  34470. export interface IScreenshotSize {
  34471. /**
  34472. * number in pixels for canvas height
  34473. */
  34474. height?: number;
  34475. /**
  34476. * multiplier allowing render at a higher or lower resolution
  34477. * If value is defined then height and width will be ignored and taken from camera
  34478. */
  34479. precision?: number;
  34480. /**
  34481. * number in pixels for canvas width
  34482. */
  34483. width?: number;
  34484. }
  34485. }
  34486. declare module BABYLON {
  34487. interface IColor4Like {
  34488. r: float;
  34489. g: float;
  34490. b: float;
  34491. a: float;
  34492. }
  34493. /**
  34494. * Class containing a set of static utilities functions
  34495. */
  34496. export class Tools {
  34497. /**
  34498. * Gets or sets the base URL to use to load assets
  34499. */
  34500. static get BaseUrl(): string;
  34501. static set BaseUrl(value: string);
  34502. /**
  34503. * Enable/Disable Custom HTTP Request Headers globally.
  34504. * default = false
  34505. * @see CustomRequestHeaders
  34506. */
  34507. static UseCustomRequestHeaders: boolean;
  34508. /**
  34509. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34510. * i.e. when loading files, where the server/service expects an Authorization header
  34511. */
  34512. static CustomRequestHeaders: {
  34513. [key: string]: string;
  34514. };
  34515. /**
  34516. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34517. */
  34518. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34519. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34520. /**
  34521. * Default behaviour for cors in the application.
  34522. * It can be a string if the expected behavior is identical in the entire app.
  34523. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34524. */
  34525. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34526. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34527. /**
  34528. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34529. * @ignorenaming
  34530. */
  34531. static get UseFallbackTexture(): boolean;
  34532. static set UseFallbackTexture(value: boolean);
  34533. /**
  34534. * Use this object to register external classes like custom textures or material
  34535. * to allow the laoders to instantiate them
  34536. */
  34537. static get RegisteredExternalClasses(): {
  34538. [key: string]: Object;
  34539. };
  34540. static set RegisteredExternalClasses(classes: {
  34541. [key: string]: Object;
  34542. });
  34543. /**
  34544. * Texture content used if a texture cannot loaded
  34545. * @ignorenaming
  34546. */
  34547. static get fallbackTexture(): string;
  34548. static set fallbackTexture(value: string);
  34549. /**
  34550. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34551. * @param u defines the coordinate on X axis
  34552. * @param v defines the coordinate on Y axis
  34553. * @param width defines the width of the source data
  34554. * @param height defines the height of the source data
  34555. * @param pixels defines the source byte array
  34556. * @param color defines the output color
  34557. */
  34558. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34559. /**
  34560. * Interpolates between a and b via alpha
  34561. * @param a The lower value (returned when alpha = 0)
  34562. * @param b The upper value (returned when alpha = 1)
  34563. * @param alpha The interpolation-factor
  34564. * @return The mixed value
  34565. */
  34566. static Mix(a: number, b: number, alpha: number): number;
  34567. /**
  34568. * Tries to instantiate a new object from a given class name
  34569. * @param className defines the class name to instantiate
  34570. * @returns the new object or null if the system was not able to do the instantiation
  34571. */
  34572. static Instantiate(className: string): any;
  34573. /**
  34574. * Provides a slice function that will work even on IE
  34575. * @param data defines the array to slice
  34576. * @param start defines the start of the data (optional)
  34577. * @param end defines the end of the data (optional)
  34578. * @returns the new sliced array
  34579. */
  34580. static Slice<T>(data: T, start?: number, end?: number): T;
  34581. /**
  34582. * Polyfill for setImmediate
  34583. * @param action defines the action to execute after the current execution block
  34584. */
  34585. static SetImmediate(action: () => void): void;
  34586. /**
  34587. * Function indicating if a number is an exponent of 2
  34588. * @param value defines the value to test
  34589. * @returns true if the value is an exponent of 2
  34590. */
  34591. static IsExponentOfTwo(value: number): boolean;
  34592. private static _tmpFloatArray;
  34593. /**
  34594. * Returns the nearest 32-bit single precision float representation of a Number
  34595. * @param value A Number. If the parameter is of a different type, it will get converted
  34596. * to a number or to NaN if it cannot be converted
  34597. * @returns number
  34598. */
  34599. static FloatRound(value: number): number;
  34600. /**
  34601. * Extracts the filename from a path
  34602. * @param path defines the path to use
  34603. * @returns the filename
  34604. */
  34605. static GetFilename(path: string): string;
  34606. /**
  34607. * Extracts the "folder" part of a path (everything before the filename).
  34608. * @param uri The URI to extract the info from
  34609. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34610. * @returns The "folder" part of the path
  34611. */
  34612. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34613. /**
  34614. * Extracts text content from a DOM element hierarchy
  34615. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34616. */
  34617. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34618. /**
  34619. * Convert an angle in radians to degrees
  34620. * @param angle defines the angle to convert
  34621. * @returns the angle in degrees
  34622. */
  34623. static ToDegrees(angle: number): number;
  34624. /**
  34625. * Convert an angle in degrees to radians
  34626. * @param angle defines the angle to convert
  34627. * @returns the angle in radians
  34628. */
  34629. static ToRadians(angle: number): number;
  34630. /**
  34631. * Returns an array if obj is not an array
  34632. * @param obj defines the object to evaluate as an array
  34633. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34634. * @returns either obj directly if obj is an array or a new array containing obj
  34635. */
  34636. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34637. /**
  34638. * Gets the pointer prefix to use
  34639. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34640. */
  34641. static GetPointerPrefix(): string;
  34642. /**
  34643. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34644. * @param url define the url we are trying
  34645. * @param element define the dom element where to configure the cors policy
  34646. */
  34647. static SetCorsBehavior(url: string | string[], element: {
  34648. crossOrigin: string | null;
  34649. }): void;
  34650. /**
  34651. * Removes unwanted characters from an url
  34652. * @param url defines the url to clean
  34653. * @returns the cleaned url
  34654. */
  34655. static CleanUrl(url: string): string;
  34656. /**
  34657. * Gets or sets a function used to pre-process url before using them to load assets
  34658. */
  34659. static get PreprocessUrl(): (url: string) => string;
  34660. static set PreprocessUrl(processor: (url: string) => string);
  34661. /**
  34662. * Loads an image as an HTMLImageElement.
  34663. * @param input url string, ArrayBuffer, or Blob to load
  34664. * @param onLoad callback called when the image successfully loads
  34665. * @param onError callback called when the image fails to load
  34666. * @param offlineProvider offline provider for caching
  34667. * @param mimeType optional mime type
  34668. * @returns the HTMLImageElement of the loaded image
  34669. */
  34670. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34671. /**
  34672. * Loads a file from a url
  34673. * @param url url string, ArrayBuffer, or Blob to load
  34674. * @param onSuccess callback called when the file successfully loads
  34675. * @param onProgress callback called while file is loading (if the server supports this mode)
  34676. * @param offlineProvider defines the offline provider for caching
  34677. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34678. * @param onError callback called when the file fails to load
  34679. * @returns a file request object
  34680. */
  34681. 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;
  34682. /**
  34683. * Loads a file from a url
  34684. * @param url the file url to load
  34685. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34686. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34687. */
  34688. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34689. /**
  34690. * Load a script (identified by an url). When the url returns, the
  34691. * content of this file is added into a new script element, attached to the DOM (body element)
  34692. * @param scriptUrl defines the url of the script to laod
  34693. * @param onSuccess defines the callback called when the script is loaded
  34694. * @param onError defines the callback to call if an error occurs
  34695. * @param scriptId defines the id of the script element
  34696. */
  34697. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34698. /**
  34699. * Load an asynchronous script (identified by an url). When the url returns, the
  34700. * content of this file is added into a new script element, attached to the DOM (body element)
  34701. * @param scriptUrl defines the url of the script to laod
  34702. * @param scriptId defines the id of the script element
  34703. * @returns a promise request object
  34704. */
  34705. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34706. /**
  34707. * Loads a file from a blob
  34708. * @param fileToLoad defines the blob to use
  34709. * @param callback defines the callback to call when data is loaded
  34710. * @param progressCallback defines the callback to call during loading process
  34711. * @returns a file request object
  34712. */
  34713. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34714. /**
  34715. * Reads a file from a File object
  34716. * @param file defines the file to load
  34717. * @param onSuccess defines the callback to call when data is loaded
  34718. * @param onProgress defines the callback to call during loading process
  34719. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34720. * @param onError defines the callback to call when an error occurs
  34721. * @returns a file request object
  34722. */
  34723. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34724. /**
  34725. * Creates a data url from a given string content
  34726. * @param content defines the content to convert
  34727. * @returns the new data url link
  34728. */
  34729. static FileAsURL(content: string): string;
  34730. /**
  34731. * Format the given number to a specific decimal format
  34732. * @param value defines the number to format
  34733. * @param decimals defines the number of decimals to use
  34734. * @returns the formatted string
  34735. */
  34736. static Format(value: number, decimals?: number): string;
  34737. /**
  34738. * Tries to copy an object by duplicating every property
  34739. * @param source defines the source object
  34740. * @param destination defines the target object
  34741. * @param doNotCopyList defines a list of properties to avoid
  34742. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34743. */
  34744. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34745. /**
  34746. * Gets a boolean indicating if the given object has no own property
  34747. * @param obj defines the object to test
  34748. * @returns true if object has no own property
  34749. */
  34750. static IsEmpty(obj: any): boolean;
  34751. /**
  34752. * Function used to register events at window level
  34753. * @param windowElement defines the Window object to use
  34754. * @param events defines the events to register
  34755. */
  34756. static RegisterTopRootEvents(windowElement: Window, events: {
  34757. name: string;
  34758. handler: Nullable<(e: FocusEvent) => any>;
  34759. }[]): void;
  34760. /**
  34761. * Function used to unregister events from window level
  34762. * @param windowElement defines the Window object to use
  34763. * @param events defines the events to unregister
  34764. */
  34765. static UnregisterTopRootEvents(windowElement: Window, events: {
  34766. name: string;
  34767. handler: Nullable<(e: FocusEvent) => any>;
  34768. }[]): void;
  34769. /**
  34770. * @ignore
  34771. */
  34772. static _ScreenshotCanvas: HTMLCanvasElement;
  34773. /**
  34774. * Dumps the current bound framebuffer
  34775. * @param width defines the rendering width
  34776. * @param height defines the rendering height
  34777. * @param engine defines the hosting engine
  34778. * @param successCallback defines the callback triggered once the data are available
  34779. * @param mimeType defines the mime type of the result
  34780. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34781. */
  34782. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34783. /**
  34784. * Converts the canvas data to blob.
  34785. * This acts as a polyfill for browsers not supporting the to blob function.
  34786. * @param canvas Defines the canvas to extract the data from
  34787. * @param successCallback Defines the callback triggered once the data are available
  34788. * @param mimeType Defines the mime type of the result
  34789. */
  34790. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34791. /**
  34792. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34793. * @param successCallback defines the callback triggered once the data are available
  34794. * @param mimeType defines the mime type of the result
  34795. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34796. */
  34797. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34798. /**
  34799. * Downloads a blob in the browser
  34800. * @param blob defines the blob to download
  34801. * @param fileName defines the name of the downloaded file
  34802. */
  34803. static Download(blob: Blob, fileName: string): void;
  34804. /**
  34805. * Captures a screenshot of the current rendering
  34806. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34807. * @param engine defines the rendering engine
  34808. * @param camera defines the source camera
  34809. * @param size This parameter can be set to a single number or to an object with the
  34810. * following (optional) properties: precision, width, height. If a single number is passed,
  34811. * it will be used for both width and height. If an object is passed, the screenshot size
  34812. * will be derived from the parameters. The precision property is a multiplier allowing
  34813. * rendering at a higher or lower resolution
  34814. * @param successCallback defines the callback receives a single parameter which contains the
  34815. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34816. * src parameter of an <img> to display it
  34817. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34818. * Check your browser for supported MIME types
  34819. */
  34820. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34821. /**
  34822. * Captures a screenshot of the current rendering
  34823. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34824. * @param engine defines the rendering engine
  34825. * @param camera defines the source camera
  34826. * @param size This parameter can be set to a single number or to an object with the
  34827. * following (optional) properties: precision, width, height. If a single number is passed,
  34828. * it will be used for both width and height. If an object is passed, the screenshot size
  34829. * will be derived from the parameters. The precision property is a multiplier allowing
  34830. * rendering at a higher or lower resolution
  34831. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34832. * Check your browser for supported MIME types
  34833. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34834. * to the src parameter of an <img> to display it
  34835. */
  34836. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34837. /**
  34838. * Generates an image screenshot from the specified camera.
  34839. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34840. * @param engine The engine to use for rendering
  34841. * @param camera The camera to use for rendering
  34842. * @param size This parameter can be set to a single number or to an object with the
  34843. * following (optional) properties: precision, width, height. If a single number is passed,
  34844. * it will be used for both width and height. If an object is passed, the screenshot size
  34845. * will be derived from the parameters. The precision property is a multiplier allowing
  34846. * rendering at a higher or lower resolution
  34847. * @param successCallback The callback receives a single parameter which contains the
  34848. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34849. * src parameter of an <img> to display it
  34850. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34851. * Check your browser for supported MIME types
  34852. * @param samples Texture samples (default: 1)
  34853. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34854. * @param fileName A name for for the downloaded file.
  34855. */
  34856. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34857. /**
  34858. * Generates an image screenshot from the specified camera.
  34859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34860. * @param engine The engine to use for rendering
  34861. * @param camera The camera to use for rendering
  34862. * @param size This parameter can be set to a single number or to an object with the
  34863. * following (optional) properties: precision, width, height. If a single number is passed,
  34864. * it will be used for both width and height. If an object is passed, the screenshot size
  34865. * will be derived from the parameters. The precision property is a multiplier allowing
  34866. * rendering at a higher or lower resolution
  34867. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34868. * Check your browser for supported MIME types
  34869. * @param samples Texture samples (default: 1)
  34870. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34871. * @param fileName A name for for the downloaded file.
  34872. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34873. * to the src parameter of an <img> to display it
  34874. */
  34875. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34876. /**
  34877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34878. * Be aware Math.random() could cause collisions, but:
  34879. * "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"
  34880. * @returns a pseudo random id
  34881. */
  34882. static RandomId(): string;
  34883. /**
  34884. * Test if the given uri is a base64 string
  34885. * @param uri The uri to test
  34886. * @return True if the uri is a base64 string or false otherwise
  34887. */
  34888. static IsBase64(uri: string): boolean;
  34889. /**
  34890. * Decode the given base64 uri.
  34891. * @param uri The uri to decode
  34892. * @return The decoded base64 data.
  34893. */
  34894. static DecodeBase64(uri: string): ArrayBuffer;
  34895. /**
  34896. * Gets the absolute url.
  34897. * @param url the input url
  34898. * @return the absolute url
  34899. */
  34900. static GetAbsoluteUrl(url: string): string;
  34901. /**
  34902. * No log
  34903. */
  34904. static readonly NoneLogLevel: number;
  34905. /**
  34906. * Only message logs
  34907. */
  34908. static readonly MessageLogLevel: number;
  34909. /**
  34910. * Only warning logs
  34911. */
  34912. static readonly WarningLogLevel: number;
  34913. /**
  34914. * Only error logs
  34915. */
  34916. static readonly ErrorLogLevel: number;
  34917. /**
  34918. * All logs
  34919. */
  34920. static readonly AllLogLevel: number;
  34921. /**
  34922. * Gets a value indicating the number of loading errors
  34923. * @ignorenaming
  34924. */
  34925. static get errorsCount(): number;
  34926. /**
  34927. * Callback called when a new log is added
  34928. */
  34929. static OnNewCacheEntry: (entry: string) => void;
  34930. /**
  34931. * Log a message to the console
  34932. * @param message defines the message to log
  34933. */
  34934. static Log(message: string): void;
  34935. /**
  34936. * Write a warning message to the console
  34937. * @param message defines the message to log
  34938. */
  34939. static Warn(message: string): void;
  34940. /**
  34941. * Write an error message to the console
  34942. * @param message defines the message to log
  34943. */
  34944. static Error(message: string): void;
  34945. /**
  34946. * Gets current log cache (list of logs)
  34947. */
  34948. static get LogCache(): string;
  34949. /**
  34950. * Clears the log cache
  34951. */
  34952. static ClearLogCache(): void;
  34953. /**
  34954. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34955. */
  34956. static set LogLevels(level: number);
  34957. /**
  34958. * Checks if the window object exists
  34959. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34960. */
  34961. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34962. /**
  34963. * No performance log
  34964. */
  34965. static readonly PerformanceNoneLogLevel: number;
  34966. /**
  34967. * Use user marks to log performance
  34968. */
  34969. static readonly PerformanceUserMarkLogLevel: number;
  34970. /**
  34971. * Log performance to the console
  34972. */
  34973. static readonly PerformanceConsoleLogLevel: number;
  34974. private static _performance;
  34975. /**
  34976. * Sets the current performance log level
  34977. */
  34978. static set PerformanceLogLevel(level: number);
  34979. private static _StartPerformanceCounterDisabled;
  34980. private static _EndPerformanceCounterDisabled;
  34981. private static _StartUserMark;
  34982. private static _EndUserMark;
  34983. private static _StartPerformanceConsole;
  34984. private static _EndPerformanceConsole;
  34985. /**
  34986. * Starts a performance counter
  34987. */
  34988. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34989. /**
  34990. * Ends a specific performance coutner
  34991. */
  34992. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34993. /**
  34994. * Gets either window.performance.now() if supported or Date.now() else
  34995. */
  34996. static get Now(): number;
  34997. /**
  34998. * This method will return the name of the class used to create the instance of the given object.
  34999. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35000. * @param object the object to get the class name from
  35001. * @param isType defines if the object is actually a type
  35002. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35003. */
  35004. static GetClassName(object: any, isType?: boolean): string;
  35005. /**
  35006. * Gets the first element of an array satisfying a given predicate
  35007. * @param array defines the array to browse
  35008. * @param predicate defines the predicate to use
  35009. * @returns null if not found or the element
  35010. */
  35011. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35012. /**
  35013. * This method will return the name of the full name of the class, including its owning module (if any).
  35014. * 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).
  35015. * @param object the object to get the class name from
  35016. * @param isType defines if the object is actually a type
  35017. * @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.
  35018. * @ignorenaming
  35019. */
  35020. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35021. /**
  35022. * Returns a promise that resolves after the given amount of time.
  35023. * @param delay Number of milliseconds to delay
  35024. * @returns Promise that resolves after the given amount of time
  35025. */
  35026. static DelayAsync(delay: number): Promise<void>;
  35027. /**
  35028. * Utility function to detect if the current user agent is Safari
  35029. * @returns whether or not the current user agent is safari
  35030. */
  35031. static IsSafari(): boolean;
  35032. }
  35033. /**
  35034. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35035. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35036. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35037. * @param name The name of the class, case should be preserved
  35038. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35039. */
  35040. export function className(name: string, module?: string): (target: Object) => void;
  35041. /**
  35042. * An implementation of a loop for asynchronous functions.
  35043. */
  35044. export class AsyncLoop {
  35045. /**
  35046. * Defines the number of iterations for the loop
  35047. */
  35048. iterations: number;
  35049. /**
  35050. * Defines the current index of the loop.
  35051. */
  35052. index: number;
  35053. private _done;
  35054. private _fn;
  35055. private _successCallback;
  35056. /**
  35057. * Constructor.
  35058. * @param iterations the number of iterations.
  35059. * @param func the function to run each iteration
  35060. * @param successCallback the callback that will be called upon succesful execution
  35061. * @param offset starting offset.
  35062. */
  35063. constructor(
  35064. /**
  35065. * Defines the number of iterations for the loop
  35066. */
  35067. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35068. /**
  35069. * Execute the next iteration. Must be called after the last iteration was finished.
  35070. */
  35071. executeNext(): void;
  35072. /**
  35073. * Break the loop and run the success callback.
  35074. */
  35075. breakLoop(): void;
  35076. /**
  35077. * Create and run an async loop.
  35078. * @param iterations the number of iterations.
  35079. * @param fn the function to run each iteration
  35080. * @param successCallback the callback that will be called upon succesful execution
  35081. * @param offset starting offset.
  35082. * @returns the created async loop object
  35083. */
  35084. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35085. /**
  35086. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35087. * @param iterations total number of iterations
  35088. * @param syncedIterations number of synchronous iterations in each async iteration.
  35089. * @param fn the function to call each iteration.
  35090. * @param callback a success call back that will be called when iterating stops.
  35091. * @param breakFunction a break condition (optional)
  35092. * @param timeout timeout settings for the setTimeout function. default - 0.
  35093. * @returns the created async loop object
  35094. */
  35095. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35096. }
  35097. }
  35098. declare module BABYLON {
  35099. /**
  35100. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35101. * The underlying implementation relies on an associative array to ensure the best performances.
  35102. * The value can be anything including 'null' but except 'undefined'
  35103. */
  35104. export class StringDictionary<T> {
  35105. /**
  35106. * This will clear this dictionary and copy the content from the 'source' one.
  35107. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35108. * @param source the dictionary to take the content from and copy to this dictionary
  35109. */
  35110. copyFrom(source: StringDictionary<T>): void;
  35111. /**
  35112. * Get a value based from its key
  35113. * @param key the given key to get the matching value from
  35114. * @return the value if found, otherwise undefined is returned
  35115. */
  35116. get(key: string): T | undefined;
  35117. /**
  35118. * Get a value from its key or add it if it doesn't exist.
  35119. * This method will ensure you that a given key/data will be present in the dictionary.
  35120. * @param key the given key to get the matching value from
  35121. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35122. * The factory will only be invoked if there's no data for the given key.
  35123. * @return the value corresponding to the key.
  35124. */
  35125. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35126. /**
  35127. * Get a value from its key if present in the dictionary otherwise add it
  35128. * @param key the key to get the value from
  35129. * @param val if there's no such key/value pair in the dictionary add it with this value
  35130. * @return the value corresponding to the key
  35131. */
  35132. getOrAdd(key: string, val: T): T;
  35133. /**
  35134. * Check if there's a given key in the dictionary
  35135. * @param key the key to check for
  35136. * @return true if the key is present, false otherwise
  35137. */
  35138. contains(key: string): boolean;
  35139. /**
  35140. * Add a new key and its corresponding value
  35141. * @param key the key to add
  35142. * @param value the value corresponding to the key
  35143. * @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
  35144. */
  35145. add(key: string, value: T): boolean;
  35146. /**
  35147. * Update a specific value associated to a key
  35148. * @param key defines the key to use
  35149. * @param value defines the value to store
  35150. * @returns true if the value was updated (or false if the key was not found)
  35151. */
  35152. set(key: string, value: T): boolean;
  35153. /**
  35154. * Get the element of the given key and remove it from the dictionary
  35155. * @param key defines the key to search
  35156. * @returns the value associated with the key or null if not found
  35157. */
  35158. getAndRemove(key: string): Nullable<T>;
  35159. /**
  35160. * Remove a key/value from the dictionary.
  35161. * @param key the key to remove
  35162. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35163. */
  35164. remove(key: string): boolean;
  35165. /**
  35166. * Clear the whole content of the dictionary
  35167. */
  35168. clear(): void;
  35169. /**
  35170. * Gets the current count
  35171. */
  35172. get count(): number;
  35173. /**
  35174. * Execute a callback on each key/val of the dictionary.
  35175. * Note that you can remove any element in this dictionary in the callback implementation
  35176. * @param callback the callback to execute on a given key/value pair
  35177. */
  35178. forEach(callback: (key: string, val: T) => void): void;
  35179. /**
  35180. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35181. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35182. * Note that you can remove any element in this dictionary in the callback implementation
  35183. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35184. * @returns the first item
  35185. */
  35186. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35187. private _count;
  35188. private _data;
  35189. }
  35190. }
  35191. declare module BABYLON {
  35192. /** @hidden */
  35193. export interface ICollisionCoordinator {
  35194. createCollider(): Collider;
  35195. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35196. init(scene: Scene): void;
  35197. }
  35198. /** @hidden */
  35199. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35200. private _scene;
  35201. private _scaledPosition;
  35202. private _scaledVelocity;
  35203. private _finalPosition;
  35204. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35205. createCollider(): Collider;
  35206. init(scene: Scene): void;
  35207. private _collideWithWorld;
  35208. }
  35209. }
  35210. declare module BABYLON {
  35211. /**
  35212. * Class used to manage all inputs for the scene.
  35213. */
  35214. export class InputManager {
  35215. /** The distance in pixel that you have to move to prevent some events */
  35216. static DragMovementThreshold: number;
  35217. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35218. static LongPressDelay: number;
  35219. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35220. static DoubleClickDelay: number;
  35221. /** If you need to check double click without raising a single click at first click, enable this flag */
  35222. static ExclusiveDoubleClickMode: boolean;
  35223. private _wheelEventName;
  35224. private _onPointerMove;
  35225. private _onPointerDown;
  35226. private _onPointerUp;
  35227. private _initClickEvent;
  35228. private _initActionManager;
  35229. private _delayedSimpleClick;
  35230. private _delayedSimpleClickTimeout;
  35231. private _previousDelayedSimpleClickTimeout;
  35232. private _meshPickProceed;
  35233. private _previousButtonPressed;
  35234. private _currentPickResult;
  35235. private _previousPickResult;
  35236. private _totalPointersPressed;
  35237. private _doubleClickOccured;
  35238. private _pointerOverMesh;
  35239. private _pickedDownMesh;
  35240. private _pickedUpMesh;
  35241. private _pointerX;
  35242. private _pointerY;
  35243. private _unTranslatedPointerX;
  35244. private _unTranslatedPointerY;
  35245. private _startingPointerPosition;
  35246. private _previousStartingPointerPosition;
  35247. private _startingPointerTime;
  35248. private _previousStartingPointerTime;
  35249. private _pointerCaptures;
  35250. private _onKeyDown;
  35251. private _onKeyUp;
  35252. private _onCanvasFocusObserver;
  35253. private _onCanvasBlurObserver;
  35254. private _scene;
  35255. /**
  35256. * Creates a new InputManager
  35257. * @param scene defines the hosting scene
  35258. */
  35259. constructor(scene: Scene);
  35260. /**
  35261. * Gets the mesh that is currently under the pointer
  35262. */
  35263. get meshUnderPointer(): Nullable<AbstractMesh>;
  35264. /**
  35265. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35266. */
  35267. get unTranslatedPointer(): Vector2;
  35268. /**
  35269. * Gets or sets the current on-screen X position of the pointer
  35270. */
  35271. get pointerX(): number;
  35272. set pointerX(value: number);
  35273. /**
  35274. * Gets or sets the current on-screen Y position of the pointer
  35275. */
  35276. get pointerY(): number;
  35277. set pointerY(value: number);
  35278. private _updatePointerPosition;
  35279. private _processPointerMove;
  35280. private _setRayOnPointerInfo;
  35281. private _checkPrePointerObservable;
  35282. /**
  35283. * Use this method to simulate a pointer move on a mesh
  35284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35287. */
  35288. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35289. /**
  35290. * Use this method to simulate a pointer down on a mesh
  35291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35294. */
  35295. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35296. private _processPointerDown;
  35297. /** @hidden */
  35298. _isPointerSwiping(): boolean;
  35299. /**
  35300. * Use this method to simulate a pointer up on a mesh
  35301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35304. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35305. */
  35306. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35307. private _processPointerUp;
  35308. /**
  35309. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35310. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35311. * @returns true if the pointer was captured
  35312. */
  35313. isPointerCaptured(pointerId?: number): boolean;
  35314. /**
  35315. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35316. * @param attachUp defines if you want to attach events to pointerup
  35317. * @param attachDown defines if you want to attach events to pointerdown
  35318. * @param attachMove defines if you want to attach events to pointermove
  35319. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35320. */
  35321. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35322. /**
  35323. * Detaches all event handlers
  35324. */
  35325. detachControl(): void;
  35326. /**
  35327. * Force the value of meshUnderPointer
  35328. * @param mesh defines the mesh to use
  35329. */
  35330. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35331. /**
  35332. * Gets the mesh under the pointer
  35333. * @returns a Mesh or null if no mesh is under the pointer
  35334. */
  35335. getPointerOverMesh(): Nullable<AbstractMesh>;
  35336. }
  35337. }
  35338. declare module BABYLON {
  35339. /**
  35340. * Helper class used to generate session unique ID
  35341. */
  35342. export class UniqueIdGenerator {
  35343. private static _UniqueIdCounter;
  35344. /**
  35345. * Gets an unique (relatively to the current scene) Id
  35346. */
  35347. static get UniqueId(): number;
  35348. }
  35349. }
  35350. declare module BABYLON {
  35351. /**
  35352. * This class defines the direct association between an animation and a target
  35353. */
  35354. export class TargetedAnimation {
  35355. /**
  35356. * Animation to perform
  35357. */
  35358. animation: Animation;
  35359. /**
  35360. * Target to animate
  35361. */
  35362. target: any;
  35363. /**
  35364. * Serialize the object
  35365. * @returns the JSON object representing the current entity
  35366. */
  35367. serialize(): any;
  35368. }
  35369. /**
  35370. * Use this class to create coordinated animations on multiple targets
  35371. */
  35372. export class AnimationGroup implements IDisposable {
  35373. /** The name of the animation group */
  35374. name: string;
  35375. private _scene;
  35376. private _targetedAnimations;
  35377. private _animatables;
  35378. private _from;
  35379. private _to;
  35380. private _isStarted;
  35381. private _isPaused;
  35382. private _speedRatio;
  35383. private _loopAnimation;
  35384. private _isAdditive;
  35385. /**
  35386. * Gets or sets the unique id of the node
  35387. */
  35388. uniqueId: number;
  35389. /**
  35390. * This observable will notify when one animation have ended
  35391. */
  35392. onAnimationEndObservable: Observable<TargetedAnimation>;
  35393. /**
  35394. * Observer raised when one animation loops
  35395. */
  35396. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35397. /**
  35398. * Observer raised when all animations have looped
  35399. */
  35400. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35401. /**
  35402. * This observable will notify when all animations have ended.
  35403. */
  35404. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35405. /**
  35406. * This observable will notify when all animations have paused.
  35407. */
  35408. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35409. /**
  35410. * This observable will notify when all animations are playing.
  35411. */
  35412. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35413. /**
  35414. * Gets the first frame
  35415. */
  35416. get from(): number;
  35417. /**
  35418. * Gets the last frame
  35419. */
  35420. get to(): number;
  35421. /**
  35422. * Define if the animations are started
  35423. */
  35424. get isStarted(): boolean;
  35425. /**
  35426. * Gets a value indicating that the current group is playing
  35427. */
  35428. get isPlaying(): boolean;
  35429. /**
  35430. * Gets or sets the speed ratio to use for all animations
  35431. */
  35432. get speedRatio(): number;
  35433. /**
  35434. * Gets or sets the speed ratio to use for all animations
  35435. */
  35436. set speedRatio(value: number);
  35437. /**
  35438. * Gets or sets if all animations should loop or not
  35439. */
  35440. get loopAnimation(): boolean;
  35441. set loopAnimation(value: boolean);
  35442. /**
  35443. * Gets or sets if all animations should be evaluated additively
  35444. */
  35445. get isAdditive(): boolean;
  35446. set isAdditive(value: boolean);
  35447. /**
  35448. * Gets the targeted animations for this animation group
  35449. */
  35450. get targetedAnimations(): Array<TargetedAnimation>;
  35451. /**
  35452. * returning the list of animatables controlled by this animation group.
  35453. */
  35454. get animatables(): Array<Animatable>;
  35455. /**
  35456. * Instantiates a new Animation Group.
  35457. * This helps managing several animations at once.
  35458. * @see http://doc.babylonjs.com/how_to/group
  35459. * @param name Defines the name of the group
  35460. * @param scene Defines the scene the group belongs to
  35461. */
  35462. constructor(
  35463. /** The name of the animation group */
  35464. name: string, scene?: Nullable<Scene>);
  35465. /**
  35466. * Add an animation (with its target) in the group
  35467. * @param animation defines the animation we want to add
  35468. * @param target defines the target of the animation
  35469. * @returns the TargetedAnimation object
  35470. */
  35471. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35472. /**
  35473. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35474. * It can add constant keys at begin or end
  35475. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35476. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35477. * @returns the animation group
  35478. */
  35479. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35480. private _animationLoopCount;
  35481. private _animationLoopFlags;
  35482. private _processLoop;
  35483. /**
  35484. * Start all animations on given targets
  35485. * @param loop defines if animations must loop
  35486. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35487. * @param from defines the from key (optional)
  35488. * @param to defines the to key (optional)
  35489. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35490. * @returns the current animation group
  35491. */
  35492. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35493. /**
  35494. * Pause all animations
  35495. * @returns the animation group
  35496. */
  35497. pause(): AnimationGroup;
  35498. /**
  35499. * Play all animations to initial state
  35500. * This function will start() the animations if they were not started or will restart() them if they were paused
  35501. * @param loop defines if animations must loop
  35502. * @returns the animation group
  35503. */
  35504. play(loop?: boolean): AnimationGroup;
  35505. /**
  35506. * Reset all animations to initial state
  35507. * @returns the animation group
  35508. */
  35509. reset(): AnimationGroup;
  35510. /**
  35511. * Restart animations from key 0
  35512. * @returns the animation group
  35513. */
  35514. restart(): AnimationGroup;
  35515. /**
  35516. * Stop all animations
  35517. * @returns the animation group
  35518. */
  35519. stop(): AnimationGroup;
  35520. /**
  35521. * Set animation weight for all animatables
  35522. * @param weight defines the weight to use
  35523. * @return the animationGroup
  35524. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35525. */
  35526. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35527. /**
  35528. * Synchronize and normalize all animatables with a source animatable
  35529. * @param root defines the root animatable to synchronize with
  35530. * @return the animationGroup
  35531. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35532. */
  35533. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35534. /**
  35535. * Goes to a specific frame in this animation group
  35536. * @param frame the frame number to go to
  35537. * @return the animationGroup
  35538. */
  35539. goToFrame(frame: number): AnimationGroup;
  35540. /**
  35541. * Dispose all associated resources
  35542. */
  35543. dispose(): void;
  35544. private _checkAnimationGroupEnded;
  35545. /**
  35546. * Clone the current animation group and returns a copy
  35547. * @param newName defines the name of the new group
  35548. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35549. * @returns the new aniamtion group
  35550. */
  35551. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35552. /**
  35553. * Serializes the animationGroup to an object
  35554. * @returns Serialized object
  35555. */
  35556. serialize(): any;
  35557. /**
  35558. * Returns a new AnimationGroup object parsed from the source provided.
  35559. * @param parsedAnimationGroup defines the source
  35560. * @param scene defines the scene that will receive the animationGroup
  35561. * @returns a new AnimationGroup
  35562. */
  35563. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35564. /**
  35565. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35566. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35567. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35568. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35569. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35570. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35571. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35572. */
  35573. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35574. /**
  35575. * Returns the string "AnimationGroup"
  35576. * @returns "AnimationGroup"
  35577. */
  35578. getClassName(): string;
  35579. /**
  35580. * Creates a detailled string about the object
  35581. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35582. * @returns a string representing the object
  35583. */
  35584. toString(fullDetails?: boolean): string;
  35585. }
  35586. }
  35587. declare module BABYLON {
  35588. /**
  35589. * Define an interface for all classes that will hold resources
  35590. */
  35591. export interface IDisposable {
  35592. /**
  35593. * Releases all held resources
  35594. */
  35595. dispose(): void;
  35596. }
  35597. /** Interface defining initialization parameters for Scene class */
  35598. export interface SceneOptions {
  35599. /**
  35600. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35601. * It will improve performance when the number of geometries becomes important.
  35602. */
  35603. useGeometryUniqueIdsMap?: boolean;
  35604. /**
  35605. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35606. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35607. */
  35608. useMaterialMeshMap?: boolean;
  35609. /**
  35610. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35611. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35612. */
  35613. useClonedMeshMap?: boolean;
  35614. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35615. virtual?: boolean;
  35616. }
  35617. /**
  35618. * Represents a scene to be rendered by the engine.
  35619. * @see http://doc.babylonjs.com/features/scene
  35620. */
  35621. export class Scene extends AbstractScene implements IAnimatable {
  35622. /** The fog is deactivated */
  35623. static readonly FOGMODE_NONE: number;
  35624. /** The fog density is following an exponential function */
  35625. static readonly FOGMODE_EXP: number;
  35626. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35627. static readonly FOGMODE_EXP2: number;
  35628. /** The fog density is following a linear function. */
  35629. static readonly FOGMODE_LINEAR: number;
  35630. /**
  35631. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35632. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35633. */
  35634. static MinDeltaTime: number;
  35635. /**
  35636. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35638. */
  35639. static MaxDeltaTime: number;
  35640. /**
  35641. * Factory used to create the default material.
  35642. * @param name The name of the material to create
  35643. * @param scene The scene to create the material for
  35644. * @returns The default material
  35645. */
  35646. static DefaultMaterialFactory(scene: Scene): Material;
  35647. /**
  35648. * Factory used to create the a collision coordinator.
  35649. * @returns The collision coordinator
  35650. */
  35651. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35652. /** @hidden */
  35653. _inputManager: InputManager;
  35654. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35655. cameraToUseForPointers: Nullable<Camera>;
  35656. /** @hidden */
  35657. readonly _isScene: boolean;
  35658. /** @hidden */
  35659. _blockEntityCollection: boolean;
  35660. /**
  35661. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35662. */
  35663. autoClear: boolean;
  35664. /**
  35665. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35666. */
  35667. autoClearDepthAndStencil: boolean;
  35668. /**
  35669. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35670. */
  35671. clearColor: Color4;
  35672. /**
  35673. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35674. */
  35675. ambientColor: Color3;
  35676. /**
  35677. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35678. * It should only be one of the following (if not the default embedded one):
  35679. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35680. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35681. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35682. * The material properties need to be setup according to the type of texture in use.
  35683. */
  35684. environmentBRDFTexture: BaseTexture;
  35685. /** @hidden */
  35686. protected _environmentTexture: Nullable<BaseTexture>;
  35687. /**
  35688. * Texture used in all pbr material as the reflection texture.
  35689. * As in the majority of the scene they are the same (exception for multi room and so on),
  35690. * this is easier to reference from here than from all the materials.
  35691. */
  35692. get environmentTexture(): Nullable<BaseTexture>;
  35693. /**
  35694. * Texture used in all pbr material as the reflection texture.
  35695. * As in the majority of the scene they are the same (exception for multi room and so on),
  35696. * this is easier to set here than in all the materials.
  35697. */
  35698. set environmentTexture(value: Nullable<BaseTexture>);
  35699. /** @hidden */
  35700. protected _environmentIntensity: number;
  35701. /**
  35702. * Intensity of the environment in all pbr material.
  35703. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35704. * As in the majority of the scene they are the same (exception for multi room and so on),
  35705. * this is easier to reference from here than from all the materials.
  35706. */
  35707. get environmentIntensity(): number;
  35708. /**
  35709. * Intensity of the environment in all pbr material.
  35710. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35711. * As in the majority of the scene they are the same (exception for multi room and so on),
  35712. * this is easier to set here than in all the materials.
  35713. */
  35714. set environmentIntensity(value: number);
  35715. /** @hidden */
  35716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35717. /**
  35718. * Default image processing configuration used either in the rendering
  35719. * Forward main pass or through the imageProcessingPostProcess if present.
  35720. * As in the majority of the scene they are the same (exception for multi camera),
  35721. * this is easier to reference from here than from all the materials and post process.
  35722. *
  35723. * No setter as we it is a shared configuration, you can set the values instead.
  35724. */
  35725. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35726. private _forceWireframe;
  35727. /**
  35728. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35729. */
  35730. set forceWireframe(value: boolean);
  35731. get forceWireframe(): boolean;
  35732. private _skipFrustumClipping;
  35733. /**
  35734. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35735. */
  35736. set skipFrustumClipping(value: boolean);
  35737. get skipFrustumClipping(): boolean;
  35738. private _forcePointsCloud;
  35739. /**
  35740. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35741. */
  35742. set forcePointsCloud(value: boolean);
  35743. get forcePointsCloud(): boolean;
  35744. /**
  35745. * Gets or sets the active clipplane 1
  35746. */
  35747. clipPlane: Nullable<Plane>;
  35748. /**
  35749. * Gets or sets the active clipplane 2
  35750. */
  35751. clipPlane2: Nullable<Plane>;
  35752. /**
  35753. * Gets or sets the active clipplane 3
  35754. */
  35755. clipPlane3: Nullable<Plane>;
  35756. /**
  35757. * Gets or sets the active clipplane 4
  35758. */
  35759. clipPlane4: Nullable<Plane>;
  35760. /**
  35761. * Gets or sets the active clipplane 5
  35762. */
  35763. clipPlane5: Nullable<Plane>;
  35764. /**
  35765. * Gets or sets the active clipplane 6
  35766. */
  35767. clipPlane6: Nullable<Plane>;
  35768. /**
  35769. * Gets or sets a boolean indicating if animations are enabled
  35770. */
  35771. animationsEnabled: boolean;
  35772. private _animationPropertiesOverride;
  35773. /**
  35774. * Gets or sets the animation properties override
  35775. */
  35776. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35777. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35778. /**
  35779. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35780. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35781. */
  35782. useConstantAnimationDeltaTime: boolean;
  35783. /**
  35784. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35785. * Please note that it requires to run a ray cast through the scene on every frame
  35786. */
  35787. constantlyUpdateMeshUnderPointer: boolean;
  35788. /**
  35789. * Defines the HTML cursor to use when hovering over interactive elements
  35790. */
  35791. hoverCursor: string;
  35792. /**
  35793. * Defines the HTML default cursor to use (empty by default)
  35794. */
  35795. defaultCursor: string;
  35796. /**
  35797. * Defines whether cursors are handled by the scene.
  35798. */
  35799. doNotHandleCursors: boolean;
  35800. /**
  35801. * This is used to call preventDefault() on pointer down
  35802. * in order to block unwanted artifacts like system double clicks
  35803. */
  35804. preventDefaultOnPointerDown: boolean;
  35805. /**
  35806. * This is used to call preventDefault() on pointer up
  35807. * in order to block unwanted artifacts like system double clicks
  35808. */
  35809. preventDefaultOnPointerUp: boolean;
  35810. /**
  35811. * Gets or sets user defined metadata
  35812. */
  35813. metadata: any;
  35814. /**
  35815. * For internal use only. Please do not use.
  35816. */
  35817. reservedDataStore: any;
  35818. /**
  35819. * Gets the name of the plugin used to load this scene (null by default)
  35820. */
  35821. loadingPluginName: string;
  35822. /**
  35823. * Use this array to add regular expressions used to disable offline support for specific urls
  35824. */
  35825. disableOfflineSupportExceptionRules: RegExp[];
  35826. /**
  35827. * An event triggered when the scene is disposed.
  35828. */
  35829. onDisposeObservable: Observable<Scene>;
  35830. private _onDisposeObserver;
  35831. /** Sets a function to be executed when this scene is disposed. */
  35832. set onDispose(callback: () => void);
  35833. /**
  35834. * An event triggered before rendering the scene (right after animations and physics)
  35835. */
  35836. onBeforeRenderObservable: Observable<Scene>;
  35837. private _onBeforeRenderObserver;
  35838. /** Sets a function to be executed before rendering this scene */
  35839. set beforeRender(callback: Nullable<() => void>);
  35840. /**
  35841. * An event triggered after rendering the scene
  35842. */
  35843. onAfterRenderObservable: Observable<Scene>;
  35844. /**
  35845. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35846. */
  35847. onAfterRenderCameraObservable: Observable<Camera>;
  35848. private _onAfterRenderObserver;
  35849. /** Sets a function to be executed after rendering this scene */
  35850. set afterRender(callback: Nullable<() => void>);
  35851. /**
  35852. * An event triggered before animating the scene
  35853. */
  35854. onBeforeAnimationsObservable: Observable<Scene>;
  35855. /**
  35856. * An event triggered after animations processing
  35857. */
  35858. onAfterAnimationsObservable: Observable<Scene>;
  35859. /**
  35860. * An event triggered before draw calls are ready to be sent
  35861. */
  35862. onBeforeDrawPhaseObservable: Observable<Scene>;
  35863. /**
  35864. * An event triggered after draw calls have been sent
  35865. */
  35866. onAfterDrawPhaseObservable: Observable<Scene>;
  35867. /**
  35868. * An event triggered when the scene is ready
  35869. */
  35870. onReadyObservable: Observable<Scene>;
  35871. /**
  35872. * An event triggered before rendering a camera
  35873. */
  35874. onBeforeCameraRenderObservable: Observable<Camera>;
  35875. private _onBeforeCameraRenderObserver;
  35876. /** Sets a function to be executed before rendering a camera*/
  35877. set beforeCameraRender(callback: () => void);
  35878. /**
  35879. * An event triggered after rendering a camera
  35880. */
  35881. onAfterCameraRenderObservable: Observable<Camera>;
  35882. private _onAfterCameraRenderObserver;
  35883. /** Sets a function to be executed after rendering a camera*/
  35884. set afterCameraRender(callback: () => void);
  35885. /**
  35886. * An event triggered when active meshes evaluation is about to start
  35887. */
  35888. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35889. /**
  35890. * An event triggered when active meshes evaluation is done
  35891. */
  35892. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35893. /**
  35894. * An event triggered when particles rendering is about to start
  35895. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35896. */
  35897. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35898. /**
  35899. * An event triggered when particles rendering is done
  35900. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35901. */
  35902. onAfterParticlesRenderingObservable: Observable<Scene>;
  35903. /**
  35904. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35905. */
  35906. onDataLoadedObservable: Observable<Scene>;
  35907. /**
  35908. * An event triggered when a camera is created
  35909. */
  35910. onNewCameraAddedObservable: Observable<Camera>;
  35911. /**
  35912. * An event triggered when a camera is removed
  35913. */
  35914. onCameraRemovedObservable: Observable<Camera>;
  35915. /**
  35916. * An event triggered when a light is created
  35917. */
  35918. onNewLightAddedObservable: Observable<Light>;
  35919. /**
  35920. * An event triggered when a light is removed
  35921. */
  35922. onLightRemovedObservable: Observable<Light>;
  35923. /**
  35924. * An event triggered when a geometry is created
  35925. */
  35926. onNewGeometryAddedObservable: Observable<Geometry>;
  35927. /**
  35928. * An event triggered when a geometry is removed
  35929. */
  35930. onGeometryRemovedObservable: Observable<Geometry>;
  35931. /**
  35932. * An event triggered when a transform node is created
  35933. */
  35934. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35935. /**
  35936. * An event triggered when a transform node is removed
  35937. */
  35938. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35939. /**
  35940. * An event triggered when a mesh is created
  35941. */
  35942. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35943. /**
  35944. * An event triggered when a mesh is removed
  35945. */
  35946. onMeshRemovedObservable: Observable<AbstractMesh>;
  35947. /**
  35948. * An event triggered when a skeleton is created
  35949. */
  35950. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35951. /**
  35952. * An event triggered when a skeleton is removed
  35953. */
  35954. onSkeletonRemovedObservable: Observable<Skeleton>;
  35955. /**
  35956. * An event triggered when a material is created
  35957. */
  35958. onNewMaterialAddedObservable: Observable<Material>;
  35959. /**
  35960. * An event triggered when a material is removed
  35961. */
  35962. onMaterialRemovedObservable: Observable<Material>;
  35963. /**
  35964. * An event triggered when a texture is created
  35965. */
  35966. onNewTextureAddedObservable: Observable<BaseTexture>;
  35967. /**
  35968. * An event triggered when a texture is removed
  35969. */
  35970. onTextureRemovedObservable: Observable<BaseTexture>;
  35971. /**
  35972. * An event triggered when render targets are about to be rendered
  35973. * Can happen multiple times per frame.
  35974. */
  35975. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35976. /**
  35977. * An event triggered when render targets were rendered.
  35978. * Can happen multiple times per frame.
  35979. */
  35980. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35981. /**
  35982. * An event triggered before calculating deterministic simulation step
  35983. */
  35984. onBeforeStepObservable: Observable<Scene>;
  35985. /**
  35986. * An event triggered after calculating deterministic simulation step
  35987. */
  35988. onAfterStepObservable: Observable<Scene>;
  35989. /**
  35990. * An event triggered when the activeCamera property is updated
  35991. */
  35992. onActiveCameraChanged: Observable<Scene>;
  35993. /**
  35994. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35995. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35996. * 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)
  35997. */
  35998. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35999. /**
  36000. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36001. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36002. * 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)
  36003. */
  36004. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36005. /**
  36006. * This Observable will when a mesh has been imported into the scene.
  36007. */
  36008. onMeshImportedObservable: Observable<AbstractMesh>;
  36009. /**
  36010. * This Observable will when an animation file has been imported into the scene.
  36011. */
  36012. onAnimationFileImportedObservable: Observable<Scene>;
  36013. /**
  36014. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36015. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36016. */
  36017. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36018. /** @hidden */
  36019. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36020. /**
  36021. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36022. */
  36023. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36024. /**
  36025. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36026. */
  36027. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36028. /**
  36029. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36030. */
  36031. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36032. /** Callback called when a pointer move is detected */
  36033. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36034. /** Callback called when a pointer down is detected */
  36035. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36036. /** Callback called when a pointer up is detected */
  36037. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36038. /** Callback called when a pointer pick is detected */
  36039. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36040. /**
  36041. * 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).
  36042. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36043. */
  36044. onPrePointerObservable: Observable<PointerInfoPre>;
  36045. /**
  36046. * Observable event triggered each time an input event is received from the rendering canvas
  36047. */
  36048. onPointerObservable: Observable<PointerInfo>;
  36049. /**
  36050. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36051. */
  36052. get unTranslatedPointer(): Vector2;
  36053. /**
  36054. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36055. */
  36056. static get DragMovementThreshold(): number;
  36057. static set DragMovementThreshold(value: number);
  36058. /**
  36059. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36060. */
  36061. static get LongPressDelay(): number;
  36062. static set LongPressDelay(value: number);
  36063. /**
  36064. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36065. */
  36066. static get DoubleClickDelay(): number;
  36067. static set DoubleClickDelay(value: number);
  36068. /** If you need to check double click without raising a single click at first click, enable this flag */
  36069. static get ExclusiveDoubleClickMode(): boolean;
  36070. static set ExclusiveDoubleClickMode(value: boolean);
  36071. /** @hidden */
  36072. _mirroredCameraPosition: Nullable<Vector3>;
  36073. /**
  36074. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36075. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36076. */
  36077. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36078. /**
  36079. * Observable event triggered each time an keyboard event is received from the hosting window
  36080. */
  36081. onKeyboardObservable: Observable<KeyboardInfo>;
  36082. private _useRightHandedSystem;
  36083. /**
  36084. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36085. */
  36086. set useRightHandedSystem(value: boolean);
  36087. get useRightHandedSystem(): boolean;
  36088. private _timeAccumulator;
  36089. private _currentStepId;
  36090. private _currentInternalStep;
  36091. /**
  36092. * Sets the step Id used by deterministic lock step
  36093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36094. * @param newStepId defines the step Id
  36095. */
  36096. setStepId(newStepId: number): void;
  36097. /**
  36098. * Gets the step Id used by deterministic lock step
  36099. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36100. * @returns the step Id
  36101. */
  36102. getStepId(): number;
  36103. /**
  36104. * Gets the internal step used by deterministic lock step
  36105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36106. * @returns the internal step
  36107. */
  36108. getInternalStep(): number;
  36109. private _fogEnabled;
  36110. /**
  36111. * Gets or sets a boolean indicating if fog is enabled on this scene
  36112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36113. * (Default is true)
  36114. */
  36115. set fogEnabled(value: boolean);
  36116. get fogEnabled(): boolean;
  36117. private _fogMode;
  36118. /**
  36119. * Gets or sets the fog mode to use
  36120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36121. * | mode | value |
  36122. * | --- | --- |
  36123. * | FOGMODE_NONE | 0 |
  36124. * | FOGMODE_EXP | 1 |
  36125. * | FOGMODE_EXP2 | 2 |
  36126. * | FOGMODE_LINEAR | 3 |
  36127. */
  36128. set fogMode(value: number);
  36129. get fogMode(): number;
  36130. /**
  36131. * Gets or sets the fog color to use
  36132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36133. * (Default is Color3(0.2, 0.2, 0.3))
  36134. */
  36135. fogColor: Color3;
  36136. /**
  36137. * Gets or sets the fog density to use
  36138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36139. * (Default is 0.1)
  36140. */
  36141. fogDensity: number;
  36142. /**
  36143. * Gets or sets the fog start distance to use
  36144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36145. * (Default is 0)
  36146. */
  36147. fogStart: number;
  36148. /**
  36149. * Gets or sets the fog end distance to use
  36150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36151. * (Default is 1000)
  36152. */
  36153. fogEnd: number;
  36154. private _shadowsEnabled;
  36155. /**
  36156. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36157. */
  36158. set shadowsEnabled(value: boolean);
  36159. get shadowsEnabled(): boolean;
  36160. private _lightsEnabled;
  36161. /**
  36162. * Gets or sets a boolean indicating if lights are enabled on this scene
  36163. */
  36164. set lightsEnabled(value: boolean);
  36165. get lightsEnabled(): boolean;
  36166. /** All of the active cameras added to this scene. */
  36167. activeCameras: Camera[];
  36168. /** @hidden */
  36169. _activeCamera: Nullable<Camera>;
  36170. /** Gets or sets the current active camera */
  36171. get activeCamera(): Nullable<Camera>;
  36172. set activeCamera(value: Nullable<Camera>);
  36173. private _defaultMaterial;
  36174. /** The default material used on meshes when no material is affected */
  36175. get defaultMaterial(): Material;
  36176. /** The default material used on meshes when no material is affected */
  36177. set defaultMaterial(value: Material);
  36178. private _texturesEnabled;
  36179. /**
  36180. * Gets or sets a boolean indicating if textures are enabled on this scene
  36181. */
  36182. set texturesEnabled(value: boolean);
  36183. get texturesEnabled(): boolean;
  36184. /**
  36185. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36186. */
  36187. physicsEnabled: boolean;
  36188. /**
  36189. * Gets or sets a boolean indicating if particles are enabled on this scene
  36190. */
  36191. particlesEnabled: boolean;
  36192. /**
  36193. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36194. */
  36195. spritesEnabled: boolean;
  36196. private _skeletonsEnabled;
  36197. /**
  36198. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36199. */
  36200. set skeletonsEnabled(value: boolean);
  36201. get skeletonsEnabled(): boolean;
  36202. /**
  36203. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36204. */
  36205. lensFlaresEnabled: boolean;
  36206. /**
  36207. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36209. */
  36210. collisionsEnabled: boolean;
  36211. private _collisionCoordinator;
  36212. /** @hidden */
  36213. get collisionCoordinator(): ICollisionCoordinator;
  36214. /**
  36215. * Defines the gravity applied to this scene (used only for collisions)
  36216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36217. */
  36218. gravity: Vector3;
  36219. /**
  36220. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36221. */
  36222. postProcessesEnabled: boolean;
  36223. /**
  36224. * The list of postprocesses added to the scene
  36225. */
  36226. postProcesses: PostProcess[];
  36227. /**
  36228. * Gets the current postprocess manager
  36229. */
  36230. postProcessManager: PostProcessManager;
  36231. /**
  36232. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36233. */
  36234. renderTargetsEnabled: boolean;
  36235. /**
  36236. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36237. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36238. */
  36239. dumpNextRenderTargets: boolean;
  36240. /**
  36241. * The list of user defined render targets added to the scene
  36242. */
  36243. customRenderTargets: RenderTargetTexture[];
  36244. /**
  36245. * Defines if texture loading must be delayed
  36246. * If true, textures will only be loaded when they need to be rendered
  36247. */
  36248. useDelayedTextureLoading: boolean;
  36249. /**
  36250. * Gets the list of meshes imported to the scene through SceneLoader
  36251. */
  36252. importedMeshesFiles: String[];
  36253. /**
  36254. * Gets or sets a boolean indicating if probes are enabled on this scene
  36255. */
  36256. probesEnabled: boolean;
  36257. /**
  36258. * Gets or sets the current offline provider to use to store scene data
  36259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36260. */
  36261. offlineProvider: IOfflineProvider;
  36262. /**
  36263. * Gets or sets the action manager associated with the scene
  36264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36265. */
  36266. actionManager: AbstractActionManager;
  36267. private _meshesForIntersections;
  36268. /**
  36269. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36270. */
  36271. proceduralTexturesEnabled: boolean;
  36272. private _engine;
  36273. private _totalVertices;
  36274. /** @hidden */
  36275. _activeIndices: PerfCounter;
  36276. /** @hidden */
  36277. _activeParticles: PerfCounter;
  36278. /** @hidden */
  36279. _activeBones: PerfCounter;
  36280. private _animationRatio;
  36281. /** @hidden */
  36282. _animationTimeLast: number;
  36283. /** @hidden */
  36284. _animationTime: number;
  36285. /**
  36286. * Gets or sets a general scale for animation speed
  36287. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36288. */
  36289. animationTimeScale: number;
  36290. /** @hidden */
  36291. _cachedMaterial: Nullable<Material>;
  36292. /** @hidden */
  36293. _cachedEffect: Nullable<Effect>;
  36294. /** @hidden */
  36295. _cachedVisibility: Nullable<number>;
  36296. private _renderId;
  36297. private _frameId;
  36298. private _executeWhenReadyTimeoutId;
  36299. private _intermediateRendering;
  36300. private _viewUpdateFlag;
  36301. private _projectionUpdateFlag;
  36302. /** @hidden */
  36303. _toBeDisposed: Nullable<IDisposable>[];
  36304. private _activeRequests;
  36305. /** @hidden */
  36306. _pendingData: any[];
  36307. private _isDisposed;
  36308. /**
  36309. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36310. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36311. */
  36312. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36313. private _activeMeshes;
  36314. private _processedMaterials;
  36315. private _renderTargets;
  36316. /** @hidden */
  36317. _activeParticleSystems: SmartArray<IParticleSystem>;
  36318. private _activeSkeletons;
  36319. private _softwareSkinnedMeshes;
  36320. private _renderingManager;
  36321. /** @hidden */
  36322. _activeAnimatables: Animatable[];
  36323. private _transformMatrix;
  36324. private _sceneUbo;
  36325. /** @hidden */
  36326. _viewMatrix: Matrix;
  36327. private _projectionMatrix;
  36328. /** @hidden */
  36329. _forcedViewPosition: Nullable<Vector3>;
  36330. /** @hidden */
  36331. _frustumPlanes: Plane[];
  36332. /**
  36333. * Gets the list of frustum planes (built from the active camera)
  36334. */
  36335. get frustumPlanes(): Plane[];
  36336. /**
  36337. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36338. * This is useful if there are more lights that the maximum simulteanous authorized
  36339. */
  36340. requireLightSorting: boolean;
  36341. /** @hidden */
  36342. readonly useMaterialMeshMap: boolean;
  36343. /** @hidden */
  36344. readonly useClonedMeshMap: boolean;
  36345. private _externalData;
  36346. private _uid;
  36347. /**
  36348. * @hidden
  36349. * Backing store of defined scene components.
  36350. */
  36351. _components: ISceneComponent[];
  36352. /**
  36353. * @hidden
  36354. * Backing store of defined scene components.
  36355. */
  36356. _serializableComponents: ISceneSerializableComponent[];
  36357. /**
  36358. * List of components to register on the next registration step.
  36359. */
  36360. private _transientComponents;
  36361. /**
  36362. * Registers the transient components if needed.
  36363. */
  36364. private _registerTransientComponents;
  36365. /**
  36366. * @hidden
  36367. * Add a component to the scene.
  36368. * Note that the ccomponent could be registered on th next frame if this is called after
  36369. * the register component stage.
  36370. * @param component Defines the component to add to the scene
  36371. */
  36372. _addComponent(component: ISceneComponent): void;
  36373. /**
  36374. * @hidden
  36375. * Gets a component from the scene.
  36376. * @param name defines the name of the component to retrieve
  36377. * @returns the component or null if not present
  36378. */
  36379. _getComponent(name: string): Nullable<ISceneComponent>;
  36380. /**
  36381. * @hidden
  36382. * Defines the actions happening before camera updates.
  36383. */
  36384. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36385. /**
  36386. * @hidden
  36387. * Defines the actions happening before clear the canvas.
  36388. */
  36389. _beforeClearStage: Stage<SimpleStageAction>;
  36390. /**
  36391. * @hidden
  36392. * Defines the actions when collecting render targets for the frame.
  36393. */
  36394. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36395. /**
  36396. * @hidden
  36397. * Defines the actions happening for one camera in the frame.
  36398. */
  36399. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36400. /**
  36401. * @hidden
  36402. * Defines the actions happening during the per mesh ready checks.
  36403. */
  36404. _isReadyForMeshStage: Stage<MeshStageAction>;
  36405. /**
  36406. * @hidden
  36407. * Defines the actions happening before evaluate active mesh checks.
  36408. */
  36409. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36410. /**
  36411. * @hidden
  36412. * Defines the actions happening during the evaluate sub mesh checks.
  36413. */
  36414. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36415. /**
  36416. * @hidden
  36417. * Defines the actions happening during the active mesh stage.
  36418. */
  36419. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36420. /**
  36421. * @hidden
  36422. * Defines the actions happening during the per camera render target step.
  36423. */
  36424. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36425. /**
  36426. * @hidden
  36427. * Defines the actions happening just before the active camera is drawing.
  36428. */
  36429. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36430. /**
  36431. * @hidden
  36432. * Defines the actions happening just before a render target is drawing.
  36433. */
  36434. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36435. /**
  36436. * @hidden
  36437. * Defines the actions happening just before a rendering group is drawing.
  36438. */
  36439. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36440. /**
  36441. * @hidden
  36442. * Defines the actions happening just before a mesh is drawing.
  36443. */
  36444. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36445. /**
  36446. * @hidden
  36447. * Defines the actions happening just after a mesh has been drawn.
  36448. */
  36449. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36450. /**
  36451. * @hidden
  36452. * Defines the actions happening just after a rendering group has been drawn.
  36453. */
  36454. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36455. /**
  36456. * @hidden
  36457. * Defines the actions happening just after the active camera has been drawn.
  36458. */
  36459. _afterCameraDrawStage: Stage<CameraStageAction>;
  36460. /**
  36461. * @hidden
  36462. * Defines the actions happening just after a render target has been drawn.
  36463. */
  36464. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36465. /**
  36466. * @hidden
  36467. * Defines the actions happening just after rendering all cameras and computing intersections.
  36468. */
  36469. _afterRenderStage: Stage<SimpleStageAction>;
  36470. /**
  36471. * @hidden
  36472. * Defines the actions happening when a pointer move event happens.
  36473. */
  36474. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36475. /**
  36476. * @hidden
  36477. * Defines the actions happening when a pointer down event happens.
  36478. */
  36479. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36480. /**
  36481. * @hidden
  36482. * Defines the actions happening when a pointer up event happens.
  36483. */
  36484. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36485. /**
  36486. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36487. */
  36488. private geometriesByUniqueId;
  36489. /**
  36490. * Creates a new Scene
  36491. * @param engine defines the engine to use to render this scene
  36492. * @param options defines the scene options
  36493. */
  36494. constructor(engine: Engine, options?: SceneOptions);
  36495. /**
  36496. * Gets a string idenfifying the name of the class
  36497. * @returns "Scene" string
  36498. */
  36499. getClassName(): string;
  36500. private _defaultMeshCandidates;
  36501. /**
  36502. * @hidden
  36503. */
  36504. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36505. private _defaultSubMeshCandidates;
  36506. /**
  36507. * @hidden
  36508. */
  36509. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36510. /**
  36511. * Sets the default candidate providers for the scene.
  36512. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36513. * and getCollidingSubMeshCandidates to their default function
  36514. */
  36515. setDefaultCandidateProviders(): void;
  36516. /**
  36517. * Gets the mesh that is currently under the pointer
  36518. */
  36519. get meshUnderPointer(): Nullable<AbstractMesh>;
  36520. /**
  36521. * Gets or sets the current on-screen X position of the pointer
  36522. */
  36523. get pointerX(): number;
  36524. set pointerX(value: number);
  36525. /**
  36526. * Gets or sets the current on-screen Y position of the pointer
  36527. */
  36528. get pointerY(): number;
  36529. set pointerY(value: number);
  36530. /**
  36531. * Gets the cached material (ie. the latest rendered one)
  36532. * @returns the cached material
  36533. */
  36534. getCachedMaterial(): Nullable<Material>;
  36535. /**
  36536. * Gets the cached effect (ie. the latest rendered one)
  36537. * @returns the cached effect
  36538. */
  36539. getCachedEffect(): Nullable<Effect>;
  36540. /**
  36541. * Gets the cached visibility state (ie. the latest rendered one)
  36542. * @returns the cached visibility state
  36543. */
  36544. getCachedVisibility(): Nullable<number>;
  36545. /**
  36546. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36547. * @param material defines the current material
  36548. * @param effect defines the current effect
  36549. * @param visibility defines the current visibility state
  36550. * @returns true if one parameter is not cached
  36551. */
  36552. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36553. /**
  36554. * Gets the engine associated with the scene
  36555. * @returns an Engine
  36556. */
  36557. getEngine(): Engine;
  36558. /**
  36559. * Gets the total number of vertices rendered per frame
  36560. * @returns the total number of vertices rendered per frame
  36561. */
  36562. getTotalVertices(): number;
  36563. /**
  36564. * Gets the performance counter for total vertices
  36565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36566. */
  36567. get totalVerticesPerfCounter(): PerfCounter;
  36568. /**
  36569. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36570. * @returns the total number of active indices rendered per frame
  36571. */
  36572. getActiveIndices(): number;
  36573. /**
  36574. * Gets the performance counter for active indices
  36575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36576. */
  36577. get totalActiveIndicesPerfCounter(): PerfCounter;
  36578. /**
  36579. * Gets the total number of active particles rendered per frame
  36580. * @returns the total number of active particles rendered per frame
  36581. */
  36582. getActiveParticles(): number;
  36583. /**
  36584. * Gets the performance counter for active particles
  36585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36586. */
  36587. get activeParticlesPerfCounter(): PerfCounter;
  36588. /**
  36589. * Gets the total number of active bones rendered per frame
  36590. * @returns the total number of active bones rendered per frame
  36591. */
  36592. getActiveBones(): number;
  36593. /**
  36594. * Gets the performance counter for active bones
  36595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36596. */
  36597. get activeBonesPerfCounter(): PerfCounter;
  36598. /**
  36599. * Gets the array of active meshes
  36600. * @returns an array of AbstractMesh
  36601. */
  36602. getActiveMeshes(): SmartArray<AbstractMesh>;
  36603. /**
  36604. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36605. * @returns a number
  36606. */
  36607. getAnimationRatio(): number;
  36608. /**
  36609. * Gets an unique Id for the current render phase
  36610. * @returns a number
  36611. */
  36612. getRenderId(): number;
  36613. /**
  36614. * Gets an unique Id for the current frame
  36615. * @returns a number
  36616. */
  36617. getFrameId(): number;
  36618. /** Call this function if you want to manually increment the render Id*/
  36619. incrementRenderId(): void;
  36620. private _createUbo;
  36621. /**
  36622. * Use this method to simulate a pointer move on a mesh
  36623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36626. * @returns the current scene
  36627. */
  36628. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36629. /**
  36630. * Use this method to simulate a pointer down on a mesh
  36631. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36632. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36633. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36634. * @returns the current scene
  36635. */
  36636. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36637. /**
  36638. * Use this method to simulate a pointer up on a mesh
  36639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36642. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36643. * @returns the current scene
  36644. */
  36645. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36646. /**
  36647. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36648. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36649. * @returns true if the pointer was captured
  36650. */
  36651. isPointerCaptured(pointerId?: number): boolean;
  36652. /**
  36653. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36654. * @param attachUp defines if you want to attach events to pointerup
  36655. * @param attachDown defines if you want to attach events to pointerdown
  36656. * @param attachMove defines if you want to attach events to pointermove
  36657. */
  36658. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36659. /** Detaches all event handlers*/
  36660. detachControl(): void;
  36661. /**
  36662. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36663. * Delay loaded resources are not taking in account
  36664. * @return true if all required resources are ready
  36665. */
  36666. isReady(): boolean;
  36667. /** Resets all cached information relative to material (including effect and visibility) */
  36668. resetCachedMaterial(): void;
  36669. /**
  36670. * Registers a function to be called before every frame render
  36671. * @param func defines the function to register
  36672. */
  36673. registerBeforeRender(func: () => void): void;
  36674. /**
  36675. * Unregisters a function called before every frame render
  36676. * @param func defines the function to unregister
  36677. */
  36678. unregisterBeforeRender(func: () => void): void;
  36679. /**
  36680. * Registers a function to be called after every frame render
  36681. * @param func defines the function to register
  36682. */
  36683. registerAfterRender(func: () => void): void;
  36684. /**
  36685. * Unregisters a function called after every frame render
  36686. * @param func defines the function to unregister
  36687. */
  36688. unregisterAfterRender(func: () => void): void;
  36689. private _executeOnceBeforeRender;
  36690. /**
  36691. * The provided function will run before render once and will be disposed afterwards.
  36692. * A timeout delay can be provided so that the function will be executed in N ms.
  36693. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36694. * @param func The function to be executed.
  36695. * @param timeout optional delay in ms
  36696. */
  36697. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36698. /** @hidden */
  36699. _addPendingData(data: any): void;
  36700. /** @hidden */
  36701. _removePendingData(data: any): void;
  36702. /**
  36703. * Returns the number of items waiting to be loaded
  36704. * @returns the number of items waiting to be loaded
  36705. */
  36706. getWaitingItemsCount(): number;
  36707. /**
  36708. * Returns a boolean indicating if the scene is still loading data
  36709. */
  36710. get isLoading(): boolean;
  36711. /**
  36712. * Registers a function to be executed when the scene is ready
  36713. * @param {Function} func - the function to be executed
  36714. */
  36715. executeWhenReady(func: () => void): void;
  36716. /**
  36717. * Returns a promise that resolves when the scene is ready
  36718. * @returns A promise that resolves when the scene is ready
  36719. */
  36720. whenReadyAsync(): Promise<void>;
  36721. /** @hidden */
  36722. _checkIsReady(): void;
  36723. /**
  36724. * Gets all animatable attached to the scene
  36725. */
  36726. get animatables(): Animatable[];
  36727. /**
  36728. * Resets the last animation time frame.
  36729. * Useful to override when animations start running when loading a scene for the first time.
  36730. */
  36731. resetLastAnimationTimeFrame(): void;
  36732. /**
  36733. * Gets the current view matrix
  36734. * @returns a Matrix
  36735. */
  36736. getViewMatrix(): Matrix;
  36737. /**
  36738. * Gets the current projection matrix
  36739. * @returns a Matrix
  36740. */
  36741. getProjectionMatrix(): Matrix;
  36742. /**
  36743. * Gets the current transform matrix
  36744. * @returns a Matrix made of View * Projection
  36745. */
  36746. getTransformMatrix(): Matrix;
  36747. /**
  36748. * Sets the current transform matrix
  36749. * @param viewL defines the View matrix to use
  36750. * @param projectionL defines the Projection matrix to use
  36751. * @param viewR defines the right View matrix to use (if provided)
  36752. * @param projectionR defines the right Projection matrix to use (if provided)
  36753. */
  36754. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36755. /**
  36756. * Gets the uniform buffer used to store scene data
  36757. * @returns a UniformBuffer
  36758. */
  36759. getSceneUniformBuffer(): UniformBuffer;
  36760. /**
  36761. * Gets an unique (relatively to the current scene) Id
  36762. * @returns an unique number for the scene
  36763. */
  36764. getUniqueId(): number;
  36765. /**
  36766. * Add a mesh to the list of scene's meshes
  36767. * @param newMesh defines the mesh to add
  36768. * @param recursive if all child meshes should also be added to the scene
  36769. */
  36770. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36771. /**
  36772. * Remove a mesh for the list of scene's meshes
  36773. * @param toRemove defines the mesh to remove
  36774. * @param recursive if all child meshes should also be removed from the scene
  36775. * @returns the index where the mesh was in the mesh list
  36776. */
  36777. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36778. /**
  36779. * Add a transform node to the list of scene's transform nodes
  36780. * @param newTransformNode defines the transform node to add
  36781. */
  36782. addTransformNode(newTransformNode: TransformNode): void;
  36783. /**
  36784. * Remove a transform node for the list of scene's transform nodes
  36785. * @param toRemove defines the transform node to remove
  36786. * @returns the index where the transform node was in the transform node list
  36787. */
  36788. removeTransformNode(toRemove: TransformNode): number;
  36789. /**
  36790. * Remove a skeleton for the list of scene's skeletons
  36791. * @param toRemove defines the skeleton to remove
  36792. * @returns the index where the skeleton was in the skeleton list
  36793. */
  36794. removeSkeleton(toRemove: Skeleton): number;
  36795. /**
  36796. * Remove a morph target for the list of scene's morph targets
  36797. * @param toRemove defines the morph target to remove
  36798. * @returns the index where the morph target was in the morph target list
  36799. */
  36800. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36801. /**
  36802. * Remove a light for the list of scene's lights
  36803. * @param toRemove defines the light to remove
  36804. * @returns the index where the light was in the light list
  36805. */
  36806. removeLight(toRemove: Light): number;
  36807. /**
  36808. * Remove a camera for the list of scene's cameras
  36809. * @param toRemove defines the camera to remove
  36810. * @returns the index where the camera was in the camera list
  36811. */
  36812. removeCamera(toRemove: Camera): number;
  36813. /**
  36814. * Remove a particle system for the list of scene's particle systems
  36815. * @param toRemove defines the particle system to remove
  36816. * @returns the index where the particle system was in the particle system list
  36817. */
  36818. removeParticleSystem(toRemove: IParticleSystem): number;
  36819. /**
  36820. * Remove a animation for the list of scene's animations
  36821. * @param toRemove defines the animation to remove
  36822. * @returns the index where the animation was in the animation list
  36823. */
  36824. removeAnimation(toRemove: Animation): number;
  36825. /**
  36826. * Will stop the animation of the given target
  36827. * @param target - the target
  36828. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36829. * @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)
  36830. */
  36831. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36832. /**
  36833. * Removes the given animation group from this scene.
  36834. * @param toRemove The animation group to remove
  36835. * @returns The index of the removed animation group
  36836. */
  36837. removeAnimationGroup(toRemove: AnimationGroup): number;
  36838. /**
  36839. * Removes the given multi-material from this scene.
  36840. * @param toRemove The multi-material to remove
  36841. * @returns The index of the removed multi-material
  36842. */
  36843. removeMultiMaterial(toRemove: MultiMaterial): number;
  36844. /**
  36845. * Removes the given material from this scene.
  36846. * @param toRemove The material to remove
  36847. * @returns The index of the removed material
  36848. */
  36849. removeMaterial(toRemove: Material): number;
  36850. /**
  36851. * Removes the given action manager from this scene.
  36852. * @param toRemove The action manager to remove
  36853. * @returns The index of the removed action manager
  36854. */
  36855. removeActionManager(toRemove: AbstractActionManager): number;
  36856. /**
  36857. * Removes the given texture from this scene.
  36858. * @param toRemove The texture to remove
  36859. * @returns The index of the removed texture
  36860. */
  36861. removeTexture(toRemove: BaseTexture): number;
  36862. /**
  36863. * Adds the given light to this scene
  36864. * @param newLight The light to add
  36865. */
  36866. addLight(newLight: Light): void;
  36867. /**
  36868. * Sorts the list list based on light priorities
  36869. */
  36870. sortLightsByPriority(): void;
  36871. /**
  36872. * Adds the given camera to this scene
  36873. * @param newCamera The camera to add
  36874. */
  36875. addCamera(newCamera: Camera): void;
  36876. /**
  36877. * Adds the given skeleton to this scene
  36878. * @param newSkeleton The skeleton to add
  36879. */
  36880. addSkeleton(newSkeleton: Skeleton): void;
  36881. /**
  36882. * Adds the given particle system to this scene
  36883. * @param newParticleSystem The particle system to add
  36884. */
  36885. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36886. /**
  36887. * Adds the given animation to this scene
  36888. * @param newAnimation The animation to add
  36889. */
  36890. addAnimation(newAnimation: Animation): void;
  36891. /**
  36892. * Adds the given animation group to this scene.
  36893. * @param newAnimationGroup The animation group to add
  36894. */
  36895. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36896. /**
  36897. * Adds the given multi-material to this scene
  36898. * @param newMultiMaterial The multi-material to add
  36899. */
  36900. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36901. /**
  36902. * Adds the given material to this scene
  36903. * @param newMaterial The material to add
  36904. */
  36905. addMaterial(newMaterial: Material): void;
  36906. /**
  36907. * Adds the given morph target to this scene
  36908. * @param newMorphTargetManager The morph target to add
  36909. */
  36910. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36911. /**
  36912. * Adds the given geometry to this scene
  36913. * @param newGeometry The geometry to add
  36914. */
  36915. addGeometry(newGeometry: Geometry): void;
  36916. /**
  36917. * Adds the given action manager to this scene
  36918. * @param newActionManager The action manager to add
  36919. */
  36920. addActionManager(newActionManager: AbstractActionManager): void;
  36921. /**
  36922. * Adds the given texture to this scene.
  36923. * @param newTexture The texture to add
  36924. */
  36925. addTexture(newTexture: BaseTexture): void;
  36926. /**
  36927. * Switch active camera
  36928. * @param newCamera defines the new active camera
  36929. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36930. */
  36931. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36932. /**
  36933. * sets the active camera of the scene using its ID
  36934. * @param id defines the camera's ID
  36935. * @return the new active camera or null if none found.
  36936. */
  36937. setActiveCameraByID(id: string): Nullable<Camera>;
  36938. /**
  36939. * sets the active camera of the scene using its name
  36940. * @param name defines the camera's name
  36941. * @returns the new active camera or null if none found.
  36942. */
  36943. setActiveCameraByName(name: string): Nullable<Camera>;
  36944. /**
  36945. * get an animation group using its name
  36946. * @param name defines the material's name
  36947. * @return the animation group or null if none found.
  36948. */
  36949. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36950. /**
  36951. * Get a material using its unique id
  36952. * @param uniqueId defines the material's unique id
  36953. * @return the material or null if none found.
  36954. */
  36955. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36956. /**
  36957. * get a material using its id
  36958. * @param id defines the material's ID
  36959. * @return the material or null if none found.
  36960. */
  36961. getMaterialByID(id: string): Nullable<Material>;
  36962. /**
  36963. * Gets a the last added material using a given id
  36964. * @param id defines the material's ID
  36965. * @return the last material with the given id or null if none found.
  36966. */
  36967. getLastMaterialByID(id: string): Nullable<Material>;
  36968. /**
  36969. * Gets a material using its name
  36970. * @param name defines the material's name
  36971. * @return the material or null if none found.
  36972. */
  36973. getMaterialByName(name: string): Nullable<Material>;
  36974. /**
  36975. * Get a texture using its unique id
  36976. * @param uniqueId defines the texture's unique id
  36977. * @return the texture or null if none found.
  36978. */
  36979. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36980. /**
  36981. * Gets a camera using its id
  36982. * @param id defines the id to look for
  36983. * @returns the camera or null if not found
  36984. */
  36985. getCameraByID(id: string): Nullable<Camera>;
  36986. /**
  36987. * Gets a camera using its unique id
  36988. * @param uniqueId defines the unique id to look for
  36989. * @returns the camera or null if not found
  36990. */
  36991. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36992. /**
  36993. * Gets a camera using its name
  36994. * @param name defines the camera's name
  36995. * @return the camera or null if none found.
  36996. */
  36997. getCameraByName(name: string): Nullable<Camera>;
  36998. /**
  36999. * Gets a bone using its id
  37000. * @param id defines the bone's id
  37001. * @return the bone or null if not found
  37002. */
  37003. getBoneByID(id: string): Nullable<Bone>;
  37004. /**
  37005. * Gets a bone using its id
  37006. * @param name defines the bone's name
  37007. * @return the bone or null if not found
  37008. */
  37009. getBoneByName(name: string): Nullable<Bone>;
  37010. /**
  37011. * Gets a light node using its name
  37012. * @param name defines the the light's name
  37013. * @return the light or null if none found.
  37014. */
  37015. getLightByName(name: string): Nullable<Light>;
  37016. /**
  37017. * Gets a light node using its id
  37018. * @param id defines the light's id
  37019. * @return the light or null if none found.
  37020. */
  37021. getLightByID(id: string): Nullable<Light>;
  37022. /**
  37023. * Gets a light node using its scene-generated unique ID
  37024. * @param uniqueId defines the light's unique id
  37025. * @return the light or null if none found.
  37026. */
  37027. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37028. /**
  37029. * Gets a particle system by id
  37030. * @param id defines the particle system id
  37031. * @return the corresponding system or null if none found
  37032. */
  37033. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37034. /**
  37035. * Gets a geometry using its ID
  37036. * @param id defines the geometry's id
  37037. * @return the geometry or null if none found.
  37038. */
  37039. getGeometryByID(id: string): Nullable<Geometry>;
  37040. private _getGeometryByUniqueID;
  37041. /**
  37042. * Add a new geometry to this scene
  37043. * @param geometry defines the geometry to be added to the scene.
  37044. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37045. * @return a boolean defining if the geometry was added or not
  37046. */
  37047. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37048. /**
  37049. * Removes an existing geometry
  37050. * @param geometry defines the geometry to be removed from the scene
  37051. * @return a boolean defining if the geometry was removed or not
  37052. */
  37053. removeGeometry(geometry: Geometry): boolean;
  37054. /**
  37055. * Gets the list of geometries attached to the scene
  37056. * @returns an array of Geometry
  37057. */
  37058. getGeometries(): Geometry[];
  37059. /**
  37060. * Gets the first added mesh found of a given ID
  37061. * @param id defines the id to search for
  37062. * @return the mesh found or null if not found at all
  37063. */
  37064. getMeshByID(id: string): Nullable<AbstractMesh>;
  37065. /**
  37066. * Gets a list of meshes using their id
  37067. * @param id defines the id to search for
  37068. * @returns a list of meshes
  37069. */
  37070. getMeshesByID(id: string): Array<AbstractMesh>;
  37071. /**
  37072. * Gets the first added transform node found of a given ID
  37073. * @param id defines the id to search for
  37074. * @return the found transform node or null if not found at all.
  37075. */
  37076. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37077. /**
  37078. * Gets a transform node with its auto-generated unique id
  37079. * @param uniqueId efines the unique id to search for
  37080. * @return the found transform node or null if not found at all.
  37081. */
  37082. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37083. /**
  37084. * Gets a list of transform nodes using their id
  37085. * @param id defines the id to search for
  37086. * @returns a list of transform nodes
  37087. */
  37088. getTransformNodesByID(id: string): Array<TransformNode>;
  37089. /**
  37090. * Gets a mesh with its auto-generated unique id
  37091. * @param uniqueId defines the unique id to search for
  37092. * @return the found mesh or null if not found at all.
  37093. */
  37094. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37095. /**
  37096. * Gets a the last added mesh using a given id
  37097. * @param id defines the id to search for
  37098. * @return the found mesh or null if not found at all.
  37099. */
  37100. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37101. /**
  37102. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37103. * @param id defines the id to search for
  37104. * @return the found node or null if not found at all
  37105. */
  37106. getLastEntryByID(id: string): Nullable<Node>;
  37107. /**
  37108. * Gets a node (Mesh, Camera, Light) using a given id
  37109. * @param id defines the id to search for
  37110. * @return the found node or null if not found at all
  37111. */
  37112. getNodeByID(id: string): Nullable<Node>;
  37113. /**
  37114. * Gets a node (Mesh, Camera, Light) using a given name
  37115. * @param name defines the name to search for
  37116. * @return the found node or null if not found at all.
  37117. */
  37118. getNodeByName(name: string): Nullable<Node>;
  37119. /**
  37120. * Gets a mesh using a given name
  37121. * @param name defines the name to search for
  37122. * @return the found mesh or null if not found at all.
  37123. */
  37124. getMeshByName(name: string): Nullable<AbstractMesh>;
  37125. /**
  37126. * Gets a transform node using a given name
  37127. * @param name defines the name to search for
  37128. * @return the found transform node or null if not found at all.
  37129. */
  37130. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37131. /**
  37132. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37133. * @param id defines the id to search for
  37134. * @return the found skeleton or null if not found at all.
  37135. */
  37136. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37137. /**
  37138. * Gets a skeleton using a given auto generated unique id
  37139. * @param uniqueId defines the unique id to search for
  37140. * @return the found skeleton or null if not found at all.
  37141. */
  37142. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37143. /**
  37144. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37145. * @param id defines the id to search for
  37146. * @return the found skeleton or null if not found at all.
  37147. */
  37148. getSkeletonById(id: string): Nullable<Skeleton>;
  37149. /**
  37150. * Gets a skeleton using a given name
  37151. * @param name defines the name to search for
  37152. * @return the found skeleton or null if not found at all.
  37153. */
  37154. getSkeletonByName(name: string): Nullable<Skeleton>;
  37155. /**
  37156. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37157. * @param id defines the id to search for
  37158. * @return the found morph target manager or null if not found at all.
  37159. */
  37160. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37161. /**
  37162. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37163. * @param id defines the id to search for
  37164. * @return the found morph target or null if not found at all.
  37165. */
  37166. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37167. /**
  37168. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37169. * @param name defines the name to search for
  37170. * @return the found morph target or null if not found at all.
  37171. */
  37172. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37173. /**
  37174. * Gets a boolean indicating if the given mesh is active
  37175. * @param mesh defines the mesh to look for
  37176. * @returns true if the mesh is in the active list
  37177. */
  37178. isActiveMesh(mesh: AbstractMesh): boolean;
  37179. /**
  37180. * Return a unique id as a string which can serve as an identifier for the scene
  37181. */
  37182. get uid(): string;
  37183. /**
  37184. * Add an externaly attached data from its key.
  37185. * This method call will fail and return false, if such key already exists.
  37186. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37187. * @param key the unique key that identifies the data
  37188. * @param data the data object to associate to the key for this Engine instance
  37189. * @return true if no such key were already present and the data was added successfully, false otherwise
  37190. */
  37191. addExternalData<T>(key: string, data: T): boolean;
  37192. /**
  37193. * Get an externaly attached data from its key
  37194. * @param key the unique key that identifies the data
  37195. * @return the associated data, if present (can be null), or undefined if not present
  37196. */
  37197. getExternalData<T>(key: string): Nullable<T>;
  37198. /**
  37199. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37200. * @param key the unique key that identifies the data
  37201. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37202. * @return the associated data, can be null if the factory returned null.
  37203. */
  37204. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37205. /**
  37206. * Remove an externaly attached data from the Engine instance
  37207. * @param key the unique key that identifies the data
  37208. * @return true if the data was successfully removed, false if it doesn't exist
  37209. */
  37210. removeExternalData(key: string): boolean;
  37211. private _evaluateSubMesh;
  37212. /**
  37213. * Clear the processed materials smart array preventing retention point in material dispose.
  37214. */
  37215. freeProcessedMaterials(): void;
  37216. private _preventFreeActiveMeshesAndRenderingGroups;
  37217. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37218. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37219. * when disposing several meshes in a row or a hierarchy of meshes.
  37220. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37221. */
  37222. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37223. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37224. /**
  37225. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37226. */
  37227. freeActiveMeshes(): void;
  37228. /**
  37229. * Clear the info related to rendering groups preventing retention points during dispose.
  37230. */
  37231. freeRenderingGroups(): void;
  37232. /** @hidden */
  37233. _isInIntermediateRendering(): boolean;
  37234. /**
  37235. * Lambda returning the list of potentially active meshes.
  37236. */
  37237. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37238. /**
  37239. * Lambda returning the list of potentially active sub meshes.
  37240. */
  37241. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37242. /**
  37243. * Lambda returning the list of potentially intersecting sub meshes.
  37244. */
  37245. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37246. /**
  37247. * Lambda returning the list of potentially colliding sub meshes.
  37248. */
  37249. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37250. private _activeMeshesFrozen;
  37251. private _skipEvaluateActiveMeshesCompletely;
  37252. /**
  37253. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37254. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37255. * @returns the current scene
  37256. */
  37257. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37258. /**
  37259. * Use this function to restart evaluating active meshes on every frame
  37260. * @returns the current scene
  37261. */
  37262. unfreezeActiveMeshes(): Scene;
  37263. private _evaluateActiveMeshes;
  37264. private _activeMesh;
  37265. /**
  37266. * Update the transform matrix to update from the current active camera
  37267. * @param force defines a boolean used to force the update even if cache is up to date
  37268. */
  37269. updateTransformMatrix(force?: boolean): void;
  37270. private _bindFrameBuffer;
  37271. /** @hidden */
  37272. _allowPostProcessClearColor: boolean;
  37273. /** @hidden */
  37274. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37275. private _processSubCameras;
  37276. private _checkIntersections;
  37277. /** @hidden */
  37278. _advancePhysicsEngineStep(step: number): void;
  37279. /**
  37280. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37281. */
  37282. getDeterministicFrameTime: () => number;
  37283. /** @hidden */
  37284. _animate(): void;
  37285. /** Execute all animations (for a frame) */
  37286. animate(): void;
  37287. /**
  37288. * Render the scene
  37289. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37290. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37291. */
  37292. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37293. /**
  37294. * Freeze all materials
  37295. * A frozen material will not be updatable but should be faster to render
  37296. */
  37297. freezeMaterials(): void;
  37298. /**
  37299. * Unfreeze all materials
  37300. * A frozen material will not be updatable but should be faster to render
  37301. */
  37302. unfreezeMaterials(): void;
  37303. /**
  37304. * Releases all held ressources
  37305. */
  37306. dispose(): void;
  37307. /**
  37308. * Gets if the scene is already disposed
  37309. */
  37310. get isDisposed(): boolean;
  37311. /**
  37312. * Call this function to reduce memory footprint of the scene.
  37313. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37314. */
  37315. clearCachedVertexData(): void;
  37316. /**
  37317. * This function will remove the local cached buffer data from texture.
  37318. * It will save memory but will prevent the texture from being rebuilt
  37319. */
  37320. cleanCachedTextureBuffer(): void;
  37321. /**
  37322. * Get the world extend vectors with an optional filter
  37323. *
  37324. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37325. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37326. */
  37327. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37328. min: Vector3;
  37329. max: Vector3;
  37330. };
  37331. /**
  37332. * Creates a ray that can be used to pick in the scene
  37333. * @param x defines the x coordinate of the origin (on-screen)
  37334. * @param y defines the y coordinate of the origin (on-screen)
  37335. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37336. * @param camera defines the camera to use for the picking
  37337. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37338. * @returns a Ray
  37339. */
  37340. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37341. /**
  37342. * Creates a ray that can be used to pick in the scene
  37343. * @param x defines the x coordinate of the origin (on-screen)
  37344. * @param y defines the y coordinate of the origin (on-screen)
  37345. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37346. * @param result defines the ray where to store the picking ray
  37347. * @param camera defines the camera to use for the picking
  37348. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37349. * @returns the current scene
  37350. */
  37351. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37352. /**
  37353. * Creates a ray that can be used to pick in the scene
  37354. * @param x defines the x coordinate of the origin (on-screen)
  37355. * @param y defines the y coordinate of the origin (on-screen)
  37356. * @param camera defines the camera to use for the picking
  37357. * @returns a Ray
  37358. */
  37359. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37360. /**
  37361. * Creates a ray that can be used to pick in the scene
  37362. * @param x defines the x coordinate of the origin (on-screen)
  37363. * @param y defines the y coordinate of the origin (on-screen)
  37364. * @param result defines the ray where to store the picking ray
  37365. * @param camera defines the camera to use for the picking
  37366. * @returns the current scene
  37367. */
  37368. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37369. /** Launch a ray to try to pick a mesh in the scene
  37370. * @param x position on screen
  37371. * @param y position on screen
  37372. * @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
  37373. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37374. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37375. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37376. * @returns a PickingInfo
  37377. */
  37378. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37379. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37380. * @param x position on screen
  37381. * @param y position on screen
  37382. * @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
  37383. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37384. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37385. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  37386. */
  37387. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37388. /** Use the given ray to pick a mesh in the scene
  37389. * @param ray The ray to use to pick meshes
  37390. * @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
  37391. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37392. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37393. * @returns a PickingInfo
  37394. */
  37395. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37396. /**
  37397. * Launch a ray to try to pick a mesh in the scene
  37398. * @param x X position on screen
  37399. * @param y Y position on screen
  37400. * @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
  37401. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37403. * @returns an array of PickingInfo
  37404. */
  37405. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37406. /**
  37407. * Launch a ray to try to pick a mesh in the scene
  37408. * @param ray Ray to use
  37409. * @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
  37410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37411. * @returns an array of PickingInfo
  37412. */
  37413. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37414. /**
  37415. * Force the value of meshUnderPointer
  37416. * @param mesh defines the mesh to use
  37417. */
  37418. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37419. /**
  37420. * Gets the mesh under the pointer
  37421. * @returns a Mesh or null if no mesh is under the pointer
  37422. */
  37423. getPointerOverMesh(): Nullable<AbstractMesh>;
  37424. /** @hidden */
  37425. _rebuildGeometries(): void;
  37426. /** @hidden */
  37427. _rebuildTextures(): void;
  37428. private _getByTags;
  37429. /**
  37430. * Get a list of meshes by tags
  37431. * @param tagsQuery defines the tags query to use
  37432. * @param forEach defines a predicate used to filter results
  37433. * @returns an array of Mesh
  37434. */
  37435. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37436. /**
  37437. * Get a list of cameras by tags
  37438. * @param tagsQuery defines the tags query to use
  37439. * @param forEach defines a predicate used to filter results
  37440. * @returns an array of Camera
  37441. */
  37442. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37443. /**
  37444. * Get a list of lights by tags
  37445. * @param tagsQuery defines the tags query to use
  37446. * @param forEach defines a predicate used to filter results
  37447. * @returns an array of Light
  37448. */
  37449. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37450. /**
  37451. * Get a list of materials by tags
  37452. * @param tagsQuery defines the tags query to use
  37453. * @param forEach defines a predicate used to filter results
  37454. * @returns an array of Material
  37455. */
  37456. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37457. /**
  37458. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37459. * This allowed control for front to back rendering or reversly depending of the special needs.
  37460. *
  37461. * @param renderingGroupId The rendering group id corresponding to its index
  37462. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37463. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37464. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37465. */
  37466. 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;
  37467. /**
  37468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37469. *
  37470. * @param renderingGroupId The rendering group id corresponding to its index
  37471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37472. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37473. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37474. */
  37475. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37476. /**
  37477. * Gets the current auto clear configuration for one rendering group of the rendering
  37478. * manager.
  37479. * @param index the rendering group index to get the information for
  37480. * @returns The auto clear setup for the requested rendering group
  37481. */
  37482. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37483. private _blockMaterialDirtyMechanism;
  37484. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37485. get blockMaterialDirtyMechanism(): boolean;
  37486. set blockMaterialDirtyMechanism(value: boolean);
  37487. /**
  37488. * Will flag all materials as dirty to trigger new shader compilation
  37489. * @param flag defines the flag used to specify which material part must be marked as dirty
  37490. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37491. */
  37492. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37493. /** @hidden */
  37494. _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;
  37495. /** @hidden */
  37496. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37497. /** @hidden */
  37498. _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;
  37499. /** @hidden */
  37500. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37501. /** @hidden */
  37502. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37503. /** @hidden */
  37504. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37505. }
  37506. }
  37507. declare module BABYLON {
  37508. /**
  37509. * Set of assets to keep when moving a scene into an asset container.
  37510. */
  37511. export class KeepAssets extends AbstractScene {
  37512. }
  37513. /**
  37514. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37515. */
  37516. export class InstantiatedEntries {
  37517. /**
  37518. * List of new root nodes (eg. nodes with no parent)
  37519. */
  37520. rootNodes: TransformNode[];
  37521. /**
  37522. * List of new skeletons
  37523. */
  37524. skeletons: Skeleton[];
  37525. /**
  37526. * List of new animation groups
  37527. */
  37528. animationGroups: AnimationGroup[];
  37529. }
  37530. /**
  37531. * Container with a set of assets that can be added or removed from a scene.
  37532. */
  37533. export class AssetContainer extends AbstractScene {
  37534. private _wasAddedToScene;
  37535. /**
  37536. * The scene the AssetContainer belongs to.
  37537. */
  37538. scene: Scene;
  37539. /**
  37540. * Instantiates an AssetContainer.
  37541. * @param scene The scene the AssetContainer belongs to.
  37542. */
  37543. constructor(scene: Scene);
  37544. /**
  37545. * Instantiate or clone all meshes and add the new ones to the scene.
  37546. * Skeletons and animation groups will all be cloned
  37547. * @param nameFunction defines an optional function used to get new names for clones
  37548. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37549. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37550. */
  37551. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37552. /**
  37553. * Adds all the assets from the container to the scene.
  37554. */
  37555. addAllToScene(): void;
  37556. /**
  37557. * Removes all the assets in the container from the scene
  37558. */
  37559. removeAllFromScene(): void;
  37560. /**
  37561. * Disposes all the assets in the container
  37562. */
  37563. dispose(): void;
  37564. private _moveAssets;
  37565. /**
  37566. * Removes all the assets contained in the scene and adds them to the container.
  37567. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37568. */
  37569. moveAllFromScene(keepAssets?: KeepAssets): void;
  37570. /**
  37571. * 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.
  37572. * @returns the root mesh
  37573. */
  37574. createRootMesh(): Mesh;
  37575. /**
  37576. * Merge animations (direct and animation groups) from this asset container into a scene
  37577. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37578. * @param animatables set of animatables to retarget to a node from the scene
  37579. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37580. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37581. */
  37582. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37583. }
  37584. }
  37585. declare module BABYLON {
  37586. /**
  37587. * Defines how the parser contract is defined.
  37588. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37589. */
  37590. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37591. /**
  37592. * Defines how the individual parser contract is defined.
  37593. * These parser can parse an individual asset
  37594. */
  37595. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37596. /**
  37597. * Base class of the scene acting as a container for the different elements composing a scene.
  37598. * This class is dynamically extended by the different components of the scene increasing
  37599. * flexibility and reducing coupling
  37600. */
  37601. export abstract class AbstractScene {
  37602. /**
  37603. * Stores the list of available parsers in the application.
  37604. */
  37605. private static _BabylonFileParsers;
  37606. /**
  37607. * Stores the list of available individual parsers in the application.
  37608. */
  37609. private static _IndividualBabylonFileParsers;
  37610. /**
  37611. * Adds a parser in the list of available ones
  37612. * @param name Defines the name of the parser
  37613. * @param parser Defines the parser to add
  37614. */
  37615. static AddParser(name: string, parser: BabylonFileParser): void;
  37616. /**
  37617. * Gets a general parser from the list of avaialble ones
  37618. * @param name Defines the name of the parser
  37619. * @returns the requested parser or null
  37620. */
  37621. static GetParser(name: string): Nullable<BabylonFileParser>;
  37622. /**
  37623. * Adds n individual parser in the list of available ones
  37624. * @param name Defines the name of the parser
  37625. * @param parser Defines the parser to add
  37626. */
  37627. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37628. /**
  37629. * Gets an individual parser from the list of avaialble ones
  37630. * @param name Defines the name of the parser
  37631. * @returns the requested parser or null
  37632. */
  37633. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37634. /**
  37635. * Parser json data and populate both a scene and its associated container object
  37636. * @param jsonData Defines the data to parse
  37637. * @param scene Defines the scene to parse the data for
  37638. * @param container Defines the container attached to the parsing sequence
  37639. * @param rootUrl Defines the root url of the data
  37640. */
  37641. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37642. /**
  37643. * Gets the list of root nodes (ie. nodes with no parent)
  37644. */
  37645. rootNodes: Node[];
  37646. /** All of the cameras added to this scene
  37647. * @see http://doc.babylonjs.com/babylon101/cameras
  37648. */
  37649. cameras: Camera[];
  37650. /**
  37651. * All of the lights added to this scene
  37652. * @see http://doc.babylonjs.com/babylon101/lights
  37653. */
  37654. lights: Light[];
  37655. /**
  37656. * All of the (abstract) meshes added to this scene
  37657. */
  37658. meshes: AbstractMesh[];
  37659. /**
  37660. * The list of skeletons added to the scene
  37661. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37662. */
  37663. skeletons: Skeleton[];
  37664. /**
  37665. * All of the particle systems added to this scene
  37666. * @see http://doc.babylonjs.com/babylon101/particles
  37667. */
  37668. particleSystems: IParticleSystem[];
  37669. /**
  37670. * Gets a list of Animations associated with the scene
  37671. */
  37672. animations: Animation[];
  37673. /**
  37674. * All of the animation groups added to this scene
  37675. * @see http://doc.babylonjs.com/how_to/group
  37676. */
  37677. animationGroups: AnimationGroup[];
  37678. /**
  37679. * All of the multi-materials added to this scene
  37680. * @see http://doc.babylonjs.com/how_to/multi_materials
  37681. */
  37682. multiMaterials: MultiMaterial[];
  37683. /**
  37684. * All of the materials added to this scene
  37685. * In the context of a Scene, it is not supposed to be modified manually.
  37686. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37687. * Note also that the order of the Material within the array is not significant and might change.
  37688. * @see http://doc.babylonjs.com/babylon101/materials
  37689. */
  37690. materials: Material[];
  37691. /**
  37692. * The list of morph target managers added to the scene
  37693. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37694. */
  37695. morphTargetManagers: MorphTargetManager[];
  37696. /**
  37697. * The list of geometries used in the scene.
  37698. */
  37699. geometries: Geometry[];
  37700. /**
  37701. * All of the tranform nodes added to this scene
  37702. * In the context of a Scene, it is not supposed to be modified manually.
  37703. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37704. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37705. * @see http://doc.babylonjs.com/how_to/transformnode
  37706. */
  37707. transformNodes: TransformNode[];
  37708. /**
  37709. * ActionManagers available on the scene.
  37710. */
  37711. actionManagers: AbstractActionManager[];
  37712. /**
  37713. * Textures to keep.
  37714. */
  37715. textures: BaseTexture[];
  37716. /**
  37717. * Environment texture for the scene
  37718. */
  37719. environmentTexture: Nullable<BaseTexture>;
  37720. /**
  37721. * @returns all meshes, lights, cameras, transformNodes and bones
  37722. */
  37723. getNodes(): Array<Node>;
  37724. }
  37725. }
  37726. declare module BABYLON {
  37727. /**
  37728. * Interface used to define options for Sound class
  37729. */
  37730. export interface ISoundOptions {
  37731. /**
  37732. * Does the sound autoplay once loaded.
  37733. */
  37734. autoplay?: boolean;
  37735. /**
  37736. * Does the sound loop after it finishes playing once.
  37737. */
  37738. loop?: boolean;
  37739. /**
  37740. * Sound's volume
  37741. */
  37742. volume?: number;
  37743. /**
  37744. * Is it a spatial sound?
  37745. */
  37746. spatialSound?: boolean;
  37747. /**
  37748. * Maximum distance to hear that sound
  37749. */
  37750. maxDistance?: number;
  37751. /**
  37752. * Uses user defined attenuation function
  37753. */
  37754. useCustomAttenuation?: boolean;
  37755. /**
  37756. * Define the roll off factor of spatial sounds.
  37757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37758. */
  37759. rolloffFactor?: number;
  37760. /**
  37761. * Define the reference distance the sound should be heard perfectly.
  37762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37763. */
  37764. refDistance?: number;
  37765. /**
  37766. * Define the distance attenuation model the sound will follow.
  37767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37768. */
  37769. distanceModel?: string;
  37770. /**
  37771. * Defines the playback speed (1 by default)
  37772. */
  37773. playbackRate?: number;
  37774. /**
  37775. * Defines if the sound is from a streaming source
  37776. */
  37777. streaming?: boolean;
  37778. /**
  37779. * Defines an optional length (in seconds) inside the sound file
  37780. */
  37781. length?: number;
  37782. /**
  37783. * Defines an optional offset (in seconds) inside the sound file
  37784. */
  37785. offset?: number;
  37786. /**
  37787. * If true, URLs will not be required to state the audio file codec to use.
  37788. */
  37789. skipCodecCheck?: boolean;
  37790. }
  37791. /**
  37792. * Defines a sound that can be played in the application.
  37793. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37795. */
  37796. export class Sound {
  37797. /**
  37798. * The name of the sound in the scene.
  37799. */
  37800. name: string;
  37801. /**
  37802. * Does the sound autoplay once loaded.
  37803. */
  37804. autoplay: boolean;
  37805. /**
  37806. * Does the sound loop after it finishes playing once.
  37807. */
  37808. loop: boolean;
  37809. /**
  37810. * Does the sound use a custom attenuation curve to simulate the falloff
  37811. * happening when the source gets further away from the camera.
  37812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37813. */
  37814. useCustomAttenuation: boolean;
  37815. /**
  37816. * The sound track id this sound belongs to.
  37817. */
  37818. soundTrackId: number;
  37819. /**
  37820. * Is this sound currently played.
  37821. */
  37822. isPlaying: boolean;
  37823. /**
  37824. * Is this sound currently paused.
  37825. */
  37826. isPaused: boolean;
  37827. /**
  37828. * Does this sound enables spatial sound.
  37829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37830. */
  37831. spatialSound: boolean;
  37832. /**
  37833. * Define the reference distance the sound should be heard perfectly.
  37834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37835. */
  37836. refDistance: number;
  37837. /**
  37838. * Define the roll off factor of spatial sounds.
  37839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37840. */
  37841. rolloffFactor: number;
  37842. /**
  37843. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37845. */
  37846. maxDistance: number;
  37847. /**
  37848. * Define the distance attenuation model the sound will follow.
  37849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37850. */
  37851. distanceModel: string;
  37852. /**
  37853. * @hidden
  37854. * Back Compat
  37855. **/
  37856. onended: () => any;
  37857. /**
  37858. * Observable event when the current playing sound finishes.
  37859. */
  37860. onEndedObservable: Observable<Sound>;
  37861. private _panningModel;
  37862. private _playbackRate;
  37863. private _streaming;
  37864. private _startTime;
  37865. private _startOffset;
  37866. private _position;
  37867. /** @hidden */
  37868. _positionInEmitterSpace: boolean;
  37869. private _localDirection;
  37870. private _volume;
  37871. private _isReadyToPlay;
  37872. private _isDirectional;
  37873. private _readyToPlayCallback;
  37874. private _audioBuffer;
  37875. private _soundSource;
  37876. private _streamingSource;
  37877. private _soundPanner;
  37878. private _soundGain;
  37879. private _inputAudioNode;
  37880. private _outputAudioNode;
  37881. private _coneInnerAngle;
  37882. private _coneOuterAngle;
  37883. private _coneOuterGain;
  37884. private _scene;
  37885. private _connectedTransformNode;
  37886. private _customAttenuationFunction;
  37887. private _registerFunc;
  37888. private _isOutputConnected;
  37889. private _htmlAudioElement;
  37890. private _urlType;
  37891. private _length?;
  37892. private _offset?;
  37893. /** @hidden */
  37894. static _SceneComponentInitialization: (scene: Scene) => void;
  37895. /**
  37896. * Create a sound and attach it to a scene
  37897. * @param name Name of your sound
  37898. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37899. * @param scene defines the scene the sound belongs to
  37900. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37901. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37902. */
  37903. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37904. /**
  37905. * Release the sound and its associated resources
  37906. */
  37907. dispose(): void;
  37908. /**
  37909. * Gets if the sounds is ready to be played or not.
  37910. * @returns true if ready, otherwise false
  37911. */
  37912. isReady(): boolean;
  37913. private _soundLoaded;
  37914. /**
  37915. * Sets the data of the sound from an audiobuffer
  37916. * @param audioBuffer The audioBuffer containing the data
  37917. */
  37918. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37919. /**
  37920. * Updates the current sounds options such as maxdistance, loop...
  37921. * @param options A JSON object containing values named as the object properties
  37922. */
  37923. updateOptions(options: ISoundOptions): void;
  37924. private _createSpatialParameters;
  37925. private _updateSpatialParameters;
  37926. /**
  37927. * Switch the panning model to HRTF:
  37928. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37930. */
  37931. switchPanningModelToHRTF(): void;
  37932. /**
  37933. * Switch the panning model to Equal Power:
  37934. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37936. */
  37937. switchPanningModelToEqualPower(): void;
  37938. private _switchPanningModel;
  37939. /**
  37940. * Connect this sound to a sound track audio node like gain...
  37941. * @param soundTrackAudioNode the sound track audio node to connect to
  37942. */
  37943. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37944. /**
  37945. * Transform this sound into a directional source
  37946. * @param coneInnerAngle Size of the inner cone in degree
  37947. * @param coneOuterAngle Size of the outer cone in degree
  37948. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37949. */
  37950. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37951. /**
  37952. * Gets or sets the inner angle for the directional cone.
  37953. */
  37954. get directionalConeInnerAngle(): number;
  37955. /**
  37956. * Gets or sets the inner angle for the directional cone.
  37957. */
  37958. set directionalConeInnerAngle(value: number);
  37959. /**
  37960. * Gets or sets the outer angle for the directional cone.
  37961. */
  37962. get directionalConeOuterAngle(): number;
  37963. /**
  37964. * Gets or sets the outer angle for the directional cone.
  37965. */
  37966. set directionalConeOuterAngle(value: number);
  37967. /**
  37968. * Sets the position of the emitter if spatial sound is enabled
  37969. * @param newPosition Defines the new posisiton
  37970. */
  37971. setPosition(newPosition: Vector3): void;
  37972. /**
  37973. * Sets the local direction of the emitter if spatial sound is enabled
  37974. * @param newLocalDirection Defines the new local direction
  37975. */
  37976. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37977. private _updateDirection;
  37978. /** @hidden */
  37979. updateDistanceFromListener(): void;
  37980. /**
  37981. * Sets a new custom attenuation function for the sound.
  37982. * @param callback Defines the function used for the attenuation
  37983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37984. */
  37985. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37986. /**
  37987. * Play the sound
  37988. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37989. * @param offset (optional) Start the sound at a specific time in seconds
  37990. * @param length (optional) Sound duration (in seconds)
  37991. */
  37992. play(time?: number, offset?: number, length?: number): void;
  37993. private _onended;
  37994. /**
  37995. * Stop the sound
  37996. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37997. */
  37998. stop(time?: number): void;
  37999. /**
  38000. * Put the sound in pause
  38001. */
  38002. pause(): void;
  38003. /**
  38004. * Sets a dedicated volume for this sounds
  38005. * @param newVolume Define the new volume of the sound
  38006. * @param time Define time for gradual change to new volume
  38007. */
  38008. setVolume(newVolume: number, time?: number): void;
  38009. /**
  38010. * Set the sound play back rate
  38011. * @param newPlaybackRate Define the playback rate the sound should be played at
  38012. */
  38013. setPlaybackRate(newPlaybackRate: number): void;
  38014. /**
  38015. * Gets the volume of the sound.
  38016. * @returns the volume of the sound
  38017. */
  38018. getVolume(): number;
  38019. /**
  38020. * Attach the sound to a dedicated mesh
  38021. * @param transformNode The transform node to connect the sound with
  38022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38023. */
  38024. attachToMesh(transformNode: TransformNode): void;
  38025. /**
  38026. * Detach the sound from the previously attached mesh
  38027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38028. */
  38029. detachFromMesh(): void;
  38030. private _onRegisterAfterWorldMatrixUpdate;
  38031. /**
  38032. * Clone the current sound in the scene.
  38033. * @returns the new sound clone
  38034. */
  38035. clone(): Nullable<Sound>;
  38036. /**
  38037. * Gets the current underlying audio buffer containing the data
  38038. * @returns the audio buffer
  38039. */
  38040. getAudioBuffer(): Nullable<AudioBuffer>;
  38041. /**
  38042. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38043. * @returns the source node
  38044. */
  38045. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38046. /**
  38047. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38048. * @returns the gain node
  38049. */
  38050. getSoundGain(): Nullable<GainNode>;
  38051. /**
  38052. * Serializes the Sound in a JSON representation
  38053. * @returns the JSON representation of the sound
  38054. */
  38055. serialize(): any;
  38056. /**
  38057. * Parse a JSON representation of a sound to innstantiate in a given scene
  38058. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38059. * @param scene Define the scene the new parsed sound should be created in
  38060. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38061. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38062. * @returns the newly parsed sound
  38063. */
  38064. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38065. }
  38066. }
  38067. declare module BABYLON {
  38068. /**
  38069. * This defines an action helpful to play a defined sound on a triggered action.
  38070. */
  38071. export class PlaySoundAction extends Action {
  38072. private _sound;
  38073. /**
  38074. * Instantiate the action
  38075. * @param triggerOptions defines the trigger options
  38076. * @param sound defines the sound to play
  38077. * @param condition defines the trigger related conditions
  38078. */
  38079. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38080. /** @hidden */
  38081. _prepare(): void;
  38082. /**
  38083. * Execute the action and play the sound.
  38084. */
  38085. execute(): void;
  38086. /**
  38087. * Serializes the actions and its related information.
  38088. * @param parent defines the object to serialize in
  38089. * @returns the serialized object
  38090. */
  38091. serialize(parent: any): any;
  38092. }
  38093. /**
  38094. * This defines an action helpful to stop a defined sound on a triggered action.
  38095. */
  38096. export class StopSoundAction extends Action {
  38097. private _sound;
  38098. /**
  38099. * Instantiate the action
  38100. * @param triggerOptions defines the trigger options
  38101. * @param sound defines the sound to stop
  38102. * @param condition defines the trigger related conditions
  38103. */
  38104. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38105. /** @hidden */
  38106. _prepare(): void;
  38107. /**
  38108. * Execute the action and stop the sound.
  38109. */
  38110. execute(): void;
  38111. /**
  38112. * Serializes the actions and its related information.
  38113. * @param parent defines the object to serialize in
  38114. * @returns the serialized object
  38115. */
  38116. serialize(parent: any): any;
  38117. }
  38118. }
  38119. declare module BABYLON {
  38120. /**
  38121. * This defines an action responsible to change the value of a property
  38122. * by interpolating between its current value and the newly set one once triggered.
  38123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38124. */
  38125. export class InterpolateValueAction extends Action {
  38126. /**
  38127. * Defines the path of the property where the value should be interpolated
  38128. */
  38129. propertyPath: string;
  38130. /**
  38131. * Defines the target value at the end of the interpolation.
  38132. */
  38133. value: any;
  38134. /**
  38135. * Defines the time it will take for the property to interpolate to the value.
  38136. */
  38137. duration: number;
  38138. /**
  38139. * Defines if the other scene animations should be stopped when the action has been triggered
  38140. */
  38141. stopOtherAnimations?: boolean;
  38142. /**
  38143. * Defines a callback raised once the interpolation animation has been done.
  38144. */
  38145. onInterpolationDone?: () => void;
  38146. /**
  38147. * Observable triggered once the interpolation animation has been done.
  38148. */
  38149. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38150. private _target;
  38151. private _effectiveTarget;
  38152. private _property;
  38153. /**
  38154. * Instantiate the action
  38155. * @param triggerOptions defines the trigger options
  38156. * @param target defines the object containing the value to interpolate
  38157. * @param propertyPath defines the path to the property in the target object
  38158. * @param value defines the target value at the end of the interpolation
  38159. * @param duration deines the time it will take for the property to interpolate to the value.
  38160. * @param condition defines the trigger related conditions
  38161. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38162. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38163. */
  38164. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38165. /** @hidden */
  38166. _prepare(): void;
  38167. /**
  38168. * Execute the action starts the value interpolation.
  38169. */
  38170. execute(): void;
  38171. /**
  38172. * Serializes the actions and its related information.
  38173. * @param parent defines the object to serialize in
  38174. * @returns the serialized object
  38175. */
  38176. serialize(parent: any): any;
  38177. }
  38178. }
  38179. declare module BABYLON {
  38180. /**
  38181. * Options allowed during the creation of a sound track.
  38182. */
  38183. export interface ISoundTrackOptions {
  38184. /**
  38185. * The volume the sound track should take during creation
  38186. */
  38187. volume?: number;
  38188. /**
  38189. * Define if the sound track is the main sound track of the scene
  38190. */
  38191. mainTrack?: boolean;
  38192. }
  38193. /**
  38194. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38195. * It will be also used in a future release to apply effects on a specific track.
  38196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38197. */
  38198. export class SoundTrack {
  38199. /**
  38200. * The unique identifier of the sound track in the scene.
  38201. */
  38202. id: number;
  38203. /**
  38204. * The list of sounds included in the sound track.
  38205. */
  38206. soundCollection: Array<Sound>;
  38207. private _outputAudioNode;
  38208. private _scene;
  38209. private _connectedAnalyser;
  38210. private _options;
  38211. private _isInitialized;
  38212. /**
  38213. * Creates a new sound track.
  38214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38215. * @param scene Define the scene the sound track belongs to
  38216. * @param options
  38217. */
  38218. constructor(scene: Scene, options?: ISoundTrackOptions);
  38219. private _initializeSoundTrackAudioGraph;
  38220. /**
  38221. * Release the sound track and its associated resources
  38222. */
  38223. dispose(): void;
  38224. /**
  38225. * Adds a sound to this sound track
  38226. * @param sound define the cound to add
  38227. * @ignoreNaming
  38228. */
  38229. AddSound(sound: Sound): void;
  38230. /**
  38231. * Removes a sound to this sound track
  38232. * @param sound define the cound to remove
  38233. * @ignoreNaming
  38234. */
  38235. RemoveSound(sound: Sound): void;
  38236. /**
  38237. * Set a global volume for the full sound track.
  38238. * @param newVolume Define the new volume of the sound track
  38239. */
  38240. setVolume(newVolume: number): void;
  38241. /**
  38242. * Switch the panning model to HRTF:
  38243. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38245. */
  38246. switchPanningModelToHRTF(): void;
  38247. /**
  38248. * Switch the panning model to Equal Power:
  38249. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38251. */
  38252. switchPanningModelToEqualPower(): void;
  38253. /**
  38254. * Connect the sound track to an audio analyser allowing some amazing
  38255. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38257. * @param analyser The analyser to connect to the engine
  38258. */
  38259. connectToAnalyser(analyser: Analyser): void;
  38260. }
  38261. }
  38262. declare module BABYLON {
  38263. interface AbstractScene {
  38264. /**
  38265. * The list of sounds used in the scene.
  38266. */
  38267. sounds: Nullable<Array<Sound>>;
  38268. }
  38269. interface Scene {
  38270. /**
  38271. * @hidden
  38272. * Backing field
  38273. */
  38274. _mainSoundTrack: SoundTrack;
  38275. /**
  38276. * The main sound track played by the scene.
  38277. * It cotains your primary collection of sounds.
  38278. */
  38279. mainSoundTrack: SoundTrack;
  38280. /**
  38281. * The list of sound tracks added to the scene
  38282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38283. */
  38284. soundTracks: Nullable<Array<SoundTrack>>;
  38285. /**
  38286. * Gets a sound using a given name
  38287. * @param name defines the name to search for
  38288. * @return the found sound or null if not found at all.
  38289. */
  38290. getSoundByName(name: string): Nullable<Sound>;
  38291. /**
  38292. * Gets or sets if audio support is enabled
  38293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38294. */
  38295. audioEnabled: boolean;
  38296. /**
  38297. * Gets or sets if audio will be output to headphones
  38298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38299. */
  38300. headphone: boolean;
  38301. /**
  38302. * Gets or sets custom audio listener position provider
  38303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38304. */
  38305. audioListenerPositionProvider: Nullable<() => Vector3>;
  38306. /**
  38307. * Gets or sets a refresh rate when using 3D audio positioning
  38308. */
  38309. audioPositioningRefreshRate: number;
  38310. }
  38311. /**
  38312. * Defines the sound scene component responsible to manage any sounds
  38313. * in a given scene.
  38314. */
  38315. export class AudioSceneComponent implements ISceneSerializableComponent {
  38316. /**
  38317. * The component name helpfull to identify the component in the list of scene components.
  38318. */
  38319. readonly name: string;
  38320. /**
  38321. * The scene the component belongs to.
  38322. */
  38323. scene: Scene;
  38324. private _audioEnabled;
  38325. /**
  38326. * Gets whether audio is enabled or not.
  38327. * Please use related enable/disable method to switch state.
  38328. */
  38329. get audioEnabled(): boolean;
  38330. private _headphone;
  38331. /**
  38332. * Gets whether audio is outputing to headphone or not.
  38333. * Please use the according Switch methods to change output.
  38334. */
  38335. get headphone(): boolean;
  38336. /**
  38337. * Gets or sets a refresh rate when using 3D audio positioning
  38338. */
  38339. audioPositioningRefreshRate: number;
  38340. private _audioListenerPositionProvider;
  38341. /**
  38342. * Gets the current audio listener position provider
  38343. */
  38344. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38345. /**
  38346. * Sets a custom listener position for all sounds in the scene
  38347. * By default, this is the position of the first active camera
  38348. */
  38349. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38350. /**
  38351. * Creates a new instance of the component for the given scene
  38352. * @param scene Defines the scene to register the component in
  38353. */
  38354. constructor(scene: Scene);
  38355. /**
  38356. * Registers the component in a given scene
  38357. */
  38358. register(): void;
  38359. /**
  38360. * Rebuilds the elements related to this component in case of
  38361. * context lost for instance.
  38362. */
  38363. rebuild(): void;
  38364. /**
  38365. * Serializes the component data to the specified json object
  38366. * @param serializationObject The object to serialize to
  38367. */
  38368. serialize(serializationObject: any): void;
  38369. /**
  38370. * Adds all the elements from the container to the scene
  38371. * @param container the container holding the elements
  38372. */
  38373. addFromContainer(container: AbstractScene): void;
  38374. /**
  38375. * Removes all the elements in the container from the scene
  38376. * @param container contains the elements to remove
  38377. * @param dispose if the removed element should be disposed (default: false)
  38378. */
  38379. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38380. /**
  38381. * Disposes the component and the associated ressources.
  38382. */
  38383. dispose(): void;
  38384. /**
  38385. * Disables audio in the associated scene.
  38386. */
  38387. disableAudio(): void;
  38388. /**
  38389. * Enables audio in the associated scene.
  38390. */
  38391. enableAudio(): void;
  38392. /**
  38393. * Switch audio to headphone output.
  38394. */
  38395. switchAudioModeForHeadphones(): void;
  38396. /**
  38397. * Switch audio to normal speakers.
  38398. */
  38399. switchAudioModeForNormalSpeakers(): void;
  38400. private _cachedCameraDirection;
  38401. private _cachedCameraPosition;
  38402. private _lastCheck;
  38403. private _afterRender;
  38404. }
  38405. }
  38406. declare module BABYLON {
  38407. /**
  38408. * Wraps one or more Sound objects and selects one with random weight for playback.
  38409. */
  38410. export class WeightedSound {
  38411. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38412. loop: boolean;
  38413. private _coneInnerAngle;
  38414. private _coneOuterAngle;
  38415. private _volume;
  38416. /** A Sound is currently playing. */
  38417. isPlaying: boolean;
  38418. /** A Sound is currently paused. */
  38419. isPaused: boolean;
  38420. private _sounds;
  38421. private _weights;
  38422. private _currentIndex?;
  38423. /**
  38424. * Creates a new WeightedSound from the list of sounds given.
  38425. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38426. * @param sounds Array of Sounds that will be selected from.
  38427. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38428. */
  38429. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38430. /**
  38431. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38432. */
  38433. get directionalConeInnerAngle(): number;
  38434. /**
  38435. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38436. */
  38437. set directionalConeInnerAngle(value: number);
  38438. /**
  38439. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38440. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38441. */
  38442. get directionalConeOuterAngle(): number;
  38443. /**
  38444. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38445. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38446. */
  38447. set directionalConeOuterAngle(value: number);
  38448. /**
  38449. * Playback volume.
  38450. */
  38451. get volume(): number;
  38452. /**
  38453. * Playback volume.
  38454. */
  38455. set volume(value: number);
  38456. private _onended;
  38457. /**
  38458. * Suspend playback
  38459. */
  38460. pause(): void;
  38461. /**
  38462. * Stop playback
  38463. */
  38464. stop(): void;
  38465. /**
  38466. * Start playback.
  38467. * @param startOffset Position the clip head at a specific time in seconds.
  38468. */
  38469. play(startOffset?: number): void;
  38470. }
  38471. }
  38472. declare module BABYLON {
  38473. /**
  38474. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38476. */
  38477. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38478. /**
  38479. * Gets the name of the behavior.
  38480. */
  38481. get name(): string;
  38482. /**
  38483. * The easing function used by animations
  38484. */
  38485. static EasingFunction: BackEase;
  38486. /**
  38487. * The easing mode used by animations
  38488. */
  38489. static EasingMode: number;
  38490. /**
  38491. * The duration of the animation, in milliseconds
  38492. */
  38493. transitionDuration: number;
  38494. /**
  38495. * Length of the distance animated by the transition when lower radius is reached
  38496. */
  38497. lowerRadiusTransitionRange: number;
  38498. /**
  38499. * Length of the distance animated by the transition when upper radius is reached
  38500. */
  38501. upperRadiusTransitionRange: number;
  38502. private _autoTransitionRange;
  38503. /**
  38504. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38505. */
  38506. get autoTransitionRange(): boolean;
  38507. /**
  38508. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38509. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38510. */
  38511. set autoTransitionRange(value: boolean);
  38512. private _attachedCamera;
  38513. private _onAfterCheckInputsObserver;
  38514. private _onMeshTargetChangedObserver;
  38515. /**
  38516. * Initializes the behavior.
  38517. */
  38518. init(): void;
  38519. /**
  38520. * Attaches the behavior to its arc rotate camera.
  38521. * @param camera Defines the camera to attach the behavior to
  38522. */
  38523. attach(camera: ArcRotateCamera): void;
  38524. /**
  38525. * Detaches the behavior from its current arc rotate camera.
  38526. */
  38527. detach(): void;
  38528. private _radiusIsAnimating;
  38529. private _radiusBounceTransition;
  38530. private _animatables;
  38531. private _cachedWheelPrecision;
  38532. /**
  38533. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38534. * @param radiusLimit The limit to check against.
  38535. * @return Bool to indicate if at limit.
  38536. */
  38537. private _isRadiusAtLimit;
  38538. /**
  38539. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38540. * @param radiusDelta The delta by which to animate to. Can be negative.
  38541. */
  38542. private _applyBoundRadiusAnimation;
  38543. /**
  38544. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38545. */
  38546. protected _clearAnimationLocks(): void;
  38547. /**
  38548. * Stops and removes all animations that have been applied to the camera
  38549. */
  38550. stopAllAnimations(): void;
  38551. }
  38552. }
  38553. declare module BABYLON {
  38554. /**
  38555. * 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.
  38556. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38557. */
  38558. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38559. /**
  38560. * Gets the name of the behavior.
  38561. */
  38562. get name(): string;
  38563. private _mode;
  38564. private _radiusScale;
  38565. private _positionScale;
  38566. private _defaultElevation;
  38567. private _elevationReturnTime;
  38568. private _elevationReturnWaitTime;
  38569. private _zoomStopsAnimation;
  38570. private _framingTime;
  38571. /**
  38572. * The easing function used by animations
  38573. */
  38574. static EasingFunction: ExponentialEase;
  38575. /**
  38576. * The easing mode used by animations
  38577. */
  38578. static EasingMode: number;
  38579. /**
  38580. * Sets the current mode used by the behavior
  38581. */
  38582. set mode(mode: number);
  38583. /**
  38584. * Gets current mode used by the behavior.
  38585. */
  38586. get mode(): number;
  38587. /**
  38588. * Sets the scale applied to the radius (1 by default)
  38589. */
  38590. set radiusScale(radius: number);
  38591. /**
  38592. * Gets the scale applied to the radius
  38593. */
  38594. get radiusScale(): number;
  38595. /**
  38596. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38597. */
  38598. set positionScale(scale: number);
  38599. /**
  38600. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38601. */
  38602. get positionScale(): number;
  38603. /**
  38604. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38605. * behaviour is triggered, in radians.
  38606. */
  38607. set defaultElevation(elevation: number);
  38608. /**
  38609. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38610. * behaviour is triggered, in radians.
  38611. */
  38612. get defaultElevation(): number;
  38613. /**
  38614. * Sets the time (in milliseconds) taken to return to the default beta position.
  38615. * Negative value indicates camera should not return to default.
  38616. */
  38617. set elevationReturnTime(speed: number);
  38618. /**
  38619. * Gets the time (in milliseconds) taken to return to the default beta position.
  38620. * Negative value indicates camera should not return to default.
  38621. */
  38622. get elevationReturnTime(): number;
  38623. /**
  38624. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38625. */
  38626. set elevationReturnWaitTime(time: number);
  38627. /**
  38628. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38629. */
  38630. get elevationReturnWaitTime(): number;
  38631. /**
  38632. * Sets the flag that indicates if user zooming should stop animation.
  38633. */
  38634. set zoomStopsAnimation(flag: boolean);
  38635. /**
  38636. * Gets the flag that indicates if user zooming should stop animation.
  38637. */
  38638. get zoomStopsAnimation(): boolean;
  38639. /**
  38640. * Sets the transition time when framing the mesh, in milliseconds
  38641. */
  38642. set framingTime(time: number);
  38643. /**
  38644. * Gets the transition time when framing the mesh, in milliseconds
  38645. */
  38646. get framingTime(): number;
  38647. /**
  38648. * Define if the behavior should automatically change the configured
  38649. * camera limits and sensibilities.
  38650. */
  38651. autoCorrectCameraLimitsAndSensibility: boolean;
  38652. private _onPrePointerObservableObserver;
  38653. private _onAfterCheckInputsObserver;
  38654. private _onMeshTargetChangedObserver;
  38655. private _attachedCamera;
  38656. private _isPointerDown;
  38657. private _lastInteractionTime;
  38658. /**
  38659. * Initializes the behavior.
  38660. */
  38661. init(): void;
  38662. /**
  38663. * Attaches the behavior to its arc rotate camera.
  38664. * @param camera Defines the camera to attach the behavior to
  38665. */
  38666. attach(camera: ArcRotateCamera): void;
  38667. /**
  38668. * Detaches the behavior from its current arc rotate camera.
  38669. */
  38670. detach(): void;
  38671. private _animatables;
  38672. private _betaIsAnimating;
  38673. private _betaTransition;
  38674. private _radiusTransition;
  38675. private _vectorTransition;
  38676. /**
  38677. * Targets the given mesh and updates zoom level accordingly.
  38678. * @param mesh The mesh to target.
  38679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38681. */
  38682. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38683. /**
  38684. * Targets the given mesh with its children and updates zoom level accordingly.
  38685. * @param mesh The mesh to target.
  38686. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38687. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38688. */
  38689. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38690. /**
  38691. * Targets the given meshes with their children and updates zoom level accordingly.
  38692. * @param meshes The mesh to target.
  38693. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38694. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38695. */
  38696. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38697. /**
  38698. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38699. * @param minimumWorld Determines the smaller position of the bounding box extend
  38700. * @param maximumWorld Determines the bigger position of the bounding box extend
  38701. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38702. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38703. */
  38704. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38705. /**
  38706. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38707. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38708. * frustum width.
  38709. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38710. * to fully enclose the mesh in the viewing frustum.
  38711. */
  38712. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38713. /**
  38714. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38715. * is automatically returned to its default position (expected to be above ground plane).
  38716. */
  38717. private _maintainCameraAboveGround;
  38718. /**
  38719. * Returns the frustum slope based on the canvas ratio and camera FOV
  38720. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38721. */
  38722. private _getFrustumSlope;
  38723. /**
  38724. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38725. */
  38726. private _clearAnimationLocks;
  38727. /**
  38728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38729. */
  38730. private _applyUserInteraction;
  38731. /**
  38732. * Stops and removes all animations that have been applied to the camera
  38733. */
  38734. stopAllAnimations(): void;
  38735. /**
  38736. * Gets a value indicating if the user is moving the camera
  38737. */
  38738. get isUserIsMoving(): boolean;
  38739. /**
  38740. * The camera can move all the way towards the mesh.
  38741. */
  38742. static IgnoreBoundsSizeMode: number;
  38743. /**
  38744. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38745. */
  38746. static FitFrustumSidesMode: number;
  38747. }
  38748. }
  38749. declare module BABYLON {
  38750. /**
  38751. * Base class for Camera Pointer Inputs.
  38752. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38753. * for example usage.
  38754. */
  38755. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38756. /**
  38757. * Defines the camera the input is attached to.
  38758. */
  38759. abstract camera: Camera;
  38760. /**
  38761. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38762. */
  38763. protected _altKey: boolean;
  38764. protected _ctrlKey: boolean;
  38765. protected _metaKey: boolean;
  38766. protected _shiftKey: boolean;
  38767. /**
  38768. * Which mouse buttons were pressed at time of last mouse event.
  38769. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38770. */
  38771. protected _buttonsPressed: number;
  38772. /**
  38773. * Defines the buttons associated with the input to handle camera move.
  38774. */
  38775. buttons: number[];
  38776. /**
  38777. * Attach the input controls to a specific dom element to get the input from.
  38778. * @param element Defines the element the controls should be listened from
  38779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38780. */
  38781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38782. /**
  38783. * Detach the current controls from the specified dom element.
  38784. * @param element Defines the element to stop listening the inputs from
  38785. */
  38786. detachControl(element: Nullable<HTMLElement>): void;
  38787. /**
  38788. * Gets the class name of the current input.
  38789. * @returns the class name
  38790. */
  38791. getClassName(): string;
  38792. /**
  38793. * Get the friendly name associated with the input class.
  38794. * @returns the input friendly name
  38795. */
  38796. getSimpleName(): string;
  38797. /**
  38798. * Called on pointer POINTERDOUBLETAP event.
  38799. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38800. */
  38801. protected onDoubleTap(type: string): void;
  38802. /**
  38803. * Called on pointer POINTERMOVE event if only a single touch is active.
  38804. * Override this method to provide functionality.
  38805. */
  38806. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38807. /**
  38808. * Called on pointer POINTERMOVE event if multiple touches are active.
  38809. * Override this method to provide functionality.
  38810. */
  38811. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38812. /**
  38813. * Called on JS contextmenu event.
  38814. * Override this method to provide functionality.
  38815. */
  38816. protected onContextMenu(evt: PointerEvent): void;
  38817. /**
  38818. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38819. * press.
  38820. * Override this method to provide functionality.
  38821. */
  38822. protected onButtonDown(evt: PointerEvent): void;
  38823. /**
  38824. * Called each time a new POINTERUP event occurs. Ie, for each button
  38825. * release.
  38826. * Override this method to provide functionality.
  38827. */
  38828. protected onButtonUp(evt: PointerEvent): void;
  38829. /**
  38830. * Called when window becomes inactive.
  38831. * Override this method to provide functionality.
  38832. */
  38833. protected onLostFocus(): void;
  38834. private _pointerInput;
  38835. private _observer;
  38836. private _onLostFocus;
  38837. private pointA;
  38838. private pointB;
  38839. }
  38840. }
  38841. declare module BABYLON {
  38842. /**
  38843. * Manage the pointers inputs to control an arc rotate camera.
  38844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38845. */
  38846. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38847. /**
  38848. * Defines the camera the input is attached to.
  38849. */
  38850. camera: ArcRotateCamera;
  38851. /**
  38852. * Gets the class name of the current input.
  38853. * @returns the class name
  38854. */
  38855. getClassName(): string;
  38856. /**
  38857. * Defines the buttons associated with the input to handle camera move.
  38858. */
  38859. buttons: number[];
  38860. /**
  38861. * Defines the pointer angular sensibility along the X axis or how fast is
  38862. * the camera rotating.
  38863. */
  38864. angularSensibilityX: number;
  38865. /**
  38866. * Defines the pointer angular sensibility along the Y axis or how fast is
  38867. * the camera rotating.
  38868. */
  38869. angularSensibilityY: number;
  38870. /**
  38871. * Defines the pointer pinch precision or how fast is the camera zooming.
  38872. */
  38873. pinchPrecision: number;
  38874. /**
  38875. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38876. * from 0.
  38877. * It defines the percentage of current camera.radius to use as delta when
  38878. * pinch zoom is used.
  38879. */
  38880. pinchDeltaPercentage: number;
  38881. /**
  38882. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38883. * that any object in the plane at the camera's target point will scale
  38884. * perfectly with finger motion.
  38885. * Overrides pinchDeltaPercentage and pinchPrecision.
  38886. */
  38887. useNaturalPinchZoom: boolean;
  38888. /**
  38889. * Defines the pointer panning sensibility or how fast is the camera moving.
  38890. */
  38891. panningSensibility: number;
  38892. /**
  38893. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38894. */
  38895. multiTouchPanning: boolean;
  38896. /**
  38897. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38898. * zoom (pinch) through multitouch.
  38899. */
  38900. multiTouchPanAndZoom: boolean;
  38901. /**
  38902. * Revers pinch action direction.
  38903. */
  38904. pinchInwards: boolean;
  38905. private _isPanClick;
  38906. private _twoFingerActivityCount;
  38907. private _isPinching;
  38908. /**
  38909. * Called on pointer POINTERMOVE event if only a single touch is active.
  38910. */
  38911. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38912. /**
  38913. * Called on pointer POINTERDOUBLETAP event.
  38914. */
  38915. protected onDoubleTap(type: string): void;
  38916. /**
  38917. * Called on pointer POINTERMOVE event if multiple touches are active.
  38918. */
  38919. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38920. /**
  38921. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38922. * press.
  38923. */
  38924. protected onButtonDown(evt: PointerEvent): void;
  38925. /**
  38926. * Called each time a new POINTERUP event occurs. Ie, for each button
  38927. * release.
  38928. */
  38929. protected onButtonUp(evt: PointerEvent): void;
  38930. /**
  38931. * Called when window becomes inactive.
  38932. */
  38933. protected onLostFocus(): void;
  38934. }
  38935. }
  38936. declare module BABYLON {
  38937. /**
  38938. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38940. */
  38941. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38942. /**
  38943. * Defines the camera the input is attached to.
  38944. */
  38945. camera: ArcRotateCamera;
  38946. /**
  38947. * Defines the list of key codes associated with the up action (increase alpha)
  38948. */
  38949. keysUp: number[];
  38950. /**
  38951. * Defines the list of key codes associated with the down action (decrease alpha)
  38952. */
  38953. keysDown: number[];
  38954. /**
  38955. * Defines the list of key codes associated with the left action (increase beta)
  38956. */
  38957. keysLeft: number[];
  38958. /**
  38959. * Defines the list of key codes associated with the right action (decrease beta)
  38960. */
  38961. keysRight: number[];
  38962. /**
  38963. * Defines the list of key codes associated with the reset action.
  38964. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38965. */
  38966. keysReset: number[];
  38967. /**
  38968. * Defines the panning sensibility of the inputs.
  38969. * (How fast is the camera panning)
  38970. */
  38971. panningSensibility: number;
  38972. /**
  38973. * Defines the zooming sensibility of the inputs.
  38974. * (How fast is the camera zooming)
  38975. */
  38976. zoomingSensibility: number;
  38977. /**
  38978. * Defines whether maintaining the alt key down switch the movement mode from
  38979. * orientation to zoom.
  38980. */
  38981. useAltToZoom: boolean;
  38982. /**
  38983. * Rotation speed of the camera
  38984. */
  38985. angularSpeed: number;
  38986. private _keys;
  38987. private _ctrlPressed;
  38988. private _altPressed;
  38989. private _onCanvasBlurObserver;
  38990. private _onKeyboardObserver;
  38991. private _engine;
  38992. private _scene;
  38993. /**
  38994. * Attach the input controls to a specific dom element to get the input from.
  38995. * @param element Defines the element the controls should be listened from
  38996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38997. */
  38998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38999. /**
  39000. * Detach the current controls from the specified dom element.
  39001. * @param element Defines the element to stop listening the inputs from
  39002. */
  39003. detachControl(element: Nullable<HTMLElement>): void;
  39004. /**
  39005. * Update the current camera state depending on the inputs that have been used this frame.
  39006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39007. */
  39008. checkInputs(): void;
  39009. /**
  39010. * Gets the class name of the current intput.
  39011. * @returns the class name
  39012. */
  39013. getClassName(): string;
  39014. /**
  39015. * Get the friendly name associated with the input class.
  39016. * @returns the input friendly name
  39017. */
  39018. getSimpleName(): string;
  39019. }
  39020. }
  39021. declare module BABYLON {
  39022. /**
  39023. * Manage the mouse wheel inputs to control an arc rotate camera.
  39024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39025. */
  39026. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39027. /**
  39028. * Defines the camera the input is attached to.
  39029. */
  39030. camera: ArcRotateCamera;
  39031. /**
  39032. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39033. */
  39034. wheelPrecision: number;
  39035. /**
  39036. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39037. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39038. */
  39039. wheelDeltaPercentage: number;
  39040. private _wheel;
  39041. private _observer;
  39042. private computeDeltaFromMouseWheelLegacyEvent;
  39043. /**
  39044. * Attach the input controls to a specific dom element to get the input from.
  39045. * @param element Defines the element the controls should be listened from
  39046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39047. */
  39048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39049. /**
  39050. * Detach the current controls from the specified dom element.
  39051. * @param element Defines the element to stop listening the inputs from
  39052. */
  39053. detachControl(element: Nullable<HTMLElement>): void;
  39054. /**
  39055. * Gets the class name of the current intput.
  39056. * @returns the class name
  39057. */
  39058. getClassName(): string;
  39059. /**
  39060. * Get the friendly name associated with the input class.
  39061. * @returns the input friendly name
  39062. */
  39063. getSimpleName(): string;
  39064. }
  39065. }
  39066. declare module BABYLON {
  39067. /**
  39068. * Default Inputs manager for the ArcRotateCamera.
  39069. * It groups all the default supported inputs for ease of use.
  39070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39071. */
  39072. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39073. /**
  39074. * Instantiates a new ArcRotateCameraInputsManager.
  39075. * @param camera Defines the camera the inputs belong to
  39076. */
  39077. constructor(camera: ArcRotateCamera);
  39078. /**
  39079. * Add mouse wheel input support to the input manager.
  39080. * @returns the current input manager
  39081. */
  39082. addMouseWheel(): ArcRotateCameraInputsManager;
  39083. /**
  39084. * Add pointers input support to the input manager.
  39085. * @returns the current input manager
  39086. */
  39087. addPointers(): ArcRotateCameraInputsManager;
  39088. /**
  39089. * Add keyboard input support to the input manager.
  39090. * @returns the current input manager
  39091. */
  39092. addKeyboard(): ArcRotateCameraInputsManager;
  39093. }
  39094. }
  39095. declare module BABYLON {
  39096. /**
  39097. * This represents an orbital type of camera.
  39098. *
  39099. * 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.
  39100. * 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.
  39101. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39102. */
  39103. export class ArcRotateCamera extends TargetCamera {
  39104. /**
  39105. * Defines the rotation angle of the camera along the longitudinal axis.
  39106. */
  39107. alpha: number;
  39108. /**
  39109. * Defines the rotation angle of the camera along the latitudinal axis.
  39110. */
  39111. beta: number;
  39112. /**
  39113. * Defines the radius of the camera from it s target point.
  39114. */
  39115. radius: number;
  39116. protected _target: Vector3;
  39117. protected _targetHost: Nullable<AbstractMesh>;
  39118. /**
  39119. * Defines the target point of the camera.
  39120. * The camera looks towards it form the radius distance.
  39121. */
  39122. get target(): Vector3;
  39123. set target(value: Vector3);
  39124. /**
  39125. * Define the current local position of the camera in the scene
  39126. */
  39127. get position(): Vector3;
  39128. set position(newPosition: Vector3);
  39129. protected _upVector: Vector3;
  39130. protected _upToYMatrix: Matrix;
  39131. protected _YToUpMatrix: Matrix;
  39132. /**
  39133. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39134. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39135. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39136. */
  39137. set upVector(vec: Vector3);
  39138. get upVector(): Vector3;
  39139. /**
  39140. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39141. */
  39142. setMatUp(): void;
  39143. /**
  39144. * Current inertia value on the longitudinal axis.
  39145. * The bigger this number the longer it will take for the camera to stop.
  39146. */
  39147. inertialAlphaOffset: number;
  39148. /**
  39149. * Current inertia value on the latitudinal axis.
  39150. * The bigger this number the longer it will take for the camera to stop.
  39151. */
  39152. inertialBetaOffset: number;
  39153. /**
  39154. * Current inertia value on the radius axis.
  39155. * The bigger this number the longer it will take for the camera to stop.
  39156. */
  39157. inertialRadiusOffset: number;
  39158. /**
  39159. * Minimum allowed angle on the longitudinal axis.
  39160. * This can help limiting how the Camera is able to move in the scene.
  39161. */
  39162. lowerAlphaLimit: Nullable<number>;
  39163. /**
  39164. * Maximum allowed angle on the longitudinal axis.
  39165. * This can help limiting how the Camera is able to move in the scene.
  39166. */
  39167. upperAlphaLimit: Nullable<number>;
  39168. /**
  39169. * Minimum allowed angle on the latitudinal axis.
  39170. * This can help limiting how the Camera is able to move in the scene.
  39171. */
  39172. lowerBetaLimit: number;
  39173. /**
  39174. * Maximum allowed angle on the latitudinal axis.
  39175. * This can help limiting how the Camera is able to move in the scene.
  39176. */
  39177. upperBetaLimit: number;
  39178. /**
  39179. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39180. * This can help limiting how the Camera is able to move in the scene.
  39181. */
  39182. lowerRadiusLimit: Nullable<number>;
  39183. /**
  39184. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39185. * This can help limiting how the Camera is able to move in the scene.
  39186. */
  39187. upperRadiusLimit: Nullable<number>;
  39188. /**
  39189. * Defines the current inertia value used during panning of the camera along the X axis.
  39190. */
  39191. inertialPanningX: number;
  39192. /**
  39193. * Defines the current inertia value used during panning of the camera along the Y axis.
  39194. */
  39195. inertialPanningY: number;
  39196. /**
  39197. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39198. * Basically if your fingers moves away from more than this distance you will be considered
  39199. * in pinch mode.
  39200. */
  39201. pinchToPanMaxDistance: number;
  39202. /**
  39203. * Defines the maximum distance the camera can pan.
  39204. * This could help keeping the cammera always in your scene.
  39205. */
  39206. panningDistanceLimit: Nullable<number>;
  39207. /**
  39208. * Defines the target of the camera before paning.
  39209. */
  39210. panningOriginTarget: Vector3;
  39211. /**
  39212. * Defines the value of the inertia used during panning.
  39213. * 0 would mean stop inertia and one would mean no decelleration at all.
  39214. */
  39215. panningInertia: number;
  39216. /**
  39217. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39218. */
  39219. get angularSensibilityX(): number;
  39220. set angularSensibilityX(value: number);
  39221. /**
  39222. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39223. */
  39224. get angularSensibilityY(): number;
  39225. set angularSensibilityY(value: number);
  39226. /**
  39227. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39228. */
  39229. get pinchPrecision(): number;
  39230. set pinchPrecision(value: number);
  39231. /**
  39232. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39233. * It will be used instead of pinchDeltaPrecision if different from 0.
  39234. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39235. */
  39236. get pinchDeltaPercentage(): number;
  39237. set pinchDeltaPercentage(value: number);
  39238. /**
  39239. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39240. * and pinch delta percentage.
  39241. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39242. * that any object in the plane at the camera's target point will scale
  39243. * perfectly with finger motion.
  39244. */
  39245. get useNaturalPinchZoom(): boolean;
  39246. set useNaturalPinchZoom(value: boolean);
  39247. /**
  39248. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39249. */
  39250. get panningSensibility(): number;
  39251. set panningSensibility(value: number);
  39252. /**
  39253. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39254. */
  39255. get keysUp(): number[];
  39256. set keysUp(value: number[]);
  39257. /**
  39258. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39259. */
  39260. get keysDown(): number[];
  39261. set keysDown(value: number[]);
  39262. /**
  39263. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39264. */
  39265. get keysLeft(): number[];
  39266. set keysLeft(value: number[]);
  39267. /**
  39268. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39269. */
  39270. get keysRight(): number[];
  39271. set keysRight(value: number[]);
  39272. /**
  39273. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39274. */
  39275. get wheelPrecision(): number;
  39276. set wheelPrecision(value: number);
  39277. /**
  39278. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39279. * It will be used instead of pinchDeltaPrecision if different from 0.
  39280. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39281. */
  39282. get wheelDeltaPercentage(): number;
  39283. set wheelDeltaPercentage(value: number);
  39284. /**
  39285. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39286. */
  39287. zoomOnFactor: number;
  39288. /**
  39289. * Defines a screen offset for the camera position.
  39290. */
  39291. targetScreenOffset: Vector2;
  39292. /**
  39293. * Allows the camera to be completely reversed.
  39294. * If false the camera can not arrive upside down.
  39295. */
  39296. allowUpsideDown: boolean;
  39297. /**
  39298. * Define if double tap/click is used to restore the previously saved state of the camera.
  39299. */
  39300. useInputToRestoreState: boolean;
  39301. /** @hidden */
  39302. _viewMatrix: Matrix;
  39303. /** @hidden */
  39304. _useCtrlForPanning: boolean;
  39305. /** @hidden */
  39306. _panningMouseButton: number;
  39307. /**
  39308. * Defines the input associated to the camera.
  39309. */
  39310. inputs: ArcRotateCameraInputsManager;
  39311. /** @hidden */
  39312. _reset: () => void;
  39313. /**
  39314. * Defines the allowed panning axis.
  39315. */
  39316. panningAxis: Vector3;
  39317. protected _localDirection: Vector3;
  39318. protected _transformedDirection: Vector3;
  39319. private _bouncingBehavior;
  39320. /**
  39321. * Gets the bouncing behavior of the camera if it has been enabled.
  39322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39323. */
  39324. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39325. /**
  39326. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39327. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39328. */
  39329. get useBouncingBehavior(): boolean;
  39330. set useBouncingBehavior(value: boolean);
  39331. private _framingBehavior;
  39332. /**
  39333. * Gets the framing behavior of the camera if it has been enabled.
  39334. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39335. */
  39336. get framingBehavior(): Nullable<FramingBehavior>;
  39337. /**
  39338. * Defines if the framing behavior of the camera is enabled on the camera.
  39339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39340. */
  39341. get useFramingBehavior(): boolean;
  39342. set useFramingBehavior(value: boolean);
  39343. private _autoRotationBehavior;
  39344. /**
  39345. * Gets the auto rotation behavior of the camera if it has been enabled.
  39346. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39347. */
  39348. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39349. /**
  39350. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39351. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39352. */
  39353. get useAutoRotationBehavior(): boolean;
  39354. set useAutoRotationBehavior(value: boolean);
  39355. /**
  39356. * Observable triggered when the mesh target has been changed on the camera.
  39357. */
  39358. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39359. /**
  39360. * Event raised when the camera is colliding with a mesh.
  39361. */
  39362. onCollide: (collidedMesh: AbstractMesh) => void;
  39363. /**
  39364. * Defines whether the camera should check collision with the objects oh the scene.
  39365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39366. */
  39367. checkCollisions: boolean;
  39368. /**
  39369. * Defines the collision radius of the camera.
  39370. * This simulates a sphere around the camera.
  39371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39372. */
  39373. collisionRadius: Vector3;
  39374. protected _collider: Collider;
  39375. protected _previousPosition: Vector3;
  39376. protected _collisionVelocity: Vector3;
  39377. protected _newPosition: Vector3;
  39378. protected _previousAlpha: number;
  39379. protected _previousBeta: number;
  39380. protected _previousRadius: number;
  39381. protected _collisionTriggered: boolean;
  39382. protected _targetBoundingCenter: Nullable<Vector3>;
  39383. private _computationVector;
  39384. /**
  39385. * Instantiates a new ArcRotateCamera in a given scene
  39386. * @param name Defines the name of the camera
  39387. * @param alpha Defines the camera rotation along the logitudinal axis
  39388. * @param beta Defines the camera rotation along the latitudinal axis
  39389. * @param radius Defines the camera distance from its target
  39390. * @param target Defines the camera target
  39391. * @param scene Defines the scene the camera belongs to
  39392. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39393. */
  39394. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39395. /** @hidden */
  39396. _initCache(): void;
  39397. /** @hidden */
  39398. _updateCache(ignoreParentClass?: boolean): void;
  39399. protected _getTargetPosition(): Vector3;
  39400. private _storedAlpha;
  39401. private _storedBeta;
  39402. private _storedRadius;
  39403. private _storedTarget;
  39404. private _storedTargetScreenOffset;
  39405. /**
  39406. * Stores the current state of the camera (alpha, beta, radius and target)
  39407. * @returns the camera itself
  39408. */
  39409. storeState(): Camera;
  39410. /**
  39411. * @hidden
  39412. * Restored camera state. You must call storeState() first
  39413. */
  39414. _restoreStateValues(): boolean;
  39415. /** @hidden */
  39416. _isSynchronizedViewMatrix(): boolean;
  39417. /**
  39418. * Attached controls to the current camera.
  39419. * @param element Defines the element the controls should be listened from
  39420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39421. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39422. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39423. */
  39424. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39425. /**
  39426. * Detach the current controls from the camera.
  39427. * The camera will stop reacting to inputs.
  39428. * @param element Defines the element to stop listening the inputs from
  39429. */
  39430. detachControl(element: HTMLElement): void;
  39431. /** @hidden */
  39432. _checkInputs(): void;
  39433. protected _checkLimits(): void;
  39434. /**
  39435. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39436. */
  39437. rebuildAnglesAndRadius(): void;
  39438. /**
  39439. * Use a position to define the current camera related information like alpha, beta and radius
  39440. * @param position Defines the position to set the camera at
  39441. */
  39442. setPosition(position: Vector3): void;
  39443. /**
  39444. * Defines the target the camera should look at.
  39445. * This will automatically adapt alpha beta and radius to fit within the new target.
  39446. * @param target Defines the new target as a Vector or a mesh
  39447. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39448. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39449. */
  39450. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39451. /** @hidden */
  39452. _getViewMatrix(): Matrix;
  39453. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39454. /**
  39455. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39456. * @param meshes Defines the mesh to zoom on
  39457. * @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)
  39458. */
  39459. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39460. /**
  39461. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39462. * The target will be changed but the radius
  39463. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39464. * @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)
  39465. */
  39466. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39467. min: Vector3;
  39468. max: Vector3;
  39469. distance: number;
  39470. }, doNotUpdateMaxZ?: boolean): void;
  39471. /**
  39472. * @override
  39473. * Override Camera.createRigCamera
  39474. */
  39475. createRigCamera(name: string, cameraIndex: number): Camera;
  39476. /**
  39477. * @hidden
  39478. * @override
  39479. * Override Camera._updateRigCameras
  39480. */
  39481. _updateRigCameras(): void;
  39482. /**
  39483. * Destroy the camera and release the current resources hold by it.
  39484. */
  39485. dispose(): void;
  39486. /**
  39487. * Gets the current object class name.
  39488. * @return the class name
  39489. */
  39490. getClassName(): string;
  39491. }
  39492. }
  39493. declare module BABYLON {
  39494. /**
  39495. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39496. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39497. */
  39498. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39499. /**
  39500. * Gets the name of the behavior.
  39501. */
  39502. get name(): string;
  39503. private _zoomStopsAnimation;
  39504. private _idleRotationSpeed;
  39505. private _idleRotationWaitTime;
  39506. private _idleRotationSpinupTime;
  39507. /**
  39508. * Sets the flag that indicates if user zooming should stop animation.
  39509. */
  39510. set zoomStopsAnimation(flag: boolean);
  39511. /**
  39512. * Gets the flag that indicates if user zooming should stop animation.
  39513. */
  39514. get zoomStopsAnimation(): boolean;
  39515. /**
  39516. * Sets the default speed at which the camera rotates around the model.
  39517. */
  39518. set idleRotationSpeed(speed: number);
  39519. /**
  39520. * Gets the default speed at which the camera rotates around the model.
  39521. */
  39522. get idleRotationSpeed(): number;
  39523. /**
  39524. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39525. */
  39526. set idleRotationWaitTime(time: number);
  39527. /**
  39528. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39529. */
  39530. get idleRotationWaitTime(): number;
  39531. /**
  39532. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39533. */
  39534. set idleRotationSpinupTime(time: number);
  39535. /**
  39536. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39537. */
  39538. get idleRotationSpinupTime(): number;
  39539. /**
  39540. * Gets a value indicating if the camera is currently rotating because of this behavior
  39541. */
  39542. get rotationInProgress(): boolean;
  39543. private _onPrePointerObservableObserver;
  39544. private _onAfterCheckInputsObserver;
  39545. private _attachedCamera;
  39546. private _isPointerDown;
  39547. private _lastFrameTime;
  39548. private _lastInteractionTime;
  39549. private _cameraRotationSpeed;
  39550. /**
  39551. * Initializes the behavior.
  39552. */
  39553. init(): void;
  39554. /**
  39555. * Attaches the behavior to its arc rotate camera.
  39556. * @param camera Defines the camera to attach the behavior to
  39557. */
  39558. attach(camera: ArcRotateCamera): void;
  39559. /**
  39560. * Detaches the behavior from its current arc rotate camera.
  39561. */
  39562. detach(): void;
  39563. /**
  39564. * Returns true if user is scrolling.
  39565. * @return true if user is scrolling.
  39566. */
  39567. private _userIsZooming;
  39568. private _lastFrameRadius;
  39569. private _shouldAnimationStopForInteraction;
  39570. /**
  39571. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39572. */
  39573. private _applyUserInteraction;
  39574. private _userIsMoving;
  39575. }
  39576. }
  39577. declare module BABYLON {
  39578. /**
  39579. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39580. */
  39581. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39582. private ui;
  39583. /**
  39584. * The name of the behavior
  39585. */
  39586. name: string;
  39587. /**
  39588. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39589. */
  39590. distanceAwayFromFace: number;
  39591. /**
  39592. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39593. */
  39594. distanceAwayFromBottomOfFace: number;
  39595. private _faceVectors;
  39596. private _target;
  39597. private _scene;
  39598. private _onRenderObserver;
  39599. private _tmpMatrix;
  39600. private _tmpVector;
  39601. /**
  39602. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39603. * @param ui The transform node that should be attched to the mesh
  39604. */
  39605. constructor(ui: TransformNode);
  39606. /**
  39607. * Initializes the behavior
  39608. */
  39609. init(): void;
  39610. private _closestFace;
  39611. private _zeroVector;
  39612. private _lookAtTmpMatrix;
  39613. private _lookAtToRef;
  39614. /**
  39615. * Attaches the AttachToBoxBehavior to the passed in mesh
  39616. * @param target The mesh that the specified node will be attached to
  39617. */
  39618. attach(target: Mesh): void;
  39619. /**
  39620. * Detaches the behavior from the mesh
  39621. */
  39622. detach(): void;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39628. */
  39629. export class FadeInOutBehavior implements Behavior<Mesh> {
  39630. /**
  39631. * Time in milliseconds to delay before fading in (Default: 0)
  39632. */
  39633. delay: number;
  39634. /**
  39635. * Time in milliseconds for the mesh to fade in (Default: 300)
  39636. */
  39637. fadeInTime: number;
  39638. private _millisecondsPerFrame;
  39639. private _hovered;
  39640. private _hoverValue;
  39641. private _ownerNode;
  39642. /**
  39643. * Instatiates the FadeInOutBehavior
  39644. */
  39645. constructor();
  39646. /**
  39647. * The name of the behavior
  39648. */
  39649. get name(): string;
  39650. /**
  39651. * Initializes the behavior
  39652. */
  39653. init(): void;
  39654. /**
  39655. * Attaches the fade behavior on the passed in mesh
  39656. * @param ownerNode The mesh that will be faded in/out once attached
  39657. */
  39658. attach(ownerNode: Mesh): void;
  39659. /**
  39660. * Detaches the behavior from the mesh
  39661. */
  39662. detach(): void;
  39663. /**
  39664. * Triggers the mesh to begin fading in or out
  39665. * @param value if the object should fade in or out (true to fade in)
  39666. */
  39667. fadeIn(value: boolean): void;
  39668. private _update;
  39669. private _setAllVisibility;
  39670. }
  39671. }
  39672. declare module BABYLON {
  39673. /**
  39674. * Class containing a set of static utilities functions for managing Pivots
  39675. * @hidden
  39676. */
  39677. export class PivotTools {
  39678. private static _PivotCached;
  39679. private static _OldPivotPoint;
  39680. private static _PivotTranslation;
  39681. private static _PivotTmpVector;
  39682. /** @hidden */
  39683. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39684. /** @hidden */
  39685. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39686. }
  39687. }
  39688. declare module BABYLON {
  39689. /**
  39690. * Class containing static functions to help procedurally build meshes
  39691. */
  39692. export class PlaneBuilder {
  39693. /**
  39694. * Creates a plane mesh
  39695. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39696. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39697. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39699. * * 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
  39700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39701. * @param name defines the name of the mesh
  39702. * @param options defines the options used to create the mesh
  39703. * @param scene defines the hosting scene
  39704. * @returns the plane mesh
  39705. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39706. */
  39707. static CreatePlane(name: string, options: {
  39708. size?: number;
  39709. width?: number;
  39710. height?: number;
  39711. sideOrientation?: number;
  39712. frontUVs?: Vector4;
  39713. backUVs?: Vector4;
  39714. updatable?: boolean;
  39715. sourcePlane?: Plane;
  39716. }, scene?: Nullable<Scene>): Mesh;
  39717. }
  39718. }
  39719. declare module BABYLON {
  39720. /**
  39721. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39722. */
  39723. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39724. private static _AnyMouseID;
  39725. /**
  39726. * Abstract mesh the behavior is set on
  39727. */
  39728. attachedNode: AbstractMesh;
  39729. private _dragPlane;
  39730. private _scene;
  39731. private _pointerObserver;
  39732. private _beforeRenderObserver;
  39733. private static _planeScene;
  39734. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39735. /**
  39736. * 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)
  39737. */
  39738. maxDragAngle: number;
  39739. /**
  39740. * @hidden
  39741. */
  39742. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39743. /**
  39744. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39745. */
  39746. currentDraggingPointerID: number;
  39747. /**
  39748. * The last position where the pointer hit the drag plane in world space
  39749. */
  39750. lastDragPosition: Vector3;
  39751. /**
  39752. * If the behavior is currently in a dragging state
  39753. */
  39754. dragging: boolean;
  39755. /**
  39756. * 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)
  39757. */
  39758. dragDeltaRatio: number;
  39759. /**
  39760. * If the drag plane orientation should be updated during the dragging (Default: true)
  39761. */
  39762. updateDragPlane: boolean;
  39763. private _debugMode;
  39764. private _moving;
  39765. /**
  39766. * Fires each time the attached mesh is dragged with the pointer
  39767. * * delta between last drag position and current drag position in world space
  39768. * * dragDistance along the drag axis
  39769. * * dragPlaneNormal normal of the current drag plane used during the drag
  39770. * * dragPlanePoint in world space where the drag intersects the drag plane
  39771. */
  39772. onDragObservable: Observable<{
  39773. delta: Vector3;
  39774. dragPlanePoint: Vector3;
  39775. dragPlaneNormal: Vector3;
  39776. dragDistance: number;
  39777. pointerId: number;
  39778. }>;
  39779. /**
  39780. * Fires each time a drag begins (eg. mouse down on mesh)
  39781. */
  39782. onDragStartObservable: Observable<{
  39783. dragPlanePoint: Vector3;
  39784. pointerId: number;
  39785. }>;
  39786. /**
  39787. * Fires each time a drag ends (eg. mouse release after drag)
  39788. */
  39789. onDragEndObservable: Observable<{
  39790. dragPlanePoint: Vector3;
  39791. pointerId: number;
  39792. }>;
  39793. /**
  39794. * If the attached mesh should be moved when dragged
  39795. */
  39796. moveAttached: boolean;
  39797. /**
  39798. * If the drag behavior will react to drag events (Default: true)
  39799. */
  39800. enabled: boolean;
  39801. /**
  39802. * If pointer events should start and release the drag (Default: true)
  39803. */
  39804. startAndReleaseDragOnPointerEvents: boolean;
  39805. /**
  39806. * If camera controls should be detached during the drag
  39807. */
  39808. detachCameraControls: boolean;
  39809. /**
  39810. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39811. */
  39812. useObjectOrientationForDragging: boolean;
  39813. private _options;
  39814. /**
  39815. * Gets the options used by the behavior
  39816. */
  39817. get options(): {
  39818. dragAxis?: Vector3;
  39819. dragPlaneNormal?: Vector3;
  39820. };
  39821. /**
  39822. * Sets the options used by the behavior
  39823. */
  39824. set options(options: {
  39825. dragAxis?: Vector3;
  39826. dragPlaneNormal?: Vector3;
  39827. });
  39828. /**
  39829. * Creates a pointer drag behavior that can be attached to a mesh
  39830. * @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)
  39831. */
  39832. constructor(options?: {
  39833. dragAxis?: Vector3;
  39834. dragPlaneNormal?: Vector3;
  39835. });
  39836. /**
  39837. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39838. */
  39839. validateDrag: (targetPosition: Vector3) => boolean;
  39840. /**
  39841. * The name of the behavior
  39842. */
  39843. get name(): string;
  39844. /**
  39845. * Initializes the behavior
  39846. */
  39847. init(): void;
  39848. private _tmpVector;
  39849. private _alternatePickedPoint;
  39850. private _worldDragAxis;
  39851. private _targetPosition;
  39852. private _attachedElement;
  39853. /**
  39854. * Attaches the drag behavior the passed in mesh
  39855. * @param ownerNode The mesh that will be dragged around once attached
  39856. * @param predicate Predicate to use for pick filtering
  39857. */
  39858. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39859. /**
  39860. * Force relase the drag action by code.
  39861. */
  39862. releaseDrag(): void;
  39863. private _startDragRay;
  39864. private _lastPointerRay;
  39865. /**
  39866. * Simulates the start of a pointer drag event on the behavior
  39867. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39868. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39869. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39870. */
  39871. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39872. private _startDrag;
  39873. private _dragDelta;
  39874. private _moveDrag;
  39875. private _pickWithRayOnDragPlane;
  39876. private _pointA;
  39877. private _pointB;
  39878. private _pointC;
  39879. private _lineA;
  39880. private _lineB;
  39881. private _localAxis;
  39882. private _lookAt;
  39883. private _updateDragPlanePosition;
  39884. /**
  39885. * Detaches the behavior from the mesh
  39886. */
  39887. detach(): void;
  39888. }
  39889. }
  39890. declare module BABYLON {
  39891. /**
  39892. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39893. */
  39894. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39895. private _dragBehaviorA;
  39896. private _dragBehaviorB;
  39897. private _startDistance;
  39898. private _initialScale;
  39899. private _targetScale;
  39900. private _ownerNode;
  39901. private _sceneRenderObserver;
  39902. /**
  39903. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39904. */
  39905. constructor();
  39906. /**
  39907. * The name of the behavior
  39908. */
  39909. get name(): string;
  39910. /**
  39911. * Initializes the behavior
  39912. */
  39913. init(): void;
  39914. private _getCurrentDistance;
  39915. /**
  39916. * Attaches the scale behavior the passed in mesh
  39917. * @param ownerNode The mesh that will be scaled around once attached
  39918. */
  39919. attach(ownerNode: Mesh): void;
  39920. /**
  39921. * Detaches the behavior from the mesh
  39922. */
  39923. detach(): void;
  39924. }
  39925. }
  39926. declare module BABYLON {
  39927. /**
  39928. * 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
  39929. */
  39930. export class SixDofDragBehavior implements Behavior<Mesh> {
  39931. private static _virtualScene;
  39932. private _ownerNode;
  39933. private _sceneRenderObserver;
  39934. private _scene;
  39935. private _targetPosition;
  39936. private _virtualOriginMesh;
  39937. private _virtualDragMesh;
  39938. private _pointerObserver;
  39939. private _moving;
  39940. private _startingOrientation;
  39941. private _attachedElement;
  39942. /**
  39943. * 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)
  39944. */
  39945. private zDragFactor;
  39946. /**
  39947. * If the object should rotate to face the drag origin
  39948. */
  39949. rotateDraggedObject: boolean;
  39950. /**
  39951. * If the behavior is currently in a dragging state
  39952. */
  39953. dragging: boolean;
  39954. /**
  39955. * 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)
  39956. */
  39957. dragDeltaRatio: number;
  39958. /**
  39959. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39960. */
  39961. currentDraggingPointerID: number;
  39962. /**
  39963. * If camera controls should be detached during the drag
  39964. */
  39965. detachCameraControls: boolean;
  39966. /**
  39967. * Fires each time a drag starts
  39968. */
  39969. onDragStartObservable: Observable<{}>;
  39970. /**
  39971. * Fires each time a drag ends (eg. mouse release after drag)
  39972. */
  39973. onDragEndObservable: Observable<{}>;
  39974. /**
  39975. * 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
  39976. */
  39977. constructor();
  39978. /**
  39979. * The name of the behavior
  39980. */
  39981. get name(): string;
  39982. /**
  39983. * Initializes the behavior
  39984. */
  39985. init(): void;
  39986. /**
  39987. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39988. */
  39989. private get _pointerCamera();
  39990. /**
  39991. * Attaches the scale behavior the passed in mesh
  39992. * @param ownerNode The mesh that will be scaled around once attached
  39993. */
  39994. attach(ownerNode: Mesh): void;
  39995. /**
  39996. * Detaches the behavior from the mesh
  39997. */
  39998. detach(): void;
  39999. }
  40000. }
  40001. declare module BABYLON {
  40002. /**
  40003. * Class used to apply inverse kinematics to bones
  40004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40005. */
  40006. export class BoneIKController {
  40007. private static _tmpVecs;
  40008. private static _tmpQuat;
  40009. private static _tmpMats;
  40010. /**
  40011. * Gets or sets the target mesh
  40012. */
  40013. targetMesh: AbstractMesh;
  40014. /** Gets or sets the mesh used as pole */
  40015. poleTargetMesh: AbstractMesh;
  40016. /**
  40017. * Gets or sets the bone used as pole
  40018. */
  40019. poleTargetBone: Nullable<Bone>;
  40020. /**
  40021. * Gets or sets the target position
  40022. */
  40023. targetPosition: Vector3;
  40024. /**
  40025. * Gets or sets the pole target position
  40026. */
  40027. poleTargetPosition: Vector3;
  40028. /**
  40029. * Gets or sets the pole target local offset
  40030. */
  40031. poleTargetLocalOffset: Vector3;
  40032. /**
  40033. * Gets or sets the pole angle
  40034. */
  40035. poleAngle: number;
  40036. /**
  40037. * Gets or sets the mesh associated with the controller
  40038. */
  40039. mesh: AbstractMesh;
  40040. /**
  40041. * 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)
  40042. */
  40043. slerpAmount: number;
  40044. private _bone1Quat;
  40045. private _bone1Mat;
  40046. private _bone2Ang;
  40047. private _bone1;
  40048. private _bone2;
  40049. private _bone1Length;
  40050. private _bone2Length;
  40051. private _maxAngle;
  40052. private _maxReach;
  40053. private _rightHandedSystem;
  40054. private _bendAxis;
  40055. private _slerping;
  40056. private _adjustRoll;
  40057. /**
  40058. * Gets or sets maximum allowed angle
  40059. */
  40060. get maxAngle(): number;
  40061. set maxAngle(value: number);
  40062. /**
  40063. * Creates a new BoneIKController
  40064. * @param mesh defines the mesh to control
  40065. * @param bone defines the bone to control
  40066. * @param options defines options to set up the controller
  40067. */
  40068. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40069. targetMesh?: AbstractMesh;
  40070. poleTargetMesh?: AbstractMesh;
  40071. poleTargetBone?: Bone;
  40072. poleTargetLocalOffset?: Vector3;
  40073. poleAngle?: number;
  40074. bendAxis?: Vector3;
  40075. maxAngle?: number;
  40076. slerpAmount?: number;
  40077. });
  40078. private _setMaxAngle;
  40079. /**
  40080. * Force the controller to update the bones
  40081. */
  40082. update(): void;
  40083. }
  40084. }
  40085. declare module BABYLON {
  40086. /**
  40087. * Class used to make a bone look toward a point in space
  40088. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40089. */
  40090. export class BoneLookController {
  40091. private static _tmpVecs;
  40092. private static _tmpQuat;
  40093. private static _tmpMats;
  40094. /**
  40095. * The target Vector3 that the bone will look at
  40096. */
  40097. target: Vector3;
  40098. /**
  40099. * The mesh that the bone is attached to
  40100. */
  40101. mesh: AbstractMesh;
  40102. /**
  40103. * The bone that will be looking to the target
  40104. */
  40105. bone: Bone;
  40106. /**
  40107. * The up axis of the coordinate system that is used when the bone is rotated
  40108. */
  40109. upAxis: Vector3;
  40110. /**
  40111. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40112. */
  40113. upAxisSpace: Space;
  40114. /**
  40115. * Used to make an adjustment to the yaw of the bone
  40116. */
  40117. adjustYaw: number;
  40118. /**
  40119. * Used to make an adjustment to the pitch of the bone
  40120. */
  40121. adjustPitch: number;
  40122. /**
  40123. * Used to make an adjustment to the roll of the bone
  40124. */
  40125. adjustRoll: number;
  40126. /**
  40127. * 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)
  40128. */
  40129. slerpAmount: number;
  40130. private _minYaw;
  40131. private _maxYaw;
  40132. private _minPitch;
  40133. private _maxPitch;
  40134. private _minYawSin;
  40135. private _minYawCos;
  40136. private _maxYawSin;
  40137. private _maxYawCos;
  40138. private _midYawConstraint;
  40139. private _minPitchTan;
  40140. private _maxPitchTan;
  40141. private _boneQuat;
  40142. private _slerping;
  40143. private _transformYawPitch;
  40144. private _transformYawPitchInv;
  40145. private _firstFrameSkipped;
  40146. private _yawRange;
  40147. private _fowardAxis;
  40148. /**
  40149. * Gets or sets the minimum yaw angle that the bone can look to
  40150. */
  40151. get minYaw(): number;
  40152. set minYaw(value: number);
  40153. /**
  40154. * Gets or sets the maximum yaw angle that the bone can look to
  40155. */
  40156. get maxYaw(): number;
  40157. set maxYaw(value: number);
  40158. /**
  40159. * Gets or sets the minimum pitch angle that the bone can look to
  40160. */
  40161. get minPitch(): number;
  40162. set minPitch(value: number);
  40163. /**
  40164. * Gets or sets the maximum pitch angle that the bone can look to
  40165. */
  40166. get maxPitch(): number;
  40167. set maxPitch(value: number);
  40168. /**
  40169. * Create a BoneLookController
  40170. * @param mesh the mesh that the bone belongs to
  40171. * @param bone the bone that will be looking to the target
  40172. * @param target the target Vector3 to look at
  40173. * @param options optional settings:
  40174. * * maxYaw: the maximum angle the bone will yaw to
  40175. * * minYaw: the minimum angle the bone will yaw to
  40176. * * maxPitch: the maximum angle the bone will pitch to
  40177. * * minPitch: the minimum angle the bone will yaw to
  40178. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40179. * * upAxis: the up axis of the coordinate system
  40180. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40181. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40182. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40183. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40184. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40185. * * adjustRoll: used to make an adjustment to the roll of the bone
  40186. **/
  40187. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40188. maxYaw?: number;
  40189. minYaw?: number;
  40190. maxPitch?: number;
  40191. minPitch?: number;
  40192. slerpAmount?: number;
  40193. upAxis?: Vector3;
  40194. upAxisSpace?: Space;
  40195. yawAxis?: Vector3;
  40196. pitchAxis?: Vector3;
  40197. adjustYaw?: number;
  40198. adjustPitch?: number;
  40199. adjustRoll?: number;
  40200. });
  40201. /**
  40202. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40203. */
  40204. update(): void;
  40205. private _getAngleDiff;
  40206. private _getAngleBetween;
  40207. private _isAngleBetween;
  40208. }
  40209. }
  40210. declare module BABYLON {
  40211. /**
  40212. * Manage the gamepad inputs to control an arc rotate camera.
  40213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40214. */
  40215. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40216. /**
  40217. * Defines the camera the input is attached to.
  40218. */
  40219. camera: ArcRotateCamera;
  40220. /**
  40221. * Defines the gamepad the input is gathering event from.
  40222. */
  40223. gamepad: Nullable<Gamepad>;
  40224. /**
  40225. * Defines the gamepad rotation sensiblity.
  40226. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40227. */
  40228. gamepadRotationSensibility: number;
  40229. /**
  40230. * Defines the gamepad move sensiblity.
  40231. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40232. */
  40233. gamepadMoveSensibility: number;
  40234. private _yAxisScale;
  40235. /**
  40236. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40237. */
  40238. get invertYAxis(): boolean;
  40239. set invertYAxis(value: boolean);
  40240. private _onGamepadConnectedObserver;
  40241. private _onGamepadDisconnectedObserver;
  40242. /**
  40243. * Attach the input controls to a specific dom element to get the input from.
  40244. * @param element Defines the element the controls should be listened from
  40245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40246. */
  40247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40248. /**
  40249. * Detach the current controls from the specified dom element.
  40250. * @param element Defines the element to stop listening the inputs from
  40251. */
  40252. detachControl(element: Nullable<HTMLElement>): void;
  40253. /**
  40254. * Update the current camera state depending on the inputs that have been used this frame.
  40255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40256. */
  40257. checkInputs(): void;
  40258. /**
  40259. * Gets the class name of the current intput.
  40260. * @returns the class name
  40261. */
  40262. getClassName(): string;
  40263. /**
  40264. * Get the friendly name associated with the input class.
  40265. * @returns the input friendly name
  40266. */
  40267. getSimpleName(): string;
  40268. }
  40269. }
  40270. declare module BABYLON {
  40271. interface ArcRotateCameraInputsManager {
  40272. /**
  40273. * Add orientation input support to the input manager.
  40274. * @returns the current input manager
  40275. */
  40276. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40277. }
  40278. /**
  40279. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40281. */
  40282. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40283. /**
  40284. * Defines the camera the input is attached to.
  40285. */
  40286. camera: ArcRotateCamera;
  40287. /**
  40288. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40289. */
  40290. alphaCorrection: number;
  40291. /**
  40292. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40293. */
  40294. gammaCorrection: number;
  40295. private _alpha;
  40296. private _gamma;
  40297. private _dirty;
  40298. private _deviceOrientationHandler;
  40299. /**
  40300. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40301. */
  40302. constructor();
  40303. /**
  40304. * Attach the input controls to a specific dom element to get the input from.
  40305. * @param element Defines the element the controls should be listened from
  40306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40307. */
  40308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40309. /** @hidden */
  40310. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40311. /**
  40312. * Update the current camera state depending on the inputs that have been used this frame.
  40313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40314. */
  40315. checkInputs(): void;
  40316. /**
  40317. * Detach the current controls from the specified dom element.
  40318. * @param element Defines the element to stop listening the inputs from
  40319. */
  40320. detachControl(element: Nullable<HTMLElement>): void;
  40321. /**
  40322. * Gets the class name of the current intput.
  40323. * @returns the class name
  40324. */
  40325. getClassName(): string;
  40326. /**
  40327. * Get the friendly name associated with the input class.
  40328. * @returns the input friendly name
  40329. */
  40330. getSimpleName(): string;
  40331. }
  40332. }
  40333. declare module BABYLON {
  40334. /**
  40335. * Listen to mouse events to control the camera.
  40336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40337. */
  40338. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40339. /**
  40340. * Defines the camera the input is attached to.
  40341. */
  40342. camera: FlyCamera;
  40343. /**
  40344. * Defines if touch is enabled. (Default is true.)
  40345. */
  40346. touchEnabled: boolean;
  40347. /**
  40348. * Defines the buttons associated with the input to handle camera rotation.
  40349. */
  40350. buttons: number[];
  40351. /**
  40352. * Assign buttons for Yaw control.
  40353. */
  40354. buttonsYaw: number[];
  40355. /**
  40356. * Assign buttons for Pitch control.
  40357. */
  40358. buttonsPitch: number[];
  40359. /**
  40360. * Assign buttons for Roll control.
  40361. */
  40362. buttonsRoll: number[];
  40363. /**
  40364. * Detect if any button is being pressed while mouse is moved.
  40365. * -1 = Mouse locked.
  40366. * 0 = Left button.
  40367. * 1 = Middle Button.
  40368. * 2 = Right Button.
  40369. */
  40370. activeButton: number;
  40371. /**
  40372. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40373. * Higher values reduce its sensitivity.
  40374. */
  40375. angularSensibility: number;
  40376. private _mousemoveCallback;
  40377. private _observer;
  40378. private _rollObserver;
  40379. private previousPosition;
  40380. private noPreventDefault;
  40381. private element;
  40382. /**
  40383. * Listen to mouse events to control the camera.
  40384. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40386. */
  40387. constructor(touchEnabled?: boolean);
  40388. /**
  40389. * Attach the mouse control to the HTML DOM element.
  40390. * @param element Defines the element that listens to the input events.
  40391. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40392. */
  40393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40394. /**
  40395. * Detach the current controls from the specified dom element.
  40396. * @param element Defines the element to stop listening the inputs from
  40397. */
  40398. detachControl(element: Nullable<HTMLElement>): void;
  40399. /**
  40400. * Gets the class name of the current input.
  40401. * @returns the class name.
  40402. */
  40403. getClassName(): string;
  40404. /**
  40405. * Get the friendly name associated with the input class.
  40406. * @returns the input's friendly name.
  40407. */
  40408. getSimpleName(): string;
  40409. private _pointerInput;
  40410. private _onMouseMove;
  40411. /**
  40412. * Rotate camera by mouse offset.
  40413. */
  40414. private rotateCamera;
  40415. }
  40416. }
  40417. declare module BABYLON {
  40418. /**
  40419. * Default Inputs manager for the FlyCamera.
  40420. * It groups all the default supported inputs for ease of use.
  40421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40422. */
  40423. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40424. /**
  40425. * Instantiates a new FlyCameraInputsManager.
  40426. * @param camera Defines the camera the inputs belong to.
  40427. */
  40428. constructor(camera: FlyCamera);
  40429. /**
  40430. * Add keyboard input support to the input manager.
  40431. * @returns the new FlyCameraKeyboardMoveInput().
  40432. */
  40433. addKeyboard(): FlyCameraInputsManager;
  40434. /**
  40435. * Add mouse input support to the input manager.
  40436. * @param touchEnabled Enable touch screen support.
  40437. * @returns the new FlyCameraMouseInput().
  40438. */
  40439. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40440. }
  40441. }
  40442. declare module BABYLON {
  40443. /**
  40444. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40445. * such as in a 3D Space Shooter or a Flight Simulator.
  40446. */
  40447. export class FlyCamera extends TargetCamera {
  40448. /**
  40449. * Define the collision ellipsoid of the camera.
  40450. * This is helpful for simulating a camera body, like a player's body.
  40451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40452. */
  40453. ellipsoid: Vector3;
  40454. /**
  40455. * Define an offset for the position of the ellipsoid around the camera.
  40456. * This can be helpful if the camera is attached away from the player's body center,
  40457. * such as at its head.
  40458. */
  40459. ellipsoidOffset: Vector3;
  40460. /**
  40461. * Enable or disable collisions of the camera with the rest of the scene objects.
  40462. */
  40463. checkCollisions: boolean;
  40464. /**
  40465. * Enable or disable gravity on the camera.
  40466. */
  40467. applyGravity: boolean;
  40468. /**
  40469. * Define the current direction the camera is moving to.
  40470. */
  40471. cameraDirection: Vector3;
  40472. /**
  40473. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40474. * This overrides and empties cameraRotation.
  40475. */
  40476. rotationQuaternion: Quaternion;
  40477. /**
  40478. * Track Roll to maintain the wanted Rolling when looking around.
  40479. */
  40480. _trackRoll: number;
  40481. /**
  40482. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40483. */
  40484. rollCorrect: number;
  40485. /**
  40486. * Mimic a banked turn, Rolling the camera when Yawing.
  40487. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40488. */
  40489. bankedTurn: boolean;
  40490. /**
  40491. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40492. */
  40493. bankedTurnLimit: number;
  40494. /**
  40495. * Value of 0 disables the banked Roll.
  40496. * Value of 1 is equal to the Yaw angle in radians.
  40497. */
  40498. bankedTurnMultiplier: number;
  40499. /**
  40500. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40501. */
  40502. inputs: FlyCameraInputsManager;
  40503. /**
  40504. * Gets the input sensibility for mouse input.
  40505. * Higher values reduce sensitivity.
  40506. */
  40507. get angularSensibility(): number;
  40508. /**
  40509. * Sets the input sensibility for a mouse input.
  40510. * Higher values reduce sensitivity.
  40511. */
  40512. set angularSensibility(value: number);
  40513. /**
  40514. * Get the keys for camera movement forward.
  40515. */
  40516. get keysForward(): number[];
  40517. /**
  40518. * Set the keys for camera movement forward.
  40519. */
  40520. set keysForward(value: number[]);
  40521. /**
  40522. * Get the keys for camera movement backward.
  40523. */
  40524. get keysBackward(): number[];
  40525. set keysBackward(value: number[]);
  40526. /**
  40527. * Get the keys for camera movement up.
  40528. */
  40529. get keysUp(): number[];
  40530. /**
  40531. * Set the keys for camera movement up.
  40532. */
  40533. set keysUp(value: number[]);
  40534. /**
  40535. * Get the keys for camera movement down.
  40536. */
  40537. get keysDown(): number[];
  40538. /**
  40539. * Set the keys for camera movement down.
  40540. */
  40541. set keysDown(value: number[]);
  40542. /**
  40543. * Get the keys for camera movement left.
  40544. */
  40545. get keysLeft(): number[];
  40546. /**
  40547. * Set the keys for camera movement left.
  40548. */
  40549. set keysLeft(value: number[]);
  40550. /**
  40551. * Set the keys for camera movement right.
  40552. */
  40553. get keysRight(): number[];
  40554. /**
  40555. * Set the keys for camera movement right.
  40556. */
  40557. set keysRight(value: number[]);
  40558. /**
  40559. * Event raised when the camera collides with a mesh in the scene.
  40560. */
  40561. onCollide: (collidedMesh: AbstractMesh) => void;
  40562. private _collider;
  40563. private _needMoveForGravity;
  40564. private _oldPosition;
  40565. private _diffPosition;
  40566. private _newPosition;
  40567. /** @hidden */
  40568. _localDirection: Vector3;
  40569. /** @hidden */
  40570. _transformedDirection: Vector3;
  40571. /**
  40572. * Instantiates a FlyCamera.
  40573. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40574. * such as in a 3D Space Shooter or a Flight Simulator.
  40575. * @param name Define the name of the camera in the scene.
  40576. * @param position Define the starting position of the camera in the scene.
  40577. * @param scene Define the scene the camera belongs to.
  40578. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40579. */
  40580. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40581. /**
  40582. * Attach a control to the HTML DOM element.
  40583. * @param element Defines the element that listens to the input events.
  40584. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40585. */
  40586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40587. /**
  40588. * Detach a control from the HTML DOM element.
  40589. * The camera will stop reacting to that input.
  40590. * @param element Defines the element that listens to the input events.
  40591. */
  40592. detachControl(element: HTMLElement): void;
  40593. private _collisionMask;
  40594. /**
  40595. * Get the mask that the camera ignores in collision events.
  40596. */
  40597. get collisionMask(): number;
  40598. /**
  40599. * Set the mask that the camera ignores in collision events.
  40600. */
  40601. set collisionMask(mask: number);
  40602. /** @hidden */
  40603. _collideWithWorld(displacement: Vector3): void;
  40604. /** @hidden */
  40605. private _onCollisionPositionChange;
  40606. /** @hidden */
  40607. _checkInputs(): void;
  40608. /** @hidden */
  40609. _decideIfNeedsToMove(): boolean;
  40610. /** @hidden */
  40611. _updatePosition(): void;
  40612. /**
  40613. * Restore the Roll to its target value at the rate specified.
  40614. * @param rate - Higher means slower restoring.
  40615. * @hidden
  40616. */
  40617. restoreRoll(rate: number): void;
  40618. /**
  40619. * Destroy the camera and release the current resources held by it.
  40620. */
  40621. dispose(): void;
  40622. /**
  40623. * Get the current object class name.
  40624. * @returns the class name.
  40625. */
  40626. getClassName(): string;
  40627. }
  40628. }
  40629. declare module BABYLON {
  40630. /**
  40631. * Listen to keyboard events to control the camera.
  40632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40633. */
  40634. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40635. /**
  40636. * Defines the camera the input is attached to.
  40637. */
  40638. camera: FlyCamera;
  40639. /**
  40640. * The list of keyboard keys used to control the forward move of the camera.
  40641. */
  40642. keysForward: number[];
  40643. /**
  40644. * The list of keyboard keys used to control the backward move of the camera.
  40645. */
  40646. keysBackward: number[];
  40647. /**
  40648. * The list of keyboard keys used to control the forward move of the camera.
  40649. */
  40650. keysUp: number[];
  40651. /**
  40652. * The list of keyboard keys used to control the backward move of the camera.
  40653. */
  40654. keysDown: number[];
  40655. /**
  40656. * The list of keyboard keys used to control the right strafe move of the camera.
  40657. */
  40658. keysRight: number[];
  40659. /**
  40660. * The list of keyboard keys used to control the left strafe move of the camera.
  40661. */
  40662. keysLeft: number[];
  40663. private _keys;
  40664. private _onCanvasBlurObserver;
  40665. private _onKeyboardObserver;
  40666. private _engine;
  40667. private _scene;
  40668. /**
  40669. * Attach the input controls to a specific dom element to get the input from.
  40670. * @param element Defines the element the controls should be listened from
  40671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40672. */
  40673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40674. /**
  40675. * Detach the current controls from the specified dom element.
  40676. * @param element Defines the element to stop listening the inputs from
  40677. */
  40678. detachControl(element: Nullable<HTMLElement>): void;
  40679. /**
  40680. * Gets the class name of the current intput.
  40681. * @returns the class name
  40682. */
  40683. getClassName(): string;
  40684. /** @hidden */
  40685. _onLostFocus(e: FocusEvent): void;
  40686. /**
  40687. * Get the friendly name associated with the input class.
  40688. * @returns the input friendly name
  40689. */
  40690. getSimpleName(): string;
  40691. /**
  40692. * Update the current camera state depending on the inputs that have been used this frame.
  40693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40694. */
  40695. checkInputs(): void;
  40696. }
  40697. }
  40698. declare module BABYLON {
  40699. /**
  40700. * Manage the mouse wheel inputs to control a follow camera.
  40701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40702. */
  40703. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40704. /**
  40705. * Defines the camera the input is attached to.
  40706. */
  40707. camera: FollowCamera;
  40708. /**
  40709. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40710. */
  40711. axisControlRadius: boolean;
  40712. /**
  40713. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40714. */
  40715. axisControlHeight: boolean;
  40716. /**
  40717. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40718. */
  40719. axisControlRotation: boolean;
  40720. /**
  40721. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40722. * relation to mouseWheel events.
  40723. */
  40724. wheelPrecision: number;
  40725. /**
  40726. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40727. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40728. */
  40729. wheelDeltaPercentage: number;
  40730. private _wheel;
  40731. private _observer;
  40732. /**
  40733. * Attach the input controls to a specific dom element to get the input from.
  40734. * @param element Defines the element the controls should be listened from
  40735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40736. */
  40737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40738. /**
  40739. * Detach the current controls from the specified dom element.
  40740. * @param element Defines the element to stop listening the inputs from
  40741. */
  40742. detachControl(element: Nullable<HTMLElement>): void;
  40743. /**
  40744. * Gets the class name of the current intput.
  40745. * @returns the class name
  40746. */
  40747. getClassName(): string;
  40748. /**
  40749. * Get the friendly name associated with the input class.
  40750. * @returns the input friendly name
  40751. */
  40752. getSimpleName(): string;
  40753. }
  40754. }
  40755. declare module BABYLON {
  40756. /**
  40757. * Manage the pointers inputs to control an follow camera.
  40758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40759. */
  40760. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40761. /**
  40762. * Defines the camera the input is attached to.
  40763. */
  40764. camera: FollowCamera;
  40765. /**
  40766. * Gets the class name of the current input.
  40767. * @returns the class name
  40768. */
  40769. getClassName(): string;
  40770. /**
  40771. * Defines the pointer angular sensibility along the X axis or how fast is
  40772. * the camera rotating.
  40773. * A negative number will reverse the axis direction.
  40774. */
  40775. angularSensibilityX: number;
  40776. /**
  40777. * Defines the pointer angular sensibility along the Y axis or how fast is
  40778. * the camera rotating.
  40779. * A negative number will reverse the axis direction.
  40780. */
  40781. angularSensibilityY: number;
  40782. /**
  40783. * Defines the pointer pinch precision or how fast is the camera zooming.
  40784. * A negative number will reverse the axis direction.
  40785. */
  40786. pinchPrecision: number;
  40787. /**
  40788. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40789. * from 0.
  40790. * It defines the percentage of current camera.radius to use as delta when
  40791. * pinch zoom is used.
  40792. */
  40793. pinchDeltaPercentage: number;
  40794. /**
  40795. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40796. */
  40797. axisXControlRadius: boolean;
  40798. /**
  40799. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40800. */
  40801. axisXControlHeight: boolean;
  40802. /**
  40803. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40804. */
  40805. axisXControlRotation: boolean;
  40806. /**
  40807. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40808. */
  40809. axisYControlRadius: boolean;
  40810. /**
  40811. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40812. */
  40813. axisYControlHeight: boolean;
  40814. /**
  40815. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40816. */
  40817. axisYControlRotation: boolean;
  40818. /**
  40819. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40820. */
  40821. axisPinchControlRadius: boolean;
  40822. /**
  40823. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40824. */
  40825. axisPinchControlHeight: boolean;
  40826. /**
  40827. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40828. */
  40829. axisPinchControlRotation: boolean;
  40830. /**
  40831. * Log error messages if basic misconfiguration has occurred.
  40832. */
  40833. warningEnable: boolean;
  40834. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40835. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40836. private _warningCounter;
  40837. private _warning;
  40838. }
  40839. }
  40840. declare module BABYLON {
  40841. /**
  40842. * Default Inputs manager for the FollowCamera.
  40843. * It groups all the default supported inputs for ease of use.
  40844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40845. */
  40846. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40847. /**
  40848. * Instantiates a new FollowCameraInputsManager.
  40849. * @param camera Defines the camera the inputs belong to
  40850. */
  40851. constructor(camera: FollowCamera);
  40852. /**
  40853. * Add keyboard input support to the input manager.
  40854. * @returns the current input manager
  40855. */
  40856. addKeyboard(): FollowCameraInputsManager;
  40857. /**
  40858. * Add mouse wheel input support to the input manager.
  40859. * @returns the current input manager
  40860. */
  40861. addMouseWheel(): FollowCameraInputsManager;
  40862. /**
  40863. * Add pointers input support to the input manager.
  40864. * @returns the current input manager
  40865. */
  40866. addPointers(): FollowCameraInputsManager;
  40867. /**
  40868. * Add orientation input support to the input manager.
  40869. * @returns the current input manager
  40870. */
  40871. addVRDeviceOrientation(): FollowCameraInputsManager;
  40872. }
  40873. }
  40874. declare module BABYLON {
  40875. /**
  40876. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40877. * an arc rotate version arcFollowCamera are available.
  40878. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40879. */
  40880. export class FollowCamera extends TargetCamera {
  40881. /**
  40882. * Distance the follow camera should follow an object at
  40883. */
  40884. radius: number;
  40885. /**
  40886. * Minimum allowed distance of the camera to the axis of rotation
  40887. * (The camera can not get closer).
  40888. * This can help limiting how the Camera is able to move in the scene.
  40889. */
  40890. lowerRadiusLimit: Nullable<number>;
  40891. /**
  40892. * Maximum allowed distance of the camera to the axis of rotation
  40893. * (The camera can not get further).
  40894. * This can help limiting how the Camera is able to move in the scene.
  40895. */
  40896. upperRadiusLimit: Nullable<number>;
  40897. /**
  40898. * Define a rotation offset between the camera and the object it follows
  40899. */
  40900. rotationOffset: number;
  40901. /**
  40902. * Minimum allowed angle to camera position relative to target object.
  40903. * This can help limiting how the Camera is able to move in the scene.
  40904. */
  40905. lowerRotationOffsetLimit: Nullable<number>;
  40906. /**
  40907. * Maximum allowed angle to camera position relative to target object.
  40908. * This can help limiting how the Camera is able to move in the scene.
  40909. */
  40910. upperRotationOffsetLimit: Nullable<number>;
  40911. /**
  40912. * Define a height offset between the camera and the object it follows.
  40913. * It can help following an object from the top (like a car chaing a plane)
  40914. */
  40915. heightOffset: number;
  40916. /**
  40917. * Minimum allowed height of camera position relative to target object.
  40918. * This can help limiting how the Camera is able to move in the scene.
  40919. */
  40920. lowerHeightOffsetLimit: Nullable<number>;
  40921. /**
  40922. * Maximum allowed height of camera position relative to target object.
  40923. * This can help limiting how the Camera is able to move in the scene.
  40924. */
  40925. upperHeightOffsetLimit: Nullable<number>;
  40926. /**
  40927. * Define how fast the camera can accelerate to follow it s target.
  40928. */
  40929. cameraAcceleration: number;
  40930. /**
  40931. * Define the speed limit of the camera following an object.
  40932. */
  40933. maxCameraSpeed: number;
  40934. /**
  40935. * Define the target of the camera.
  40936. */
  40937. lockedTarget: Nullable<AbstractMesh>;
  40938. /**
  40939. * Defines the input associated with the camera.
  40940. */
  40941. inputs: FollowCameraInputsManager;
  40942. /**
  40943. * Instantiates the follow camera.
  40944. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40945. * @param name Define the name of the camera in the scene
  40946. * @param position Define the position of the camera
  40947. * @param scene Define the scene the camera belong to
  40948. * @param lockedTarget Define the target of the camera
  40949. */
  40950. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40951. private _follow;
  40952. /**
  40953. * Attached controls to the current camera.
  40954. * @param element Defines the element the controls should be listened from
  40955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40956. */
  40957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40958. /**
  40959. * Detach the current controls from the camera.
  40960. * The camera will stop reacting to inputs.
  40961. * @param element Defines the element to stop listening the inputs from
  40962. */
  40963. detachControl(element: HTMLElement): void;
  40964. /** @hidden */
  40965. _checkInputs(): void;
  40966. private _checkLimits;
  40967. /**
  40968. * Gets the camera class name.
  40969. * @returns the class name
  40970. */
  40971. getClassName(): string;
  40972. }
  40973. /**
  40974. * Arc Rotate version of the follow camera.
  40975. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40976. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40977. */
  40978. export class ArcFollowCamera extends TargetCamera {
  40979. /** The longitudinal angle of the camera */
  40980. alpha: number;
  40981. /** The latitudinal angle of the camera */
  40982. beta: number;
  40983. /** The radius of the camera from its target */
  40984. radius: number;
  40985. /** Define the camera target (the messh it should follow) */
  40986. target: Nullable<AbstractMesh>;
  40987. private _cartesianCoordinates;
  40988. /**
  40989. * Instantiates a new ArcFollowCamera
  40990. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40991. * @param name Define the name of the camera
  40992. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40993. * @param beta Define the rotation angle of the camera around the elevation axis
  40994. * @param radius Define the radius of the camera from its target point
  40995. * @param target Define the target of the camera
  40996. * @param scene Define the scene the camera belongs to
  40997. */
  40998. constructor(name: string,
  40999. /** The longitudinal angle of the camera */
  41000. alpha: number,
  41001. /** The latitudinal angle of the camera */
  41002. beta: number,
  41003. /** The radius of the camera from its target */
  41004. radius: number,
  41005. /** Define the camera target (the messh it should follow) */
  41006. target: Nullable<AbstractMesh>, scene: Scene);
  41007. private _follow;
  41008. /** @hidden */
  41009. _checkInputs(): void;
  41010. /**
  41011. * Returns the class name of the object.
  41012. * It is mostly used internally for serialization purposes.
  41013. */
  41014. getClassName(): string;
  41015. }
  41016. }
  41017. declare module BABYLON {
  41018. /**
  41019. * Manage the keyboard inputs to control the movement of a follow camera.
  41020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41021. */
  41022. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41023. /**
  41024. * Defines the camera the input is attached to.
  41025. */
  41026. camera: FollowCamera;
  41027. /**
  41028. * Defines the list of key codes associated with the up action (increase heightOffset)
  41029. */
  41030. keysHeightOffsetIncr: number[];
  41031. /**
  41032. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41033. */
  41034. keysHeightOffsetDecr: number[];
  41035. /**
  41036. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41037. */
  41038. keysHeightOffsetModifierAlt: boolean;
  41039. /**
  41040. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41041. */
  41042. keysHeightOffsetModifierCtrl: boolean;
  41043. /**
  41044. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41045. */
  41046. keysHeightOffsetModifierShift: boolean;
  41047. /**
  41048. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41049. */
  41050. keysRotationOffsetIncr: number[];
  41051. /**
  41052. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41053. */
  41054. keysRotationOffsetDecr: number[];
  41055. /**
  41056. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41057. */
  41058. keysRotationOffsetModifierAlt: boolean;
  41059. /**
  41060. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41061. */
  41062. keysRotationOffsetModifierCtrl: boolean;
  41063. /**
  41064. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41065. */
  41066. keysRotationOffsetModifierShift: boolean;
  41067. /**
  41068. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41069. */
  41070. keysRadiusIncr: number[];
  41071. /**
  41072. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41073. */
  41074. keysRadiusDecr: number[];
  41075. /**
  41076. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41077. */
  41078. keysRadiusModifierAlt: boolean;
  41079. /**
  41080. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41081. */
  41082. keysRadiusModifierCtrl: boolean;
  41083. /**
  41084. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41085. */
  41086. keysRadiusModifierShift: boolean;
  41087. /**
  41088. * Defines the rate of change of heightOffset.
  41089. */
  41090. heightSensibility: number;
  41091. /**
  41092. * Defines the rate of change of rotationOffset.
  41093. */
  41094. rotationSensibility: number;
  41095. /**
  41096. * Defines the rate of change of radius.
  41097. */
  41098. radiusSensibility: number;
  41099. private _keys;
  41100. private _ctrlPressed;
  41101. private _altPressed;
  41102. private _shiftPressed;
  41103. private _onCanvasBlurObserver;
  41104. private _onKeyboardObserver;
  41105. private _engine;
  41106. private _scene;
  41107. /**
  41108. * Attach the input controls to a specific dom element to get the input from.
  41109. * @param element Defines the element the controls should be listened from
  41110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41111. */
  41112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41113. /**
  41114. * Detach the current controls from the specified dom element.
  41115. * @param element Defines the element to stop listening the inputs from
  41116. */
  41117. detachControl(element: Nullable<HTMLElement>): void;
  41118. /**
  41119. * Update the current camera state depending on the inputs that have been used this frame.
  41120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41121. */
  41122. checkInputs(): void;
  41123. /**
  41124. * Gets the class name of the current input.
  41125. * @returns the class name
  41126. */
  41127. getClassName(): string;
  41128. /**
  41129. * Get the friendly name associated with the input class.
  41130. * @returns the input friendly name
  41131. */
  41132. getSimpleName(): string;
  41133. /**
  41134. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41135. * allow modification of the heightOffset value.
  41136. */
  41137. private _modifierHeightOffset;
  41138. /**
  41139. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41140. * allow modification of the rotationOffset value.
  41141. */
  41142. private _modifierRotationOffset;
  41143. /**
  41144. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41145. * allow modification of the radius value.
  41146. */
  41147. private _modifierRadius;
  41148. }
  41149. }
  41150. declare module BABYLON {
  41151. interface FreeCameraInputsManager {
  41152. /**
  41153. * @hidden
  41154. */
  41155. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41156. /**
  41157. * Add orientation input support to the input manager.
  41158. * @returns the current input manager
  41159. */
  41160. addDeviceOrientation(): FreeCameraInputsManager;
  41161. }
  41162. /**
  41163. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41164. * Screen rotation is taken into account.
  41165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41166. */
  41167. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41168. private _camera;
  41169. private _screenOrientationAngle;
  41170. private _constantTranform;
  41171. private _screenQuaternion;
  41172. private _alpha;
  41173. private _beta;
  41174. private _gamma;
  41175. /**
  41176. * Can be used to detect if a device orientation sensor is available on a device
  41177. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41178. * @returns a promise that will resolve on orientation change
  41179. */
  41180. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41181. /**
  41182. * @hidden
  41183. */
  41184. _onDeviceOrientationChangedObservable: Observable<void>;
  41185. /**
  41186. * Instantiates a new input
  41187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41188. */
  41189. constructor();
  41190. /**
  41191. * Define the camera controlled by the input.
  41192. */
  41193. get camera(): FreeCamera;
  41194. set camera(camera: FreeCamera);
  41195. /**
  41196. * Attach the input controls to a specific dom element to get the input from.
  41197. * @param element Defines the element the controls should be listened from
  41198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41199. */
  41200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41201. private _orientationChanged;
  41202. private _deviceOrientation;
  41203. /**
  41204. * Detach the current controls from the specified dom element.
  41205. * @param element Defines the element to stop listening the inputs from
  41206. */
  41207. detachControl(element: Nullable<HTMLElement>): void;
  41208. /**
  41209. * Update the current camera state depending on the inputs that have been used this frame.
  41210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41211. */
  41212. checkInputs(): void;
  41213. /**
  41214. * Gets the class name of the current intput.
  41215. * @returns the class name
  41216. */
  41217. getClassName(): string;
  41218. /**
  41219. * Get the friendly name associated with the input class.
  41220. * @returns the input friendly name
  41221. */
  41222. getSimpleName(): string;
  41223. }
  41224. }
  41225. declare module BABYLON {
  41226. /**
  41227. * Manage the gamepad inputs to control a free camera.
  41228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41229. */
  41230. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41231. /**
  41232. * Define the camera the input is attached to.
  41233. */
  41234. camera: FreeCamera;
  41235. /**
  41236. * Define the Gamepad controlling the input
  41237. */
  41238. gamepad: Nullable<Gamepad>;
  41239. /**
  41240. * Defines the gamepad rotation sensiblity.
  41241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41242. */
  41243. gamepadAngularSensibility: number;
  41244. /**
  41245. * Defines the gamepad move sensiblity.
  41246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41247. */
  41248. gamepadMoveSensibility: number;
  41249. private _yAxisScale;
  41250. /**
  41251. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41252. */
  41253. get invertYAxis(): boolean;
  41254. set invertYAxis(value: boolean);
  41255. private _onGamepadConnectedObserver;
  41256. private _onGamepadDisconnectedObserver;
  41257. private _cameraTransform;
  41258. private _deltaTransform;
  41259. private _vector3;
  41260. private _vector2;
  41261. /**
  41262. * Attach the input controls to a specific dom element to get the input from.
  41263. * @param element Defines the element the controls should be listened from
  41264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41265. */
  41266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41267. /**
  41268. * Detach the current controls from the specified dom element.
  41269. * @param element Defines the element to stop listening the inputs from
  41270. */
  41271. detachControl(element: Nullable<HTMLElement>): void;
  41272. /**
  41273. * Update the current camera state depending on the inputs that have been used this frame.
  41274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41275. */
  41276. checkInputs(): void;
  41277. /**
  41278. * Gets the class name of the current intput.
  41279. * @returns the class name
  41280. */
  41281. getClassName(): string;
  41282. /**
  41283. * Get the friendly name associated with the input class.
  41284. * @returns the input friendly name
  41285. */
  41286. getSimpleName(): string;
  41287. }
  41288. }
  41289. declare module BABYLON {
  41290. /**
  41291. * Defines the potential axis of a Joystick
  41292. */
  41293. export enum JoystickAxis {
  41294. /** X axis */
  41295. X = 0,
  41296. /** Y axis */
  41297. Y = 1,
  41298. /** Z axis */
  41299. Z = 2
  41300. }
  41301. /**
  41302. * Class used to define virtual joystick (used in touch mode)
  41303. */
  41304. export class VirtualJoystick {
  41305. /**
  41306. * Gets or sets a boolean indicating that left and right values must be inverted
  41307. */
  41308. reverseLeftRight: boolean;
  41309. /**
  41310. * Gets or sets a boolean indicating that up and down values must be inverted
  41311. */
  41312. reverseUpDown: boolean;
  41313. /**
  41314. * Gets the offset value for the position (ie. the change of the position value)
  41315. */
  41316. deltaPosition: Vector3;
  41317. /**
  41318. * Gets a boolean indicating if the virtual joystick was pressed
  41319. */
  41320. pressed: boolean;
  41321. /**
  41322. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41323. */
  41324. static Canvas: Nullable<HTMLCanvasElement>;
  41325. private static _globalJoystickIndex;
  41326. private static vjCanvasContext;
  41327. private static vjCanvasWidth;
  41328. private static vjCanvasHeight;
  41329. private static halfWidth;
  41330. private _action;
  41331. private _axisTargetedByLeftAndRight;
  41332. private _axisTargetedByUpAndDown;
  41333. private _joystickSensibility;
  41334. private _inversedSensibility;
  41335. private _joystickPointerID;
  41336. private _joystickColor;
  41337. private _joystickPointerPos;
  41338. private _joystickPreviousPointerPos;
  41339. private _joystickPointerStartPos;
  41340. private _deltaJoystickVector;
  41341. private _leftJoystick;
  41342. private _touches;
  41343. private _onPointerDownHandlerRef;
  41344. private _onPointerMoveHandlerRef;
  41345. private _onPointerUpHandlerRef;
  41346. private _onResize;
  41347. /**
  41348. * Creates a new virtual joystick
  41349. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41350. */
  41351. constructor(leftJoystick?: boolean);
  41352. /**
  41353. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41354. * @param newJoystickSensibility defines the new sensibility
  41355. */
  41356. setJoystickSensibility(newJoystickSensibility: number): void;
  41357. private _onPointerDown;
  41358. private _onPointerMove;
  41359. private _onPointerUp;
  41360. /**
  41361. * Change the color of the virtual joystick
  41362. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41363. */
  41364. setJoystickColor(newColor: string): void;
  41365. /**
  41366. * Defines a callback to call when the joystick is touched
  41367. * @param action defines the callback
  41368. */
  41369. setActionOnTouch(action: () => any): void;
  41370. /**
  41371. * Defines which axis you'd like to control for left & right
  41372. * @param axis defines the axis to use
  41373. */
  41374. setAxisForLeftRight(axis: JoystickAxis): void;
  41375. /**
  41376. * Defines which axis you'd like to control for up & down
  41377. * @param axis defines the axis to use
  41378. */
  41379. setAxisForUpDown(axis: JoystickAxis): void;
  41380. private _drawVirtualJoystick;
  41381. /**
  41382. * Release internal HTML canvas
  41383. */
  41384. releaseCanvas(): void;
  41385. }
  41386. }
  41387. declare module BABYLON {
  41388. interface FreeCameraInputsManager {
  41389. /**
  41390. * Add virtual joystick input support to the input manager.
  41391. * @returns the current input manager
  41392. */
  41393. addVirtualJoystick(): FreeCameraInputsManager;
  41394. }
  41395. /**
  41396. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41398. */
  41399. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41400. /**
  41401. * Defines the camera the input is attached to.
  41402. */
  41403. camera: FreeCamera;
  41404. private _leftjoystick;
  41405. private _rightjoystick;
  41406. /**
  41407. * Gets the left stick of the virtual joystick.
  41408. * @returns The virtual Joystick
  41409. */
  41410. getLeftJoystick(): VirtualJoystick;
  41411. /**
  41412. * Gets the right stick of the virtual joystick.
  41413. * @returns The virtual Joystick
  41414. */
  41415. getRightJoystick(): VirtualJoystick;
  41416. /**
  41417. * Update the current camera state depending on the inputs that have been used this frame.
  41418. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41419. */
  41420. checkInputs(): void;
  41421. /**
  41422. * Attach the input controls to a specific dom element to get the input from.
  41423. * @param element Defines the element the controls should be listened from
  41424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41425. */
  41426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41427. /**
  41428. * Detach the current controls from the specified dom element.
  41429. * @param element Defines the element to stop listening the inputs from
  41430. */
  41431. detachControl(element: Nullable<HTMLElement>): void;
  41432. /**
  41433. * Gets the class name of the current intput.
  41434. * @returns the class name
  41435. */
  41436. getClassName(): string;
  41437. /**
  41438. * Get the friendly name associated with the input class.
  41439. * @returns the input friendly name
  41440. */
  41441. getSimpleName(): string;
  41442. }
  41443. }
  41444. declare module BABYLON {
  41445. /**
  41446. * This represents a FPS type of camera controlled by touch.
  41447. * This is like a universal camera minus the Gamepad controls.
  41448. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41449. */
  41450. export class TouchCamera extends FreeCamera {
  41451. /**
  41452. * Defines the touch sensibility for rotation.
  41453. * The higher the faster.
  41454. */
  41455. get touchAngularSensibility(): number;
  41456. set touchAngularSensibility(value: number);
  41457. /**
  41458. * Defines the touch sensibility for move.
  41459. * The higher the faster.
  41460. */
  41461. get touchMoveSensibility(): number;
  41462. set touchMoveSensibility(value: number);
  41463. /**
  41464. * Instantiates a new touch camera.
  41465. * This represents a FPS type of camera controlled by touch.
  41466. * This is like a universal camera minus the Gamepad controls.
  41467. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41468. * @param name Define the name of the camera in the scene
  41469. * @param position Define the start position of the camera in the scene
  41470. * @param scene Define the scene the camera belongs to
  41471. */
  41472. constructor(name: string, position: Vector3, scene: Scene);
  41473. /**
  41474. * Gets the current object class name.
  41475. * @return the class name
  41476. */
  41477. getClassName(): string;
  41478. /** @hidden */
  41479. _setupInputs(): void;
  41480. }
  41481. }
  41482. declare module BABYLON {
  41483. /**
  41484. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41485. * being tilted forward or back and left or right.
  41486. */
  41487. export class DeviceOrientationCamera extends FreeCamera {
  41488. private _initialQuaternion;
  41489. private _quaternionCache;
  41490. private _tmpDragQuaternion;
  41491. private _disablePointerInputWhenUsingDeviceOrientation;
  41492. /**
  41493. * Creates a new device orientation camera
  41494. * @param name The name of the camera
  41495. * @param position The start position camera
  41496. * @param scene The scene the camera belongs to
  41497. */
  41498. constructor(name: string, position: Vector3, scene: Scene);
  41499. /**
  41500. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41501. */
  41502. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41503. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41504. private _dragFactor;
  41505. /**
  41506. * Enabled turning on the y axis when the orientation sensor is active
  41507. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41508. */
  41509. enableHorizontalDragging(dragFactor?: number): void;
  41510. /**
  41511. * Gets the current instance class name ("DeviceOrientationCamera").
  41512. * This helps avoiding instanceof at run time.
  41513. * @returns the class name
  41514. */
  41515. getClassName(): string;
  41516. /**
  41517. * @hidden
  41518. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41519. */
  41520. _checkInputs(): void;
  41521. /**
  41522. * Reset the camera to its default orientation on the specified axis only.
  41523. * @param axis The axis to reset
  41524. */
  41525. resetToCurrentRotation(axis?: Axis): void;
  41526. }
  41527. }
  41528. declare module BABYLON {
  41529. /**
  41530. * Defines supported buttons for XBox360 compatible gamepads
  41531. */
  41532. export enum Xbox360Button {
  41533. /** A */
  41534. A = 0,
  41535. /** B */
  41536. B = 1,
  41537. /** X */
  41538. X = 2,
  41539. /** Y */
  41540. Y = 3,
  41541. /** Left button */
  41542. LB = 4,
  41543. /** Right button */
  41544. RB = 5,
  41545. /** Back */
  41546. Back = 8,
  41547. /** Start */
  41548. Start = 9,
  41549. /** Left stick */
  41550. LeftStick = 10,
  41551. /** Right stick */
  41552. RightStick = 11
  41553. }
  41554. /** Defines values for XBox360 DPad */
  41555. export enum Xbox360Dpad {
  41556. /** Up */
  41557. Up = 12,
  41558. /** Down */
  41559. Down = 13,
  41560. /** Left */
  41561. Left = 14,
  41562. /** Right */
  41563. Right = 15
  41564. }
  41565. /**
  41566. * Defines a XBox360 gamepad
  41567. */
  41568. export class Xbox360Pad extends Gamepad {
  41569. private _leftTrigger;
  41570. private _rightTrigger;
  41571. private _onlefttriggerchanged;
  41572. private _onrighttriggerchanged;
  41573. private _onbuttondown;
  41574. private _onbuttonup;
  41575. private _ondpaddown;
  41576. private _ondpadup;
  41577. /** Observable raised when a button is pressed */
  41578. onButtonDownObservable: Observable<Xbox360Button>;
  41579. /** Observable raised when a button is released */
  41580. onButtonUpObservable: Observable<Xbox360Button>;
  41581. /** Observable raised when a pad is pressed */
  41582. onPadDownObservable: Observable<Xbox360Dpad>;
  41583. /** Observable raised when a pad is released */
  41584. onPadUpObservable: Observable<Xbox360Dpad>;
  41585. private _buttonA;
  41586. private _buttonB;
  41587. private _buttonX;
  41588. private _buttonY;
  41589. private _buttonBack;
  41590. private _buttonStart;
  41591. private _buttonLB;
  41592. private _buttonRB;
  41593. private _buttonLeftStick;
  41594. private _buttonRightStick;
  41595. private _dPadUp;
  41596. private _dPadDown;
  41597. private _dPadLeft;
  41598. private _dPadRight;
  41599. private _isXboxOnePad;
  41600. /**
  41601. * Creates a new XBox360 gamepad object
  41602. * @param id defines the id of this gamepad
  41603. * @param index defines its index
  41604. * @param gamepad defines the internal HTML gamepad object
  41605. * @param xboxOne defines if it is a XBox One gamepad
  41606. */
  41607. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41608. /**
  41609. * Defines the callback to call when left trigger is pressed
  41610. * @param callback defines the callback to use
  41611. */
  41612. onlefttriggerchanged(callback: (value: number) => void): void;
  41613. /**
  41614. * Defines the callback to call when right trigger is pressed
  41615. * @param callback defines the callback to use
  41616. */
  41617. onrighttriggerchanged(callback: (value: number) => void): void;
  41618. /**
  41619. * Gets the left trigger value
  41620. */
  41621. get leftTrigger(): number;
  41622. /**
  41623. * Sets the left trigger value
  41624. */
  41625. set leftTrigger(newValue: number);
  41626. /**
  41627. * Gets the right trigger value
  41628. */
  41629. get rightTrigger(): number;
  41630. /**
  41631. * Sets the right trigger value
  41632. */
  41633. set rightTrigger(newValue: number);
  41634. /**
  41635. * Defines the callback to call when a button is pressed
  41636. * @param callback defines the callback to use
  41637. */
  41638. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41639. /**
  41640. * Defines the callback to call when a button is released
  41641. * @param callback defines the callback to use
  41642. */
  41643. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41644. /**
  41645. * Defines the callback to call when a pad is pressed
  41646. * @param callback defines the callback to use
  41647. */
  41648. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41649. /**
  41650. * Defines the callback to call when a pad is released
  41651. * @param callback defines the callback to use
  41652. */
  41653. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41654. private _setButtonValue;
  41655. private _setDPadValue;
  41656. /**
  41657. * Gets the value of the `A` button
  41658. */
  41659. get buttonA(): number;
  41660. /**
  41661. * Sets the value of the `A` button
  41662. */
  41663. set buttonA(value: number);
  41664. /**
  41665. * Gets the value of the `B` button
  41666. */
  41667. get buttonB(): number;
  41668. /**
  41669. * Sets the value of the `B` button
  41670. */
  41671. set buttonB(value: number);
  41672. /**
  41673. * Gets the value of the `X` button
  41674. */
  41675. get buttonX(): number;
  41676. /**
  41677. * Sets the value of the `X` button
  41678. */
  41679. set buttonX(value: number);
  41680. /**
  41681. * Gets the value of the `Y` button
  41682. */
  41683. get buttonY(): number;
  41684. /**
  41685. * Sets the value of the `Y` button
  41686. */
  41687. set buttonY(value: number);
  41688. /**
  41689. * Gets the value of the `Start` button
  41690. */
  41691. get buttonStart(): number;
  41692. /**
  41693. * Sets the value of the `Start` button
  41694. */
  41695. set buttonStart(value: number);
  41696. /**
  41697. * Gets the value of the `Back` button
  41698. */
  41699. get buttonBack(): number;
  41700. /**
  41701. * Sets the value of the `Back` button
  41702. */
  41703. set buttonBack(value: number);
  41704. /**
  41705. * Gets the value of the `Left` button
  41706. */
  41707. get buttonLB(): number;
  41708. /**
  41709. * Sets the value of the `Left` button
  41710. */
  41711. set buttonLB(value: number);
  41712. /**
  41713. * Gets the value of the `Right` button
  41714. */
  41715. get buttonRB(): number;
  41716. /**
  41717. * Sets the value of the `Right` button
  41718. */
  41719. set buttonRB(value: number);
  41720. /**
  41721. * Gets the value of the Left joystick
  41722. */
  41723. get buttonLeftStick(): number;
  41724. /**
  41725. * Sets the value of the Left joystick
  41726. */
  41727. set buttonLeftStick(value: number);
  41728. /**
  41729. * Gets the value of the Right joystick
  41730. */
  41731. get buttonRightStick(): number;
  41732. /**
  41733. * Sets the value of the Right joystick
  41734. */
  41735. set buttonRightStick(value: number);
  41736. /**
  41737. * Gets the value of D-pad up
  41738. */
  41739. get dPadUp(): number;
  41740. /**
  41741. * Sets the value of D-pad up
  41742. */
  41743. set dPadUp(value: number);
  41744. /**
  41745. * Gets the value of D-pad down
  41746. */
  41747. get dPadDown(): number;
  41748. /**
  41749. * Sets the value of D-pad down
  41750. */
  41751. set dPadDown(value: number);
  41752. /**
  41753. * Gets the value of D-pad left
  41754. */
  41755. get dPadLeft(): number;
  41756. /**
  41757. * Sets the value of D-pad left
  41758. */
  41759. set dPadLeft(value: number);
  41760. /**
  41761. * Gets the value of D-pad right
  41762. */
  41763. get dPadRight(): number;
  41764. /**
  41765. * Sets the value of D-pad right
  41766. */
  41767. set dPadRight(value: number);
  41768. /**
  41769. * Force the gamepad to synchronize with device values
  41770. */
  41771. update(): void;
  41772. /**
  41773. * Disposes the gamepad
  41774. */
  41775. dispose(): void;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /**
  41780. * Defines supported buttons for DualShock compatible gamepads
  41781. */
  41782. export enum DualShockButton {
  41783. /** Cross */
  41784. Cross = 0,
  41785. /** Circle */
  41786. Circle = 1,
  41787. /** Square */
  41788. Square = 2,
  41789. /** Triangle */
  41790. Triangle = 3,
  41791. /** L1 */
  41792. L1 = 4,
  41793. /** R1 */
  41794. R1 = 5,
  41795. /** Share */
  41796. Share = 8,
  41797. /** Options */
  41798. Options = 9,
  41799. /** Left stick */
  41800. LeftStick = 10,
  41801. /** Right stick */
  41802. RightStick = 11
  41803. }
  41804. /** Defines values for DualShock DPad */
  41805. export enum DualShockDpad {
  41806. /** Up */
  41807. Up = 12,
  41808. /** Down */
  41809. Down = 13,
  41810. /** Left */
  41811. Left = 14,
  41812. /** Right */
  41813. Right = 15
  41814. }
  41815. /**
  41816. * Defines a DualShock gamepad
  41817. */
  41818. export class DualShockPad extends Gamepad {
  41819. private _leftTrigger;
  41820. private _rightTrigger;
  41821. private _onlefttriggerchanged;
  41822. private _onrighttriggerchanged;
  41823. private _onbuttondown;
  41824. private _onbuttonup;
  41825. private _ondpaddown;
  41826. private _ondpadup;
  41827. /** Observable raised when a button is pressed */
  41828. onButtonDownObservable: Observable<DualShockButton>;
  41829. /** Observable raised when a button is released */
  41830. onButtonUpObservable: Observable<DualShockButton>;
  41831. /** Observable raised when a pad is pressed */
  41832. onPadDownObservable: Observable<DualShockDpad>;
  41833. /** Observable raised when a pad is released */
  41834. onPadUpObservable: Observable<DualShockDpad>;
  41835. private _buttonCross;
  41836. private _buttonCircle;
  41837. private _buttonSquare;
  41838. private _buttonTriangle;
  41839. private _buttonShare;
  41840. private _buttonOptions;
  41841. private _buttonL1;
  41842. private _buttonR1;
  41843. private _buttonLeftStick;
  41844. private _buttonRightStick;
  41845. private _dPadUp;
  41846. private _dPadDown;
  41847. private _dPadLeft;
  41848. private _dPadRight;
  41849. /**
  41850. * Creates a new DualShock gamepad object
  41851. * @param id defines the id of this gamepad
  41852. * @param index defines its index
  41853. * @param gamepad defines the internal HTML gamepad object
  41854. */
  41855. constructor(id: string, index: number, gamepad: any);
  41856. /**
  41857. * Defines the callback to call when left trigger is pressed
  41858. * @param callback defines the callback to use
  41859. */
  41860. onlefttriggerchanged(callback: (value: number) => void): void;
  41861. /**
  41862. * Defines the callback to call when right trigger is pressed
  41863. * @param callback defines the callback to use
  41864. */
  41865. onrighttriggerchanged(callback: (value: number) => void): void;
  41866. /**
  41867. * Gets the left trigger value
  41868. */
  41869. get leftTrigger(): number;
  41870. /**
  41871. * Sets the left trigger value
  41872. */
  41873. set leftTrigger(newValue: number);
  41874. /**
  41875. * Gets the right trigger value
  41876. */
  41877. get rightTrigger(): number;
  41878. /**
  41879. * Sets the right trigger value
  41880. */
  41881. set rightTrigger(newValue: number);
  41882. /**
  41883. * Defines the callback to call when a button is pressed
  41884. * @param callback defines the callback to use
  41885. */
  41886. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41887. /**
  41888. * Defines the callback to call when a button is released
  41889. * @param callback defines the callback to use
  41890. */
  41891. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41892. /**
  41893. * Defines the callback to call when a pad is pressed
  41894. * @param callback defines the callback to use
  41895. */
  41896. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41897. /**
  41898. * Defines the callback to call when a pad is released
  41899. * @param callback defines the callback to use
  41900. */
  41901. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41902. private _setButtonValue;
  41903. private _setDPadValue;
  41904. /**
  41905. * Gets the value of the `Cross` button
  41906. */
  41907. get buttonCross(): number;
  41908. /**
  41909. * Sets the value of the `Cross` button
  41910. */
  41911. set buttonCross(value: number);
  41912. /**
  41913. * Gets the value of the `Circle` button
  41914. */
  41915. get buttonCircle(): number;
  41916. /**
  41917. * Sets the value of the `Circle` button
  41918. */
  41919. set buttonCircle(value: number);
  41920. /**
  41921. * Gets the value of the `Square` button
  41922. */
  41923. get buttonSquare(): number;
  41924. /**
  41925. * Sets the value of the `Square` button
  41926. */
  41927. set buttonSquare(value: number);
  41928. /**
  41929. * Gets the value of the `Triangle` button
  41930. */
  41931. get buttonTriangle(): number;
  41932. /**
  41933. * Sets the value of the `Triangle` button
  41934. */
  41935. set buttonTriangle(value: number);
  41936. /**
  41937. * Gets the value of the `Options` button
  41938. */
  41939. get buttonOptions(): number;
  41940. /**
  41941. * Sets the value of the `Options` button
  41942. */
  41943. set buttonOptions(value: number);
  41944. /**
  41945. * Gets the value of the `Share` button
  41946. */
  41947. get buttonShare(): number;
  41948. /**
  41949. * Sets the value of the `Share` button
  41950. */
  41951. set buttonShare(value: number);
  41952. /**
  41953. * Gets the value of the `L1` button
  41954. */
  41955. get buttonL1(): number;
  41956. /**
  41957. * Sets the value of the `L1` button
  41958. */
  41959. set buttonL1(value: number);
  41960. /**
  41961. * Gets the value of the `R1` button
  41962. */
  41963. get buttonR1(): number;
  41964. /**
  41965. * Sets the value of the `R1` button
  41966. */
  41967. set buttonR1(value: number);
  41968. /**
  41969. * Gets the value of the Left joystick
  41970. */
  41971. get buttonLeftStick(): number;
  41972. /**
  41973. * Sets the value of the Left joystick
  41974. */
  41975. set buttonLeftStick(value: number);
  41976. /**
  41977. * Gets the value of the Right joystick
  41978. */
  41979. get buttonRightStick(): number;
  41980. /**
  41981. * Sets the value of the Right joystick
  41982. */
  41983. set buttonRightStick(value: number);
  41984. /**
  41985. * Gets the value of D-pad up
  41986. */
  41987. get dPadUp(): number;
  41988. /**
  41989. * Sets the value of D-pad up
  41990. */
  41991. set dPadUp(value: number);
  41992. /**
  41993. * Gets the value of D-pad down
  41994. */
  41995. get dPadDown(): number;
  41996. /**
  41997. * Sets the value of D-pad down
  41998. */
  41999. set dPadDown(value: number);
  42000. /**
  42001. * Gets the value of D-pad left
  42002. */
  42003. get dPadLeft(): number;
  42004. /**
  42005. * Sets the value of D-pad left
  42006. */
  42007. set dPadLeft(value: number);
  42008. /**
  42009. * Gets the value of D-pad right
  42010. */
  42011. get dPadRight(): number;
  42012. /**
  42013. * Sets the value of D-pad right
  42014. */
  42015. set dPadRight(value: number);
  42016. /**
  42017. * Force the gamepad to synchronize with device values
  42018. */
  42019. update(): void;
  42020. /**
  42021. * Disposes the gamepad
  42022. */
  42023. dispose(): void;
  42024. }
  42025. }
  42026. declare module BABYLON {
  42027. /**
  42028. * Manager for handling gamepads
  42029. */
  42030. export class GamepadManager {
  42031. private _scene?;
  42032. private _babylonGamepads;
  42033. private _oneGamepadConnected;
  42034. /** @hidden */
  42035. _isMonitoring: boolean;
  42036. private _gamepadEventSupported;
  42037. private _gamepadSupport?;
  42038. /**
  42039. * observable to be triggered when the gamepad controller has been connected
  42040. */
  42041. onGamepadConnectedObservable: Observable<Gamepad>;
  42042. /**
  42043. * observable to be triggered when the gamepad controller has been disconnected
  42044. */
  42045. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42046. private _onGamepadConnectedEvent;
  42047. private _onGamepadDisconnectedEvent;
  42048. /**
  42049. * Initializes the gamepad manager
  42050. * @param _scene BabylonJS scene
  42051. */
  42052. constructor(_scene?: Scene | undefined);
  42053. /**
  42054. * The gamepads in the game pad manager
  42055. */
  42056. get gamepads(): Gamepad[];
  42057. /**
  42058. * Get the gamepad controllers based on type
  42059. * @param type The type of gamepad controller
  42060. * @returns Nullable gamepad
  42061. */
  42062. getGamepadByType(type?: number): Nullable<Gamepad>;
  42063. /**
  42064. * Disposes the gamepad manager
  42065. */
  42066. dispose(): void;
  42067. private _addNewGamepad;
  42068. private _startMonitoringGamepads;
  42069. private _stopMonitoringGamepads;
  42070. /** @hidden */
  42071. _checkGamepadsStatus(): void;
  42072. private _updateGamepadObjects;
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. interface Scene {
  42077. /** @hidden */
  42078. _gamepadManager: Nullable<GamepadManager>;
  42079. /**
  42080. * Gets the gamepad manager associated with the scene
  42081. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42082. */
  42083. gamepadManager: GamepadManager;
  42084. }
  42085. /**
  42086. * Interface representing a free camera inputs manager
  42087. */
  42088. interface FreeCameraInputsManager {
  42089. /**
  42090. * Adds gamepad input support to the FreeCameraInputsManager.
  42091. * @returns the FreeCameraInputsManager
  42092. */
  42093. addGamepad(): FreeCameraInputsManager;
  42094. }
  42095. /**
  42096. * Interface representing an arc rotate camera inputs manager
  42097. */
  42098. interface ArcRotateCameraInputsManager {
  42099. /**
  42100. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42101. * @returns the camera inputs manager
  42102. */
  42103. addGamepad(): ArcRotateCameraInputsManager;
  42104. }
  42105. /**
  42106. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42107. */
  42108. export class GamepadSystemSceneComponent implements ISceneComponent {
  42109. /**
  42110. * The component name helpfull to identify the component in the list of scene components.
  42111. */
  42112. readonly name: string;
  42113. /**
  42114. * The scene the component belongs to.
  42115. */
  42116. scene: Scene;
  42117. /**
  42118. * Creates a new instance of the component for the given scene
  42119. * @param scene Defines the scene to register the component in
  42120. */
  42121. constructor(scene: Scene);
  42122. /**
  42123. * Registers the component in a given scene
  42124. */
  42125. register(): void;
  42126. /**
  42127. * Rebuilds the elements related to this component in case of
  42128. * context lost for instance.
  42129. */
  42130. rebuild(): void;
  42131. /**
  42132. * Disposes the component and the associated ressources
  42133. */
  42134. dispose(): void;
  42135. private _beforeCameraUpdate;
  42136. }
  42137. }
  42138. declare module BABYLON {
  42139. /**
  42140. * 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,
  42141. * which still works and will still be found in many Playgrounds.
  42142. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42143. */
  42144. export class UniversalCamera extends TouchCamera {
  42145. /**
  42146. * Defines the gamepad rotation sensiblity.
  42147. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42148. */
  42149. get gamepadAngularSensibility(): number;
  42150. set gamepadAngularSensibility(value: number);
  42151. /**
  42152. * Defines the gamepad move sensiblity.
  42153. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42154. */
  42155. get gamepadMoveSensibility(): number;
  42156. set gamepadMoveSensibility(value: number);
  42157. /**
  42158. * 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,
  42159. * which still works and will still be found in many Playgrounds.
  42160. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42161. * @param name Define the name of the camera in the scene
  42162. * @param position Define the start position of the camera in the scene
  42163. * @param scene Define the scene the camera belongs to
  42164. */
  42165. constructor(name: string, position: Vector3, scene: Scene);
  42166. /**
  42167. * Gets the current object class name.
  42168. * @return the class name
  42169. */
  42170. getClassName(): string;
  42171. }
  42172. }
  42173. declare module BABYLON {
  42174. /**
  42175. * This represents a FPS type of camera. This is only here for back compat purpose.
  42176. * Please use the UniversalCamera instead as both are identical.
  42177. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42178. */
  42179. export class GamepadCamera extends UniversalCamera {
  42180. /**
  42181. * Instantiates a new Gamepad Camera
  42182. * This represents a FPS type of camera. This is only here for back compat purpose.
  42183. * Please use the UniversalCamera instead as both are identical.
  42184. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42185. * @param name Define the name of the camera in the scene
  42186. * @param position Define the start position of the camera in the scene
  42187. * @param scene Define the scene the camera belongs to
  42188. */
  42189. constructor(name: string, position: Vector3, scene: Scene);
  42190. /**
  42191. * Gets the current object class name.
  42192. * @return the class name
  42193. */
  42194. getClassName(): string;
  42195. }
  42196. }
  42197. declare module BABYLON {
  42198. /** @hidden */
  42199. export var passPixelShader: {
  42200. name: string;
  42201. shader: string;
  42202. };
  42203. }
  42204. declare module BABYLON {
  42205. /** @hidden */
  42206. export var passCubePixelShader: {
  42207. name: string;
  42208. shader: string;
  42209. };
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * PassPostProcess which produces an output the same as it's input
  42214. */
  42215. export class PassPostProcess extends PostProcess {
  42216. /**
  42217. * Creates the PassPostProcess
  42218. * @param name The name of the effect.
  42219. * @param options The required width/height ratio to downsize to before computing the render pass.
  42220. * @param camera The camera to apply the render pass to.
  42221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42222. * @param engine The engine which the post process will be applied. (default: current engine)
  42223. * @param reusable If the post process can be reused on the same frame. (default: false)
  42224. * @param textureType The type of texture to be used when performing the post processing.
  42225. * @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)
  42226. */
  42227. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42228. }
  42229. /**
  42230. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42231. */
  42232. export class PassCubePostProcess extends PostProcess {
  42233. private _face;
  42234. /**
  42235. * Gets or sets the cube face to display.
  42236. * * 0 is +X
  42237. * * 1 is -X
  42238. * * 2 is +Y
  42239. * * 3 is -Y
  42240. * * 4 is +Z
  42241. * * 5 is -Z
  42242. */
  42243. get face(): number;
  42244. set face(value: number);
  42245. /**
  42246. * Creates the PassCubePostProcess
  42247. * @param name The name of the effect.
  42248. * @param options The required width/height ratio to downsize to before computing the render pass.
  42249. * @param camera The camera to apply the render pass to.
  42250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42251. * @param engine The engine which the post process will be applied. (default: current engine)
  42252. * @param reusable If the post process can be reused on the same frame. (default: false)
  42253. * @param textureType The type of texture to be used when performing the post processing.
  42254. * @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)
  42255. */
  42256. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42257. }
  42258. }
  42259. declare module BABYLON {
  42260. /** @hidden */
  42261. export var anaglyphPixelShader: {
  42262. name: string;
  42263. shader: string;
  42264. };
  42265. }
  42266. declare module BABYLON {
  42267. /**
  42268. * Postprocess used to generate anaglyphic rendering
  42269. */
  42270. export class AnaglyphPostProcess extends PostProcess {
  42271. private _passedProcess;
  42272. /**
  42273. * Creates a new AnaglyphPostProcess
  42274. * @param name defines postprocess name
  42275. * @param options defines creation options or target ratio scale
  42276. * @param rigCameras defines cameras using this postprocess
  42277. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42278. * @param engine defines hosting engine
  42279. * @param reusable defines if the postprocess will be reused multiple times per frame
  42280. */
  42281. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42287. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42288. */
  42289. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42290. /**
  42291. * Creates a new AnaglyphArcRotateCamera
  42292. * @param name defines camera name
  42293. * @param alpha defines alpha angle (in radians)
  42294. * @param beta defines beta angle (in radians)
  42295. * @param radius defines radius
  42296. * @param target defines camera target
  42297. * @param interaxialDistance defines distance between each color axis
  42298. * @param scene defines the hosting scene
  42299. */
  42300. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42301. /**
  42302. * Gets camera class name
  42303. * @returns AnaglyphArcRotateCamera
  42304. */
  42305. getClassName(): string;
  42306. }
  42307. }
  42308. declare module BABYLON {
  42309. /**
  42310. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42311. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42312. */
  42313. export class AnaglyphFreeCamera extends FreeCamera {
  42314. /**
  42315. * Creates a new AnaglyphFreeCamera
  42316. * @param name defines camera name
  42317. * @param position defines initial position
  42318. * @param interaxialDistance defines distance between each color axis
  42319. * @param scene defines the hosting scene
  42320. */
  42321. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42322. /**
  42323. * Gets camera class name
  42324. * @returns AnaglyphFreeCamera
  42325. */
  42326. getClassName(): string;
  42327. }
  42328. }
  42329. declare module BABYLON {
  42330. /**
  42331. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42332. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42333. */
  42334. export class AnaglyphGamepadCamera extends GamepadCamera {
  42335. /**
  42336. * Creates a new AnaglyphGamepadCamera
  42337. * @param name defines camera name
  42338. * @param position defines initial position
  42339. * @param interaxialDistance defines distance between each color axis
  42340. * @param scene defines the hosting scene
  42341. */
  42342. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42343. /**
  42344. * Gets camera class name
  42345. * @returns AnaglyphGamepadCamera
  42346. */
  42347. getClassName(): string;
  42348. }
  42349. }
  42350. declare module BABYLON {
  42351. /**
  42352. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42353. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42354. */
  42355. export class AnaglyphUniversalCamera extends UniversalCamera {
  42356. /**
  42357. * Creates a new AnaglyphUniversalCamera
  42358. * @param name defines camera name
  42359. * @param position defines initial position
  42360. * @param interaxialDistance defines distance between each color axis
  42361. * @param scene defines the hosting scene
  42362. */
  42363. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42364. /**
  42365. * Gets camera class name
  42366. * @returns AnaglyphUniversalCamera
  42367. */
  42368. getClassName(): string;
  42369. }
  42370. }
  42371. declare module BABYLON {
  42372. /**
  42373. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42374. * @see http://doc.babylonjs.com/features/cameras
  42375. */
  42376. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42377. /**
  42378. * Creates a new StereoscopicArcRotateCamera
  42379. * @param name defines camera name
  42380. * @param alpha defines alpha angle (in radians)
  42381. * @param beta defines beta angle (in radians)
  42382. * @param radius defines radius
  42383. * @param target defines camera target
  42384. * @param interaxialDistance defines distance between each color axis
  42385. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42386. * @param scene defines the hosting scene
  42387. */
  42388. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42389. /**
  42390. * Gets camera class name
  42391. * @returns StereoscopicArcRotateCamera
  42392. */
  42393. getClassName(): string;
  42394. }
  42395. }
  42396. declare module BABYLON {
  42397. /**
  42398. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42399. * @see http://doc.babylonjs.com/features/cameras
  42400. */
  42401. export class StereoscopicFreeCamera extends FreeCamera {
  42402. /**
  42403. * Creates a new StereoscopicFreeCamera
  42404. * @param name defines camera name
  42405. * @param position defines initial position
  42406. * @param interaxialDistance defines distance between each color axis
  42407. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42408. * @param scene defines the hosting scene
  42409. */
  42410. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42411. /**
  42412. * Gets camera class name
  42413. * @returns StereoscopicFreeCamera
  42414. */
  42415. getClassName(): string;
  42416. }
  42417. }
  42418. declare module BABYLON {
  42419. /**
  42420. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42421. * @see http://doc.babylonjs.com/features/cameras
  42422. */
  42423. export class StereoscopicGamepadCamera extends GamepadCamera {
  42424. /**
  42425. * Creates a new StereoscopicGamepadCamera
  42426. * @param name defines camera name
  42427. * @param position defines initial position
  42428. * @param interaxialDistance defines distance between each color axis
  42429. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42430. * @param scene defines the hosting scene
  42431. */
  42432. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42433. /**
  42434. * Gets camera class name
  42435. * @returns StereoscopicGamepadCamera
  42436. */
  42437. getClassName(): string;
  42438. }
  42439. }
  42440. declare module BABYLON {
  42441. /**
  42442. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42443. * @see http://doc.babylonjs.com/features/cameras
  42444. */
  42445. export class StereoscopicUniversalCamera extends UniversalCamera {
  42446. /**
  42447. * Creates a new StereoscopicUniversalCamera
  42448. * @param name defines camera name
  42449. * @param position defines initial position
  42450. * @param interaxialDistance defines distance between each color axis
  42451. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42452. * @param scene defines the hosting scene
  42453. */
  42454. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42455. /**
  42456. * Gets camera class name
  42457. * @returns StereoscopicUniversalCamera
  42458. */
  42459. getClassName(): string;
  42460. }
  42461. }
  42462. declare module BABYLON {
  42463. /**
  42464. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42465. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42466. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42467. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42468. */
  42469. export class VirtualJoysticksCamera extends FreeCamera {
  42470. /**
  42471. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42472. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42473. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42474. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42475. * @param name Define the name of the camera in the scene
  42476. * @param position Define the start position of the camera in the scene
  42477. * @param scene Define the scene the camera belongs to
  42478. */
  42479. constructor(name: string, position: Vector3, scene: Scene);
  42480. /**
  42481. * Gets the current object class name.
  42482. * @return the class name
  42483. */
  42484. getClassName(): string;
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * This represents all the required metrics to create a VR camera.
  42490. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42491. */
  42492. export class VRCameraMetrics {
  42493. /**
  42494. * Define the horizontal resolution off the screen.
  42495. */
  42496. hResolution: number;
  42497. /**
  42498. * Define the vertical resolution off the screen.
  42499. */
  42500. vResolution: number;
  42501. /**
  42502. * Define the horizontal screen size.
  42503. */
  42504. hScreenSize: number;
  42505. /**
  42506. * Define the vertical screen size.
  42507. */
  42508. vScreenSize: number;
  42509. /**
  42510. * Define the vertical screen center position.
  42511. */
  42512. vScreenCenter: number;
  42513. /**
  42514. * Define the distance of the eyes to the screen.
  42515. */
  42516. eyeToScreenDistance: number;
  42517. /**
  42518. * Define the distance between both lenses
  42519. */
  42520. lensSeparationDistance: number;
  42521. /**
  42522. * Define the distance between both viewer's eyes.
  42523. */
  42524. interpupillaryDistance: number;
  42525. /**
  42526. * Define the distortion factor of the VR postprocess.
  42527. * Please, touch with care.
  42528. */
  42529. distortionK: number[];
  42530. /**
  42531. * Define the chromatic aberration correction factors for the VR post process.
  42532. */
  42533. chromaAbCorrection: number[];
  42534. /**
  42535. * Define the scale factor of the post process.
  42536. * The smaller the better but the slower.
  42537. */
  42538. postProcessScaleFactor: number;
  42539. /**
  42540. * Define an offset for the lens center.
  42541. */
  42542. lensCenterOffset: number;
  42543. /**
  42544. * Define if the current vr camera should compensate the distortion of the lense or not.
  42545. */
  42546. compensateDistortion: boolean;
  42547. /**
  42548. * Defines if multiview should be enabled when rendering (Default: false)
  42549. */
  42550. multiviewEnabled: boolean;
  42551. /**
  42552. * Gets the rendering aspect ratio based on the provided resolutions.
  42553. */
  42554. get aspectRatio(): number;
  42555. /**
  42556. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42557. */
  42558. get aspectRatioFov(): number;
  42559. /**
  42560. * @hidden
  42561. */
  42562. get leftHMatrix(): Matrix;
  42563. /**
  42564. * @hidden
  42565. */
  42566. get rightHMatrix(): Matrix;
  42567. /**
  42568. * @hidden
  42569. */
  42570. get leftPreViewMatrix(): Matrix;
  42571. /**
  42572. * @hidden
  42573. */
  42574. get rightPreViewMatrix(): Matrix;
  42575. /**
  42576. * Get the default VRMetrics based on the most generic setup.
  42577. * @returns the default vr metrics
  42578. */
  42579. static GetDefault(): VRCameraMetrics;
  42580. }
  42581. }
  42582. declare module BABYLON {
  42583. /** @hidden */
  42584. export var vrDistortionCorrectionPixelShader: {
  42585. name: string;
  42586. shader: string;
  42587. };
  42588. }
  42589. declare module BABYLON {
  42590. /**
  42591. * VRDistortionCorrectionPostProcess used for mobile VR
  42592. */
  42593. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42594. private _isRightEye;
  42595. private _distortionFactors;
  42596. private _postProcessScaleFactor;
  42597. private _lensCenterOffset;
  42598. private _scaleIn;
  42599. private _scaleFactor;
  42600. private _lensCenter;
  42601. /**
  42602. * Initializes the VRDistortionCorrectionPostProcess
  42603. * @param name The name of the effect.
  42604. * @param camera The camera to apply the render pass to.
  42605. * @param isRightEye If this is for the right eye distortion
  42606. * @param vrMetrics All the required metrics for the VR camera
  42607. */
  42608. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42609. }
  42610. }
  42611. declare module BABYLON {
  42612. /**
  42613. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42614. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42615. */
  42616. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42617. /**
  42618. * Creates a new VRDeviceOrientationArcRotateCamera
  42619. * @param name defines camera name
  42620. * @param alpha defines the camera rotation along the logitudinal axis
  42621. * @param beta defines the camera rotation along the latitudinal axis
  42622. * @param radius defines the camera distance from its target
  42623. * @param target defines the camera target
  42624. * @param scene defines the scene the camera belongs to
  42625. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42626. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42627. */
  42628. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42629. /**
  42630. * Gets camera class name
  42631. * @returns VRDeviceOrientationArcRotateCamera
  42632. */
  42633. getClassName(): string;
  42634. }
  42635. }
  42636. declare module BABYLON {
  42637. /**
  42638. * Camera used to simulate VR rendering (based on FreeCamera)
  42639. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42640. */
  42641. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42642. /**
  42643. * Creates a new VRDeviceOrientationFreeCamera
  42644. * @param name defines camera name
  42645. * @param position defines the start position of the camera
  42646. * @param scene defines the scene the camera belongs to
  42647. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42648. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42649. */
  42650. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42651. /**
  42652. * Gets camera class name
  42653. * @returns VRDeviceOrientationFreeCamera
  42654. */
  42655. getClassName(): string;
  42656. }
  42657. }
  42658. declare module BABYLON {
  42659. /**
  42660. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42661. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42662. */
  42663. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42664. /**
  42665. * Creates a new VRDeviceOrientationGamepadCamera
  42666. * @param name defines camera name
  42667. * @param position defines the start position of the camera
  42668. * @param scene defines the scene the camera belongs to
  42669. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42670. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42671. */
  42672. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42673. /**
  42674. * Gets camera class name
  42675. * @returns VRDeviceOrientationGamepadCamera
  42676. */
  42677. getClassName(): string;
  42678. }
  42679. }
  42680. declare module BABYLON {
  42681. /** @hidden */
  42682. export var imageProcessingPixelShader: {
  42683. name: string;
  42684. shader: string;
  42685. };
  42686. }
  42687. declare module BABYLON {
  42688. /**
  42689. * ImageProcessingPostProcess
  42690. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42691. */
  42692. export class ImageProcessingPostProcess extends PostProcess {
  42693. /**
  42694. * Default configuration related to image processing available in the PBR Material.
  42695. */
  42696. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42697. /**
  42698. * Gets the image processing configuration used either in this material.
  42699. */
  42700. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42701. /**
  42702. * Sets the Default image processing configuration used either in the this material.
  42703. *
  42704. * If sets to null, the scene one is in use.
  42705. */
  42706. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42707. /**
  42708. * Keep track of the image processing observer to allow dispose and replace.
  42709. */
  42710. private _imageProcessingObserver;
  42711. /**
  42712. * Attaches a new image processing configuration to the PBR Material.
  42713. * @param configuration
  42714. */
  42715. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42716. /**
  42717. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42718. */
  42719. get colorCurves(): Nullable<ColorCurves>;
  42720. /**
  42721. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42722. */
  42723. set colorCurves(value: Nullable<ColorCurves>);
  42724. /**
  42725. * Gets wether the color curves effect is enabled.
  42726. */
  42727. get colorCurvesEnabled(): boolean;
  42728. /**
  42729. * Sets wether the color curves effect is enabled.
  42730. */
  42731. set colorCurvesEnabled(value: boolean);
  42732. /**
  42733. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42734. */
  42735. get colorGradingTexture(): Nullable<BaseTexture>;
  42736. /**
  42737. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42738. */
  42739. set colorGradingTexture(value: Nullable<BaseTexture>);
  42740. /**
  42741. * Gets wether the color grading effect is enabled.
  42742. */
  42743. get colorGradingEnabled(): boolean;
  42744. /**
  42745. * Gets wether the color grading effect is enabled.
  42746. */
  42747. set colorGradingEnabled(value: boolean);
  42748. /**
  42749. * Gets exposure used in the effect.
  42750. */
  42751. get exposure(): number;
  42752. /**
  42753. * Sets exposure used in the effect.
  42754. */
  42755. set exposure(value: number);
  42756. /**
  42757. * Gets wether tonemapping is enabled or not.
  42758. */
  42759. get toneMappingEnabled(): boolean;
  42760. /**
  42761. * Sets wether tonemapping is enabled or not
  42762. */
  42763. set toneMappingEnabled(value: boolean);
  42764. /**
  42765. * Gets the type of tone mapping effect.
  42766. */
  42767. get toneMappingType(): number;
  42768. /**
  42769. * Sets the type of tone mapping effect.
  42770. */
  42771. set toneMappingType(value: number);
  42772. /**
  42773. * Gets contrast used in the effect.
  42774. */
  42775. get contrast(): number;
  42776. /**
  42777. * Sets contrast used in the effect.
  42778. */
  42779. set contrast(value: number);
  42780. /**
  42781. * Gets Vignette stretch size.
  42782. */
  42783. get vignetteStretch(): number;
  42784. /**
  42785. * Sets Vignette stretch size.
  42786. */
  42787. set vignetteStretch(value: number);
  42788. /**
  42789. * Gets Vignette centre X Offset.
  42790. */
  42791. get vignetteCentreX(): number;
  42792. /**
  42793. * Sets Vignette centre X Offset.
  42794. */
  42795. set vignetteCentreX(value: number);
  42796. /**
  42797. * Gets Vignette centre Y Offset.
  42798. */
  42799. get vignetteCentreY(): number;
  42800. /**
  42801. * Sets Vignette centre Y Offset.
  42802. */
  42803. set vignetteCentreY(value: number);
  42804. /**
  42805. * Gets Vignette weight or intensity of the vignette effect.
  42806. */
  42807. get vignetteWeight(): number;
  42808. /**
  42809. * Sets Vignette weight or intensity of the vignette effect.
  42810. */
  42811. set vignetteWeight(value: number);
  42812. /**
  42813. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42814. * if vignetteEnabled is set to true.
  42815. */
  42816. get vignetteColor(): Color4;
  42817. /**
  42818. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42819. * if vignetteEnabled is set to true.
  42820. */
  42821. set vignetteColor(value: Color4);
  42822. /**
  42823. * Gets Camera field of view used by the Vignette effect.
  42824. */
  42825. get vignetteCameraFov(): number;
  42826. /**
  42827. * Sets Camera field of view used by the Vignette effect.
  42828. */
  42829. set vignetteCameraFov(value: number);
  42830. /**
  42831. * Gets the vignette blend mode allowing different kind of effect.
  42832. */
  42833. get vignetteBlendMode(): number;
  42834. /**
  42835. * Sets the vignette blend mode allowing different kind of effect.
  42836. */
  42837. set vignetteBlendMode(value: number);
  42838. /**
  42839. * Gets wether the vignette effect is enabled.
  42840. */
  42841. get vignetteEnabled(): boolean;
  42842. /**
  42843. * Sets wether the vignette effect is enabled.
  42844. */
  42845. set vignetteEnabled(value: boolean);
  42846. private _fromLinearSpace;
  42847. /**
  42848. * Gets wether the input of the processing is in Gamma or Linear Space.
  42849. */
  42850. get fromLinearSpace(): boolean;
  42851. /**
  42852. * Sets wether the input of the processing is in Gamma or Linear Space.
  42853. */
  42854. set fromLinearSpace(value: boolean);
  42855. /**
  42856. * Defines cache preventing GC.
  42857. */
  42858. private _defines;
  42859. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42860. /**
  42861. * "ImageProcessingPostProcess"
  42862. * @returns "ImageProcessingPostProcess"
  42863. */
  42864. getClassName(): string;
  42865. protected _updateParameters(): void;
  42866. dispose(camera?: Camera): void;
  42867. }
  42868. }
  42869. declare module BABYLON {
  42870. /**
  42871. * Class containing static functions to help procedurally build meshes
  42872. */
  42873. export class GroundBuilder {
  42874. /**
  42875. * Creates a ground mesh
  42876. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42877. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42879. * @param name defines the name of the mesh
  42880. * @param options defines the options used to create the mesh
  42881. * @param scene defines the hosting scene
  42882. * @returns the ground mesh
  42883. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42884. */
  42885. static CreateGround(name: string, options: {
  42886. width?: number;
  42887. height?: number;
  42888. subdivisions?: number;
  42889. subdivisionsX?: number;
  42890. subdivisionsY?: number;
  42891. updatable?: boolean;
  42892. }, scene: any): Mesh;
  42893. /**
  42894. * Creates a tiled ground mesh
  42895. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42896. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42897. * * 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
  42898. * * 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
  42899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42900. * @param name defines the name of the mesh
  42901. * @param options defines the options used to create the mesh
  42902. * @param scene defines the hosting scene
  42903. * @returns the tiled ground mesh
  42904. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42905. */
  42906. static CreateTiledGround(name: string, options: {
  42907. xmin: number;
  42908. zmin: number;
  42909. xmax: number;
  42910. zmax: number;
  42911. subdivisions?: {
  42912. w: number;
  42913. h: number;
  42914. };
  42915. precision?: {
  42916. w: number;
  42917. h: number;
  42918. };
  42919. updatable?: boolean;
  42920. }, scene?: Nullable<Scene>): Mesh;
  42921. /**
  42922. * Creates a ground mesh from a height map
  42923. * * The parameter `url` sets the URL of the height map image resource.
  42924. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42925. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42926. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42927. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42928. * * 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.
  42929. * * 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).
  42930. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42932. * @param name defines the name of the mesh
  42933. * @param url defines the url to the height map
  42934. * @param options defines the options used to create the mesh
  42935. * @param scene defines the hosting scene
  42936. * @returns the ground mesh
  42937. * @see https://doc.babylonjs.com/babylon101/height_map
  42938. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42939. */
  42940. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42941. width?: number;
  42942. height?: number;
  42943. subdivisions?: number;
  42944. minHeight?: number;
  42945. maxHeight?: number;
  42946. colorFilter?: Color3;
  42947. alphaFilter?: number;
  42948. updatable?: boolean;
  42949. onReady?: (mesh: GroundMesh) => void;
  42950. }, scene?: Nullable<Scene>): GroundMesh;
  42951. }
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Class containing static functions to help procedurally build meshes
  42956. */
  42957. export class TorusBuilder {
  42958. /**
  42959. * Creates a torus mesh
  42960. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42961. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42962. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42964. * * 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
  42965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42966. * @param name defines the name of the mesh
  42967. * @param options defines the options used to create the mesh
  42968. * @param scene defines the hosting scene
  42969. * @returns the torus mesh
  42970. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42971. */
  42972. static CreateTorus(name: string, options: {
  42973. diameter?: number;
  42974. thickness?: number;
  42975. tessellation?: number;
  42976. updatable?: boolean;
  42977. sideOrientation?: number;
  42978. frontUVs?: Vector4;
  42979. backUVs?: Vector4;
  42980. }, scene: any): Mesh;
  42981. }
  42982. }
  42983. declare module BABYLON {
  42984. /**
  42985. * Class containing static functions to help procedurally build meshes
  42986. */
  42987. export class CylinderBuilder {
  42988. /**
  42989. * Creates a cylinder or a cone mesh
  42990. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42991. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42992. * * 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.
  42993. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42994. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42995. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42996. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42997. * * 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).
  42998. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42999. * * 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).
  43000. * * 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
  43001. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43002. * * 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
  43003. * * 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.
  43004. * * If `enclose` is false, a ring surface is one element.
  43005. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43006. * * 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
  43007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43008. * * 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
  43009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43010. * @param name defines the name of the mesh
  43011. * @param options defines the options used to create the mesh
  43012. * @param scene defines the hosting scene
  43013. * @returns the cylinder mesh
  43014. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43015. */
  43016. static CreateCylinder(name: string, options: {
  43017. height?: number;
  43018. diameterTop?: number;
  43019. diameterBottom?: number;
  43020. diameter?: number;
  43021. tessellation?: number;
  43022. subdivisions?: number;
  43023. arc?: number;
  43024. faceColors?: Color4[];
  43025. faceUV?: Vector4[];
  43026. updatable?: boolean;
  43027. hasRings?: boolean;
  43028. enclose?: boolean;
  43029. cap?: number;
  43030. sideOrientation?: number;
  43031. frontUVs?: Vector4;
  43032. backUVs?: Vector4;
  43033. }, scene: any): Mesh;
  43034. }
  43035. }
  43036. declare module BABYLON {
  43037. /**
  43038. * States of the webXR experience
  43039. */
  43040. export enum WebXRState {
  43041. /**
  43042. * Transitioning to being in XR mode
  43043. */
  43044. ENTERING_XR = 0,
  43045. /**
  43046. * Transitioning to non XR mode
  43047. */
  43048. EXITING_XR = 1,
  43049. /**
  43050. * In XR mode and presenting
  43051. */
  43052. IN_XR = 2,
  43053. /**
  43054. * Not entered XR mode
  43055. */
  43056. NOT_IN_XR = 3
  43057. }
  43058. /**
  43059. * Abstraction of the XR render target
  43060. */
  43061. export interface WebXRRenderTarget extends IDisposable {
  43062. /**
  43063. * xrpresent context of the canvas which can be used to display/mirror xr content
  43064. */
  43065. canvasContext: WebGLRenderingContext;
  43066. /**
  43067. * xr layer for the canvas
  43068. */
  43069. xrLayer: Nullable<XRWebGLLayer>;
  43070. /**
  43071. * Initializes the xr layer for the session
  43072. * @param xrSession xr session
  43073. * @returns a promise that will resolve once the XR Layer has been created
  43074. */
  43075. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43076. }
  43077. }
  43078. declare module BABYLON {
  43079. /**
  43080. * COnfiguration object for WebXR output canvas
  43081. */
  43082. export class WebXRManagedOutputCanvasOptions {
  43083. /**
  43084. * An optional canvas in case you wish to create it yourself and provide it here.
  43085. * If not provided, a new canvas will be created
  43086. */
  43087. canvasElement?: HTMLCanvasElement;
  43088. /**
  43089. * Options for this XR Layer output
  43090. */
  43091. canvasOptions?: XRWebGLLayerOptions;
  43092. /**
  43093. * CSS styling for a newly created canvas (if not provided)
  43094. */
  43095. newCanvasCssStyle?: string;
  43096. /**
  43097. * Get the default values of the configuration object
  43098. * @returns default values of this configuration object
  43099. */
  43100. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43101. }
  43102. /**
  43103. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43104. */
  43105. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43106. private _options;
  43107. private _canvas;
  43108. private _engine;
  43109. /**
  43110. * Rendering context of the canvas which can be used to display/mirror xr content
  43111. */
  43112. canvasContext: WebGLRenderingContext;
  43113. /**
  43114. * xr layer for the canvas
  43115. */
  43116. xrLayer: Nullable<XRWebGLLayer>;
  43117. /**
  43118. * Initializes the canvas to be added/removed upon entering/exiting xr
  43119. * @param _xrSessionManager The XR Session manager
  43120. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43121. */
  43122. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43123. /**
  43124. * Disposes of the object
  43125. */
  43126. dispose(): void;
  43127. /**
  43128. * Initializes the xr layer for the session
  43129. * @param xrSession xr session
  43130. * @returns a promise that will resolve once the XR Layer has been created
  43131. */
  43132. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43133. private _addCanvas;
  43134. private _removeCanvas;
  43135. private _setManagedOutputCanvas;
  43136. }
  43137. }
  43138. declare module BABYLON {
  43139. /**
  43140. * Manages an XRSession to work with Babylon's engine
  43141. * @see https://doc.babylonjs.com/how_to/webxr
  43142. */
  43143. export class WebXRSessionManager implements IDisposable {
  43144. /** The scene which the session should be created for */
  43145. scene: Scene;
  43146. private _referenceSpace;
  43147. private _rttProvider;
  43148. private _sessionEnded;
  43149. private _xrNavigator;
  43150. private baseLayer;
  43151. /**
  43152. * The base reference space from which the session started. good if you want to reset your
  43153. * reference space
  43154. */
  43155. baseReferenceSpace: XRReferenceSpace;
  43156. /**
  43157. * Current XR frame
  43158. */
  43159. currentFrame: Nullable<XRFrame>;
  43160. /** WebXR timestamp updated every frame */
  43161. currentTimestamp: number;
  43162. /**
  43163. * Used just in case of a failure to initialize an immersive session.
  43164. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43165. */
  43166. defaultHeightCompensation: number;
  43167. /**
  43168. * Fires every time a new xrFrame arrives which can be used to update the camera
  43169. */
  43170. onXRFrameObservable: Observable<XRFrame>;
  43171. /**
  43172. * Fires when the reference space changed
  43173. */
  43174. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43175. /**
  43176. * Fires when the xr session is ended either by the device or manually done
  43177. */
  43178. onXRSessionEnded: Observable<any>;
  43179. /**
  43180. * Fires when the xr session is ended either by the device or manually done
  43181. */
  43182. onXRSessionInit: Observable<XRSession>;
  43183. /**
  43184. * Underlying xr session
  43185. */
  43186. session: XRSession;
  43187. /**
  43188. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43189. * or get the offset the player is currently at.
  43190. */
  43191. viewerReferenceSpace: XRReferenceSpace;
  43192. /**
  43193. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43194. * @param scene The scene which the session should be created for
  43195. */
  43196. constructor(
  43197. /** The scene which the session should be created for */
  43198. scene: Scene);
  43199. /**
  43200. * The current reference space used in this session. This reference space can constantly change!
  43201. * It is mainly used to offset the camera's position.
  43202. */
  43203. get referenceSpace(): XRReferenceSpace;
  43204. /**
  43205. * Set a new reference space and triggers the observable
  43206. */
  43207. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43208. /**
  43209. * Disposes of the session manager
  43210. */
  43211. dispose(): void;
  43212. /**
  43213. * Stops the xrSession and restores the render loop
  43214. * @returns Promise which resolves after it exits XR
  43215. */
  43216. exitXRAsync(): Promise<void>;
  43217. /**
  43218. * Gets the correct render target texture to be rendered this frame for this eye
  43219. * @param eye the eye for which to get the render target
  43220. * @returns the render target for the specified eye
  43221. */
  43222. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43223. /**
  43224. * Creates a WebXRRenderTarget object for the XR session
  43225. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43226. * @param options optional options to provide when creating a new render target
  43227. * @returns a WebXR render target to which the session can render
  43228. */
  43229. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43230. /**
  43231. * Initializes the manager
  43232. * After initialization enterXR can be called to start an XR session
  43233. * @returns Promise which resolves after it is initialized
  43234. */
  43235. initializeAsync(): Promise<void>;
  43236. /**
  43237. * Initializes an xr session
  43238. * @param xrSessionMode mode to initialize
  43239. * @param xrSessionInit defines optional and required values to pass to the session builder
  43240. * @returns a promise which will resolve once the session has been initialized
  43241. */
  43242. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43243. /**
  43244. * Checks if a session would be supported for the creation options specified
  43245. * @param sessionMode session mode to check if supported eg. immersive-vr
  43246. * @returns A Promise that resolves to true if supported and false if not
  43247. */
  43248. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43249. /**
  43250. * Resets the reference space to the one started the session
  43251. */
  43252. resetReferenceSpace(): void;
  43253. /**
  43254. * Starts rendering to the xr layer
  43255. */
  43256. runXRRenderLoop(): void;
  43257. /**
  43258. * Sets the reference space on the xr session
  43259. * @param referenceSpaceType space to set
  43260. * @returns a promise that will resolve once the reference space has been set
  43261. */
  43262. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43263. /**
  43264. * Updates the render state of the session
  43265. * @param state state to set
  43266. * @returns a promise that resolves once the render state has been updated
  43267. */
  43268. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43269. /**
  43270. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43271. * @param sessionMode defines the session to test
  43272. * @returns a promise with boolean as final value
  43273. */
  43274. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43275. private _createRenderTargetTexture;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * WebXR Camera which holds the views for the xrSession
  43281. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43282. */
  43283. export class WebXRCamera extends FreeCamera {
  43284. private _xrSessionManager;
  43285. private _firstFrame;
  43286. private _referenceQuaternion;
  43287. private _referencedPosition;
  43288. private _xrInvPositionCache;
  43289. private _xrInvQuaternionCache;
  43290. /**
  43291. * Should position compensation execute on first frame.
  43292. * This is used when copying the position from a native (non XR) camera
  43293. */
  43294. compensateOnFirstFrame: boolean;
  43295. /**
  43296. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43297. * @param name the name of the camera
  43298. * @param scene the scene to add the camera to
  43299. * @param _xrSessionManager a constructed xr session manager
  43300. */
  43301. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43302. /**
  43303. * Return the user's height, unrelated to the current ground.
  43304. * This will be the y position of this camera, when ground level is 0.
  43305. */
  43306. get realWorldHeight(): number;
  43307. /** @hidden */
  43308. _updateForDualEyeDebugging(): void;
  43309. /**
  43310. * Sets this camera's transformation based on a non-vr camera
  43311. * @param otherCamera the non-vr camera to copy the transformation from
  43312. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43313. */
  43314. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43315. /**
  43316. * Gets the current instance class name ("WebXRCamera").
  43317. * @returns the class name
  43318. */
  43319. getClassName(): string;
  43320. private _updateFromXRSession;
  43321. private _updateNumberOfRigCameras;
  43322. private _updateReferenceSpace;
  43323. private _updateReferenceSpaceOffset;
  43324. }
  43325. }
  43326. declare module BABYLON {
  43327. /**
  43328. * Defining the interface required for a (webxr) feature
  43329. */
  43330. export interface IWebXRFeature extends IDisposable {
  43331. /**
  43332. * Is this feature attached
  43333. */
  43334. attached: boolean;
  43335. /**
  43336. * Should auto-attach be disabled?
  43337. */
  43338. disableAutoAttach: boolean;
  43339. /**
  43340. * Attach the feature to the session
  43341. * Will usually be called by the features manager
  43342. *
  43343. * @param force should attachment be forced (even when already attached)
  43344. * @returns true if successful.
  43345. */
  43346. attach(force?: boolean): boolean;
  43347. /**
  43348. * Detach the feature from the session
  43349. * Will usually be called by the features manager
  43350. *
  43351. * @returns true if successful.
  43352. */
  43353. detach(): boolean;
  43354. }
  43355. /**
  43356. * A list of the currently available features without referencing them
  43357. */
  43358. export class WebXRFeatureName {
  43359. /**
  43360. * The name of the anchor system feature
  43361. */
  43362. static ANCHOR_SYSTEM: string;
  43363. /**
  43364. * The name of the background remover feature
  43365. */
  43366. static BACKGROUND_REMOVER: string;
  43367. /**
  43368. * The name of the hit test feature
  43369. */
  43370. static HIT_TEST: string;
  43371. /**
  43372. * physics impostors for xr controllers feature
  43373. */
  43374. static PHYSICS_CONTROLLERS: string;
  43375. /**
  43376. * The name of the plane detection feature
  43377. */
  43378. static PLANE_DETECTION: string;
  43379. /**
  43380. * The name of the pointer selection feature
  43381. */
  43382. static POINTER_SELECTION: string;
  43383. /**
  43384. * The name of the teleportation feature
  43385. */
  43386. static TELEPORTATION: string;
  43387. }
  43388. /**
  43389. * Defining the constructor of a feature. Used to register the modules.
  43390. */
  43391. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43392. /**
  43393. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43394. * It is mainly used in AR sessions.
  43395. *
  43396. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43397. */
  43398. export class WebXRFeaturesManager implements IDisposable {
  43399. private _xrSessionManager;
  43400. private static readonly _AvailableFeatures;
  43401. private _features;
  43402. /**
  43403. * constructs a new features manages.
  43404. *
  43405. * @param _xrSessionManager an instance of WebXRSessionManager
  43406. */
  43407. constructor(_xrSessionManager: WebXRSessionManager);
  43408. /**
  43409. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43410. * Mainly used internally.
  43411. *
  43412. * @param featureName the name of the feature to register
  43413. * @param constructorFunction the function used to construct the module
  43414. * @param version the (babylon) version of the module
  43415. * @param stable is that a stable version of this module
  43416. */
  43417. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43418. /**
  43419. * Returns a constructor of a specific feature.
  43420. *
  43421. * @param featureName the name of the feature to construct
  43422. * @param version the version of the feature to load
  43423. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43424. * @param options optional options provided to the module.
  43425. * @returns a function that, when called, will return a new instance of this feature
  43426. */
  43427. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43428. /**
  43429. * Can be used to return the list of features currently registered
  43430. *
  43431. * @returns an Array of available features
  43432. */
  43433. static GetAvailableFeatures(): string[];
  43434. /**
  43435. * Gets the versions available for a specific feature
  43436. * @param featureName the name of the feature
  43437. * @returns an array with the available versions
  43438. */
  43439. static GetAvailableVersions(featureName: string): string[];
  43440. /**
  43441. * Return the latest unstable version of this feature
  43442. * @param featureName the name of the feature to search
  43443. * @returns the version number. if not found will return -1
  43444. */
  43445. static GetLatestVersionOfFeature(featureName: string): number;
  43446. /**
  43447. * Return the latest stable version of this feature
  43448. * @param featureName the name of the feature to search
  43449. * @returns the version number. if not found will return -1
  43450. */
  43451. static GetStableVersionOfFeature(featureName: string): number;
  43452. /**
  43453. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43454. * Can be used during a session to start a feature
  43455. * @param featureName the name of feature to attach
  43456. */
  43457. attachFeature(featureName: string): void;
  43458. /**
  43459. * Can be used inside a session or when the session ends to detach a specific feature
  43460. * @param featureName the name of the feature to detach
  43461. */
  43462. detachFeature(featureName: string): void;
  43463. /**
  43464. * Used to disable an already-enabled feature
  43465. * The feature will be disposed and will be recreated once enabled.
  43466. * @param featureName the feature to disable
  43467. * @returns true if disable was successful
  43468. */
  43469. disableFeature(featureName: string | {
  43470. Name: string;
  43471. }): boolean;
  43472. /**
  43473. * dispose this features manager
  43474. */
  43475. dispose(): void;
  43476. /**
  43477. * 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.
  43478. * 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.
  43479. *
  43480. * @param featureName the name of the feature to load or the class of the feature
  43481. * @param version optional version to load. if not provided the latest version will be enabled
  43482. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43483. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43484. * @returns a new constructed feature or throws an error if feature not found.
  43485. */
  43486. enableFeature(featureName: string | {
  43487. Name: string;
  43488. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43489. /**
  43490. * get the implementation of an enabled feature.
  43491. * @param featureName the name of the feature to load
  43492. * @returns the feature class, if found
  43493. */
  43494. getEnabledFeature(featureName: string): IWebXRFeature;
  43495. /**
  43496. * Get the list of enabled features
  43497. * @returns an array of enabled features
  43498. */
  43499. getEnabledFeatures(): string[];
  43500. }
  43501. }
  43502. declare module BABYLON {
  43503. /**
  43504. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43505. * @see https://doc.babylonjs.com/how_to/webxr
  43506. */
  43507. export class WebXRExperienceHelper implements IDisposable {
  43508. private scene;
  43509. private _nonVRCamera;
  43510. private _originalSceneAutoClear;
  43511. private _supported;
  43512. /**
  43513. * Camera used to render xr content
  43514. */
  43515. camera: WebXRCamera;
  43516. /** A features manager for this xr session */
  43517. featuresManager: WebXRFeaturesManager;
  43518. /**
  43519. * Observers registered here will be triggered after the camera's initial transformation is set
  43520. * This can be used to set a different ground level or an extra rotation.
  43521. *
  43522. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43523. * to the position set after this observable is done executing.
  43524. */
  43525. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43526. /**
  43527. * Fires when the state of the experience helper has changed
  43528. */
  43529. onStateChangedObservable: Observable<WebXRState>;
  43530. /** Session manager used to keep track of xr session */
  43531. sessionManager: WebXRSessionManager;
  43532. /**
  43533. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43534. */
  43535. state: WebXRState;
  43536. /**
  43537. * Creates a WebXRExperienceHelper
  43538. * @param scene The scene the helper should be created in
  43539. */
  43540. private constructor();
  43541. /**
  43542. * Creates the experience helper
  43543. * @param scene the scene to attach the experience helper to
  43544. * @returns a promise for the experience helper
  43545. */
  43546. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43547. /**
  43548. * Disposes of the experience helper
  43549. */
  43550. dispose(): void;
  43551. /**
  43552. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43553. * @param sessionMode options for the XR session
  43554. * @param referenceSpaceType frame of reference of the XR session
  43555. * @param renderTarget the output canvas that will be used to enter XR mode
  43556. * @returns promise that resolves after xr mode has entered
  43557. */
  43558. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43559. /**
  43560. * Exits XR mode and returns the scene to its original state
  43561. * @returns promise that resolves after xr mode has exited
  43562. */
  43563. exitXRAsync(): Promise<void>;
  43564. private _nonXRToXRCamera;
  43565. private _setState;
  43566. }
  43567. }
  43568. declare module BABYLON {
  43569. /**
  43570. * X-Y values for axes in WebXR
  43571. */
  43572. export interface IWebXRMotionControllerAxesValue {
  43573. /**
  43574. * The value of the x axis
  43575. */
  43576. x: number;
  43577. /**
  43578. * The value of the y-axis
  43579. */
  43580. y: number;
  43581. }
  43582. /**
  43583. * changed / previous values for the values of this component
  43584. */
  43585. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43586. /**
  43587. * current (this frame) value
  43588. */
  43589. current: T;
  43590. /**
  43591. * previous (last change) value
  43592. */
  43593. previous: T;
  43594. }
  43595. /**
  43596. * Represents changes in the component between current frame and last values recorded
  43597. */
  43598. export interface IWebXRMotionControllerComponentChanges {
  43599. /**
  43600. * will be populated with previous and current values if axes changed
  43601. */
  43602. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43603. /**
  43604. * will be populated with previous and current values if pressed changed
  43605. */
  43606. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43607. /**
  43608. * will be populated with previous and current values if touched changed
  43609. */
  43610. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43611. /**
  43612. * will be populated with previous and current values if value changed
  43613. */
  43614. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43615. }
  43616. /**
  43617. * This class represents a single component (for example button or thumbstick) of a motion controller
  43618. */
  43619. export class WebXRControllerComponent implements IDisposable {
  43620. /**
  43621. * the id of this component
  43622. */
  43623. id: string;
  43624. /**
  43625. * the type of the component
  43626. */
  43627. type: MotionControllerComponentType;
  43628. private _buttonIndex;
  43629. private _axesIndices;
  43630. private _axes;
  43631. private _changes;
  43632. private _currentValue;
  43633. private _hasChanges;
  43634. private _pressed;
  43635. private _touched;
  43636. /**
  43637. * button component type
  43638. */
  43639. static BUTTON_TYPE: MotionControllerComponentType;
  43640. /**
  43641. * squeeze component type
  43642. */
  43643. static SQUEEZE_TYPE: MotionControllerComponentType;
  43644. /**
  43645. * Thumbstick component type
  43646. */
  43647. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43648. /**
  43649. * Touchpad component type
  43650. */
  43651. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43652. /**
  43653. * trigger component type
  43654. */
  43655. static TRIGGER_TYPE: MotionControllerComponentType;
  43656. /**
  43657. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43658. * the axes data changes
  43659. */
  43660. onAxisValueChangedObservable: Observable<{
  43661. x: number;
  43662. y: number;
  43663. }>;
  43664. /**
  43665. * Observers registered here will be triggered when the state of a button changes
  43666. * State change is either pressed / touched / value
  43667. */
  43668. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43669. /**
  43670. * Creates a new component for a motion controller.
  43671. * It is created by the motion controller itself
  43672. *
  43673. * @param id the id of this component
  43674. * @param type the type of the component
  43675. * @param _buttonIndex index in the buttons array of the gamepad
  43676. * @param _axesIndices indices of the values in the axes array of the gamepad
  43677. */
  43678. constructor(
  43679. /**
  43680. * the id of this component
  43681. */
  43682. id: string,
  43683. /**
  43684. * the type of the component
  43685. */
  43686. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43687. /**
  43688. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43689. */
  43690. get axes(): IWebXRMotionControllerAxesValue;
  43691. /**
  43692. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43693. */
  43694. get changes(): IWebXRMotionControllerComponentChanges;
  43695. /**
  43696. * Return whether or not the component changed the last frame
  43697. */
  43698. get hasChanges(): boolean;
  43699. /**
  43700. * is the button currently pressed
  43701. */
  43702. get pressed(): boolean;
  43703. /**
  43704. * is the button currently touched
  43705. */
  43706. get touched(): boolean;
  43707. /**
  43708. * Get the current value of this component
  43709. */
  43710. get value(): number;
  43711. /**
  43712. * Dispose this component
  43713. */
  43714. dispose(): void;
  43715. /**
  43716. * Are there axes correlating to this component
  43717. * @return true is axes data is available
  43718. */
  43719. isAxes(): boolean;
  43720. /**
  43721. * Is this component a button (hence - pressable)
  43722. * @returns true if can be pressed
  43723. */
  43724. isButton(): boolean;
  43725. /**
  43726. * update this component using the gamepad object it is in. Called on every frame
  43727. * @param nativeController the native gamepad controller object
  43728. */
  43729. update(nativeController: IMinimalMotionControllerObject): void;
  43730. }
  43731. }
  43732. declare module BABYLON {
  43733. /**
  43734. * Class used to represent data loading progression
  43735. */
  43736. export class SceneLoaderProgressEvent {
  43737. /** defines if data length to load can be evaluated */
  43738. readonly lengthComputable: boolean;
  43739. /** defines the loaded data length */
  43740. readonly loaded: number;
  43741. /** defines the data length to load */
  43742. readonly total: number;
  43743. /**
  43744. * Create a new progress event
  43745. * @param lengthComputable defines if data length to load can be evaluated
  43746. * @param loaded defines the loaded data length
  43747. * @param total defines the data length to load
  43748. */
  43749. constructor(
  43750. /** defines if data length to load can be evaluated */
  43751. lengthComputable: boolean,
  43752. /** defines the loaded data length */
  43753. loaded: number,
  43754. /** defines the data length to load */
  43755. total: number);
  43756. /**
  43757. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43758. * @param event defines the source event
  43759. * @returns a new SceneLoaderProgressEvent
  43760. */
  43761. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43762. }
  43763. /**
  43764. * Interface used by SceneLoader plugins to define supported file extensions
  43765. */
  43766. export interface ISceneLoaderPluginExtensions {
  43767. /**
  43768. * Defines the list of supported extensions
  43769. */
  43770. [extension: string]: {
  43771. isBinary: boolean;
  43772. };
  43773. }
  43774. /**
  43775. * Interface used by SceneLoader plugin factory
  43776. */
  43777. export interface ISceneLoaderPluginFactory {
  43778. /**
  43779. * Defines the name of the factory
  43780. */
  43781. name: string;
  43782. /**
  43783. * Function called to create a new plugin
  43784. * @return the new plugin
  43785. */
  43786. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43787. /**
  43788. * The callback that returns true if the data can be directly loaded.
  43789. * @param data string containing the file data
  43790. * @returns if the data can be loaded directly
  43791. */
  43792. canDirectLoad?(data: string): boolean;
  43793. }
  43794. /**
  43795. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43796. */
  43797. export interface ISceneLoaderPluginBase {
  43798. /**
  43799. * The friendly name of this plugin.
  43800. */
  43801. name: string;
  43802. /**
  43803. * The file extensions supported by this plugin.
  43804. */
  43805. extensions: string | ISceneLoaderPluginExtensions;
  43806. /**
  43807. * The callback called when loading from a url.
  43808. * @param scene scene loading this url
  43809. * @param url url to load
  43810. * @param onSuccess callback called when the file successfully loads
  43811. * @param onProgress callback called while file is loading (if the server supports this mode)
  43812. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43813. * @param onError callback called when the file fails to load
  43814. * @returns a file request object
  43815. */
  43816. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43817. /**
  43818. * The callback called when loading from a file object.
  43819. * @param scene scene loading this file
  43820. * @param file defines the file to load
  43821. * @param onSuccess defines the callback to call when data is loaded
  43822. * @param onProgress defines the callback to call during loading process
  43823. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43824. * @param onError defines the callback to call when an error occurs
  43825. * @returns a file request object
  43826. */
  43827. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43828. /**
  43829. * The callback that returns true if the data can be directly loaded.
  43830. * @param data string containing the file data
  43831. * @returns if the data can be loaded directly
  43832. */
  43833. canDirectLoad?(data: string): boolean;
  43834. /**
  43835. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43836. * @param scene scene loading this data
  43837. * @param data string containing the data
  43838. * @returns data to pass to the plugin
  43839. */
  43840. directLoad?(scene: Scene, data: string): any;
  43841. /**
  43842. * The callback that allows custom handling of the root url based on the response url.
  43843. * @param rootUrl the original root url
  43844. * @param responseURL the response url if available
  43845. * @returns the new root url
  43846. */
  43847. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43848. }
  43849. /**
  43850. * Interface used to define a SceneLoader plugin
  43851. */
  43852. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43853. /**
  43854. * Import meshes into a scene.
  43855. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43856. * @param scene The scene to import into
  43857. * @param data The data to import
  43858. * @param rootUrl The root url for scene and resources
  43859. * @param meshes The meshes array to import into
  43860. * @param particleSystems The particle systems array to import into
  43861. * @param skeletons The skeletons array to import into
  43862. * @param onError The callback when import fails
  43863. * @returns True if successful or false otherwise
  43864. */
  43865. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43866. /**
  43867. * Load into a scene.
  43868. * @param scene The scene to load into
  43869. * @param data The data to import
  43870. * @param rootUrl The root url for scene and resources
  43871. * @param onError The callback when import fails
  43872. * @returns True if successful or false otherwise
  43873. */
  43874. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43875. /**
  43876. * Load into an asset container.
  43877. * @param scene The scene to load into
  43878. * @param data The data to import
  43879. * @param rootUrl The root url for scene and resources
  43880. * @param onError The callback when import fails
  43881. * @returns The loaded asset container
  43882. */
  43883. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43884. }
  43885. /**
  43886. * Interface used to define an async SceneLoader plugin
  43887. */
  43888. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43889. /**
  43890. * Import meshes into a scene.
  43891. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43892. * @param scene The scene to import into
  43893. * @param data The data to import
  43894. * @param rootUrl The root url for scene and resources
  43895. * @param onProgress The callback when the load progresses
  43896. * @param fileName Defines the name of the file to load
  43897. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43898. */
  43899. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43900. meshes: AbstractMesh[];
  43901. particleSystems: IParticleSystem[];
  43902. skeletons: Skeleton[];
  43903. animationGroups: AnimationGroup[];
  43904. }>;
  43905. /**
  43906. * Load into a scene.
  43907. * @param scene The scene to load into
  43908. * @param data The data to import
  43909. * @param rootUrl The root url for scene and resources
  43910. * @param onProgress The callback when the load progresses
  43911. * @param fileName Defines the name of the file to load
  43912. * @returns Nothing
  43913. */
  43914. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43915. /**
  43916. * Load into an asset container.
  43917. * @param scene The scene to load into
  43918. * @param data The data to import
  43919. * @param rootUrl The root url for scene and resources
  43920. * @param onProgress The callback when the load progresses
  43921. * @param fileName Defines the name of the file to load
  43922. * @returns The loaded asset container
  43923. */
  43924. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43925. }
  43926. /**
  43927. * Mode that determines how to handle old animation groups before loading new ones.
  43928. */
  43929. export enum SceneLoaderAnimationGroupLoadingMode {
  43930. /**
  43931. * Reset all old animations to initial state then dispose them.
  43932. */
  43933. Clean = 0,
  43934. /**
  43935. * Stop all old animations.
  43936. */
  43937. Stop = 1,
  43938. /**
  43939. * Restart old animations from first frame.
  43940. */
  43941. Sync = 2,
  43942. /**
  43943. * Old animations remains untouched.
  43944. */
  43945. NoSync = 3
  43946. }
  43947. /**
  43948. * Class used to load scene from various file formats using registered plugins
  43949. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43950. */
  43951. export class SceneLoader {
  43952. /**
  43953. * No logging while loading
  43954. */
  43955. static readonly NO_LOGGING: number;
  43956. /**
  43957. * Minimal logging while loading
  43958. */
  43959. static readonly MINIMAL_LOGGING: number;
  43960. /**
  43961. * Summary logging while loading
  43962. */
  43963. static readonly SUMMARY_LOGGING: number;
  43964. /**
  43965. * Detailled logging while loading
  43966. */
  43967. static readonly DETAILED_LOGGING: number;
  43968. /**
  43969. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43970. */
  43971. static get ForceFullSceneLoadingForIncremental(): boolean;
  43972. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43973. /**
  43974. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43975. */
  43976. static get ShowLoadingScreen(): boolean;
  43977. static set ShowLoadingScreen(value: boolean);
  43978. /**
  43979. * Defines the current logging level (while loading the scene)
  43980. * @ignorenaming
  43981. */
  43982. static get loggingLevel(): number;
  43983. static set loggingLevel(value: number);
  43984. /**
  43985. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43986. */
  43987. static get CleanBoneMatrixWeights(): boolean;
  43988. static set CleanBoneMatrixWeights(value: boolean);
  43989. /**
  43990. * Event raised when a plugin is used to load a scene
  43991. */
  43992. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43993. private static _registeredPlugins;
  43994. private static _getDefaultPlugin;
  43995. private static _getPluginForExtension;
  43996. private static _getPluginForDirectLoad;
  43997. private static _getPluginForFilename;
  43998. private static _getDirectLoad;
  43999. private static _loadData;
  44000. private static _getFileInfo;
  44001. /**
  44002. * Gets a plugin that can load the given extension
  44003. * @param extension defines the extension to load
  44004. * @returns a plugin or null if none works
  44005. */
  44006. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44007. /**
  44008. * Gets a boolean indicating that the given extension can be loaded
  44009. * @param extension defines the extension to load
  44010. * @returns true if the extension is supported
  44011. */
  44012. static IsPluginForExtensionAvailable(extension: string): boolean;
  44013. /**
  44014. * Adds a new plugin to the list of registered plugins
  44015. * @param plugin defines the plugin to add
  44016. */
  44017. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44018. /**
  44019. * Import meshes into a scene
  44020. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44021. * @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)
  44022. * @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)
  44023. * @param scene the instance of BABYLON.Scene to append to
  44024. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44025. * @param onProgress a callback with a progress event for each file being loaded
  44026. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44027. * @param pluginExtension the extension used to determine the plugin
  44028. * @returns The loaded plugin
  44029. */
  44030. 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>;
  44031. /**
  44032. * Import meshes into a scene
  44033. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44034. * @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)
  44035. * @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)
  44036. * @param scene the instance of BABYLON.Scene to append to
  44037. * @param onProgress a callback with a progress event for each file being loaded
  44038. * @param pluginExtension the extension used to determine the plugin
  44039. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44040. */
  44041. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44042. meshes: AbstractMesh[];
  44043. particleSystems: IParticleSystem[];
  44044. skeletons: Skeleton[];
  44045. animationGroups: AnimationGroup[];
  44046. }>;
  44047. /**
  44048. * Load a scene
  44049. * @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)
  44050. * @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)
  44051. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44052. * @param onSuccess a callback with the scene when import succeeds
  44053. * @param onProgress a callback with a progress event for each file being loaded
  44054. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44055. * @param pluginExtension the extension used to determine the plugin
  44056. * @returns The loaded plugin
  44057. */
  44058. 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>;
  44059. /**
  44060. * Load a scene
  44061. * @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)
  44062. * @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)
  44063. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44064. * @param onProgress a callback with a progress event for each file being loaded
  44065. * @param pluginExtension the extension used to determine the plugin
  44066. * @returns The loaded scene
  44067. */
  44068. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44069. /**
  44070. * Append a scene
  44071. * @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)
  44072. * @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)
  44073. * @param scene is the instance of BABYLON.Scene to append to
  44074. * @param onSuccess a callback with the scene when import succeeds
  44075. * @param onProgress a callback with a progress event for each file being loaded
  44076. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44077. * @param pluginExtension the extension used to determine the plugin
  44078. * @returns The loaded plugin
  44079. */
  44080. 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>;
  44081. /**
  44082. * Append a scene
  44083. * @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)
  44084. * @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)
  44085. * @param scene is the instance of BABYLON.Scene to append to
  44086. * @param onProgress a callback with a progress event for each file being loaded
  44087. * @param pluginExtension the extension used to determine the plugin
  44088. * @returns The given scene
  44089. */
  44090. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44091. /**
  44092. * Load a scene into an asset container
  44093. * @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)
  44094. * @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)
  44095. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44096. * @param onSuccess a callback with the scene when import succeeds
  44097. * @param onProgress a callback with a progress event for each file being loaded
  44098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44099. * @param pluginExtension the extension used to determine the plugin
  44100. * @returns The loaded plugin
  44101. */
  44102. 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>;
  44103. /**
  44104. * Load a scene into an asset container
  44105. * @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)
  44106. * @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)
  44107. * @param scene is the instance of Scene to append to
  44108. * @param onProgress a callback with a progress event for each file being loaded
  44109. * @param pluginExtension the extension used to determine the plugin
  44110. * @returns The loaded asset container
  44111. */
  44112. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44113. /**
  44114. * Import animations from a file into a scene
  44115. * @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)
  44116. * @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)
  44117. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44118. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44119. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44120. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44121. * @param onSuccess a callback with the scene when import succeeds
  44122. * @param onProgress a callback with a progress event for each file being loaded
  44123. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44124. */
  44125. 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;
  44126. /**
  44127. * Import animations from a file into a scene
  44128. * @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)
  44129. * @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)
  44130. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44131. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44132. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44133. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44134. * @param onSuccess a callback with the scene when import succeeds
  44135. * @param onProgress a callback with a progress event for each file being loaded
  44136. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44137. * @returns the updated scene with imported animations
  44138. */
  44139. 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>;
  44140. }
  44141. }
  44142. declare module BABYLON {
  44143. /**
  44144. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44145. */
  44146. export type MotionControllerHandedness = "none" | "left" | "right";
  44147. /**
  44148. * The type of components available in motion controllers.
  44149. * This is not the name of the component.
  44150. */
  44151. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44152. /**
  44153. * The state of a controller component
  44154. */
  44155. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44156. /**
  44157. * The schema of motion controller layout.
  44158. * No object will be initialized using this interface
  44159. * This is used just to define the profile.
  44160. */
  44161. export interface IMotionControllerLayout {
  44162. /**
  44163. * Path to load the assets. Usually relative to the base path
  44164. */
  44165. assetPath: string;
  44166. /**
  44167. * Available components (unsorted)
  44168. */
  44169. components: {
  44170. /**
  44171. * A map of component Ids
  44172. */
  44173. [componentId: string]: {
  44174. /**
  44175. * The type of input the component outputs
  44176. */
  44177. type: MotionControllerComponentType;
  44178. /**
  44179. * The indices of this component in the gamepad object
  44180. */
  44181. gamepadIndices: {
  44182. /**
  44183. * Index of button
  44184. */
  44185. button?: number;
  44186. /**
  44187. * If available, index of x-axis
  44188. */
  44189. xAxis?: number;
  44190. /**
  44191. * If available, index of y-axis
  44192. */
  44193. yAxis?: number;
  44194. };
  44195. /**
  44196. * The mesh's root node name
  44197. */
  44198. rootNodeName: string;
  44199. /**
  44200. * Animation definitions for this model
  44201. */
  44202. visualResponses: {
  44203. [stateKey: string]: {
  44204. /**
  44205. * What property will be animated
  44206. */
  44207. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44208. /**
  44209. * What states influence this visual response
  44210. */
  44211. states: MotionControllerComponentStateType[];
  44212. /**
  44213. * Type of animation - movement or visibility
  44214. */
  44215. valueNodeProperty: "transform" | "visibility";
  44216. /**
  44217. * Base node name to move. Its position will be calculated according to the min and max nodes
  44218. */
  44219. valueNodeName?: string;
  44220. /**
  44221. * Minimum movement node
  44222. */
  44223. minNodeName?: string;
  44224. /**
  44225. * Max movement node
  44226. */
  44227. maxNodeName?: string;
  44228. };
  44229. };
  44230. /**
  44231. * If touch enabled, what is the name of node to display user feedback
  44232. */
  44233. touchPointNodeName?: string;
  44234. };
  44235. };
  44236. /**
  44237. * Is it xr standard mapping or not
  44238. */
  44239. gamepadMapping: "" | "xr-standard";
  44240. /**
  44241. * Base root node of this entire model
  44242. */
  44243. rootNodeName: string;
  44244. /**
  44245. * Defines the main button component id
  44246. */
  44247. selectComponentId: string;
  44248. }
  44249. /**
  44250. * A definition for the layout map in the input profile
  44251. */
  44252. export interface IMotionControllerLayoutMap {
  44253. /**
  44254. * Layouts with handedness type as a key
  44255. */
  44256. [handedness: string]: IMotionControllerLayout;
  44257. }
  44258. /**
  44259. * The XR Input profile schema
  44260. * Profiles can be found here:
  44261. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44262. */
  44263. export interface IMotionControllerProfile {
  44264. /**
  44265. * fallback profiles for this profileId
  44266. */
  44267. fallbackProfileIds: string[];
  44268. /**
  44269. * The layout map, with handedness as key
  44270. */
  44271. layouts: IMotionControllerLayoutMap;
  44272. /**
  44273. * The id of this profile
  44274. * correlates to the profile(s) in the xrInput.profiles array
  44275. */
  44276. profileId: string;
  44277. }
  44278. /**
  44279. * A helper-interface for the 3 meshes needed for controller button animation
  44280. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44281. */
  44282. export interface IMotionControllerButtonMeshMap {
  44283. /**
  44284. * the mesh that defines the pressed value mesh position.
  44285. * This is used to find the max-position of this button
  44286. */
  44287. pressedMesh: AbstractMesh;
  44288. /**
  44289. * the mesh that defines the unpressed value mesh position.
  44290. * This is used to find the min (or initial) position of this button
  44291. */
  44292. unpressedMesh: AbstractMesh;
  44293. /**
  44294. * The mesh that will be changed when value changes
  44295. */
  44296. valueMesh: AbstractMesh;
  44297. }
  44298. /**
  44299. * A helper-interface for the 3 meshes needed for controller axis animation.
  44300. * This will be expanded when touchpad animations are fully supported
  44301. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44302. */
  44303. export interface IMotionControllerMeshMap {
  44304. /**
  44305. * the mesh that defines the maximum value mesh position.
  44306. */
  44307. maxMesh?: AbstractMesh;
  44308. /**
  44309. * the mesh that defines the minimum value mesh position.
  44310. */
  44311. minMesh?: AbstractMesh;
  44312. /**
  44313. * The mesh that will be changed when axis value changes
  44314. */
  44315. valueMesh: AbstractMesh;
  44316. }
  44317. /**
  44318. * The elements needed for change-detection of the gamepad objects in motion controllers
  44319. */
  44320. export interface IMinimalMotionControllerObject {
  44321. /**
  44322. * Available axes of this controller
  44323. */
  44324. axes: number[];
  44325. /**
  44326. * An array of available buttons
  44327. */
  44328. buttons: Array<{
  44329. /**
  44330. * Value of the button/trigger
  44331. */
  44332. value: number;
  44333. /**
  44334. * If the button/trigger is currently touched
  44335. */
  44336. touched: boolean;
  44337. /**
  44338. * If the button/trigger is currently pressed
  44339. */
  44340. pressed: boolean;
  44341. }>;
  44342. /**
  44343. * EXPERIMENTAL haptic support.
  44344. */
  44345. hapticActuators?: Array<{
  44346. pulse: (value: number, duration: number) => Promise<boolean>;
  44347. }>;
  44348. }
  44349. /**
  44350. * An Abstract Motion controller
  44351. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44352. * Each component has an observable to check for changes in value and state
  44353. */
  44354. export abstract class WebXRAbstractMotionController implements IDisposable {
  44355. protected scene: Scene;
  44356. protected layout: IMotionControllerLayout;
  44357. /**
  44358. * The gamepad object correlating to this controller
  44359. */
  44360. gamepadObject: IMinimalMotionControllerObject;
  44361. /**
  44362. * handedness (left/right/none) of this controller
  44363. */
  44364. handedness: MotionControllerHandedness;
  44365. private _initComponent;
  44366. private _modelReady;
  44367. /**
  44368. * A map of components (WebXRControllerComponent) in this motion controller
  44369. * Components have a ComponentType and can also have both button and axis definitions
  44370. */
  44371. readonly components: {
  44372. [id: string]: WebXRControllerComponent;
  44373. };
  44374. /**
  44375. * Disable the model's animation. Can be set at any time.
  44376. */
  44377. disableAnimation: boolean;
  44378. /**
  44379. * Observers registered here will be triggered when the model of this controller is done loading
  44380. */
  44381. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44382. /**
  44383. * The profile id of this motion controller
  44384. */
  44385. abstract profileId: string;
  44386. /**
  44387. * The root mesh of the model. It is null if the model was not yet initialized
  44388. */
  44389. rootMesh: Nullable<AbstractMesh>;
  44390. /**
  44391. * constructs a new abstract motion controller
  44392. * @param scene the scene to which the model of the controller will be added
  44393. * @param layout The profile layout to load
  44394. * @param gamepadObject The gamepad object correlating to this controller
  44395. * @param handedness handedness (left/right/none) of this controller
  44396. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44397. */
  44398. constructor(scene: Scene, layout: IMotionControllerLayout,
  44399. /**
  44400. * The gamepad object correlating to this controller
  44401. */
  44402. gamepadObject: IMinimalMotionControllerObject,
  44403. /**
  44404. * handedness (left/right/none) of this controller
  44405. */
  44406. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44407. /**
  44408. * Dispose this controller, the model mesh and all its components
  44409. */
  44410. dispose(): void;
  44411. /**
  44412. * Returns all components of specific type
  44413. * @param type the type to search for
  44414. * @return an array of components with this type
  44415. */
  44416. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44417. /**
  44418. * get a component based an its component id as defined in layout.components
  44419. * @param id the id of the component
  44420. * @returns the component correlates to the id or undefined if not found
  44421. */
  44422. getComponent(id: string): WebXRControllerComponent;
  44423. /**
  44424. * Get the list of components available in this motion controller
  44425. * @returns an array of strings correlating to available components
  44426. */
  44427. getComponentIds(): string[];
  44428. /**
  44429. * Get the first component of specific type
  44430. * @param type type of component to find
  44431. * @return a controller component or null if not found
  44432. */
  44433. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44434. /**
  44435. * Get the main (Select) component of this controller as defined in the layout
  44436. * @returns the main component of this controller
  44437. */
  44438. getMainComponent(): WebXRControllerComponent;
  44439. /**
  44440. * Loads the model correlating to this controller
  44441. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44442. * @returns A promise fulfilled with the result of the model loading
  44443. */
  44444. loadModel(): Promise<boolean>;
  44445. /**
  44446. * Update this model using the current XRFrame
  44447. * @param xrFrame the current xr frame to use and update the model
  44448. */
  44449. updateFromXRFrame(xrFrame: XRFrame): void;
  44450. /**
  44451. * Backwards compatibility due to a deeply-integrated typo
  44452. */
  44453. get handness(): XREye;
  44454. /**
  44455. * Pulse (vibrate) this controller
  44456. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  44457. * Consecutive calls to this function will cancel the last pulse call
  44458. *
  44459. * @param value the strength of the pulse in 0.0...1.0 range
  44460. * @param duration Duration of the pulse in milliseconds
  44461. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  44462. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  44463. */
  44464. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  44465. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44466. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44467. /**
  44468. * Moves the axis on the controller mesh based on its current state
  44469. * @param axis the index of the axis
  44470. * @param axisValue the value of the axis which determines the meshes new position
  44471. * @hidden
  44472. */
  44473. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44474. /**
  44475. * Update the model itself with the current frame data
  44476. * @param xrFrame the frame to use for updating the model mesh
  44477. */
  44478. protected updateModel(xrFrame: XRFrame): void;
  44479. /**
  44480. * Get the filename and path for this controller's model
  44481. * @returns a map of filename and path
  44482. */
  44483. protected abstract _getFilenameAndPath(): {
  44484. filename: string;
  44485. path: string;
  44486. };
  44487. /**
  44488. * This function is called before the mesh is loaded. It checks for loading constraints.
  44489. * For example, this function can check if the GLB loader is available
  44490. * If this function returns false, the generic controller will be loaded instead
  44491. * @returns Is the client ready to load the mesh
  44492. */
  44493. protected abstract _getModelLoadingConstraints(): boolean;
  44494. /**
  44495. * This function will be called after the model was successfully loaded and can be used
  44496. * for mesh transformations before it is available for the user
  44497. * @param meshes the loaded meshes
  44498. */
  44499. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44500. /**
  44501. * Set the root mesh for this controller. Important for the WebXR controller class
  44502. * @param meshes the loaded meshes
  44503. */
  44504. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44505. /**
  44506. * A function executed each frame that updates the mesh (if needed)
  44507. * @param xrFrame the current xrFrame
  44508. */
  44509. protected abstract _updateModel(xrFrame: XRFrame): void;
  44510. private _getGenericFilenameAndPath;
  44511. private _getGenericParentMesh;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * A generic trigger-only motion controller for WebXR
  44517. */
  44518. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44519. /**
  44520. * Static version of the profile id of this controller
  44521. */
  44522. static ProfileId: string;
  44523. profileId: string;
  44524. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44525. protected _getFilenameAndPath(): {
  44526. filename: string;
  44527. path: string;
  44528. };
  44529. protected _getModelLoadingConstraints(): boolean;
  44530. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44531. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44532. protected _updateModel(): void;
  44533. }
  44534. }
  44535. declare module BABYLON {
  44536. /**
  44537. * Class containing static functions to help procedurally build meshes
  44538. */
  44539. export class SphereBuilder {
  44540. /**
  44541. * Creates a sphere mesh
  44542. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44543. * * 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`)
  44544. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44545. * * 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
  44546. * * 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)
  44547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44548. * * 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
  44549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44550. * @param name defines the name of the mesh
  44551. * @param options defines the options used to create the mesh
  44552. * @param scene defines the hosting scene
  44553. * @returns the sphere mesh
  44554. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44555. */
  44556. static CreateSphere(name: string, options: {
  44557. segments?: number;
  44558. diameter?: number;
  44559. diameterX?: number;
  44560. diameterY?: number;
  44561. diameterZ?: number;
  44562. arc?: number;
  44563. slice?: number;
  44564. sideOrientation?: number;
  44565. frontUVs?: Vector4;
  44566. backUVs?: Vector4;
  44567. updatable?: boolean;
  44568. }, scene?: Nullable<Scene>): Mesh;
  44569. }
  44570. }
  44571. declare module BABYLON {
  44572. /**
  44573. * A profiled motion controller has its profile loaded from an online repository.
  44574. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44575. */
  44576. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44577. private _repositoryUrl;
  44578. private _buttonMeshMapping;
  44579. private _touchDots;
  44580. /**
  44581. * The profile ID of this controller. Will be populated when the controller initializes.
  44582. */
  44583. profileId: string;
  44584. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44585. dispose(): void;
  44586. protected _getFilenameAndPath(): {
  44587. filename: string;
  44588. path: string;
  44589. };
  44590. protected _getModelLoadingConstraints(): boolean;
  44591. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44592. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44593. protected _updateModel(_xrFrame: XRFrame): void;
  44594. }
  44595. }
  44596. declare module BABYLON {
  44597. /**
  44598. * A construction function type to create a new controller based on an xrInput object
  44599. */
  44600. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44601. /**
  44602. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44603. *
  44604. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44605. * it should be replaced with auto-loaded controllers.
  44606. *
  44607. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44608. */
  44609. export class WebXRMotionControllerManager {
  44610. private static _AvailableControllers;
  44611. private static _Fallbacks;
  44612. private static _ProfileLoadingPromises;
  44613. private static _ProfilesList;
  44614. /**
  44615. * The base URL of the online controller repository. Can be changed at any time.
  44616. */
  44617. static BaseRepositoryUrl: string;
  44618. /**
  44619. * Which repository gets priority - local or online
  44620. */
  44621. static PrioritizeOnlineRepository: boolean;
  44622. /**
  44623. * Use the online repository, or use only locally-defined controllers
  44624. */
  44625. static UseOnlineRepository: boolean;
  44626. /**
  44627. * Clear the cache used for profile loading and reload when requested again
  44628. */
  44629. static ClearProfilesCache(): void;
  44630. /**
  44631. * Register the default fallbacks.
  44632. * This function is called automatically when this file is imported.
  44633. */
  44634. static DefaultFallbacks(): void;
  44635. /**
  44636. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44637. * @param profileId the profile to which a fallback needs to be found
  44638. * @return an array with corresponding fallback profiles
  44639. */
  44640. static FindFallbackWithProfileId(profileId: string): string[];
  44641. /**
  44642. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44643. * The order of search:
  44644. *
  44645. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44646. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44647. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44648. * 4) return the generic trigger controller if none were found
  44649. *
  44650. * @param xrInput the xrInput to which a new controller is initialized
  44651. * @param scene the scene to which the model will be added
  44652. * @param forceProfile force a certain profile for this controller
  44653. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44654. */
  44655. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44656. /**
  44657. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44658. *
  44659. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44660. *
  44661. * @param type the profile type to register
  44662. * @param constructFunction the function to be called when loading this profile
  44663. */
  44664. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44665. /**
  44666. * Register a fallback to a specific profile.
  44667. * @param profileId the profileId that will receive the fallbacks
  44668. * @param fallbacks A list of fallback profiles
  44669. */
  44670. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44671. /**
  44672. * Will update the list of profiles available in the repository
  44673. * @return a promise that resolves to a map of profiles available online
  44674. */
  44675. static UpdateProfilesList(): Promise<{
  44676. [profile: string]: string;
  44677. }>;
  44678. private static _LoadProfileFromRepository;
  44679. private static _LoadProfilesFromAvailableControllers;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. /**
  44684. * Configuration options for the WebXR controller creation
  44685. */
  44686. export interface IWebXRControllerOptions {
  44687. /**
  44688. * Should the controller mesh be animated when a user interacts with it
  44689. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44690. */
  44691. disableMotionControllerAnimation?: boolean;
  44692. /**
  44693. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44694. */
  44695. doNotLoadControllerMesh?: boolean;
  44696. /**
  44697. * Force a specific controller type for this controller.
  44698. * This can be used when creating your own profile or when testing different controllers
  44699. */
  44700. forceControllerProfile?: string;
  44701. /**
  44702. * Defines a rendering group ID for meshes that will be loaded.
  44703. * This is for the default controllers only.
  44704. */
  44705. renderingGroupId?: number;
  44706. }
  44707. /**
  44708. * Represents an XR controller
  44709. */
  44710. export class WebXRInputSource {
  44711. private _scene;
  44712. /** The underlying input source for the controller */
  44713. inputSource: XRInputSource;
  44714. private _options;
  44715. private _tmpQuaternion;
  44716. private _tmpVector;
  44717. private _uniqueId;
  44718. /**
  44719. * 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
  44720. */
  44721. grip?: AbstractMesh;
  44722. /**
  44723. * If available, this is the gamepad object related to this controller.
  44724. * Using this object it is possible to get click events and trackpad changes of the
  44725. * webxr controller that is currently being used.
  44726. */
  44727. motionController?: WebXRAbstractMotionController;
  44728. /**
  44729. * Event that fires when the controller is removed/disposed.
  44730. * The object provided as event data is this controller, after associated assets were disposed.
  44731. * uniqueId is still available.
  44732. */
  44733. onDisposeObservable: Observable<WebXRInputSource>;
  44734. /**
  44735. * Will be triggered when the mesh associated with the motion controller is done loading.
  44736. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44737. * A shortened version of controller -> motion controller -> on mesh loaded.
  44738. */
  44739. onMeshLoadedObservable: Observable<AbstractMesh>;
  44740. /**
  44741. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44742. */
  44743. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44744. /**
  44745. * Pointer which can be used to select objects or attach a visible laser to
  44746. */
  44747. pointer: AbstractMesh;
  44748. /**
  44749. * Creates the controller
  44750. * @see https://doc.babylonjs.com/how_to/webxr
  44751. * @param _scene the scene which the controller should be associated to
  44752. * @param inputSource the underlying input source for the controller
  44753. * @param _options options for this controller creation
  44754. */
  44755. constructor(_scene: Scene,
  44756. /** The underlying input source for the controller */
  44757. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44758. /**
  44759. * Get this controllers unique id
  44760. */
  44761. get uniqueId(): string;
  44762. /**
  44763. * Disposes of the object
  44764. */
  44765. dispose(): void;
  44766. /**
  44767. * Gets a world space ray coming from the pointer or grip
  44768. * @param result the resulting ray
  44769. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44770. */
  44771. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44772. /**
  44773. * Updates the controller pose based on the given XRFrame
  44774. * @param xrFrame xr frame to update the pose with
  44775. * @param referenceSpace reference space to use
  44776. */
  44777. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44778. }
  44779. }
  44780. declare module BABYLON {
  44781. /**
  44782. * The schema for initialization options of the XR Input class
  44783. */
  44784. export interface IWebXRInputOptions {
  44785. /**
  44786. * If set to true no model will be automatically loaded
  44787. */
  44788. doNotLoadControllerMeshes?: boolean;
  44789. /**
  44790. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44791. * If not found, the xr input profile data will be used.
  44792. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44793. */
  44794. forceInputProfile?: string;
  44795. /**
  44796. * Do not send a request to the controller repository to load the profile.
  44797. *
  44798. * Instead, use the controllers available in babylon itself.
  44799. */
  44800. disableOnlineControllerRepository?: boolean;
  44801. /**
  44802. * A custom URL for the controllers repository
  44803. */
  44804. customControllersRepositoryURL?: string;
  44805. /**
  44806. * Should the controller model's components not move according to the user input
  44807. */
  44808. disableControllerAnimation?: boolean;
  44809. /**
  44810. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  44811. */
  44812. controllerOptions?: IWebXRControllerOptions;
  44813. }
  44814. /**
  44815. * XR input used to track XR inputs such as controllers/rays
  44816. */
  44817. export class WebXRInput implements IDisposable {
  44818. /**
  44819. * the xr session manager for this session
  44820. */
  44821. xrSessionManager: WebXRSessionManager;
  44822. /**
  44823. * the WebXR camera for this session. Mainly used for teleportation
  44824. */
  44825. xrCamera: WebXRCamera;
  44826. private readonly options;
  44827. /**
  44828. * XR controllers being tracked
  44829. */
  44830. controllers: Array<WebXRInputSource>;
  44831. private _frameObserver;
  44832. private _sessionEndedObserver;
  44833. private _sessionInitObserver;
  44834. /**
  44835. * Event when a controller has been connected/added
  44836. */
  44837. onControllerAddedObservable: Observable<WebXRInputSource>;
  44838. /**
  44839. * Event when a controller has been removed/disconnected
  44840. */
  44841. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44842. /**
  44843. * Initializes the WebXRInput
  44844. * @param xrSessionManager the xr session manager for this session
  44845. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44846. * @param options = initialization options for this xr input
  44847. */
  44848. constructor(
  44849. /**
  44850. * the xr session manager for this session
  44851. */
  44852. xrSessionManager: WebXRSessionManager,
  44853. /**
  44854. * the WebXR camera for this session. Mainly used for teleportation
  44855. */
  44856. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44857. private _onInputSourcesChange;
  44858. private _addAndRemoveControllers;
  44859. /**
  44860. * Disposes of the object
  44861. */
  44862. dispose(): void;
  44863. }
  44864. }
  44865. declare module BABYLON {
  44866. /**
  44867. * This is the base class for all WebXR features.
  44868. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44869. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44870. */
  44871. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44872. protected _xrSessionManager: WebXRSessionManager;
  44873. private _attached;
  44874. private _removeOnDetach;
  44875. /**
  44876. * Should auto-attach be disabled?
  44877. */
  44878. disableAutoAttach: boolean;
  44879. /**
  44880. * Construct a new (abstract) WebXR feature
  44881. * @param _xrSessionManager the xr session manager for this feature
  44882. */
  44883. constructor(_xrSessionManager: WebXRSessionManager);
  44884. /**
  44885. * Is this feature attached
  44886. */
  44887. get attached(): boolean;
  44888. /**
  44889. * attach this feature
  44890. *
  44891. * @param force should attachment be forced (even when already attached)
  44892. * @returns true if successful, false is failed or already attached
  44893. */
  44894. attach(force?: boolean): boolean;
  44895. /**
  44896. * detach this feature.
  44897. *
  44898. * @returns true if successful, false if failed or already detached
  44899. */
  44900. detach(): boolean;
  44901. /**
  44902. * Dispose this feature and all of the resources attached
  44903. */
  44904. dispose(): void;
  44905. /**
  44906. * This is used to register callbacks that will automatically be removed when detach is called.
  44907. * @param observable the observable to which the observer will be attached
  44908. * @param callback the callback to register
  44909. */
  44910. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44911. /**
  44912. * Code in this function will be executed on each xrFrame received from the browser.
  44913. * This function will not execute after the feature is detached.
  44914. * @param _xrFrame the current frame
  44915. */
  44916. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44917. }
  44918. }
  44919. declare module BABYLON {
  44920. /**
  44921. * Renders a layer on top of an existing scene
  44922. */
  44923. export class UtilityLayerRenderer implements IDisposable {
  44924. /** the original scene that will be rendered on top of */
  44925. originalScene: Scene;
  44926. private _pointerCaptures;
  44927. private _lastPointerEvents;
  44928. private static _DefaultUtilityLayer;
  44929. private static _DefaultKeepDepthUtilityLayer;
  44930. private _sharedGizmoLight;
  44931. private _renderCamera;
  44932. /**
  44933. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44934. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44935. * @returns the camera that is used when rendering the utility layer
  44936. */
  44937. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44938. /**
  44939. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44940. * @param cam the camera that should be used when rendering the utility layer
  44941. */
  44942. setRenderCamera(cam: Nullable<Camera>): void;
  44943. /**
  44944. * @hidden
  44945. * Light which used by gizmos to get light shading
  44946. */
  44947. _getSharedGizmoLight(): HemisphericLight;
  44948. /**
  44949. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44950. */
  44951. pickUtilitySceneFirst: boolean;
  44952. /**
  44953. * 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)
  44954. */
  44955. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44956. /**
  44957. * 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)
  44958. */
  44959. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44960. /**
  44961. * The scene that is rendered on top of the original scene
  44962. */
  44963. utilityLayerScene: Scene;
  44964. /**
  44965. * If the utility layer should automatically be rendered on top of existing scene
  44966. */
  44967. shouldRender: boolean;
  44968. /**
  44969. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44970. */
  44971. onlyCheckPointerDownEvents: boolean;
  44972. /**
  44973. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44974. */
  44975. processAllEvents: boolean;
  44976. /**
  44977. * Observable raised when the pointer move from the utility layer scene to the main scene
  44978. */
  44979. onPointerOutObservable: Observable<number>;
  44980. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44981. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44982. private _afterRenderObserver;
  44983. private _sceneDisposeObserver;
  44984. private _originalPointerObserver;
  44985. /**
  44986. * Instantiates a UtilityLayerRenderer
  44987. * @param originalScene the original scene that will be rendered on top of
  44988. * @param handleEvents boolean indicating if the utility layer should handle events
  44989. */
  44990. constructor(
  44991. /** the original scene that will be rendered on top of */
  44992. originalScene: Scene, handleEvents?: boolean);
  44993. private _notifyObservers;
  44994. /**
  44995. * Renders the utility layers scene on top of the original scene
  44996. */
  44997. render(): void;
  44998. /**
  44999. * Disposes of the renderer
  45000. */
  45001. dispose(): void;
  45002. private _updateCamera;
  45003. }
  45004. }
  45005. declare module BABYLON {
  45006. /**
  45007. * Options interface for the pointer selection module
  45008. */
  45009. export interface IWebXRControllerPointerSelectionOptions {
  45010. /**
  45011. * if provided, this scene will be used to render meshes.
  45012. */
  45013. customUtilityLayerScene?: Scene;
  45014. /**
  45015. * 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)
  45016. * If not disabled, the last picked point will be used to execute a pointer up event
  45017. * If disabled, pointer up event will be triggered right after the pointer down event.
  45018. * Used in screen and gaze target ray mode only
  45019. */
  45020. disablePointerUpOnTouchOut: boolean;
  45021. /**
  45022. * For gaze mode (time to select instead of press)
  45023. */
  45024. forceGazeMode: boolean;
  45025. /**
  45026. * 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
  45027. * to start a new countdown to the pointer down event.
  45028. * Defaults to 1.
  45029. */
  45030. gazeModePointerMovedFactor?: number;
  45031. /**
  45032. * Different button type to use instead of the main component
  45033. */
  45034. overrideButtonId?: string;
  45035. /**
  45036. * use this rendering group id for the meshes (optional)
  45037. */
  45038. renderingGroupId?: number;
  45039. /**
  45040. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45041. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45042. * 3000 means 3 seconds between pointing at something and selecting it
  45043. */
  45044. timeToSelect?: number;
  45045. /**
  45046. * Should meshes created here be added to a utility layer or the main scene
  45047. */
  45048. useUtilityLayer?: boolean;
  45049. /**
  45050. * the xr input to use with this pointer selection
  45051. */
  45052. xrInput: WebXRInput;
  45053. }
  45054. /**
  45055. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45056. */
  45057. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45058. private readonly _options;
  45059. private static _idCounter;
  45060. private _attachController;
  45061. private _controllers;
  45062. private _scene;
  45063. private _tmpVectorForPickCompare;
  45064. /**
  45065. * The module's name
  45066. */
  45067. static readonly Name: string;
  45068. /**
  45069. * The (Babylon) version of this module.
  45070. * This is an integer representing the implementation version.
  45071. * This number does not correspond to the WebXR specs version
  45072. */
  45073. static readonly Version: number;
  45074. /**
  45075. * Disable lighting on the laser pointer (so it will always be visible)
  45076. */
  45077. disablePointerLighting: boolean;
  45078. /**
  45079. * Disable lighting on the selection mesh (so it will always be visible)
  45080. */
  45081. disableSelectionMeshLighting: boolean;
  45082. /**
  45083. * Should the laser pointer be displayed
  45084. */
  45085. displayLaserPointer: boolean;
  45086. /**
  45087. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45088. */
  45089. displaySelectionMesh: boolean;
  45090. /**
  45091. * This color will be set to the laser pointer when selection is triggered
  45092. */
  45093. laserPointerPickedColor: Color3;
  45094. /**
  45095. * Default color of the laser pointer
  45096. */
  45097. lasterPointerDefaultColor: Color3;
  45098. /**
  45099. * default color of the selection ring
  45100. */
  45101. selectionMeshDefaultColor: Color3;
  45102. /**
  45103. * This color will be applied to the selection ring when selection is triggered
  45104. */
  45105. selectionMeshPickedColor: Color3;
  45106. /**
  45107. * Optional filter to be used for ray selection. This predicate shares behavior with
  45108. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45109. */
  45110. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45111. /**
  45112. * constructs a new background remover module
  45113. * @param _xrSessionManager the session manager for this module
  45114. * @param _options read-only options to be used in this module
  45115. */
  45116. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45117. /**
  45118. * attach this feature
  45119. * Will usually be called by the features manager
  45120. *
  45121. * @returns true if successful.
  45122. */
  45123. attach(): boolean;
  45124. /**
  45125. * detach this feature.
  45126. * Will usually be called by the features manager
  45127. *
  45128. * @returns true if successful.
  45129. */
  45130. detach(): boolean;
  45131. /**
  45132. * Will get the mesh under a specific pointer.
  45133. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45134. * @param controllerId the controllerId to check
  45135. * @returns The mesh under pointer or null if no mesh is under the pointer
  45136. */
  45137. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45138. /**
  45139. * Get the xr controller that correlates to the pointer id in the pointer event
  45140. *
  45141. * @param id the pointer id to search for
  45142. * @returns the controller that correlates to this id or null if not found
  45143. */
  45144. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45145. protected _onXRFrame(_xrFrame: XRFrame): void;
  45146. private _attachGazeMode;
  45147. private _attachScreenRayMode;
  45148. private _attachTrackedPointerRayMode;
  45149. private _convertNormalToDirectionOfRay;
  45150. private _detachController;
  45151. private _generateNewMeshPair;
  45152. private _pickingMoved;
  45153. private _updatePointerDistance;
  45154. }
  45155. }
  45156. declare module BABYLON {
  45157. /**
  45158. * Button which can be used to enter a different mode of XR
  45159. */
  45160. export class WebXREnterExitUIButton {
  45161. /** button element */
  45162. element: HTMLElement;
  45163. /** XR initialization options for the button */
  45164. sessionMode: XRSessionMode;
  45165. /** Reference space type */
  45166. referenceSpaceType: XRReferenceSpaceType;
  45167. /**
  45168. * Creates a WebXREnterExitUIButton
  45169. * @param element button element
  45170. * @param sessionMode XR initialization session mode
  45171. * @param referenceSpaceType the type of reference space to be used
  45172. */
  45173. constructor(
  45174. /** button element */
  45175. element: HTMLElement,
  45176. /** XR initialization options for the button */
  45177. sessionMode: XRSessionMode,
  45178. /** Reference space type */
  45179. referenceSpaceType: XRReferenceSpaceType);
  45180. /**
  45181. * Extendable function which can be used to update the button's visuals when the state changes
  45182. * @param activeButton the current active button in the UI
  45183. */
  45184. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45185. }
  45186. /**
  45187. * Options to create the webXR UI
  45188. */
  45189. export class WebXREnterExitUIOptions {
  45190. /**
  45191. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45192. */
  45193. customButtons?: Array<WebXREnterExitUIButton>;
  45194. /**
  45195. * A reference space type to use when creating the default button.
  45196. * Default is local-floor
  45197. */
  45198. referenceSpaceType?: XRReferenceSpaceType;
  45199. /**
  45200. * Context to enter xr with
  45201. */
  45202. renderTarget?: Nullable<WebXRRenderTarget>;
  45203. /**
  45204. * A session mode to use when creating the default button.
  45205. * Default is immersive-vr
  45206. */
  45207. sessionMode?: XRSessionMode;
  45208. }
  45209. /**
  45210. * UI to allow the user to enter/exit XR mode
  45211. */
  45212. export class WebXREnterExitUI implements IDisposable {
  45213. private scene;
  45214. /** version of the options passed to this UI */
  45215. options: WebXREnterExitUIOptions;
  45216. private _activeButton;
  45217. private _buttons;
  45218. private _overlay;
  45219. /**
  45220. * Fired every time the active button is changed.
  45221. *
  45222. * When xr is entered via a button that launches xr that button will be the callback parameter
  45223. *
  45224. * When exiting xr the callback parameter will be null)
  45225. */
  45226. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45227. /**
  45228. *
  45229. * @param scene babylon scene object to use
  45230. * @param options (read-only) version of the options passed to this UI
  45231. */
  45232. private constructor();
  45233. /**
  45234. * Creates UI to allow the user to enter/exit XR mode
  45235. * @param scene the scene to add the ui to
  45236. * @param helper the xr experience helper to enter/exit xr with
  45237. * @param options options to configure the UI
  45238. * @returns the created ui
  45239. */
  45240. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45241. /**
  45242. * Disposes of the XR UI component
  45243. */
  45244. dispose(): void;
  45245. private _updateButtons;
  45246. }
  45247. }
  45248. declare module BABYLON {
  45249. /**
  45250. * Class containing static functions to help procedurally build meshes
  45251. */
  45252. export class LinesBuilder {
  45253. /**
  45254. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45255. * * 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
  45256. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45257. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45258. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45259. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45260. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45261. * * 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
  45262. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45265. * @param name defines the name of the new line system
  45266. * @param options defines the options used to create the line system
  45267. * @param scene defines the hosting scene
  45268. * @returns a new line system mesh
  45269. */
  45270. static CreateLineSystem(name: string, options: {
  45271. lines: Vector3[][];
  45272. updatable?: boolean;
  45273. instance?: Nullable<LinesMesh>;
  45274. colors?: Nullable<Color4[][]>;
  45275. useVertexAlpha?: boolean;
  45276. }, scene: Nullable<Scene>): LinesMesh;
  45277. /**
  45278. * Creates a line mesh
  45279. * 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
  45280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45281. * * The parameter `points` is an array successive Vector3
  45282. * * 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
  45283. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45284. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45285. * * When updating an instance, remember that only point positions can change, not the number of points
  45286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45288. * @param name defines the name of the new line system
  45289. * @param options defines the options used to create the line system
  45290. * @param scene defines the hosting scene
  45291. * @returns a new line mesh
  45292. */
  45293. static CreateLines(name: string, options: {
  45294. points: Vector3[];
  45295. updatable?: boolean;
  45296. instance?: Nullable<LinesMesh>;
  45297. colors?: Color4[];
  45298. useVertexAlpha?: boolean;
  45299. }, scene?: Nullable<Scene>): LinesMesh;
  45300. /**
  45301. * Creates a dashed line mesh
  45302. * * 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
  45303. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45304. * * The parameter `points` is an array successive Vector3
  45305. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45306. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45307. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45308. * * 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
  45309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45310. * * When updating an instance, remember that only point positions can change, not the number of points
  45311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45312. * @param name defines the name of the mesh
  45313. * @param options defines the options used to create the mesh
  45314. * @param scene defines the hosting scene
  45315. * @returns the dashed line mesh
  45316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45317. */
  45318. static CreateDashedLines(name: string, options: {
  45319. points: Vector3[];
  45320. dashSize?: number;
  45321. gapSize?: number;
  45322. dashNb?: number;
  45323. updatable?: boolean;
  45324. instance?: LinesMesh;
  45325. useVertexAlpha?: boolean;
  45326. }, scene?: Nullable<Scene>): LinesMesh;
  45327. }
  45328. }
  45329. declare module BABYLON {
  45330. /**
  45331. * The options container for the teleportation module
  45332. */
  45333. export interface IWebXRTeleportationOptions {
  45334. /**
  45335. * if provided, this scene will be used to render meshes.
  45336. */
  45337. customUtilityLayerScene?: Scene;
  45338. /**
  45339. * Values to configure the default target mesh
  45340. */
  45341. defaultTargetMeshOptions?: {
  45342. /**
  45343. * Fill color of the teleportation area
  45344. */
  45345. teleportationFillColor?: string;
  45346. /**
  45347. * Border color for the teleportation area
  45348. */
  45349. teleportationBorderColor?: string;
  45350. /**
  45351. * Disable the mesh's animation sequence
  45352. */
  45353. disableAnimation?: boolean;
  45354. /**
  45355. * Disable lighting on the material or the ring and arrow
  45356. */
  45357. disableLighting?: boolean;
  45358. /**
  45359. * Override the default material of the torus and arrow
  45360. */
  45361. torusArrowMaterial?: Material;
  45362. };
  45363. /**
  45364. * A list of meshes to use as floor meshes.
  45365. * Meshes can be added and removed after initializing the feature using the
  45366. * addFloorMesh and removeFloorMesh functions
  45367. * If empty, rotation will still work
  45368. */
  45369. floorMeshes?: AbstractMesh[];
  45370. /**
  45371. * use this rendering group id for the meshes (optional)
  45372. */
  45373. renderingGroupId?: number;
  45374. /**
  45375. * Should teleportation move only to snap points
  45376. */
  45377. snapPointsOnly?: boolean;
  45378. /**
  45379. * An array of points to which the teleportation will snap to.
  45380. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45381. */
  45382. snapPositions?: Vector3[];
  45383. /**
  45384. * How close should the teleportation ray be in order to snap to position.
  45385. * Default to 0.8 units (meters)
  45386. */
  45387. snapToPositionRadius?: number;
  45388. /**
  45389. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45390. * If you want to support rotation, make sure your mesh has a direction indicator.
  45391. *
  45392. * When left untouched, the default mesh will be initialized.
  45393. */
  45394. teleportationTargetMesh?: AbstractMesh;
  45395. /**
  45396. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45397. */
  45398. timeToTeleport?: number;
  45399. /**
  45400. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45401. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45402. */
  45403. useMainComponentOnly?: boolean;
  45404. /**
  45405. * Should meshes created here be added to a utility layer or the main scene
  45406. */
  45407. useUtilityLayer?: boolean;
  45408. /**
  45409. * Babylon XR Input class for controller
  45410. */
  45411. xrInput: WebXRInput;
  45412. }
  45413. /**
  45414. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45415. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45416. * the input of the attached controllers.
  45417. */
  45418. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45419. private _options;
  45420. private _controllers;
  45421. private _currentTeleportationControllerId;
  45422. private _floorMeshes;
  45423. private _quadraticBezierCurve;
  45424. private _selectionFeature;
  45425. private _snapToPositions;
  45426. private _snappedToPoint;
  45427. private _teleportationRingMaterial?;
  45428. private _tmpRay;
  45429. private _tmpVector;
  45430. /**
  45431. * The module's name
  45432. */
  45433. static readonly Name: string;
  45434. /**
  45435. * The (Babylon) version of this module.
  45436. * This is an integer representing the implementation version.
  45437. * This number does not correspond to the webxr specs version
  45438. */
  45439. static readonly Version: number;
  45440. /**
  45441. * Is movement backwards enabled
  45442. */
  45443. backwardsMovementEnabled: boolean;
  45444. /**
  45445. * Distance to travel when moving backwards
  45446. */
  45447. backwardsTeleportationDistance: number;
  45448. /**
  45449. * The distance from the user to the inspection point in the direction of the controller
  45450. * A higher number will allow the user to move further
  45451. * defaults to 5 (meters, in xr units)
  45452. */
  45453. parabolicCheckRadius: number;
  45454. /**
  45455. * Should the module support parabolic ray on top of direct ray
  45456. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45457. * Very helpful when moving between floors / different heights
  45458. */
  45459. parabolicRayEnabled: boolean;
  45460. /**
  45461. * How much rotation should be applied when rotating right and left
  45462. */
  45463. rotationAngle: number;
  45464. /**
  45465. * Is rotation enabled when moving forward?
  45466. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45467. */
  45468. rotationEnabled: boolean;
  45469. /**
  45470. * constructs a new anchor system
  45471. * @param _xrSessionManager an instance of WebXRSessionManager
  45472. * @param _options configuration object for this feature
  45473. */
  45474. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45475. /**
  45476. * Get the snapPointsOnly flag
  45477. */
  45478. get snapPointsOnly(): boolean;
  45479. /**
  45480. * Sets the snapPointsOnly flag
  45481. * @param snapToPoints should teleportation be exclusively to snap points
  45482. */
  45483. set snapPointsOnly(snapToPoints: boolean);
  45484. /**
  45485. * Add a new mesh to the floor meshes array
  45486. * @param mesh the mesh to use as floor mesh
  45487. */
  45488. addFloorMesh(mesh: AbstractMesh): void;
  45489. /**
  45490. * Add a new snap-to point to fix teleportation to this position
  45491. * @param newSnapPoint The new Snap-To point
  45492. */
  45493. addSnapPoint(newSnapPoint: Vector3): void;
  45494. attach(): boolean;
  45495. detach(): boolean;
  45496. dispose(): void;
  45497. /**
  45498. * Remove a mesh from the floor meshes array
  45499. * @param mesh the mesh to remove
  45500. */
  45501. removeFloorMesh(mesh: AbstractMesh): void;
  45502. /**
  45503. * Remove a mesh from the floor meshes array using its name
  45504. * @param name the mesh name to remove
  45505. */
  45506. removeFloorMeshByName(name: string): void;
  45507. /**
  45508. * 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
  45509. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45510. * @returns was the point found and removed or not
  45511. */
  45512. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45513. /**
  45514. * This function sets a selection feature that will be disabled when
  45515. * the forward ray is shown and will be reattached when hidden.
  45516. * This is used to remove the selection rays when moving.
  45517. * @param selectionFeature the feature to disable when forward movement is enabled
  45518. */
  45519. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45520. protected _onXRFrame(_xrFrame: XRFrame): void;
  45521. private _attachController;
  45522. private _createDefaultTargetMesh;
  45523. private _detachController;
  45524. private _findClosestSnapPointWithRadius;
  45525. private _setTargetMeshPosition;
  45526. private _setTargetMeshVisibility;
  45527. private _showParabolicPath;
  45528. private _teleportForward;
  45529. }
  45530. }
  45531. declare module BABYLON {
  45532. /**
  45533. * Options for the default xr helper
  45534. */
  45535. export class WebXRDefaultExperienceOptions {
  45536. /**
  45537. * Enable or disable default UI to enter XR
  45538. */
  45539. disableDefaultUI?: boolean;
  45540. /**
  45541. * Should teleportation not initialize. defaults to false.
  45542. */
  45543. disableTeleportation?: boolean;
  45544. /**
  45545. * Floor meshes that will be used for teleport
  45546. */
  45547. floorMeshes?: Array<AbstractMesh>;
  45548. /**
  45549. * If set to true, the first frame will not be used to reset position
  45550. * The first frame is mainly used when copying transformation from the old camera
  45551. * Mainly used in AR
  45552. */
  45553. ignoreNativeCameraTransformation?: boolean;
  45554. /**
  45555. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45556. */
  45557. inputOptions?: IWebXRInputOptions;
  45558. /**
  45559. * optional configuration for the output canvas
  45560. */
  45561. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45562. /**
  45563. * optional UI options. This can be used among other to change session mode and reference space type
  45564. */
  45565. uiOptions?: WebXREnterExitUIOptions;
  45566. /**
  45567. * When loading teleportation and pointer select, use stable versions instead of latest.
  45568. */
  45569. useStablePlugins?: boolean;
  45570. /**
  45571. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  45572. */
  45573. renderingGroupId?: number;
  45574. }
  45575. /**
  45576. * Default experience which provides a similar setup to the previous webVRExperience
  45577. */
  45578. export class WebXRDefaultExperience {
  45579. /**
  45580. * Base experience
  45581. */
  45582. baseExperience: WebXRExperienceHelper;
  45583. /**
  45584. * Enables ui for entering/exiting xr
  45585. */
  45586. enterExitUI: WebXREnterExitUI;
  45587. /**
  45588. * Input experience extension
  45589. */
  45590. input: WebXRInput;
  45591. /**
  45592. * Enables laser pointer and selection
  45593. */
  45594. pointerSelection: WebXRControllerPointerSelection;
  45595. /**
  45596. * Default target xr should render to
  45597. */
  45598. renderTarget: WebXRRenderTarget;
  45599. /**
  45600. * Enables teleportation
  45601. */
  45602. teleportation: WebXRMotionControllerTeleportation;
  45603. private constructor();
  45604. /**
  45605. * Creates the default xr experience
  45606. * @param scene scene
  45607. * @param options options for basic configuration
  45608. * @returns resulting WebXRDefaultExperience
  45609. */
  45610. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45611. /**
  45612. * DIsposes of the experience helper
  45613. */
  45614. dispose(): void;
  45615. }
  45616. }
  45617. declare module BABYLON {
  45618. /**
  45619. * Options to modify the vr teleportation behavior.
  45620. */
  45621. export interface VRTeleportationOptions {
  45622. /**
  45623. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45624. */
  45625. floorMeshName?: string;
  45626. /**
  45627. * A list of meshes to be used as the teleportation floor. (default: empty)
  45628. */
  45629. floorMeshes?: Mesh[];
  45630. /**
  45631. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45632. */
  45633. teleportationMode?: number;
  45634. /**
  45635. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45636. */
  45637. teleportationTime?: number;
  45638. /**
  45639. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45640. */
  45641. teleportationSpeed?: number;
  45642. /**
  45643. * The easing function used in the animation or null for Linear. (default CircleEase)
  45644. */
  45645. easingFunction?: EasingFunction;
  45646. }
  45647. /**
  45648. * Options to modify the vr experience helper's behavior.
  45649. */
  45650. export interface VRExperienceHelperOptions extends WebVROptions {
  45651. /**
  45652. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45653. */
  45654. createDeviceOrientationCamera?: boolean;
  45655. /**
  45656. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45657. */
  45658. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45659. /**
  45660. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45661. */
  45662. laserToggle?: boolean;
  45663. /**
  45664. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45665. */
  45666. floorMeshes?: Mesh[];
  45667. /**
  45668. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45669. */
  45670. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45671. /**
  45672. * Defines if WebXR should be used instead of WebVR (if available)
  45673. */
  45674. useXR?: boolean;
  45675. }
  45676. /**
  45677. * Event containing information after VR has been entered
  45678. */
  45679. export class OnAfterEnteringVRObservableEvent {
  45680. /**
  45681. * If entering vr was successful
  45682. */
  45683. success: boolean;
  45684. }
  45685. /**
  45686. * Helps to quickly add VR support to an existing scene.
  45687. * See http://doc.babylonjs.com/how_to/webvr_helper
  45688. */
  45689. export class VRExperienceHelper {
  45690. /** Options to modify the vr experience helper's behavior. */
  45691. webVROptions: VRExperienceHelperOptions;
  45692. private _scene;
  45693. private _position;
  45694. private _btnVR;
  45695. private _btnVRDisplayed;
  45696. private _webVRsupported;
  45697. private _webVRready;
  45698. private _webVRrequesting;
  45699. private _webVRpresenting;
  45700. private _hasEnteredVR;
  45701. private _fullscreenVRpresenting;
  45702. private _inputElement;
  45703. private _webVRCamera;
  45704. private _vrDeviceOrientationCamera;
  45705. private _deviceOrientationCamera;
  45706. private _existingCamera;
  45707. private _onKeyDown;
  45708. private _onVrDisplayPresentChange;
  45709. private _onVRDisplayChanged;
  45710. private _onVRRequestPresentStart;
  45711. private _onVRRequestPresentComplete;
  45712. /**
  45713. * 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)
  45714. */
  45715. enableGazeEvenWhenNoPointerLock: boolean;
  45716. /**
  45717. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45718. */
  45719. exitVROnDoubleTap: boolean;
  45720. /**
  45721. * Observable raised right before entering VR.
  45722. */
  45723. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45724. /**
  45725. * Observable raised when entering VR has completed.
  45726. */
  45727. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45728. /**
  45729. * Observable raised when exiting VR.
  45730. */
  45731. onExitingVRObservable: Observable<VRExperienceHelper>;
  45732. /**
  45733. * Observable raised when controller mesh is loaded.
  45734. */
  45735. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45736. /** Return this.onEnteringVRObservable
  45737. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45738. */
  45739. get onEnteringVR(): Observable<VRExperienceHelper>;
  45740. /** Return this.onExitingVRObservable
  45741. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45742. */
  45743. get onExitingVR(): Observable<VRExperienceHelper>;
  45744. /** Return this.onControllerMeshLoadedObservable
  45745. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45746. */
  45747. get onControllerMeshLoaded(): Observable<WebVRController>;
  45748. private _rayLength;
  45749. private _useCustomVRButton;
  45750. private _teleportationRequested;
  45751. private _teleportActive;
  45752. private _floorMeshName;
  45753. private _floorMeshesCollection;
  45754. private _teleportationMode;
  45755. private _teleportationTime;
  45756. private _teleportationSpeed;
  45757. private _teleportationEasing;
  45758. private _rotationAllowed;
  45759. private _teleportBackwardsVector;
  45760. private _teleportationTarget;
  45761. private _isDefaultTeleportationTarget;
  45762. private _postProcessMove;
  45763. private _teleportationFillColor;
  45764. private _teleportationBorderColor;
  45765. private _rotationAngle;
  45766. private _haloCenter;
  45767. private _cameraGazer;
  45768. private _padSensibilityUp;
  45769. private _padSensibilityDown;
  45770. private _leftController;
  45771. private _rightController;
  45772. private _gazeColor;
  45773. private _laserColor;
  45774. private _pickedLaserColor;
  45775. private _pickedGazeColor;
  45776. /**
  45777. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45778. */
  45779. onNewMeshSelected: Observable<AbstractMesh>;
  45780. /**
  45781. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45782. * This observable will provide the mesh and the controller used to select the mesh
  45783. */
  45784. onMeshSelectedWithController: Observable<{
  45785. mesh: AbstractMesh;
  45786. controller: WebVRController;
  45787. }>;
  45788. /**
  45789. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45790. */
  45791. onNewMeshPicked: Observable<PickingInfo>;
  45792. private _circleEase;
  45793. /**
  45794. * Observable raised before camera teleportation
  45795. */
  45796. onBeforeCameraTeleport: Observable<Vector3>;
  45797. /**
  45798. * Observable raised after camera teleportation
  45799. */
  45800. onAfterCameraTeleport: Observable<Vector3>;
  45801. /**
  45802. * Observable raised when current selected mesh gets unselected
  45803. */
  45804. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45805. private _raySelectionPredicate;
  45806. /**
  45807. * To be optionaly changed by user to define custom ray selection
  45808. */
  45809. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45810. /**
  45811. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45812. */
  45813. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45814. /**
  45815. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45816. */
  45817. teleportationEnabled: boolean;
  45818. private _defaultHeight;
  45819. private _teleportationInitialized;
  45820. private _interactionsEnabled;
  45821. private _interactionsRequested;
  45822. private _displayGaze;
  45823. private _displayLaserPointer;
  45824. /**
  45825. * The mesh used to display where the user is going to teleport.
  45826. */
  45827. get teleportationTarget(): Mesh;
  45828. /**
  45829. * Sets the mesh to be used to display where the user is going to teleport.
  45830. */
  45831. set teleportationTarget(value: Mesh);
  45832. /**
  45833. * 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
  45834. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45835. * See http://doc.babylonjs.com/resources/baking_transformations
  45836. */
  45837. get gazeTrackerMesh(): Mesh;
  45838. set gazeTrackerMesh(value: Mesh);
  45839. /**
  45840. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45841. */
  45842. updateGazeTrackerScale: boolean;
  45843. /**
  45844. * If the gaze trackers color should be updated when selecting meshes
  45845. */
  45846. updateGazeTrackerColor: boolean;
  45847. /**
  45848. * If the controller laser color should be updated when selecting meshes
  45849. */
  45850. updateControllerLaserColor: boolean;
  45851. /**
  45852. * The gaze tracking mesh corresponding to the left controller
  45853. */
  45854. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45855. /**
  45856. * The gaze tracking mesh corresponding to the right controller
  45857. */
  45858. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45859. /**
  45860. * If the ray of the gaze should be displayed.
  45861. */
  45862. get displayGaze(): boolean;
  45863. /**
  45864. * Sets if the ray of the gaze should be displayed.
  45865. */
  45866. set displayGaze(value: boolean);
  45867. /**
  45868. * If the ray of the LaserPointer should be displayed.
  45869. */
  45870. get displayLaserPointer(): boolean;
  45871. /**
  45872. * Sets if the ray of the LaserPointer should be displayed.
  45873. */
  45874. set displayLaserPointer(value: boolean);
  45875. /**
  45876. * The deviceOrientationCamera used as the camera when not in VR.
  45877. */
  45878. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45879. /**
  45880. * Based on the current WebVR support, returns the current VR camera used.
  45881. */
  45882. get currentVRCamera(): Nullable<Camera>;
  45883. /**
  45884. * The webVRCamera which is used when in VR.
  45885. */
  45886. get webVRCamera(): WebVRFreeCamera;
  45887. /**
  45888. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45889. */
  45890. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45891. /**
  45892. * The html button that is used to trigger entering into VR.
  45893. */
  45894. get vrButton(): Nullable<HTMLButtonElement>;
  45895. private get _teleportationRequestInitiated();
  45896. /**
  45897. * Defines whether or not Pointer lock should be requested when switching to
  45898. * full screen.
  45899. */
  45900. requestPointerLockOnFullScreen: boolean;
  45901. /**
  45902. * If asking to force XR, this will be populated with the default xr experience
  45903. */
  45904. xr: WebXRDefaultExperience;
  45905. /**
  45906. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45907. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45908. */
  45909. xrTestDone: boolean;
  45910. /**
  45911. * Instantiates a VRExperienceHelper.
  45912. * Helps to quickly add VR support to an existing scene.
  45913. * @param scene The scene the VRExperienceHelper belongs to.
  45914. * @param webVROptions Options to modify the vr experience helper's behavior.
  45915. */
  45916. constructor(scene: Scene,
  45917. /** Options to modify the vr experience helper's behavior. */
  45918. webVROptions?: VRExperienceHelperOptions);
  45919. private completeVRInit;
  45920. private _onDefaultMeshLoaded;
  45921. private _onResize;
  45922. private _onFullscreenChange;
  45923. /**
  45924. * Gets a value indicating if we are currently in VR mode.
  45925. */
  45926. get isInVRMode(): boolean;
  45927. private onVrDisplayPresentChange;
  45928. private onVRDisplayChanged;
  45929. private moveButtonToBottomRight;
  45930. private displayVRButton;
  45931. private updateButtonVisibility;
  45932. private _cachedAngularSensibility;
  45933. /**
  45934. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45935. * Otherwise, will use the fullscreen API.
  45936. */
  45937. enterVR(): void;
  45938. /**
  45939. * Attempt to exit VR, or fullscreen.
  45940. */
  45941. exitVR(): void;
  45942. /**
  45943. * The position of the vr experience helper.
  45944. */
  45945. get position(): Vector3;
  45946. /**
  45947. * Sets the position of the vr experience helper.
  45948. */
  45949. set position(value: Vector3);
  45950. /**
  45951. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45952. */
  45953. enableInteractions(): void;
  45954. private get _noControllerIsActive();
  45955. private beforeRender;
  45956. private _isTeleportationFloor;
  45957. /**
  45958. * Adds a floor mesh to be used for teleportation.
  45959. * @param floorMesh the mesh to be used for teleportation.
  45960. */
  45961. addFloorMesh(floorMesh: Mesh): void;
  45962. /**
  45963. * Removes a floor mesh from being used for teleportation.
  45964. * @param floorMesh the mesh to be removed.
  45965. */
  45966. removeFloorMesh(floorMesh: Mesh): void;
  45967. /**
  45968. * Enables interactions and teleportation using the VR controllers and gaze.
  45969. * @param vrTeleportationOptions options to modify teleportation behavior.
  45970. */
  45971. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45972. private _onNewGamepadConnected;
  45973. private _tryEnableInteractionOnController;
  45974. private _onNewGamepadDisconnected;
  45975. private _enableInteractionOnController;
  45976. private _checkTeleportWithRay;
  45977. private _checkRotate;
  45978. private _checkTeleportBackwards;
  45979. private _enableTeleportationOnController;
  45980. private _createTeleportationCircles;
  45981. private _displayTeleportationTarget;
  45982. private _hideTeleportationTarget;
  45983. private _rotateCamera;
  45984. private _moveTeleportationSelectorTo;
  45985. private _workingVector;
  45986. private _workingQuaternion;
  45987. private _workingMatrix;
  45988. /**
  45989. * Time Constant Teleportation Mode
  45990. */
  45991. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45992. /**
  45993. * Speed Constant Teleportation Mode
  45994. */
  45995. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45996. /**
  45997. * Teleports the users feet to the desired location
  45998. * @param location The location where the user's feet should be placed
  45999. */
  46000. teleportCamera(location: Vector3): void;
  46001. private _convertNormalToDirectionOfRay;
  46002. private _castRayAndSelectObject;
  46003. private _notifySelectedMeshUnselected;
  46004. /**
  46005. * Permanently set new colors for the laser pointer
  46006. * @param color the new laser color
  46007. * @param pickedColor the new laser color when picked mesh detected
  46008. */
  46009. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46010. /**
  46011. * Set lighting enabled / disabled on the laser pointer of both controllers
  46012. * @param enabled should the lighting be enabled on the laser pointer
  46013. */
  46014. setLaserLightingState(enabled?: boolean): void;
  46015. /**
  46016. * Permanently set new colors for the gaze pointer
  46017. * @param color the new gaze color
  46018. * @param pickedColor the new gaze color when picked mesh detected
  46019. */
  46020. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46021. /**
  46022. * Sets the color of the laser ray from the vr controllers.
  46023. * @param color new color for the ray.
  46024. */
  46025. changeLaserColor(color: Color3): void;
  46026. /**
  46027. * Sets the color of the ray from the vr headsets gaze.
  46028. * @param color new color for the ray.
  46029. */
  46030. changeGazeColor(color: Color3): void;
  46031. /**
  46032. * Exits VR and disposes of the vr experience helper
  46033. */
  46034. dispose(): void;
  46035. /**
  46036. * Gets the name of the VRExperienceHelper class
  46037. * @returns "VRExperienceHelper"
  46038. */
  46039. getClassName(): string;
  46040. }
  46041. }
  46042. declare module BABYLON {
  46043. /**
  46044. * Contains an array of blocks representing the octree
  46045. */
  46046. export interface IOctreeContainer<T> {
  46047. /**
  46048. * Blocks within the octree
  46049. */
  46050. blocks: Array<OctreeBlock<T>>;
  46051. }
  46052. /**
  46053. * Class used to store a cell in an octree
  46054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46055. */
  46056. export class OctreeBlock<T> {
  46057. /**
  46058. * Gets the content of the current block
  46059. */
  46060. entries: T[];
  46061. /**
  46062. * Gets the list of block children
  46063. */
  46064. blocks: Array<OctreeBlock<T>>;
  46065. private _depth;
  46066. private _maxDepth;
  46067. private _capacity;
  46068. private _minPoint;
  46069. private _maxPoint;
  46070. private _boundingVectors;
  46071. private _creationFunc;
  46072. /**
  46073. * Creates a new block
  46074. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46075. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46076. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46077. * @param depth defines the current depth of this block in the octree
  46078. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46079. * @param creationFunc defines a callback to call when an element is added to the block
  46080. */
  46081. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46082. /**
  46083. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46084. */
  46085. get capacity(): number;
  46086. /**
  46087. * Gets the minimum vector (in world space) of the block's bounding box
  46088. */
  46089. get minPoint(): Vector3;
  46090. /**
  46091. * Gets the maximum vector (in world space) of the block's bounding box
  46092. */
  46093. get maxPoint(): Vector3;
  46094. /**
  46095. * Add a new element to this block
  46096. * @param entry defines the element to add
  46097. */
  46098. addEntry(entry: T): void;
  46099. /**
  46100. * Remove an element from this block
  46101. * @param entry defines the element to remove
  46102. */
  46103. removeEntry(entry: T): void;
  46104. /**
  46105. * Add an array of elements to this block
  46106. * @param entries defines the array of elements to add
  46107. */
  46108. addEntries(entries: T[]): void;
  46109. /**
  46110. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46111. * @param frustumPlanes defines the frustum planes to test
  46112. * @param selection defines the array to store current content if selection is positive
  46113. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46114. */
  46115. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46116. /**
  46117. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46118. * @param sphereCenter defines the bounding sphere center
  46119. * @param sphereRadius defines the bounding sphere radius
  46120. * @param selection defines the array to store current content if selection is positive
  46121. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46122. */
  46123. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46124. /**
  46125. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46126. * @param ray defines the ray to test with
  46127. * @param selection defines the array to store current content if selection is positive
  46128. */
  46129. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46130. /**
  46131. * Subdivide the content into child blocks (this block will then be empty)
  46132. */
  46133. createInnerBlocks(): void;
  46134. /**
  46135. * @hidden
  46136. */
  46137. 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;
  46138. }
  46139. }
  46140. declare module BABYLON {
  46141. /**
  46142. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46143. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46144. */
  46145. export class Octree<T> {
  46146. /** 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.) */
  46147. maxDepth: number;
  46148. /**
  46149. * Blocks within the octree containing objects
  46150. */
  46151. blocks: Array<OctreeBlock<T>>;
  46152. /**
  46153. * Content stored in the octree
  46154. */
  46155. dynamicContent: T[];
  46156. private _maxBlockCapacity;
  46157. private _selectionContent;
  46158. private _creationFunc;
  46159. /**
  46160. * Creates a octree
  46161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46162. * @param creationFunc function to be used to instatiate the octree
  46163. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46164. * @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.)
  46165. */
  46166. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46167. /** 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.) */
  46168. maxDepth?: number);
  46169. /**
  46170. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46171. * @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);
  46172. * @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);
  46173. * @param entries meshes to be added to the octree blocks
  46174. */
  46175. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46176. /**
  46177. * Adds a mesh to the octree
  46178. * @param entry Mesh to add to the octree
  46179. */
  46180. addMesh(entry: T): void;
  46181. /**
  46182. * Remove an element from the octree
  46183. * @param entry defines the element to remove
  46184. */
  46185. removeMesh(entry: T): void;
  46186. /**
  46187. * Selects an array of meshes within the frustum
  46188. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46189. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46190. * @returns array of meshes within the frustum
  46191. */
  46192. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46193. /**
  46194. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46195. * @param sphereCenter defines the bounding sphere center
  46196. * @param sphereRadius defines the bounding sphere radius
  46197. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46198. * @returns an array of objects that intersect the sphere
  46199. */
  46200. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46201. /**
  46202. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46203. * @param ray defines the ray to test with
  46204. * @returns array of intersected objects
  46205. */
  46206. intersectsRay(ray: Ray): SmartArray<T>;
  46207. /**
  46208. * Adds a mesh into the octree block if it intersects the block
  46209. */
  46210. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46211. /**
  46212. * Adds a submesh into the octree block if it intersects the block
  46213. */
  46214. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46215. }
  46216. }
  46217. declare module BABYLON {
  46218. interface Scene {
  46219. /**
  46220. * @hidden
  46221. * Backing Filed
  46222. */
  46223. _selectionOctree: Octree<AbstractMesh>;
  46224. /**
  46225. * Gets the octree used to boost mesh selection (picking)
  46226. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46227. */
  46228. selectionOctree: Octree<AbstractMesh>;
  46229. /**
  46230. * Creates or updates the octree used to boost selection (picking)
  46231. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46232. * @param maxCapacity defines the maximum capacity per leaf
  46233. * @param maxDepth defines the maximum depth of the octree
  46234. * @returns an octree of AbstractMesh
  46235. */
  46236. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46237. }
  46238. interface AbstractMesh {
  46239. /**
  46240. * @hidden
  46241. * Backing Field
  46242. */
  46243. _submeshesOctree: Octree<SubMesh>;
  46244. /**
  46245. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46246. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46247. * @param maxCapacity defines the maximum size of each block (64 by default)
  46248. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46249. * @returns the new octree
  46250. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46252. */
  46253. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46254. }
  46255. /**
  46256. * Defines the octree scene component responsible to manage any octrees
  46257. * in a given scene.
  46258. */
  46259. export class OctreeSceneComponent {
  46260. /**
  46261. * The component name help to identify the component in the list of scene components.
  46262. */
  46263. readonly name: string;
  46264. /**
  46265. * The scene the component belongs to.
  46266. */
  46267. scene: Scene;
  46268. /**
  46269. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46270. */
  46271. readonly checksIsEnabled: boolean;
  46272. /**
  46273. * Creates a new instance of the component for the given scene
  46274. * @param scene Defines the scene to register the component in
  46275. */
  46276. constructor(scene: Scene);
  46277. /**
  46278. * Registers the component in a given scene
  46279. */
  46280. register(): void;
  46281. /**
  46282. * Return the list of active meshes
  46283. * @returns the list of active meshes
  46284. */
  46285. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46286. /**
  46287. * Return the list of active sub meshes
  46288. * @param mesh The mesh to get the candidates sub meshes from
  46289. * @returns the list of active sub meshes
  46290. */
  46291. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46292. private _tempRay;
  46293. /**
  46294. * Return the list of sub meshes intersecting with a given local ray
  46295. * @param mesh defines the mesh to find the submesh for
  46296. * @param localRay defines the ray in local space
  46297. * @returns the list of intersecting sub meshes
  46298. */
  46299. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46300. /**
  46301. * Return the list of sub meshes colliding with a collider
  46302. * @param mesh defines the mesh to find the submesh for
  46303. * @param collider defines the collider to evaluate the collision against
  46304. * @returns the list of colliding sub meshes
  46305. */
  46306. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46307. /**
  46308. * Rebuilds the elements related to this component in case of
  46309. * context lost for instance.
  46310. */
  46311. rebuild(): void;
  46312. /**
  46313. * Disposes the component and the associated ressources.
  46314. */
  46315. dispose(): void;
  46316. }
  46317. }
  46318. declare module BABYLON {
  46319. /**
  46320. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46321. */
  46322. export class Gizmo implements IDisposable {
  46323. /** The utility layer the gizmo will be added to */
  46324. gizmoLayer: UtilityLayerRenderer;
  46325. /**
  46326. * The root mesh of the gizmo
  46327. */
  46328. _rootMesh: Mesh;
  46329. private _attachedMesh;
  46330. /**
  46331. * Ratio for the scale of the gizmo (Default: 1)
  46332. */
  46333. scaleRatio: number;
  46334. /**
  46335. * If a custom mesh has been set (Default: false)
  46336. */
  46337. protected _customMeshSet: boolean;
  46338. /**
  46339. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46340. * * When set, interactions will be enabled
  46341. */
  46342. get attachedMesh(): Nullable<AbstractMesh>;
  46343. set attachedMesh(value: Nullable<AbstractMesh>);
  46344. /**
  46345. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46346. * @param mesh The mesh to replace the default mesh of the gizmo
  46347. */
  46348. setCustomMesh(mesh: Mesh): void;
  46349. /**
  46350. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46351. */
  46352. updateGizmoRotationToMatchAttachedMesh: boolean;
  46353. /**
  46354. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46355. */
  46356. updateGizmoPositionToMatchAttachedMesh: boolean;
  46357. /**
  46358. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46359. */
  46360. updateScale: boolean;
  46361. protected _interactionsEnabled: boolean;
  46362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46363. private _beforeRenderObserver;
  46364. private _tempVector;
  46365. /**
  46366. * Creates a gizmo
  46367. * @param gizmoLayer The utility layer the gizmo will be added to
  46368. */
  46369. constructor(
  46370. /** The utility layer the gizmo will be added to */
  46371. gizmoLayer?: UtilityLayerRenderer);
  46372. /**
  46373. * Updates the gizmo to match the attached mesh's position/rotation
  46374. */
  46375. protected _update(): void;
  46376. /**
  46377. * Disposes of the gizmo
  46378. */
  46379. dispose(): void;
  46380. }
  46381. }
  46382. declare module BABYLON {
  46383. /**
  46384. * Single plane drag gizmo
  46385. */
  46386. export class PlaneDragGizmo extends Gizmo {
  46387. /**
  46388. * Drag behavior responsible for the gizmos dragging interactions
  46389. */
  46390. dragBehavior: PointerDragBehavior;
  46391. private _pointerObserver;
  46392. /**
  46393. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46394. */
  46395. snapDistance: number;
  46396. /**
  46397. * Event that fires each time the gizmo snaps to a new location.
  46398. * * snapDistance is the the change in distance
  46399. */
  46400. onSnapObservable: Observable<{
  46401. snapDistance: number;
  46402. }>;
  46403. private _plane;
  46404. private _coloredMaterial;
  46405. private _hoverMaterial;
  46406. private _isEnabled;
  46407. private _parent;
  46408. /** @hidden */
  46409. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46410. /** @hidden */
  46411. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46412. /**
  46413. * Creates a PlaneDragGizmo
  46414. * @param gizmoLayer The utility layer the gizmo will be added to
  46415. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46416. * @param color The color of the gizmo
  46417. */
  46418. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46419. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46420. /**
  46421. * If the gizmo is enabled
  46422. */
  46423. set isEnabled(value: boolean);
  46424. get isEnabled(): boolean;
  46425. /**
  46426. * Disposes of the gizmo
  46427. */
  46428. dispose(): void;
  46429. }
  46430. }
  46431. declare module BABYLON {
  46432. /**
  46433. * Gizmo that enables dragging a mesh along 3 axis
  46434. */
  46435. export class PositionGizmo extends Gizmo {
  46436. /**
  46437. * Internal gizmo used for interactions on the x axis
  46438. */
  46439. xGizmo: AxisDragGizmo;
  46440. /**
  46441. * Internal gizmo used for interactions on the y axis
  46442. */
  46443. yGizmo: AxisDragGizmo;
  46444. /**
  46445. * Internal gizmo used for interactions on the z axis
  46446. */
  46447. zGizmo: AxisDragGizmo;
  46448. /**
  46449. * Internal gizmo used for interactions on the yz plane
  46450. */
  46451. xPlaneGizmo: PlaneDragGizmo;
  46452. /**
  46453. * Internal gizmo used for interactions on the xz plane
  46454. */
  46455. yPlaneGizmo: PlaneDragGizmo;
  46456. /**
  46457. * Internal gizmo used for interactions on the xy plane
  46458. */
  46459. zPlaneGizmo: PlaneDragGizmo;
  46460. /**
  46461. * private variables
  46462. */
  46463. private _meshAttached;
  46464. private _updateGizmoRotationToMatchAttachedMesh;
  46465. private _snapDistance;
  46466. private _scaleRatio;
  46467. /** Fires an event when any of it's sub gizmos are dragged */
  46468. onDragStartObservable: Observable<unknown>;
  46469. /** Fires an event when any of it's sub gizmos are released from dragging */
  46470. onDragEndObservable: Observable<unknown>;
  46471. /**
  46472. * If set to true, planar drag is enabled
  46473. */
  46474. private _planarGizmoEnabled;
  46475. get attachedMesh(): Nullable<AbstractMesh>;
  46476. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46477. /**
  46478. * Creates a PositionGizmo
  46479. * @param gizmoLayer The utility layer the gizmo will be added to
  46480. */
  46481. constructor(gizmoLayer?: UtilityLayerRenderer);
  46482. /**
  46483. * If the planar drag gizmo is enabled
  46484. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46485. */
  46486. set planarGizmoEnabled(value: boolean);
  46487. get planarGizmoEnabled(): boolean;
  46488. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46489. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46490. /**
  46491. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46492. */
  46493. set snapDistance(value: number);
  46494. get snapDistance(): number;
  46495. /**
  46496. * Ratio for the scale of the gizmo (Default: 1)
  46497. */
  46498. set scaleRatio(value: number);
  46499. get scaleRatio(): number;
  46500. /**
  46501. * Disposes of the gizmo
  46502. */
  46503. dispose(): void;
  46504. /**
  46505. * CustomMeshes are not supported by this gizmo
  46506. * @param mesh The mesh to replace the default mesh of the gizmo
  46507. */
  46508. setCustomMesh(mesh: Mesh): void;
  46509. }
  46510. }
  46511. declare module BABYLON {
  46512. /**
  46513. * Single axis drag gizmo
  46514. */
  46515. export class AxisDragGizmo extends Gizmo {
  46516. /**
  46517. * Drag behavior responsible for the gizmos dragging interactions
  46518. */
  46519. dragBehavior: PointerDragBehavior;
  46520. private _pointerObserver;
  46521. /**
  46522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46523. */
  46524. snapDistance: number;
  46525. /**
  46526. * Event that fires each time the gizmo snaps to a new location.
  46527. * * snapDistance is the the change in distance
  46528. */
  46529. onSnapObservable: Observable<{
  46530. snapDistance: number;
  46531. }>;
  46532. private _isEnabled;
  46533. private _parent;
  46534. private _arrow;
  46535. private _coloredMaterial;
  46536. private _hoverMaterial;
  46537. /** @hidden */
  46538. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46539. /** @hidden */
  46540. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46541. /**
  46542. * Creates an AxisDragGizmo
  46543. * @param gizmoLayer The utility layer the gizmo will be added to
  46544. * @param dragAxis The axis which the gizmo will be able to drag on
  46545. * @param color The color of the gizmo
  46546. */
  46547. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46549. /**
  46550. * If the gizmo is enabled
  46551. */
  46552. set isEnabled(value: boolean);
  46553. get isEnabled(): boolean;
  46554. /**
  46555. * Disposes of the gizmo
  46556. */
  46557. dispose(): void;
  46558. }
  46559. }
  46560. declare module BABYLON.Debug {
  46561. /**
  46562. * The Axes viewer will show 3 axes in a specific point in space
  46563. */
  46564. export class AxesViewer {
  46565. private _xAxis;
  46566. private _yAxis;
  46567. private _zAxis;
  46568. private _scaleLinesFactor;
  46569. private _instanced;
  46570. /**
  46571. * Gets the hosting scene
  46572. */
  46573. scene: Scene;
  46574. /**
  46575. * Gets or sets a number used to scale line length
  46576. */
  46577. scaleLines: number;
  46578. /** Gets the node hierarchy used to render x-axis */
  46579. get xAxis(): TransformNode;
  46580. /** Gets the node hierarchy used to render y-axis */
  46581. get yAxis(): TransformNode;
  46582. /** Gets the node hierarchy used to render z-axis */
  46583. get zAxis(): TransformNode;
  46584. /**
  46585. * Creates a new AxesViewer
  46586. * @param scene defines the hosting scene
  46587. * @param scaleLines defines a number used to scale line length (1 by default)
  46588. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46589. * @param xAxis defines the node hierarchy used to render the x-axis
  46590. * @param yAxis defines the node hierarchy used to render the y-axis
  46591. * @param zAxis defines the node hierarchy used to render the z-axis
  46592. */
  46593. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46594. /**
  46595. * Force the viewer to update
  46596. * @param position defines the position of the viewer
  46597. * @param xaxis defines the x axis of the viewer
  46598. * @param yaxis defines the y axis of the viewer
  46599. * @param zaxis defines the z axis of the viewer
  46600. */
  46601. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46602. /**
  46603. * Creates an instance of this axes viewer.
  46604. * @returns a new axes viewer with instanced meshes
  46605. */
  46606. createInstance(): AxesViewer;
  46607. /** Releases resources */
  46608. dispose(): void;
  46609. private static _SetRenderingGroupId;
  46610. }
  46611. }
  46612. declare module BABYLON.Debug {
  46613. /**
  46614. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46615. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46616. */
  46617. export class BoneAxesViewer extends AxesViewer {
  46618. /**
  46619. * Gets or sets the target mesh where to display the axes viewer
  46620. */
  46621. mesh: Nullable<Mesh>;
  46622. /**
  46623. * Gets or sets the target bone where to display the axes viewer
  46624. */
  46625. bone: Nullable<Bone>;
  46626. /** Gets current position */
  46627. pos: Vector3;
  46628. /** Gets direction of X axis */
  46629. xaxis: Vector3;
  46630. /** Gets direction of Y axis */
  46631. yaxis: Vector3;
  46632. /** Gets direction of Z axis */
  46633. zaxis: Vector3;
  46634. /**
  46635. * Creates a new BoneAxesViewer
  46636. * @param scene defines the hosting scene
  46637. * @param bone defines the target bone
  46638. * @param mesh defines the target mesh
  46639. * @param scaleLines defines a scaling factor for line length (1 by default)
  46640. */
  46641. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46642. /**
  46643. * Force the viewer to update
  46644. */
  46645. update(): void;
  46646. /** Releases resources */
  46647. dispose(): void;
  46648. }
  46649. }
  46650. declare module BABYLON {
  46651. /**
  46652. * Interface used to define scene explorer extensibility option
  46653. */
  46654. export interface IExplorerExtensibilityOption {
  46655. /**
  46656. * Define the option label
  46657. */
  46658. label: string;
  46659. /**
  46660. * Defines the action to execute on click
  46661. */
  46662. action: (entity: any) => void;
  46663. }
  46664. /**
  46665. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46666. */
  46667. export interface IExplorerExtensibilityGroup {
  46668. /**
  46669. * Defines a predicate to test if a given type mut be extended
  46670. */
  46671. predicate: (entity: any) => boolean;
  46672. /**
  46673. * Gets the list of options added to a type
  46674. */
  46675. entries: IExplorerExtensibilityOption[];
  46676. }
  46677. /**
  46678. * Interface used to define the options to use to create the Inspector
  46679. */
  46680. export interface IInspectorOptions {
  46681. /**
  46682. * Display in overlay mode (default: false)
  46683. */
  46684. overlay?: boolean;
  46685. /**
  46686. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46687. */
  46688. globalRoot?: HTMLElement;
  46689. /**
  46690. * Display the Scene explorer
  46691. */
  46692. showExplorer?: boolean;
  46693. /**
  46694. * Display the property inspector
  46695. */
  46696. showInspector?: boolean;
  46697. /**
  46698. * Display in embed mode (both panes on the right)
  46699. */
  46700. embedMode?: boolean;
  46701. /**
  46702. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46703. */
  46704. handleResize?: boolean;
  46705. /**
  46706. * Allow the panes to popup (default: true)
  46707. */
  46708. enablePopup?: boolean;
  46709. /**
  46710. * Allow the panes to be closed by users (default: true)
  46711. */
  46712. enableClose?: boolean;
  46713. /**
  46714. * Optional list of extensibility entries
  46715. */
  46716. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46717. /**
  46718. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46719. */
  46720. inspectorURL?: string;
  46721. /**
  46722. * Optional initial tab (default to DebugLayerTab.Properties)
  46723. */
  46724. initialTab?: DebugLayerTab;
  46725. }
  46726. interface Scene {
  46727. /**
  46728. * @hidden
  46729. * Backing field
  46730. */
  46731. _debugLayer: DebugLayer;
  46732. /**
  46733. * Gets the debug layer (aka Inspector) associated with the scene
  46734. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46735. */
  46736. debugLayer: DebugLayer;
  46737. }
  46738. /**
  46739. * Enum of inspector action tab
  46740. */
  46741. export enum DebugLayerTab {
  46742. /**
  46743. * Properties tag (default)
  46744. */
  46745. Properties = 0,
  46746. /**
  46747. * Debug tab
  46748. */
  46749. Debug = 1,
  46750. /**
  46751. * Statistics tab
  46752. */
  46753. Statistics = 2,
  46754. /**
  46755. * Tools tab
  46756. */
  46757. Tools = 3,
  46758. /**
  46759. * Settings tab
  46760. */
  46761. Settings = 4
  46762. }
  46763. /**
  46764. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46765. * what is happening in your scene
  46766. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46767. */
  46768. export class DebugLayer {
  46769. /**
  46770. * Define the url to get the inspector script from.
  46771. * By default it uses the babylonjs CDN.
  46772. * @ignoreNaming
  46773. */
  46774. static InspectorURL: string;
  46775. private _scene;
  46776. private BJSINSPECTOR;
  46777. private _onPropertyChangedObservable?;
  46778. /**
  46779. * Observable triggered when a property is changed through the inspector.
  46780. */
  46781. get onPropertyChangedObservable(): any;
  46782. /**
  46783. * Instantiates a new debug layer.
  46784. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46785. * what is happening in your scene
  46786. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46787. * @param scene Defines the scene to inspect
  46788. */
  46789. constructor(scene: Scene);
  46790. /** Creates the inspector window. */
  46791. private _createInspector;
  46792. /**
  46793. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46794. * @param entity defines the entity to select
  46795. * @param lineContainerTitle defines the specific block to highlight
  46796. */
  46797. select(entity: any, lineContainerTitle?: string): void;
  46798. /** Get the inspector from bundle or global */
  46799. private _getGlobalInspector;
  46800. /**
  46801. * Get if the inspector is visible or not.
  46802. * @returns true if visible otherwise, false
  46803. */
  46804. isVisible(): boolean;
  46805. /**
  46806. * Hide the inspector and close its window.
  46807. */
  46808. hide(): void;
  46809. /**
  46810. * Launch the debugLayer.
  46811. * @param config Define the configuration of the inspector
  46812. * @return a promise fulfilled when the debug layer is visible
  46813. */
  46814. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46815. }
  46816. }
  46817. declare module BABYLON {
  46818. /**
  46819. * Class containing static functions to help procedurally build meshes
  46820. */
  46821. export class BoxBuilder {
  46822. /**
  46823. * Creates a box mesh
  46824. * * The parameter `size` sets the size (float) of each box side (default 1)
  46825. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46826. * * 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)
  46827. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46829. * * 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
  46830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46831. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46832. * @param name defines the name of the mesh
  46833. * @param options defines the options used to create the mesh
  46834. * @param scene defines the hosting scene
  46835. * @returns the box mesh
  46836. */
  46837. static CreateBox(name: string, options: {
  46838. size?: number;
  46839. width?: number;
  46840. height?: number;
  46841. depth?: number;
  46842. faceUV?: Vector4[];
  46843. faceColors?: Color4[];
  46844. sideOrientation?: number;
  46845. frontUVs?: Vector4;
  46846. backUVs?: Vector4;
  46847. wrap?: boolean;
  46848. topBaseAt?: number;
  46849. bottomBaseAt?: number;
  46850. updatable?: boolean;
  46851. }, scene?: Nullable<Scene>): Mesh;
  46852. }
  46853. }
  46854. declare module BABYLON.Debug {
  46855. /**
  46856. * Used to show the physics impostor around the specific mesh
  46857. */
  46858. export class PhysicsViewer {
  46859. /** @hidden */
  46860. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46861. /** @hidden */
  46862. protected _meshes: Array<Nullable<AbstractMesh>>;
  46863. /** @hidden */
  46864. protected _scene: Nullable<Scene>;
  46865. /** @hidden */
  46866. protected _numMeshes: number;
  46867. /** @hidden */
  46868. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46869. private _renderFunction;
  46870. private _utilityLayer;
  46871. private _debugBoxMesh;
  46872. private _debugSphereMesh;
  46873. private _debugCylinderMesh;
  46874. private _debugMaterial;
  46875. private _debugMeshMeshes;
  46876. /**
  46877. * Creates a new PhysicsViewer
  46878. * @param scene defines the hosting scene
  46879. */
  46880. constructor(scene: Scene);
  46881. /** @hidden */
  46882. protected _updateDebugMeshes(): void;
  46883. /**
  46884. * Renders a specified physic impostor
  46885. * @param impostor defines the impostor to render
  46886. * @param targetMesh defines the mesh represented by the impostor
  46887. * @returns the new debug mesh used to render the impostor
  46888. */
  46889. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46890. /**
  46891. * Hides a specified physic impostor
  46892. * @param impostor defines the impostor to hide
  46893. */
  46894. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46895. private _getDebugMaterial;
  46896. private _getDebugBoxMesh;
  46897. private _getDebugSphereMesh;
  46898. private _getDebugCylinderMesh;
  46899. private _getDebugMeshMesh;
  46900. private _getDebugMesh;
  46901. /** Releases all resources */
  46902. dispose(): void;
  46903. }
  46904. }
  46905. declare module BABYLON {
  46906. /**
  46907. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46908. * in order to better appreciate the issue one might have.
  46909. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46910. */
  46911. export class RayHelper {
  46912. /**
  46913. * Defines the ray we are currently tryin to visualize.
  46914. */
  46915. ray: Nullable<Ray>;
  46916. private _renderPoints;
  46917. private _renderLine;
  46918. private _renderFunction;
  46919. private _scene;
  46920. private _updateToMeshFunction;
  46921. private _attachedToMesh;
  46922. private _meshSpaceDirection;
  46923. private _meshSpaceOrigin;
  46924. /**
  46925. * Helper function to create a colored helper in a scene in one line.
  46926. * @param ray Defines the ray we are currently tryin to visualize
  46927. * @param scene Defines the scene the ray is used in
  46928. * @param color Defines the color we want to see the ray in
  46929. * @returns The newly created ray helper.
  46930. */
  46931. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46932. /**
  46933. * Instantiate a new ray helper.
  46934. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46935. * in order to better appreciate the issue one might have.
  46936. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46937. * @param ray Defines the ray we are currently tryin to visualize
  46938. */
  46939. constructor(ray: Ray);
  46940. /**
  46941. * Shows the ray we are willing to debug.
  46942. * @param scene Defines the scene the ray needs to be rendered in
  46943. * @param color Defines the color the ray needs to be rendered in
  46944. */
  46945. show(scene: Scene, color?: Color3): void;
  46946. /**
  46947. * Hides the ray we are debugging.
  46948. */
  46949. hide(): void;
  46950. private _render;
  46951. /**
  46952. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46953. * @param mesh Defines the mesh we want the helper attached to
  46954. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46955. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46956. * @param length Defines the length of the ray
  46957. */
  46958. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46959. /**
  46960. * Detach the ray helper from the mesh it has previously been attached to.
  46961. */
  46962. detachFromMesh(): void;
  46963. private _updateToMesh;
  46964. /**
  46965. * Dispose the helper and release its associated resources.
  46966. */
  46967. dispose(): void;
  46968. }
  46969. }
  46970. declare module BABYLON.Debug {
  46971. /**
  46972. * Class used to render a debug view of a given skeleton
  46973. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46974. */
  46975. export class SkeletonViewer {
  46976. /** defines the skeleton to render */
  46977. skeleton: Skeleton;
  46978. /** defines the mesh attached to the skeleton */
  46979. mesh: AbstractMesh;
  46980. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46981. autoUpdateBonesMatrices: boolean;
  46982. /** defines the rendering group id to use with the viewer */
  46983. renderingGroupId: number;
  46984. /** Gets or sets the color used to render the skeleton */
  46985. color: Color3;
  46986. private _scene;
  46987. private _debugLines;
  46988. private _debugMesh;
  46989. private _isEnabled;
  46990. private _renderFunction;
  46991. private _utilityLayer;
  46992. /**
  46993. * Returns the mesh used to render the bones
  46994. */
  46995. get debugMesh(): Nullable<LinesMesh>;
  46996. /**
  46997. * Creates a new SkeletonViewer
  46998. * @param skeleton defines the skeleton to render
  46999. * @param mesh defines the mesh attached to the skeleton
  47000. * @param scene defines the hosting scene
  47001. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47002. * @param renderingGroupId defines the rendering group id to use with the viewer
  47003. */
  47004. constructor(
  47005. /** defines the skeleton to render */
  47006. skeleton: Skeleton,
  47007. /** defines the mesh attached to the skeleton */
  47008. mesh: AbstractMesh, scene: Scene,
  47009. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47010. autoUpdateBonesMatrices?: boolean,
  47011. /** defines the rendering group id to use with the viewer */
  47012. renderingGroupId?: number);
  47013. /** Gets or sets a boolean indicating if the viewer is enabled */
  47014. set isEnabled(value: boolean);
  47015. get isEnabled(): boolean;
  47016. private _getBonePosition;
  47017. private _getLinesForBonesWithLength;
  47018. private _getLinesForBonesNoLength;
  47019. /** Update the viewer to sync with current skeleton state */
  47020. update(): void;
  47021. /** Release associated resources */
  47022. dispose(): void;
  47023. }
  47024. }
  47025. declare module BABYLON {
  47026. /**
  47027. * This class will take all inputs from Keyboard, Pointer, and
  47028. * any Gamepads and provide a polling system that all devices
  47029. * will use. This class assumes that there will only be one
  47030. * pointer device and one keyboard.
  47031. */
  47032. export class DeviceInputSystem implements IDisposable {
  47033. /** POINTER_DEVICE */
  47034. static readonly POINTER_DEVICE: string;
  47035. /** KEYBOARD_DEVICE */
  47036. static readonly KEYBOARD_DEVICE: string;
  47037. /**
  47038. * Observable to be triggered when a device is connected
  47039. */
  47040. onDeviceConnectedObservable: Observable<string>;
  47041. /**
  47042. * Observable to be triggered when a device is disconnected
  47043. */
  47044. onDeviceDisconnectedObservable: Observable<string>;
  47045. private _inputs;
  47046. private _gamepads;
  47047. private _keyboardActive;
  47048. private _pointerActive;
  47049. private _elementToAttachTo;
  47050. private _keyboardDownEvent;
  47051. private _keyboardUpEvent;
  47052. private _pointerMoveEvent;
  47053. private _pointerDownEvent;
  47054. private _pointerUpEvent;
  47055. private _gamepadConnectedEvent;
  47056. private _gamepadDisconnectedEvent;
  47057. private static _MAX_KEYCODES;
  47058. private static _MAX_POINTER_INPUTS;
  47059. /**
  47060. * Default Constructor
  47061. * @param engine - engine to pull input element from
  47062. */
  47063. constructor(engine: Engine);
  47064. /**
  47065. * Checks for current device input value, given an id and input index
  47066. * @param deviceName Id of connected device
  47067. * @param inputIndex Index of device input
  47068. * @returns Current value of input
  47069. */
  47070. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  47071. /**
  47072. * Dispose of all the eventlisteners and clears the observables
  47073. */
  47074. dispose(): void;
  47075. /**
  47076. * Add device and inputs to device map
  47077. * @param deviceName Assigned name of device (may be SN)
  47078. * @param numberOfInputs Number of input entries to create for given device
  47079. */
  47080. private _registerDevice;
  47081. /**
  47082. * Given a specific device name, remove that device from the device map
  47083. * @param deviceName Name of device to be removed
  47084. */
  47085. private _unregisterDevice;
  47086. /**
  47087. * Handle all actions that come from keyboard interaction
  47088. */
  47089. private _handleKeyActions;
  47090. /**
  47091. * Handle all actions that come from pointer interaction
  47092. */
  47093. private _handlePointerActions;
  47094. /**
  47095. * Handle all actions that come from gamepad interaction
  47096. */
  47097. private _handleGamepadActions;
  47098. /**
  47099. * Update all non-event based devices with each frame
  47100. */
  47101. private _updateDevice;
  47102. }
  47103. }
  47104. declare module BABYLON {
  47105. /**
  47106. * Options to create the null engine
  47107. */
  47108. export class NullEngineOptions {
  47109. /**
  47110. * Render width (Default: 512)
  47111. */
  47112. renderWidth: number;
  47113. /**
  47114. * Render height (Default: 256)
  47115. */
  47116. renderHeight: number;
  47117. /**
  47118. * Texture size (Default: 512)
  47119. */
  47120. textureSize: number;
  47121. /**
  47122. * If delta time between frames should be constant
  47123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47124. */
  47125. deterministicLockstep: boolean;
  47126. /**
  47127. * Maximum about of steps between frames (Default: 4)
  47128. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47129. */
  47130. lockstepMaxSteps: number;
  47131. }
  47132. /**
  47133. * The null engine class provides support for headless version of babylon.js.
  47134. * This can be used in server side scenario or for testing purposes
  47135. */
  47136. export class NullEngine extends Engine {
  47137. private _options;
  47138. /**
  47139. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47141. * @returns true if engine is in deterministic lock step mode
  47142. */
  47143. isDeterministicLockStep(): boolean;
  47144. /**
  47145. * Gets the max steps when engine is running in deterministic lock step
  47146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47147. * @returns the max steps
  47148. */
  47149. getLockstepMaxSteps(): number;
  47150. /**
  47151. * Gets the current hardware scaling level.
  47152. * By default the hardware scaling level is computed from the window device ratio.
  47153. * 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.
  47154. * @returns a number indicating the current hardware scaling level
  47155. */
  47156. getHardwareScalingLevel(): number;
  47157. constructor(options?: NullEngineOptions);
  47158. /**
  47159. * Creates a vertex buffer
  47160. * @param vertices the data for the vertex buffer
  47161. * @returns the new WebGL static buffer
  47162. */
  47163. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47164. /**
  47165. * Creates a new index buffer
  47166. * @param indices defines the content of the index buffer
  47167. * @param updatable defines if the index buffer must be updatable
  47168. * @returns a new webGL buffer
  47169. */
  47170. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47171. /**
  47172. * Clear the current render buffer or the current render target (if any is set up)
  47173. * @param color defines the color to use
  47174. * @param backBuffer defines if the back buffer must be cleared
  47175. * @param depth defines if the depth buffer must be cleared
  47176. * @param stencil defines if the stencil buffer must be cleared
  47177. */
  47178. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47179. /**
  47180. * Gets the current render width
  47181. * @param useScreen defines if screen size must be used (or the current render target if any)
  47182. * @returns a number defining the current render width
  47183. */
  47184. getRenderWidth(useScreen?: boolean): number;
  47185. /**
  47186. * Gets the current render height
  47187. * @param useScreen defines if screen size must be used (or the current render target if any)
  47188. * @returns a number defining the current render height
  47189. */
  47190. getRenderHeight(useScreen?: boolean): number;
  47191. /**
  47192. * Set the WebGL's viewport
  47193. * @param viewport defines the viewport element to be used
  47194. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47195. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47196. */
  47197. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47199. /**
  47200. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47201. * @param pipelineContext defines the pipeline context to use
  47202. * @param uniformsNames defines the list of uniform names
  47203. * @returns an array of webGL uniform locations
  47204. */
  47205. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47206. /**
  47207. * Gets the lsit of active attributes for a given webGL program
  47208. * @param pipelineContext defines the pipeline context to use
  47209. * @param attributesNames defines the list of attribute names to get
  47210. * @returns an array of indices indicating the offset of each attribute
  47211. */
  47212. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47213. /**
  47214. * Binds an effect to the webGL context
  47215. * @param effect defines the effect to bind
  47216. */
  47217. bindSamplers(effect: Effect): void;
  47218. /**
  47219. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47220. * @param effect defines the effect to activate
  47221. */
  47222. enableEffect(effect: Effect): void;
  47223. /**
  47224. * Set various states to the webGL context
  47225. * @param culling defines backface culling state
  47226. * @param zOffset defines the value to apply to zOffset (0 by default)
  47227. * @param force defines if states must be applied even if cache is up to date
  47228. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47229. */
  47230. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47231. /**
  47232. * Set the value of an uniform to an array of int32
  47233. * @param uniform defines the webGL uniform location where to store the value
  47234. * @param array defines the array of int32 to store
  47235. */
  47236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47237. /**
  47238. * Set the value of an uniform to an array of int32 (stored as vec2)
  47239. * @param uniform defines the webGL uniform location where to store the value
  47240. * @param array defines the array of int32 to store
  47241. */
  47242. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47243. /**
  47244. * Set the value of an uniform to an array of int32 (stored as vec3)
  47245. * @param uniform defines the webGL uniform location where to store the value
  47246. * @param array defines the array of int32 to store
  47247. */
  47248. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47249. /**
  47250. * Set the value of an uniform to an array of int32 (stored as vec4)
  47251. * @param uniform defines the webGL uniform location where to store the value
  47252. * @param array defines the array of int32 to store
  47253. */
  47254. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47255. /**
  47256. * Set the value of an uniform to an array of float32
  47257. * @param uniform defines the webGL uniform location where to store the value
  47258. * @param array defines the array of float32 to store
  47259. */
  47260. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47261. /**
  47262. * Set the value of an uniform to an array of float32 (stored as vec2)
  47263. * @param uniform defines the webGL uniform location where to store the value
  47264. * @param array defines the array of float32 to store
  47265. */
  47266. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47267. /**
  47268. * Set the value of an uniform to an array of float32 (stored as vec3)
  47269. * @param uniform defines the webGL uniform location where to store the value
  47270. * @param array defines the array of float32 to store
  47271. */
  47272. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47273. /**
  47274. * Set the value of an uniform to an array of float32 (stored as vec4)
  47275. * @param uniform defines the webGL uniform location where to store the value
  47276. * @param array defines the array of float32 to store
  47277. */
  47278. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47279. /**
  47280. * Set the value of an uniform to an array of number
  47281. * @param uniform defines the webGL uniform location where to store the value
  47282. * @param array defines the array of number to store
  47283. */
  47284. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47285. /**
  47286. * Set the value of an uniform to an array of number (stored as vec2)
  47287. * @param uniform defines the webGL uniform location where to store the value
  47288. * @param array defines the array of number to store
  47289. */
  47290. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47291. /**
  47292. * Set the value of an uniform to an array of number (stored as vec3)
  47293. * @param uniform defines the webGL uniform location where to store the value
  47294. * @param array defines the array of number to store
  47295. */
  47296. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47297. /**
  47298. * Set the value of an uniform to an array of number (stored as vec4)
  47299. * @param uniform defines the webGL uniform location where to store the value
  47300. * @param array defines the array of number to store
  47301. */
  47302. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47303. /**
  47304. * Set the value of an uniform to an array of float32 (stored as matrices)
  47305. * @param uniform defines the webGL uniform location where to store the value
  47306. * @param matrices defines the array of float32 to store
  47307. */
  47308. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47309. /**
  47310. * Set the value of an uniform to a matrix (3x3)
  47311. * @param uniform defines the webGL uniform location where to store the value
  47312. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47313. */
  47314. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47315. /**
  47316. * Set the value of an uniform to a matrix (2x2)
  47317. * @param uniform defines the webGL uniform location where to store the value
  47318. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47319. */
  47320. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47321. /**
  47322. * Set the value of an uniform to a number (float)
  47323. * @param uniform defines the webGL uniform location where to store the value
  47324. * @param value defines the float number to store
  47325. */
  47326. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47327. /**
  47328. * Set the value of an uniform to a vec2
  47329. * @param uniform defines the webGL uniform location where to store the value
  47330. * @param x defines the 1st component of the value
  47331. * @param y defines the 2nd component of the value
  47332. */
  47333. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47334. /**
  47335. * Set the value of an uniform to a vec3
  47336. * @param uniform defines the webGL uniform location where to store the value
  47337. * @param x defines the 1st component of the value
  47338. * @param y defines the 2nd component of the value
  47339. * @param z defines the 3rd component of the value
  47340. */
  47341. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47342. /**
  47343. * Set the value of an uniform to a boolean
  47344. * @param uniform defines the webGL uniform location where to store the value
  47345. * @param bool defines the boolean to store
  47346. */
  47347. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47348. /**
  47349. * Set the value of an uniform to a vec4
  47350. * @param uniform defines the webGL uniform location where to store the value
  47351. * @param x defines the 1st component of the value
  47352. * @param y defines the 2nd component of the value
  47353. * @param z defines the 3rd component of the value
  47354. * @param w defines the 4th component of the value
  47355. */
  47356. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47357. /**
  47358. * Sets the current alpha mode
  47359. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47360. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47361. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47362. */
  47363. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47364. /**
  47365. * Bind webGl buffers directly to the webGL context
  47366. * @param vertexBuffers defines the vertex buffer to bind
  47367. * @param indexBuffer defines the index buffer to bind
  47368. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47369. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47370. * @param effect defines the effect associated with the vertex buffer
  47371. */
  47372. bindBuffers(vertexBuffers: {
  47373. [key: string]: VertexBuffer;
  47374. }, indexBuffer: DataBuffer, effect: Effect): void;
  47375. /**
  47376. * Force the entire cache to be cleared
  47377. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47378. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47379. */
  47380. wipeCaches(bruteForce?: boolean): void;
  47381. /**
  47382. * Send a draw order
  47383. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47384. * @param indexStart defines the starting index
  47385. * @param indexCount defines the number of index to draw
  47386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47387. */
  47388. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47389. /**
  47390. * Draw a list of indexed primitives
  47391. * @param fillMode defines the primitive to use
  47392. * @param indexStart defines the starting index
  47393. * @param indexCount defines the number of index to draw
  47394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47395. */
  47396. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47397. /**
  47398. * Draw a list of unindexed primitives
  47399. * @param fillMode defines the primitive to use
  47400. * @param verticesStart defines the index of first vertex to draw
  47401. * @param verticesCount defines the count of vertices to draw
  47402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47403. */
  47404. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47405. /** @hidden */
  47406. _createTexture(): WebGLTexture;
  47407. /** @hidden */
  47408. _releaseTexture(texture: InternalTexture): void;
  47409. /**
  47410. * Usually called from Texture.ts.
  47411. * Passed information to create a WebGLTexture
  47412. * @param urlArg defines a value which contains one of the following:
  47413. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47414. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47415. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47417. * @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)
  47418. * @param scene needed for loading to the correct scene
  47419. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47420. * @param onLoad optional callback to be called upon successful completion
  47421. * @param onError optional callback to be called upon failure
  47422. * @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
  47423. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47424. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47425. * @param forcedExtension defines the extension to use to pick the right loader
  47426. * @param mimeType defines an optional mime type
  47427. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47428. */
  47429. 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;
  47430. /**
  47431. * Creates a new render target texture
  47432. * @param size defines the size of the texture
  47433. * @param options defines the options used to create the texture
  47434. * @returns a new render target texture stored in an InternalTexture
  47435. */
  47436. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47437. /**
  47438. * Update the sampling mode of a given texture
  47439. * @param samplingMode defines the required sampling mode
  47440. * @param texture defines the texture to update
  47441. */
  47442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47443. /**
  47444. * Binds the frame buffer to the specified texture.
  47445. * @param texture The texture to render to or null for the default canvas
  47446. * @param faceIndex The face of the texture to render to in case of cube texture
  47447. * @param requiredWidth The width of the target to render to
  47448. * @param requiredHeight The height of the target to render to
  47449. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47450. * @param lodLevel defines le lod level to bind to the frame buffer
  47451. */
  47452. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47453. /**
  47454. * Unbind the current render target texture from the webGL context
  47455. * @param texture defines the render target texture to unbind
  47456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47458. */
  47459. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47460. /**
  47461. * Creates a dynamic vertex buffer
  47462. * @param vertices the data for the dynamic vertex buffer
  47463. * @returns the new WebGL dynamic buffer
  47464. */
  47465. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47466. /**
  47467. * Update the content of a dynamic texture
  47468. * @param texture defines the texture to update
  47469. * @param canvas defines the canvas containing the source
  47470. * @param invertY defines if data must be stored with Y axis inverted
  47471. * @param premulAlpha defines if alpha is stored as premultiplied
  47472. * @param format defines the format of the data
  47473. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47474. */
  47475. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47476. /**
  47477. * Gets a boolean indicating if all created effects are ready
  47478. * @returns true if all effects are ready
  47479. */
  47480. areAllEffectsReady(): boolean;
  47481. /**
  47482. * @hidden
  47483. * Get the current error code of the webGL context
  47484. * @returns the error code
  47485. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47486. */
  47487. getError(): number;
  47488. /** @hidden */
  47489. _getUnpackAlignement(): number;
  47490. /** @hidden */
  47491. _unpackFlipY(value: boolean): void;
  47492. /**
  47493. * Update a dynamic index buffer
  47494. * @param indexBuffer defines the target index buffer
  47495. * @param indices defines the data to update
  47496. * @param offset defines the offset in the target index buffer where update should start
  47497. */
  47498. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47499. /**
  47500. * Updates a dynamic vertex buffer.
  47501. * @param vertexBuffer the vertex buffer to update
  47502. * @param vertices the data used to update the vertex buffer
  47503. * @param byteOffset the byte offset of the data (optional)
  47504. * @param byteLength the byte length of the data (optional)
  47505. */
  47506. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47507. /** @hidden */
  47508. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47509. /** @hidden */
  47510. _bindTexture(channel: number, texture: InternalTexture): void;
  47511. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47512. /**
  47513. * 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
  47514. */
  47515. releaseEffects(): void;
  47516. displayLoadingUI(): void;
  47517. hideLoadingUI(): void;
  47518. /** @hidden */
  47519. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47520. /** @hidden */
  47521. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47522. /** @hidden */
  47523. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47524. /** @hidden */
  47525. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47526. }
  47527. }
  47528. declare module BABYLON {
  47529. /**
  47530. * @hidden
  47531. **/
  47532. export class _TimeToken {
  47533. _startTimeQuery: Nullable<WebGLQuery>;
  47534. _endTimeQuery: Nullable<WebGLQuery>;
  47535. _timeElapsedQuery: Nullable<WebGLQuery>;
  47536. _timeElapsedQueryEnded: boolean;
  47537. }
  47538. }
  47539. declare module BABYLON {
  47540. /** @hidden */
  47541. export class _OcclusionDataStorage {
  47542. /** @hidden */
  47543. occlusionInternalRetryCounter: number;
  47544. /** @hidden */
  47545. isOcclusionQueryInProgress: boolean;
  47546. /** @hidden */
  47547. isOccluded: boolean;
  47548. /** @hidden */
  47549. occlusionRetryCount: number;
  47550. /** @hidden */
  47551. occlusionType: number;
  47552. /** @hidden */
  47553. occlusionQueryAlgorithmType: number;
  47554. }
  47555. interface Engine {
  47556. /**
  47557. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47558. * @return the new query
  47559. */
  47560. createQuery(): WebGLQuery;
  47561. /**
  47562. * Delete and release a webGL query
  47563. * @param query defines the query to delete
  47564. * @return the current engine
  47565. */
  47566. deleteQuery(query: WebGLQuery): Engine;
  47567. /**
  47568. * Check if a given query has resolved and got its value
  47569. * @param query defines the query to check
  47570. * @returns true if the query got its value
  47571. */
  47572. isQueryResultAvailable(query: WebGLQuery): boolean;
  47573. /**
  47574. * Gets the value of a given query
  47575. * @param query defines the query to check
  47576. * @returns the value of the query
  47577. */
  47578. getQueryResult(query: WebGLQuery): number;
  47579. /**
  47580. * Initiates an occlusion query
  47581. * @param algorithmType defines the algorithm to use
  47582. * @param query defines the query to use
  47583. * @returns the current engine
  47584. * @see http://doc.babylonjs.com/features/occlusionquery
  47585. */
  47586. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47587. /**
  47588. * Ends an occlusion query
  47589. * @see http://doc.babylonjs.com/features/occlusionquery
  47590. * @param algorithmType defines the algorithm to use
  47591. * @returns the current engine
  47592. */
  47593. endOcclusionQuery(algorithmType: number): Engine;
  47594. /**
  47595. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47596. * Please note that only one query can be issued at a time
  47597. * @returns a time token used to track the time span
  47598. */
  47599. startTimeQuery(): Nullable<_TimeToken>;
  47600. /**
  47601. * Ends a time query
  47602. * @param token defines the token used to measure the time span
  47603. * @returns the time spent (in ns)
  47604. */
  47605. endTimeQuery(token: _TimeToken): int;
  47606. /** @hidden */
  47607. _currentNonTimestampToken: Nullable<_TimeToken>;
  47608. /** @hidden */
  47609. _createTimeQuery(): WebGLQuery;
  47610. /** @hidden */
  47611. _deleteTimeQuery(query: WebGLQuery): void;
  47612. /** @hidden */
  47613. _getGlAlgorithmType(algorithmType: number): number;
  47614. /** @hidden */
  47615. _getTimeQueryResult(query: WebGLQuery): any;
  47616. /** @hidden */
  47617. _getTimeQueryAvailability(query: WebGLQuery): any;
  47618. }
  47619. interface AbstractMesh {
  47620. /**
  47621. * Backing filed
  47622. * @hidden
  47623. */
  47624. __occlusionDataStorage: _OcclusionDataStorage;
  47625. /**
  47626. * Access property
  47627. * @hidden
  47628. */
  47629. _occlusionDataStorage: _OcclusionDataStorage;
  47630. /**
  47631. * 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.
  47632. * The default value is -1 which means don't break the query and wait till the result
  47633. * @see http://doc.babylonjs.com/features/occlusionquery
  47634. */
  47635. occlusionRetryCount: number;
  47636. /**
  47637. * 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:
  47638. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47639. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47640. * * 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.
  47641. * @see http://doc.babylonjs.com/features/occlusionquery
  47642. */
  47643. occlusionType: number;
  47644. /**
  47645. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47646. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47647. * * 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.
  47648. * @see http://doc.babylonjs.com/features/occlusionquery
  47649. */
  47650. occlusionQueryAlgorithmType: number;
  47651. /**
  47652. * 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
  47653. * @see http://doc.babylonjs.com/features/occlusionquery
  47654. */
  47655. isOccluded: boolean;
  47656. /**
  47657. * Flag to check the progress status of the query
  47658. * @see http://doc.babylonjs.com/features/occlusionquery
  47659. */
  47660. isOcclusionQueryInProgress: boolean;
  47661. }
  47662. }
  47663. declare module BABYLON {
  47664. /** @hidden */
  47665. export var _forceTransformFeedbackToBundle: boolean;
  47666. interface Engine {
  47667. /**
  47668. * Creates a webGL transform feedback object
  47669. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47670. * @returns the webGL transform feedback object
  47671. */
  47672. createTransformFeedback(): WebGLTransformFeedback;
  47673. /**
  47674. * Delete a webGL transform feedback object
  47675. * @param value defines the webGL transform feedback object to delete
  47676. */
  47677. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47678. /**
  47679. * Bind a webGL transform feedback object to the webgl context
  47680. * @param value defines the webGL transform feedback object to bind
  47681. */
  47682. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47683. /**
  47684. * Begins a transform feedback operation
  47685. * @param usePoints defines if points or triangles must be used
  47686. */
  47687. beginTransformFeedback(usePoints: boolean): void;
  47688. /**
  47689. * Ends a transform feedback operation
  47690. */
  47691. endTransformFeedback(): void;
  47692. /**
  47693. * Specify the varyings to use with transform feedback
  47694. * @param program defines the associated webGL program
  47695. * @param value defines the list of strings representing the varying names
  47696. */
  47697. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47698. /**
  47699. * Bind a webGL buffer for a transform feedback operation
  47700. * @param value defines the webGL buffer to bind
  47701. */
  47702. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47703. }
  47704. }
  47705. declare module BABYLON {
  47706. /**
  47707. * Creation options of the multi render target texture.
  47708. */
  47709. export interface IMultiRenderTargetOptions {
  47710. /**
  47711. * Define if the texture needs to create mip maps after render.
  47712. */
  47713. generateMipMaps?: boolean;
  47714. /**
  47715. * Define the types of all the draw buffers we want to create
  47716. */
  47717. types?: number[];
  47718. /**
  47719. * Define the sampling modes of all the draw buffers we want to create
  47720. */
  47721. samplingModes?: number[];
  47722. /**
  47723. * Define if a depth buffer is required
  47724. */
  47725. generateDepthBuffer?: boolean;
  47726. /**
  47727. * Define if a stencil buffer is required
  47728. */
  47729. generateStencilBuffer?: boolean;
  47730. /**
  47731. * Define if a depth texture is required instead of a depth buffer
  47732. */
  47733. generateDepthTexture?: boolean;
  47734. /**
  47735. * Define the number of desired draw buffers
  47736. */
  47737. textureCount?: number;
  47738. /**
  47739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47740. */
  47741. doNotChangeAspectRatio?: boolean;
  47742. /**
  47743. * Define the default type of the buffers we are creating
  47744. */
  47745. defaultType?: number;
  47746. }
  47747. /**
  47748. * A multi render target, like a render target provides the ability to render to a texture.
  47749. * Unlike the render target, it can render to several draw buffers in one draw.
  47750. * This is specially interesting in deferred rendering or for any effects requiring more than
  47751. * just one color from a single pass.
  47752. */
  47753. export class MultiRenderTarget extends RenderTargetTexture {
  47754. private _internalTextures;
  47755. private _textures;
  47756. private _multiRenderTargetOptions;
  47757. /**
  47758. * Get if draw buffers are currently supported by the used hardware and browser.
  47759. */
  47760. get isSupported(): boolean;
  47761. /**
  47762. * Get the list of textures generated by the multi render target.
  47763. */
  47764. get textures(): Texture[];
  47765. /**
  47766. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47767. */
  47768. get depthTexture(): Texture;
  47769. /**
  47770. * Set the wrapping mode on U of all the textures we are rendering to.
  47771. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47772. */
  47773. set wrapU(wrap: number);
  47774. /**
  47775. * Set the wrapping mode on V of all the textures we are rendering to.
  47776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47777. */
  47778. set wrapV(wrap: number);
  47779. /**
  47780. * Instantiate a new multi render target texture.
  47781. * A multi render target, like a render target provides the ability to render to a texture.
  47782. * Unlike the render target, it can render to several draw buffers in one draw.
  47783. * This is specially interesting in deferred rendering or for any effects requiring more than
  47784. * just one color from a single pass.
  47785. * @param name Define the name of the texture
  47786. * @param size Define the size of the buffers to render to
  47787. * @param count Define the number of target we are rendering into
  47788. * @param scene Define the scene the texture belongs to
  47789. * @param options Define the options used to create the multi render target
  47790. */
  47791. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47792. /** @hidden */
  47793. _rebuild(): void;
  47794. private _createInternalTextures;
  47795. private _createTextures;
  47796. /**
  47797. * Define the number of samples used if MSAA is enabled.
  47798. */
  47799. get samples(): number;
  47800. set samples(value: number);
  47801. /**
  47802. * Resize all the textures in the multi render target.
  47803. * Be carrefull as it will recreate all the data in the new texture.
  47804. * @param size Define the new size
  47805. */
  47806. resize(size: any): void;
  47807. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47808. /**
  47809. * Dispose the render targets and their associated resources
  47810. */
  47811. dispose(): void;
  47812. /**
  47813. * Release all the underlying texture used as draw buffers.
  47814. */
  47815. releaseInternalTextures(): void;
  47816. }
  47817. }
  47818. declare module BABYLON {
  47819. interface ThinEngine {
  47820. /**
  47821. * Unbind a list of render target textures from the webGL context
  47822. * This is used only when drawBuffer extension or webGL2 are active
  47823. * @param textures defines the render target textures to unbind
  47824. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47825. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47826. */
  47827. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47828. /**
  47829. * Create a multi render target texture
  47830. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47831. * @param size defines the size of the texture
  47832. * @param options defines the creation options
  47833. * @returns the cube texture as an InternalTexture
  47834. */
  47835. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47836. /**
  47837. * Update the sample count for a given multiple render target texture
  47838. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47839. * @param textures defines the textures to update
  47840. * @param samples defines the sample count to set
  47841. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47842. */
  47843. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47844. }
  47845. }
  47846. declare module BABYLON {
  47847. /**
  47848. * Class used to define an additional view for the engine
  47849. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47850. */
  47851. export class EngineView {
  47852. /** Defines the canvas where to render the view */
  47853. target: HTMLCanvasElement;
  47854. /** Defines an optional camera used to render the view (will use active camera else) */
  47855. camera?: Camera;
  47856. }
  47857. interface Engine {
  47858. /**
  47859. * Gets or sets the HTML element to use for attaching events
  47860. */
  47861. inputElement: Nullable<HTMLElement>;
  47862. /**
  47863. * Gets the current engine view
  47864. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47865. */
  47866. activeView: Nullable<EngineView>;
  47867. /** Gets or sets the list of views */
  47868. views: EngineView[];
  47869. /**
  47870. * Register a new child canvas
  47871. * @param canvas defines the canvas to register
  47872. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47873. * @returns the associated view
  47874. */
  47875. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47876. /**
  47877. * Remove a registered child canvas
  47878. * @param canvas defines the canvas to remove
  47879. * @returns the current engine
  47880. */
  47881. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47882. }
  47883. }
  47884. declare module BABYLON {
  47885. interface Engine {
  47886. /** @hidden */
  47887. _excludedCompressedTextures: string[];
  47888. /** @hidden */
  47889. _textureFormatInUse: string;
  47890. /**
  47891. * Gets the list of texture formats supported
  47892. */
  47893. readonly texturesSupported: Array<string>;
  47894. /**
  47895. * Gets the texture format in use
  47896. */
  47897. readonly textureFormatInUse: Nullable<string>;
  47898. /**
  47899. * Set the compressed texture extensions or file names to skip.
  47900. *
  47901. * @param skippedFiles defines the list of those texture files you want to skip
  47902. * Example: [".dds", ".env", "myfile.png"]
  47903. */
  47904. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47905. /**
  47906. * Set the compressed texture format to use, based on the formats you have, and the formats
  47907. * supported by the hardware / browser.
  47908. *
  47909. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47910. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47911. * to API arguments needed to compressed textures. This puts the burden on the container
  47912. * generator to house the arcane code for determining these for current & future formats.
  47913. *
  47914. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47915. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47916. *
  47917. * Note: The result of this call is not taken into account when a texture is base64.
  47918. *
  47919. * @param formatsAvailable defines the list of those format families you have created
  47920. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47921. *
  47922. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47923. * @returns The extension selected.
  47924. */
  47925. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47926. }
  47927. }
  47928. declare module BABYLON {
  47929. /**
  47930. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47931. */
  47932. export interface CubeMapInfo {
  47933. /**
  47934. * The pixel array for the front face.
  47935. * This is stored in format, left to right, up to down format.
  47936. */
  47937. front: Nullable<ArrayBufferView>;
  47938. /**
  47939. * The pixel array for the back face.
  47940. * This is stored in format, left to right, up to down format.
  47941. */
  47942. back: Nullable<ArrayBufferView>;
  47943. /**
  47944. * The pixel array for the left face.
  47945. * This is stored in format, left to right, up to down format.
  47946. */
  47947. left: Nullable<ArrayBufferView>;
  47948. /**
  47949. * The pixel array for the right face.
  47950. * This is stored in format, left to right, up to down format.
  47951. */
  47952. right: Nullable<ArrayBufferView>;
  47953. /**
  47954. * The pixel array for the up face.
  47955. * This is stored in format, left to right, up to down format.
  47956. */
  47957. up: Nullable<ArrayBufferView>;
  47958. /**
  47959. * The pixel array for the down face.
  47960. * This is stored in format, left to right, up to down format.
  47961. */
  47962. down: Nullable<ArrayBufferView>;
  47963. /**
  47964. * The size of the cubemap stored.
  47965. *
  47966. * Each faces will be size * size pixels.
  47967. */
  47968. size: number;
  47969. /**
  47970. * The format of the texture.
  47971. *
  47972. * RGBA, RGB.
  47973. */
  47974. format: number;
  47975. /**
  47976. * The type of the texture data.
  47977. *
  47978. * UNSIGNED_INT, FLOAT.
  47979. */
  47980. type: number;
  47981. /**
  47982. * Specifies whether the texture is in gamma space.
  47983. */
  47984. gammaSpace: boolean;
  47985. }
  47986. /**
  47987. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47988. */
  47989. export class PanoramaToCubeMapTools {
  47990. private static FACE_FRONT;
  47991. private static FACE_BACK;
  47992. private static FACE_RIGHT;
  47993. private static FACE_LEFT;
  47994. private static FACE_DOWN;
  47995. private static FACE_UP;
  47996. /**
  47997. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47998. *
  47999. * @param float32Array The source data.
  48000. * @param inputWidth The width of the input panorama.
  48001. * @param inputHeight The height of the input panorama.
  48002. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48003. * @return The cubemap data
  48004. */
  48005. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48006. private static CreateCubemapTexture;
  48007. private static CalcProjectionSpherical;
  48008. }
  48009. }
  48010. declare module BABYLON {
  48011. /**
  48012. * Helper class dealing with the extraction of spherical polynomial dataArray
  48013. * from a cube map.
  48014. */
  48015. export class CubeMapToSphericalPolynomialTools {
  48016. private static FileFaces;
  48017. /**
  48018. * Converts a texture to the according Spherical Polynomial data.
  48019. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48020. *
  48021. * @param texture The texture to extract the information from.
  48022. * @return The Spherical Polynomial data.
  48023. */
  48024. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48025. /**
  48026. * Converts a cubemap to the according Spherical Polynomial data.
  48027. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48028. *
  48029. * @param cubeInfo The Cube map to extract the information from.
  48030. * @return The Spherical Polynomial data.
  48031. */
  48032. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48033. }
  48034. }
  48035. declare module BABYLON {
  48036. interface BaseTexture {
  48037. /**
  48038. * Get the polynomial representation of the texture data.
  48039. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48040. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48041. */
  48042. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48043. }
  48044. }
  48045. declare module BABYLON {
  48046. /** @hidden */
  48047. export var rgbdEncodePixelShader: {
  48048. name: string;
  48049. shader: string;
  48050. };
  48051. }
  48052. declare module BABYLON {
  48053. /** @hidden */
  48054. export var rgbdDecodePixelShader: {
  48055. name: string;
  48056. shader: string;
  48057. };
  48058. }
  48059. declare module BABYLON {
  48060. /**
  48061. * Raw texture data and descriptor sufficient for WebGL texture upload
  48062. */
  48063. export interface EnvironmentTextureInfo {
  48064. /**
  48065. * Version of the environment map
  48066. */
  48067. version: number;
  48068. /**
  48069. * Width of image
  48070. */
  48071. width: number;
  48072. /**
  48073. * Irradiance information stored in the file.
  48074. */
  48075. irradiance: any;
  48076. /**
  48077. * Specular information stored in the file.
  48078. */
  48079. specular: any;
  48080. }
  48081. /**
  48082. * Defines One Image in the file. It requires only the position in the file
  48083. * as well as the length.
  48084. */
  48085. interface BufferImageData {
  48086. /**
  48087. * Length of the image data.
  48088. */
  48089. length: number;
  48090. /**
  48091. * Position of the data from the null terminator delimiting the end of the JSON.
  48092. */
  48093. position: number;
  48094. }
  48095. /**
  48096. * Defines the specular data enclosed in the file.
  48097. * This corresponds to the version 1 of the data.
  48098. */
  48099. export interface EnvironmentTextureSpecularInfoV1 {
  48100. /**
  48101. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48102. */
  48103. specularDataPosition?: number;
  48104. /**
  48105. * This contains all the images data needed to reconstruct the cubemap.
  48106. */
  48107. mipmaps: Array<BufferImageData>;
  48108. /**
  48109. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48110. */
  48111. lodGenerationScale: number;
  48112. }
  48113. /**
  48114. * Sets of helpers addressing the serialization and deserialization of environment texture
  48115. * stored in a BabylonJS env file.
  48116. * Those files are usually stored as .env files.
  48117. */
  48118. export class EnvironmentTextureTools {
  48119. /**
  48120. * Magic number identifying the env file.
  48121. */
  48122. private static _MagicBytes;
  48123. /**
  48124. * Gets the environment info from an env file.
  48125. * @param data The array buffer containing the .env bytes.
  48126. * @returns the environment file info (the json header) if successfully parsed.
  48127. */
  48128. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48129. /**
  48130. * Creates an environment texture from a loaded cube texture.
  48131. * @param texture defines the cube texture to convert in env file
  48132. * @return a promise containing the environment data if succesfull.
  48133. */
  48134. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48135. /**
  48136. * Creates a JSON representation of the spherical data.
  48137. * @param texture defines the texture containing the polynomials
  48138. * @return the JSON representation of the spherical info
  48139. */
  48140. private static _CreateEnvTextureIrradiance;
  48141. /**
  48142. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48143. * @param data the image data
  48144. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48145. * @return the views described by info providing access to the underlying buffer
  48146. */
  48147. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48148. /**
  48149. * Uploads the texture info contained in the env file to the GPU.
  48150. * @param texture defines the internal texture to upload to
  48151. * @param data defines the data to load
  48152. * @param info defines the texture info retrieved through the GetEnvInfo method
  48153. * @returns a promise
  48154. */
  48155. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48156. private static _OnImageReadyAsync;
  48157. /**
  48158. * Uploads the levels of image data to the GPU.
  48159. * @param texture defines the internal texture to upload to
  48160. * @param imageData defines the array buffer views of image data [mipmap][face]
  48161. * @returns a promise
  48162. */
  48163. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48164. /**
  48165. * Uploads spherical polynomials information to the texture.
  48166. * @param texture defines the texture we are trying to upload the information to
  48167. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48168. */
  48169. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48170. /** @hidden */
  48171. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48172. }
  48173. }
  48174. declare module BABYLON {
  48175. /**
  48176. * Contains position and normal vectors for a vertex
  48177. */
  48178. export class PositionNormalVertex {
  48179. /** the position of the vertex (defaut: 0,0,0) */
  48180. position: Vector3;
  48181. /** the normal of the vertex (defaut: 0,1,0) */
  48182. normal: Vector3;
  48183. /**
  48184. * Creates a PositionNormalVertex
  48185. * @param position the position of the vertex (defaut: 0,0,0)
  48186. * @param normal the normal of the vertex (defaut: 0,1,0)
  48187. */
  48188. constructor(
  48189. /** the position of the vertex (defaut: 0,0,0) */
  48190. position?: Vector3,
  48191. /** the normal of the vertex (defaut: 0,1,0) */
  48192. normal?: Vector3);
  48193. /**
  48194. * Clones the PositionNormalVertex
  48195. * @returns the cloned PositionNormalVertex
  48196. */
  48197. clone(): PositionNormalVertex;
  48198. }
  48199. /**
  48200. * Contains position, normal and uv vectors for a vertex
  48201. */
  48202. export class PositionNormalTextureVertex {
  48203. /** the position of the vertex (defaut: 0,0,0) */
  48204. position: Vector3;
  48205. /** the normal of the vertex (defaut: 0,1,0) */
  48206. normal: Vector3;
  48207. /** the uv of the vertex (default: 0,0) */
  48208. uv: Vector2;
  48209. /**
  48210. * Creates a PositionNormalTextureVertex
  48211. * @param position the position of the vertex (defaut: 0,0,0)
  48212. * @param normal the normal of the vertex (defaut: 0,1,0)
  48213. * @param uv the uv of the vertex (default: 0,0)
  48214. */
  48215. constructor(
  48216. /** the position of the vertex (defaut: 0,0,0) */
  48217. position?: Vector3,
  48218. /** the normal of the vertex (defaut: 0,1,0) */
  48219. normal?: Vector3,
  48220. /** the uv of the vertex (default: 0,0) */
  48221. uv?: Vector2);
  48222. /**
  48223. * Clones the PositionNormalTextureVertex
  48224. * @returns the cloned PositionNormalTextureVertex
  48225. */
  48226. clone(): PositionNormalTextureVertex;
  48227. }
  48228. }
  48229. declare module BABYLON {
  48230. /** @hidden */
  48231. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48232. private _genericAttributeLocation;
  48233. private _varyingLocationCount;
  48234. private _varyingLocationMap;
  48235. private _replacements;
  48236. private _textureCount;
  48237. private _uniforms;
  48238. lineProcessor(line: string): string;
  48239. attributeProcessor(attribute: string): string;
  48240. varyingProcessor(varying: string, isFragment: boolean): string;
  48241. uniformProcessor(uniform: string): string;
  48242. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48243. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48244. }
  48245. }
  48246. declare module BABYLON {
  48247. /**
  48248. * Container for accessors for natively-stored mesh data buffers.
  48249. */
  48250. class NativeDataBuffer extends DataBuffer {
  48251. /**
  48252. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48253. */
  48254. nativeIndexBuffer?: any;
  48255. /**
  48256. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48257. */
  48258. nativeVertexBuffer?: any;
  48259. }
  48260. /** @hidden */
  48261. class NativeTexture extends InternalTexture {
  48262. getInternalTexture(): InternalTexture;
  48263. getViewCount(): number;
  48264. }
  48265. /** @hidden */
  48266. export class NativeEngine extends Engine {
  48267. private readonly _native;
  48268. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48269. private readonly INVALID_HANDLE;
  48270. getHardwareScalingLevel(): number;
  48271. constructor();
  48272. dispose(): void;
  48273. /**
  48274. * Can be used to override the current requestAnimationFrame requester.
  48275. * @hidden
  48276. */
  48277. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48278. /**
  48279. * Override default engine behavior.
  48280. * @param color
  48281. * @param backBuffer
  48282. * @param depth
  48283. * @param stencil
  48284. */
  48285. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48286. /**
  48287. * Gets host document
  48288. * @returns the host document object
  48289. */
  48290. getHostDocument(): Nullable<Document>;
  48291. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48292. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48293. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48294. recordVertexArrayObject(vertexBuffers: {
  48295. [key: string]: VertexBuffer;
  48296. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48297. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48298. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48299. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48300. /**
  48301. * Draw a list of indexed primitives
  48302. * @param fillMode defines the primitive to use
  48303. * @param indexStart defines the starting index
  48304. * @param indexCount defines the number of index to draw
  48305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48306. */
  48307. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48308. /**
  48309. * Draw a list of unindexed primitives
  48310. * @param fillMode defines the primitive to use
  48311. * @param verticesStart defines the index of first vertex to draw
  48312. * @param verticesCount defines the count of vertices to draw
  48313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48314. */
  48315. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48316. createPipelineContext(): IPipelineContext;
  48317. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48318. /** @hidden */
  48319. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48320. /** @hidden */
  48321. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48322. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48323. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48324. protected _setProgram(program: WebGLProgram): void;
  48325. _releaseEffect(effect: Effect): void;
  48326. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48327. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48328. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48329. bindSamplers(effect: Effect): void;
  48330. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48331. getRenderWidth(useScreen?: boolean): number;
  48332. getRenderHeight(useScreen?: boolean): number;
  48333. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48334. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48335. /**
  48336. * Set the z offset to apply to current rendering
  48337. * @param value defines the offset to apply
  48338. */
  48339. setZOffset(value: number): void;
  48340. /**
  48341. * Gets the current value of the zOffset
  48342. * @returns the current zOffset state
  48343. */
  48344. getZOffset(): number;
  48345. /**
  48346. * Enable or disable depth buffering
  48347. * @param enable defines the state to set
  48348. */
  48349. setDepthBuffer(enable: boolean): void;
  48350. /**
  48351. * Gets a boolean indicating if depth writing is enabled
  48352. * @returns the current depth writing state
  48353. */
  48354. getDepthWrite(): boolean;
  48355. /**
  48356. * Enable or disable depth writing
  48357. * @param enable defines the state to set
  48358. */
  48359. setDepthWrite(enable: boolean): void;
  48360. /**
  48361. * Enable or disable color writing
  48362. * @param enable defines the state to set
  48363. */
  48364. setColorWrite(enable: boolean): void;
  48365. /**
  48366. * Gets a boolean indicating if color writing is enabled
  48367. * @returns the current color writing state
  48368. */
  48369. getColorWrite(): boolean;
  48370. /**
  48371. * Sets alpha constants used by some alpha blending modes
  48372. * @param r defines the red component
  48373. * @param g defines the green component
  48374. * @param b defines the blue component
  48375. * @param a defines the alpha component
  48376. */
  48377. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48378. /**
  48379. * Sets the current alpha mode
  48380. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48381. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48382. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48383. */
  48384. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48385. /**
  48386. * Gets the current alpha mode
  48387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48388. * @returns the current alpha mode
  48389. */
  48390. getAlphaMode(): number;
  48391. setInt(uniform: WebGLUniformLocation, int: number): void;
  48392. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48393. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48394. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48395. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48396. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48397. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48398. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48399. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48400. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48401. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48402. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48403. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48404. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48405. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48406. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48407. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48408. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48410. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48411. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48412. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48413. wipeCaches(bruteForce?: boolean): void;
  48414. _createTexture(): WebGLTexture;
  48415. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48416. /**
  48417. * Usually called from Texture.ts.
  48418. * Passed information to create a WebGLTexture
  48419. * @param url defines a value which contains one of the following:
  48420. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48421. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48422. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48424. * @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)
  48425. * @param scene needed for loading to the correct scene
  48426. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48427. * @param onLoad optional callback to be called upon successful completion
  48428. * @param onError optional callback to be called upon failure
  48429. * @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
  48430. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48431. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48432. * @param forcedExtension defines the extension to use to pick the right loader
  48433. * @param mimeType defines an optional mime type
  48434. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48435. */
  48436. 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;
  48437. /**
  48438. * Creates a cube texture
  48439. * @param rootUrl defines the url where the files to load is located
  48440. * @param scene defines the current scene
  48441. * @param files defines the list of files to load (1 per face)
  48442. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48443. * @param onLoad defines an optional callback raised when the texture is loaded
  48444. * @param onError defines an optional callback raised if there is an issue to load the texture
  48445. * @param format defines the format of the data
  48446. * @param forcedExtension defines the extension to use to pick the right loader
  48447. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48448. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48449. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48450. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48451. * @returns the cube texture as an InternalTexture
  48452. */
  48453. 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;
  48454. private _getSamplingFilter;
  48455. private static _GetNativeTextureFormat;
  48456. createRenderTargetTexture(size: number | {
  48457. width: number;
  48458. height: number;
  48459. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48462. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48465. /**
  48466. * Updates a dynamic vertex buffer.
  48467. * @param vertexBuffer the vertex buffer to update
  48468. * @param data the data used to update the vertex buffer
  48469. * @param byteOffset the byte offset of the data (optional)
  48470. * @param byteLength the byte length of the data (optional)
  48471. */
  48472. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48473. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48474. private _updateAnisotropicLevel;
  48475. private _getAddressMode;
  48476. /** @hidden */
  48477. _bindTexture(channel: number, texture: InternalTexture): void;
  48478. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48479. releaseEffects(): void;
  48480. /** @hidden */
  48481. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48482. /** @hidden */
  48483. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48484. /** @hidden */
  48485. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48486. /** @hidden */
  48487. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48488. }
  48489. }
  48490. declare module BABYLON {
  48491. /**
  48492. * Gather the list of clipboard event types as constants.
  48493. */
  48494. export class ClipboardEventTypes {
  48495. /**
  48496. * The clipboard event is fired when a copy command is active (pressed).
  48497. */
  48498. static readonly COPY: number;
  48499. /**
  48500. * The clipboard event is fired when a cut command is active (pressed).
  48501. */
  48502. static readonly CUT: number;
  48503. /**
  48504. * The clipboard event is fired when a paste command is active (pressed).
  48505. */
  48506. static readonly PASTE: number;
  48507. }
  48508. /**
  48509. * This class is used to store clipboard related info for the onClipboardObservable event.
  48510. */
  48511. export class ClipboardInfo {
  48512. /**
  48513. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48514. */
  48515. type: number;
  48516. /**
  48517. * Defines the related dom event
  48518. */
  48519. event: ClipboardEvent;
  48520. /**
  48521. *Creates an instance of ClipboardInfo.
  48522. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48523. * @param event Defines the related dom event
  48524. */
  48525. constructor(
  48526. /**
  48527. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48528. */
  48529. type: number,
  48530. /**
  48531. * Defines the related dom event
  48532. */
  48533. event: ClipboardEvent);
  48534. /**
  48535. * Get the clipboard event's type from the keycode.
  48536. * @param keyCode Defines the keyCode for the current keyboard event.
  48537. * @return {number}
  48538. */
  48539. static GetTypeFromCharacter(keyCode: number): number;
  48540. }
  48541. }
  48542. declare module BABYLON {
  48543. /**
  48544. * Google Daydream controller
  48545. */
  48546. export class DaydreamController extends WebVRController {
  48547. /**
  48548. * Base Url for the controller model.
  48549. */
  48550. static MODEL_BASE_URL: string;
  48551. /**
  48552. * File name for the controller model.
  48553. */
  48554. static MODEL_FILENAME: string;
  48555. /**
  48556. * Gamepad Id prefix used to identify Daydream Controller.
  48557. */
  48558. static readonly GAMEPAD_ID_PREFIX: string;
  48559. /**
  48560. * Creates a new DaydreamController from a gamepad
  48561. * @param vrGamepad the gamepad that the controller should be created from
  48562. */
  48563. constructor(vrGamepad: any);
  48564. /**
  48565. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48566. * @param scene scene in which to add meshes
  48567. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48568. */
  48569. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48570. /**
  48571. * Called once for each button that changed state since the last frame
  48572. * @param buttonIdx Which button index changed
  48573. * @param state New state of the button
  48574. * @param changes Which properties on the state changed since last frame
  48575. */
  48576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48577. }
  48578. }
  48579. declare module BABYLON {
  48580. /**
  48581. * Gear VR Controller
  48582. */
  48583. export class GearVRController extends WebVRController {
  48584. /**
  48585. * Base Url for the controller model.
  48586. */
  48587. static MODEL_BASE_URL: string;
  48588. /**
  48589. * File name for the controller model.
  48590. */
  48591. static MODEL_FILENAME: string;
  48592. /**
  48593. * Gamepad Id prefix used to identify this controller.
  48594. */
  48595. static readonly GAMEPAD_ID_PREFIX: string;
  48596. private readonly _buttonIndexToObservableNameMap;
  48597. /**
  48598. * Creates a new GearVRController from a gamepad
  48599. * @param vrGamepad the gamepad that the controller should be created from
  48600. */
  48601. constructor(vrGamepad: any);
  48602. /**
  48603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48604. * @param scene scene in which to add meshes
  48605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48606. */
  48607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48608. /**
  48609. * Called once for each button that changed state since the last frame
  48610. * @param buttonIdx Which button index changed
  48611. * @param state New state of the button
  48612. * @param changes Which properties on the state changed since last frame
  48613. */
  48614. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48615. }
  48616. }
  48617. declare module BABYLON {
  48618. /**
  48619. * Generic Controller
  48620. */
  48621. export class GenericController extends WebVRController {
  48622. /**
  48623. * Base Url for the controller model.
  48624. */
  48625. static readonly MODEL_BASE_URL: string;
  48626. /**
  48627. * File name for the controller model.
  48628. */
  48629. static readonly MODEL_FILENAME: string;
  48630. /**
  48631. * Creates a new GenericController from a gamepad
  48632. * @param vrGamepad the gamepad that the controller should be created from
  48633. */
  48634. constructor(vrGamepad: any);
  48635. /**
  48636. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48637. * @param scene scene in which to add meshes
  48638. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48639. */
  48640. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48641. /**
  48642. * Called once for each button that changed state since the last frame
  48643. * @param buttonIdx Which button index changed
  48644. * @param state New state of the button
  48645. * @param changes Which properties on the state changed since last frame
  48646. */
  48647. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48648. }
  48649. }
  48650. declare module BABYLON {
  48651. /**
  48652. * Oculus Touch Controller
  48653. */
  48654. export class OculusTouchController extends WebVRController {
  48655. /**
  48656. * Base Url for the controller model.
  48657. */
  48658. static MODEL_BASE_URL: string;
  48659. /**
  48660. * File name for the left controller model.
  48661. */
  48662. static MODEL_LEFT_FILENAME: string;
  48663. /**
  48664. * File name for the right controller model.
  48665. */
  48666. static MODEL_RIGHT_FILENAME: string;
  48667. /**
  48668. * Base Url for the Quest controller model.
  48669. */
  48670. static QUEST_MODEL_BASE_URL: string;
  48671. /**
  48672. * @hidden
  48673. * If the controllers are running on a device that needs the updated Quest controller models
  48674. */
  48675. static _IsQuest: boolean;
  48676. /**
  48677. * Fired when the secondary trigger on this controller is modified
  48678. */
  48679. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48680. /**
  48681. * Fired when the thumb rest on this controller is modified
  48682. */
  48683. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48684. /**
  48685. * Creates a new OculusTouchController from a gamepad
  48686. * @param vrGamepad the gamepad that the controller should be created from
  48687. */
  48688. constructor(vrGamepad: any);
  48689. /**
  48690. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48691. * @param scene scene in which to add meshes
  48692. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48693. */
  48694. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48695. /**
  48696. * Fired when the A button on this controller is modified
  48697. */
  48698. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48699. /**
  48700. * Fired when the B button on this controller is modified
  48701. */
  48702. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48703. /**
  48704. * Fired when the X button on this controller is modified
  48705. */
  48706. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48707. /**
  48708. * Fired when the Y button on this controller is modified
  48709. */
  48710. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48711. /**
  48712. * Called once for each button that changed state since the last frame
  48713. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48714. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48715. * 2) secondary trigger (same)
  48716. * 3) A (right) X (left), touch, pressed = value
  48717. * 4) B / Y
  48718. * 5) thumb rest
  48719. * @param buttonIdx Which button index changed
  48720. * @param state New state of the button
  48721. * @param changes Which properties on the state changed since last frame
  48722. */
  48723. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48724. }
  48725. }
  48726. declare module BABYLON {
  48727. /**
  48728. * Vive Controller
  48729. */
  48730. export class ViveController extends WebVRController {
  48731. /**
  48732. * Base Url for the controller model.
  48733. */
  48734. static MODEL_BASE_URL: string;
  48735. /**
  48736. * File name for the controller model.
  48737. */
  48738. static MODEL_FILENAME: string;
  48739. /**
  48740. * Creates a new ViveController from a gamepad
  48741. * @param vrGamepad the gamepad that the controller should be created from
  48742. */
  48743. constructor(vrGamepad: any);
  48744. /**
  48745. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48746. * @param scene scene in which to add meshes
  48747. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48748. */
  48749. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48750. /**
  48751. * Fired when the left button on this controller is modified
  48752. */
  48753. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48754. /**
  48755. * Fired when the right button on this controller is modified
  48756. */
  48757. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48758. /**
  48759. * Fired when the menu button on this controller is modified
  48760. */
  48761. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48762. /**
  48763. * Called once for each button that changed state since the last frame
  48764. * Vive mapping:
  48765. * 0: touchpad
  48766. * 1: trigger
  48767. * 2: left AND right buttons
  48768. * 3: menu button
  48769. * @param buttonIdx Which button index changed
  48770. * @param state New state of the button
  48771. * @param changes Which properties on the state changed since last frame
  48772. */
  48773. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48774. }
  48775. }
  48776. declare module BABYLON {
  48777. /**
  48778. * Defines the WindowsMotionController object that the state of the windows motion controller
  48779. */
  48780. export class WindowsMotionController extends WebVRController {
  48781. /**
  48782. * The base url used to load the left and right controller models
  48783. */
  48784. static MODEL_BASE_URL: string;
  48785. /**
  48786. * The name of the left controller model file
  48787. */
  48788. static MODEL_LEFT_FILENAME: string;
  48789. /**
  48790. * The name of the right controller model file
  48791. */
  48792. static MODEL_RIGHT_FILENAME: string;
  48793. /**
  48794. * The controller name prefix for this controller type
  48795. */
  48796. static readonly GAMEPAD_ID_PREFIX: string;
  48797. /**
  48798. * The controller id pattern for this controller type
  48799. */
  48800. private static readonly GAMEPAD_ID_PATTERN;
  48801. private _loadedMeshInfo;
  48802. protected readonly _mapping: {
  48803. buttons: string[];
  48804. buttonMeshNames: {
  48805. trigger: string;
  48806. menu: string;
  48807. grip: string;
  48808. thumbstick: string;
  48809. trackpad: string;
  48810. };
  48811. buttonObservableNames: {
  48812. trigger: string;
  48813. menu: string;
  48814. grip: string;
  48815. thumbstick: string;
  48816. trackpad: string;
  48817. };
  48818. axisMeshNames: string[];
  48819. pointingPoseMeshName: string;
  48820. };
  48821. /**
  48822. * Fired when the trackpad on this controller is clicked
  48823. */
  48824. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48825. /**
  48826. * Fired when the trackpad on this controller is modified
  48827. */
  48828. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48829. /**
  48830. * The current x and y values of this controller's trackpad
  48831. */
  48832. trackpad: StickValues;
  48833. /**
  48834. * Creates a new WindowsMotionController from a gamepad
  48835. * @param vrGamepad the gamepad that the controller should be created from
  48836. */
  48837. constructor(vrGamepad: any);
  48838. /**
  48839. * Fired when the trigger on this controller is modified
  48840. */
  48841. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48842. /**
  48843. * Fired when the menu button on this controller is modified
  48844. */
  48845. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48846. /**
  48847. * Fired when the grip button on this controller is modified
  48848. */
  48849. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48850. /**
  48851. * Fired when the thumbstick button on this controller is modified
  48852. */
  48853. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48854. /**
  48855. * Fired when the touchpad button on this controller is modified
  48856. */
  48857. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48858. /**
  48859. * Fired when the touchpad values on this controller are modified
  48860. */
  48861. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48862. protected _updateTrackpad(): void;
  48863. /**
  48864. * Called once per frame by the engine.
  48865. */
  48866. update(): void;
  48867. /**
  48868. * Called once for each button that changed state since the last frame
  48869. * @param buttonIdx Which button index changed
  48870. * @param state New state of the button
  48871. * @param changes Which properties on the state changed since last frame
  48872. */
  48873. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48874. /**
  48875. * Moves the buttons on the controller mesh based on their current state
  48876. * @param buttonName the name of the button to move
  48877. * @param buttonValue the value of the button which determines the buttons new position
  48878. */
  48879. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48880. /**
  48881. * Moves the axis on the controller mesh based on its current state
  48882. * @param axis the index of the axis
  48883. * @param axisValue the value of the axis which determines the meshes new position
  48884. * @hidden
  48885. */
  48886. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48887. /**
  48888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48889. * @param scene scene in which to add meshes
  48890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48891. */
  48892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48893. /**
  48894. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48895. * can be transformed by button presses and axes values, based on this._mapping.
  48896. *
  48897. * @param scene scene in which the meshes exist
  48898. * @param meshes list of meshes that make up the controller model to process
  48899. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48900. */
  48901. private processModel;
  48902. private createMeshInfo;
  48903. /**
  48904. * Gets the ray of the controller in the direction the controller is pointing
  48905. * @param length the length the resulting ray should be
  48906. * @returns a ray in the direction the controller is pointing
  48907. */
  48908. getForwardRay(length?: number): Ray;
  48909. /**
  48910. * Disposes of the controller
  48911. */
  48912. dispose(): void;
  48913. }
  48914. /**
  48915. * This class represents a new windows motion controller in XR.
  48916. */
  48917. export class XRWindowsMotionController extends WindowsMotionController {
  48918. /**
  48919. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48920. */
  48921. protected readonly _mapping: {
  48922. buttons: string[];
  48923. buttonMeshNames: {
  48924. trigger: string;
  48925. menu: string;
  48926. grip: string;
  48927. thumbstick: string;
  48928. trackpad: string;
  48929. };
  48930. buttonObservableNames: {
  48931. trigger: string;
  48932. menu: string;
  48933. grip: string;
  48934. thumbstick: string;
  48935. trackpad: string;
  48936. };
  48937. axisMeshNames: string[];
  48938. pointingPoseMeshName: string;
  48939. };
  48940. /**
  48941. * Construct a new XR-Based windows motion controller
  48942. *
  48943. * @param gamepadInfo the gamepad object from the browser
  48944. */
  48945. constructor(gamepadInfo: any);
  48946. /**
  48947. * holds the thumbstick values (X,Y)
  48948. */
  48949. thumbstickValues: StickValues;
  48950. /**
  48951. * Fired when the thumbstick on this controller is clicked
  48952. */
  48953. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48954. /**
  48955. * Fired when the thumbstick on this controller is modified
  48956. */
  48957. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48958. /**
  48959. * Fired when the touchpad button on this controller is modified
  48960. */
  48961. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48962. /**
  48963. * Fired when the touchpad values on this controller are modified
  48964. */
  48965. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48966. /**
  48967. * Fired when the thumbstick button on this controller is modified
  48968. * here to prevent breaking changes
  48969. */
  48970. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48971. /**
  48972. * updating the thumbstick(!) and not the trackpad.
  48973. * This is named this way due to the difference between WebVR and XR and to avoid
  48974. * changing the parent class.
  48975. */
  48976. protected _updateTrackpad(): void;
  48977. /**
  48978. * Disposes the class with joy
  48979. */
  48980. dispose(): void;
  48981. }
  48982. }
  48983. declare module BABYLON {
  48984. /**
  48985. * Class containing static functions to help procedurally build meshes
  48986. */
  48987. export class PolyhedronBuilder {
  48988. /**
  48989. * Creates a polyhedron mesh
  48990. * * 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
  48991. * * The parameter `size` (positive float, default 1) sets the polygon size
  48992. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48993. * * 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`
  48994. * * 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
  48995. * * 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)`)
  48996. * * 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
  48997. * * 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
  48998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48999. * * 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
  49000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49001. * @param name defines the name of the mesh
  49002. * @param options defines the options used to create the mesh
  49003. * @param scene defines the hosting scene
  49004. * @returns the polyhedron mesh
  49005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49006. */
  49007. static CreatePolyhedron(name: string, options: {
  49008. type?: number;
  49009. size?: number;
  49010. sizeX?: number;
  49011. sizeY?: number;
  49012. sizeZ?: number;
  49013. custom?: any;
  49014. faceUV?: Vector4[];
  49015. faceColors?: Color4[];
  49016. flat?: boolean;
  49017. updatable?: boolean;
  49018. sideOrientation?: number;
  49019. frontUVs?: Vector4;
  49020. backUVs?: Vector4;
  49021. }, scene?: Nullable<Scene>): Mesh;
  49022. }
  49023. }
  49024. declare module BABYLON {
  49025. /**
  49026. * Gizmo that enables scaling a mesh along 3 axis
  49027. */
  49028. export class ScaleGizmo extends Gizmo {
  49029. /**
  49030. * Internal gizmo used for interactions on the x axis
  49031. */
  49032. xGizmo: AxisScaleGizmo;
  49033. /**
  49034. * Internal gizmo used for interactions on the y axis
  49035. */
  49036. yGizmo: AxisScaleGizmo;
  49037. /**
  49038. * Internal gizmo used for interactions on the z axis
  49039. */
  49040. zGizmo: AxisScaleGizmo;
  49041. /**
  49042. * Internal gizmo used to scale all axis equally
  49043. */
  49044. uniformScaleGizmo: AxisScaleGizmo;
  49045. private _meshAttached;
  49046. private _updateGizmoRotationToMatchAttachedMesh;
  49047. private _snapDistance;
  49048. private _scaleRatio;
  49049. private _uniformScalingMesh;
  49050. private _octahedron;
  49051. private _sensitivity;
  49052. /** Fires an event when any of it's sub gizmos are dragged */
  49053. onDragStartObservable: Observable<unknown>;
  49054. /** Fires an event when any of it's sub gizmos are released from dragging */
  49055. onDragEndObservable: Observable<unknown>;
  49056. get attachedMesh(): Nullable<AbstractMesh>;
  49057. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49058. /**
  49059. * Creates a ScaleGizmo
  49060. * @param gizmoLayer The utility layer the gizmo will be added to
  49061. */
  49062. constructor(gizmoLayer?: UtilityLayerRenderer);
  49063. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49064. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49065. /**
  49066. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49067. */
  49068. set snapDistance(value: number);
  49069. get snapDistance(): number;
  49070. /**
  49071. * Ratio for the scale of the gizmo (Default: 1)
  49072. */
  49073. set scaleRatio(value: number);
  49074. get scaleRatio(): number;
  49075. /**
  49076. * Sensitivity factor for dragging (Default: 1)
  49077. */
  49078. set sensitivity(value: number);
  49079. get sensitivity(): number;
  49080. /**
  49081. * Disposes of the gizmo
  49082. */
  49083. dispose(): void;
  49084. }
  49085. }
  49086. declare module BABYLON {
  49087. /**
  49088. * Single axis scale gizmo
  49089. */
  49090. export class AxisScaleGizmo extends Gizmo {
  49091. /**
  49092. * Drag behavior responsible for the gizmos dragging interactions
  49093. */
  49094. dragBehavior: PointerDragBehavior;
  49095. private _pointerObserver;
  49096. /**
  49097. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49098. */
  49099. snapDistance: number;
  49100. /**
  49101. * Event that fires each time the gizmo snaps to a new location.
  49102. * * snapDistance is the the change in distance
  49103. */
  49104. onSnapObservable: Observable<{
  49105. snapDistance: number;
  49106. }>;
  49107. /**
  49108. * If the scaling operation should be done on all axis (default: false)
  49109. */
  49110. uniformScaling: boolean;
  49111. /**
  49112. * Custom sensitivity value for the drag strength
  49113. */
  49114. sensitivity: number;
  49115. private _isEnabled;
  49116. private _parent;
  49117. private _arrow;
  49118. private _coloredMaterial;
  49119. private _hoverMaterial;
  49120. /**
  49121. * Creates an AxisScaleGizmo
  49122. * @param gizmoLayer The utility layer the gizmo will be added to
  49123. * @param dragAxis The axis which the gizmo will be able to scale on
  49124. * @param color The color of the gizmo
  49125. */
  49126. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49128. /**
  49129. * If the gizmo is enabled
  49130. */
  49131. set isEnabled(value: boolean);
  49132. get isEnabled(): boolean;
  49133. /**
  49134. * Disposes of the gizmo
  49135. */
  49136. dispose(): void;
  49137. /**
  49138. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49139. * @param mesh The mesh to replace the default mesh of the gizmo
  49140. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49141. */
  49142. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49143. }
  49144. }
  49145. declare module BABYLON {
  49146. /**
  49147. * Bounding box gizmo
  49148. */
  49149. export class BoundingBoxGizmo extends Gizmo {
  49150. private _lineBoundingBox;
  49151. private _rotateSpheresParent;
  49152. private _scaleBoxesParent;
  49153. private _boundingDimensions;
  49154. private _renderObserver;
  49155. private _pointerObserver;
  49156. private _scaleDragSpeed;
  49157. private _tmpQuaternion;
  49158. private _tmpVector;
  49159. private _tmpRotationMatrix;
  49160. /**
  49161. * 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)
  49162. */
  49163. ignoreChildren: boolean;
  49164. /**
  49165. * 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)
  49166. */
  49167. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49168. /**
  49169. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49170. */
  49171. rotationSphereSize: number;
  49172. /**
  49173. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49174. */
  49175. scaleBoxSize: number;
  49176. /**
  49177. * 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)
  49178. */
  49179. fixedDragMeshScreenSize: boolean;
  49180. /**
  49181. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49182. */
  49183. fixedDragMeshScreenSizeDistanceFactor: number;
  49184. /**
  49185. * Fired when a rotation sphere or scale box is dragged
  49186. */
  49187. onDragStartObservable: Observable<{}>;
  49188. /**
  49189. * Fired when a scale box is dragged
  49190. */
  49191. onScaleBoxDragObservable: Observable<{}>;
  49192. /**
  49193. * Fired when a scale box drag is ended
  49194. */
  49195. onScaleBoxDragEndObservable: Observable<{}>;
  49196. /**
  49197. * Fired when a rotation sphere is dragged
  49198. */
  49199. onRotationSphereDragObservable: Observable<{}>;
  49200. /**
  49201. * Fired when a rotation sphere drag is ended
  49202. */
  49203. onRotationSphereDragEndObservable: Observable<{}>;
  49204. /**
  49205. * 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)
  49206. */
  49207. scalePivot: Nullable<Vector3>;
  49208. /**
  49209. * Mesh used as a pivot to rotate the attached mesh
  49210. */
  49211. private _anchorMesh;
  49212. private _existingMeshScale;
  49213. private _dragMesh;
  49214. private pointerDragBehavior;
  49215. private coloredMaterial;
  49216. private hoverColoredMaterial;
  49217. /**
  49218. * Sets the color of the bounding box gizmo
  49219. * @param color the color to set
  49220. */
  49221. setColor(color: Color3): void;
  49222. /**
  49223. * Creates an BoundingBoxGizmo
  49224. * @param gizmoLayer The utility layer the gizmo will be added to
  49225. * @param color The color of the gizmo
  49226. */
  49227. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49228. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49229. private _selectNode;
  49230. /**
  49231. * Updates the bounding box information for the Gizmo
  49232. */
  49233. updateBoundingBox(): void;
  49234. private _updateRotationSpheres;
  49235. private _updateScaleBoxes;
  49236. /**
  49237. * Enables rotation on the specified axis and disables rotation on the others
  49238. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49239. */
  49240. setEnabledRotationAxis(axis: string): void;
  49241. /**
  49242. * Enables/disables scaling
  49243. * @param enable if scaling should be enabled
  49244. * @param homogeneousScaling defines if scaling should only be homogeneous
  49245. */
  49246. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49247. private _updateDummy;
  49248. /**
  49249. * Enables a pointer drag behavior on the bounding box of the gizmo
  49250. */
  49251. enableDragBehavior(): void;
  49252. /**
  49253. * Disposes of the gizmo
  49254. */
  49255. dispose(): void;
  49256. /**
  49257. * 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)
  49258. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49259. * @returns the bounding box mesh with the passed in mesh as a child
  49260. */
  49261. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49262. /**
  49263. * CustomMeshes are not supported by this gizmo
  49264. * @param mesh The mesh to replace the default mesh of the gizmo
  49265. */
  49266. setCustomMesh(mesh: Mesh): void;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /**
  49271. * Single plane rotation gizmo
  49272. */
  49273. export class PlaneRotationGizmo extends Gizmo {
  49274. /**
  49275. * Drag behavior responsible for the gizmos dragging interactions
  49276. */
  49277. dragBehavior: PointerDragBehavior;
  49278. private _pointerObserver;
  49279. /**
  49280. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49281. */
  49282. snapDistance: number;
  49283. /**
  49284. * Event that fires each time the gizmo snaps to a new location.
  49285. * * snapDistance is the the change in distance
  49286. */
  49287. onSnapObservable: Observable<{
  49288. snapDistance: number;
  49289. }>;
  49290. private _isEnabled;
  49291. private _parent;
  49292. /**
  49293. * Creates a PlaneRotationGizmo
  49294. * @param gizmoLayer The utility layer the gizmo will be added to
  49295. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49296. * @param color The color of the gizmo
  49297. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49298. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49299. */
  49300. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49301. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49302. /**
  49303. * If the gizmo is enabled
  49304. */
  49305. set isEnabled(value: boolean);
  49306. get isEnabled(): boolean;
  49307. /**
  49308. * Disposes of the gizmo
  49309. */
  49310. dispose(): void;
  49311. }
  49312. }
  49313. declare module BABYLON {
  49314. /**
  49315. * Gizmo that enables rotating a mesh along 3 axis
  49316. */
  49317. export class RotationGizmo extends Gizmo {
  49318. /**
  49319. * Internal gizmo used for interactions on the x axis
  49320. */
  49321. xGizmo: PlaneRotationGizmo;
  49322. /**
  49323. * Internal gizmo used for interactions on the y axis
  49324. */
  49325. yGizmo: PlaneRotationGizmo;
  49326. /**
  49327. * Internal gizmo used for interactions on the z axis
  49328. */
  49329. zGizmo: PlaneRotationGizmo;
  49330. /** Fires an event when any of it's sub gizmos are dragged */
  49331. onDragStartObservable: Observable<unknown>;
  49332. /** Fires an event when any of it's sub gizmos are released from dragging */
  49333. onDragEndObservable: Observable<unknown>;
  49334. private _meshAttached;
  49335. get attachedMesh(): Nullable<AbstractMesh>;
  49336. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49337. /**
  49338. * Creates a RotationGizmo
  49339. * @param gizmoLayer The utility layer the gizmo will be added to
  49340. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49341. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49342. */
  49343. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49344. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49345. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49346. /**
  49347. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49348. */
  49349. set snapDistance(value: number);
  49350. get snapDistance(): number;
  49351. /**
  49352. * Ratio for the scale of the gizmo (Default: 1)
  49353. */
  49354. set scaleRatio(value: number);
  49355. get scaleRatio(): number;
  49356. /**
  49357. * Disposes of the gizmo
  49358. */
  49359. dispose(): void;
  49360. /**
  49361. * CustomMeshes are not supported by this gizmo
  49362. * @param mesh The mesh to replace the default mesh of the gizmo
  49363. */
  49364. setCustomMesh(mesh: Mesh): void;
  49365. }
  49366. }
  49367. declare module BABYLON {
  49368. /**
  49369. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49370. */
  49371. export class GizmoManager implements IDisposable {
  49372. private scene;
  49373. /**
  49374. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49375. */
  49376. gizmos: {
  49377. positionGizmo: Nullable<PositionGizmo>;
  49378. rotationGizmo: Nullable<RotationGizmo>;
  49379. scaleGizmo: Nullable<ScaleGizmo>;
  49380. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49381. };
  49382. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49383. clearGizmoOnEmptyPointerEvent: boolean;
  49384. /** Fires an event when the manager is attached to a mesh */
  49385. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49386. private _gizmosEnabled;
  49387. private _pointerObserver;
  49388. private _attachedMesh;
  49389. private _boundingBoxColor;
  49390. private _defaultUtilityLayer;
  49391. private _defaultKeepDepthUtilityLayer;
  49392. /**
  49393. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49394. */
  49395. boundingBoxDragBehavior: SixDofDragBehavior;
  49396. /**
  49397. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49398. */
  49399. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49400. /**
  49401. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49402. */
  49403. usePointerToAttachGizmos: boolean;
  49404. /**
  49405. * Utility layer that the bounding box gizmo belongs to
  49406. */
  49407. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49408. /**
  49409. * Utility layer that all gizmos besides bounding box belong to
  49410. */
  49411. get utilityLayer(): UtilityLayerRenderer;
  49412. /**
  49413. * Instatiates a gizmo manager
  49414. * @param scene the scene to overlay the gizmos on top of
  49415. */
  49416. constructor(scene: Scene);
  49417. /**
  49418. * Attaches a set of gizmos to the specified mesh
  49419. * @param mesh The mesh the gizmo's should be attached to
  49420. */
  49421. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49422. /**
  49423. * If the position gizmo is enabled
  49424. */
  49425. set positionGizmoEnabled(value: boolean);
  49426. get positionGizmoEnabled(): boolean;
  49427. /**
  49428. * If the rotation gizmo is enabled
  49429. */
  49430. set rotationGizmoEnabled(value: boolean);
  49431. get rotationGizmoEnabled(): boolean;
  49432. /**
  49433. * If the scale gizmo is enabled
  49434. */
  49435. set scaleGizmoEnabled(value: boolean);
  49436. get scaleGizmoEnabled(): boolean;
  49437. /**
  49438. * If the boundingBox gizmo is enabled
  49439. */
  49440. set boundingBoxGizmoEnabled(value: boolean);
  49441. get boundingBoxGizmoEnabled(): boolean;
  49442. /**
  49443. * Disposes of the gizmo manager
  49444. */
  49445. dispose(): void;
  49446. }
  49447. }
  49448. declare module BABYLON {
  49449. /**
  49450. * A directional light is defined by a direction (what a surprise!).
  49451. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49452. * 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.
  49453. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49454. */
  49455. export class DirectionalLight extends ShadowLight {
  49456. private _shadowFrustumSize;
  49457. /**
  49458. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49459. */
  49460. get shadowFrustumSize(): number;
  49461. /**
  49462. * Specifies a fix frustum size for the shadow generation.
  49463. */
  49464. set shadowFrustumSize(value: number);
  49465. private _shadowOrthoScale;
  49466. /**
  49467. * Gets the shadow projection scale against the optimal computed one.
  49468. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49469. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49470. */
  49471. get shadowOrthoScale(): number;
  49472. /**
  49473. * Sets the shadow projection scale against the optimal computed one.
  49474. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49475. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49476. */
  49477. set shadowOrthoScale(value: number);
  49478. /**
  49479. * Automatically compute the projection matrix to best fit (including all the casters)
  49480. * on each frame.
  49481. */
  49482. autoUpdateExtends: boolean;
  49483. /**
  49484. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49485. * on each frame. autoUpdateExtends must be set to true for this to work
  49486. */
  49487. autoCalcShadowZBounds: boolean;
  49488. private _orthoLeft;
  49489. private _orthoRight;
  49490. private _orthoTop;
  49491. private _orthoBottom;
  49492. /**
  49493. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49494. * The directional light is emitted from everywhere in the given direction.
  49495. * It can cast shadows.
  49496. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49497. * @param name The friendly name of the light
  49498. * @param direction The direction of the light
  49499. * @param scene The scene the light belongs to
  49500. */
  49501. constructor(name: string, direction: Vector3, scene: Scene);
  49502. /**
  49503. * Returns the string "DirectionalLight".
  49504. * @return The class name
  49505. */
  49506. getClassName(): string;
  49507. /**
  49508. * Returns the integer 1.
  49509. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49510. */
  49511. getTypeID(): number;
  49512. /**
  49513. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49514. * Returns the DirectionalLight Shadow projection matrix.
  49515. */
  49516. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49517. /**
  49518. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49519. * Returns the DirectionalLight Shadow projection matrix.
  49520. */
  49521. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49522. /**
  49523. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49524. * Returns the DirectionalLight Shadow projection matrix.
  49525. */
  49526. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49527. protected _buildUniformLayout(): void;
  49528. /**
  49529. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49530. * @param effect The effect to update
  49531. * @param lightIndex The index of the light in the effect to update
  49532. * @returns The directional light
  49533. */
  49534. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49535. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49536. /**
  49537. * Gets the minZ used for shadow according to both the scene and the light.
  49538. *
  49539. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49540. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49541. * @param activeCamera The camera we are returning the min for
  49542. * @returns the depth min z
  49543. */
  49544. getDepthMinZ(activeCamera: Camera): number;
  49545. /**
  49546. * Gets the maxZ used for shadow according to both the scene and the light.
  49547. *
  49548. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49549. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49550. * @param activeCamera The camera we are returning the max for
  49551. * @returns the depth max z
  49552. */
  49553. getDepthMaxZ(activeCamera: Camera): number;
  49554. /**
  49555. * Prepares the list of defines specific to the light type.
  49556. * @param defines the list of defines
  49557. * @param lightIndex defines the index of the light for the effect
  49558. */
  49559. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49560. }
  49561. }
  49562. declare module BABYLON {
  49563. /**
  49564. * Class containing static functions to help procedurally build meshes
  49565. */
  49566. export class HemisphereBuilder {
  49567. /**
  49568. * Creates a hemisphere mesh
  49569. * @param name defines the name of the mesh
  49570. * @param options defines the options used to create the mesh
  49571. * @param scene defines the hosting scene
  49572. * @returns the hemisphere mesh
  49573. */
  49574. static CreateHemisphere(name: string, options: {
  49575. segments?: number;
  49576. diameter?: number;
  49577. sideOrientation?: number;
  49578. }, scene: any): Mesh;
  49579. }
  49580. }
  49581. declare module BABYLON {
  49582. /**
  49583. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49584. * These values define a cone of light starting from the position, emitting toward the direction.
  49585. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49586. * and the exponent defines the speed of the decay of the light with distance (reach).
  49587. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49588. */
  49589. export class SpotLight extends ShadowLight {
  49590. private _angle;
  49591. private _innerAngle;
  49592. private _cosHalfAngle;
  49593. private _lightAngleScale;
  49594. private _lightAngleOffset;
  49595. /**
  49596. * Gets the cone angle of the spot light in Radians.
  49597. */
  49598. get angle(): number;
  49599. /**
  49600. * Sets the cone angle of the spot light in Radians.
  49601. */
  49602. set angle(value: number);
  49603. /**
  49604. * Only used in gltf falloff mode, this defines the angle where
  49605. * the directional falloff will start before cutting at angle which could be seen
  49606. * as outer angle.
  49607. */
  49608. get innerAngle(): number;
  49609. /**
  49610. * Only used in gltf falloff mode, this defines the angle where
  49611. * the directional falloff will start before cutting at angle which could be seen
  49612. * as outer angle.
  49613. */
  49614. set innerAngle(value: number);
  49615. private _shadowAngleScale;
  49616. /**
  49617. * Allows scaling the angle of the light for shadow generation only.
  49618. */
  49619. get shadowAngleScale(): number;
  49620. /**
  49621. * Allows scaling the angle of the light for shadow generation only.
  49622. */
  49623. set shadowAngleScale(value: number);
  49624. /**
  49625. * The light decay speed with the distance from the emission spot.
  49626. */
  49627. exponent: number;
  49628. private _projectionTextureMatrix;
  49629. /**
  49630. * Allows reading the projecton texture
  49631. */
  49632. get projectionTextureMatrix(): Matrix;
  49633. protected _projectionTextureLightNear: number;
  49634. /**
  49635. * Gets the near clip of the Spotlight for texture projection.
  49636. */
  49637. get projectionTextureLightNear(): number;
  49638. /**
  49639. * Sets the near clip of the Spotlight for texture projection.
  49640. */
  49641. set projectionTextureLightNear(value: number);
  49642. protected _projectionTextureLightFar: number;
  49643. /**
  49644. * Gets the far clip of the Spotlight for texture projection.
  49645. */
  49646. get projectionTextureLightFar(): number;
  49647. /**
  49648. * Sets the far clip of the Spotlight for texture projection.
  49649. */
  49650. set projectionTextureLightFar(value: number);
  49651. protected _projectionTextureUpDirection: Vector3;
  49652. /**
  49653. * Gets the Up vector of the Spotlight for texture projection.
  49654. */
  49655. get projectionTextureUpDirection(): Vector3;
  49656. /**
  49657. * Sets the Up vector of the Spotlight for texture projection.
  49658. */
  49659. set projectionTextureUpDirection(value: Vector3);
  49660. private _projectionTexture;
  49661. /**
  49662. * Gets the projection texture of the light.
  49663. */
  49664. get projectionTexture(): Nullable<BaseTexture>;
  49665. /**
  49666. * Sets the projection texture of the light.
  49667. */
  49668. set projectionTexture(value: Nullable<BaseTexture>);
  49669. private _projectionTextureViewLightDirty;
  49670. private _projectionTextureProjectionLightDirty;
  49671. private _projectionTextureDirty;
  49672. private _projectionTextureViewTargetVector;
  49673. private _projectionTextureViewLightMatrix;
  49674. private _projectionTextureProjectionLightMatrix;
  49675. private _projectionTextureScalingMatrix;
  49676. /**
  49677. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49678. * It can cast shadows.
  49679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49680. * @param name The light friendly name
  49681. * @param position The position of the spot light in the scene
  49682. * @param direction The direction of the light in the scene
  49683. * @param angle The cone angle of the light in Radians
  49684. * @param exponent The light decay speed with the distance from the emission spot
  49685. * @param scene The scene the lights belongs to
  49686. */
  49687. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49688. /**
  49689. * Returns the string "SpotLight".
  49690. * @returns the class name
  49691. */
  49692. getClassName(): string;
  49693. /**
  49694. * Returns the integer 2.
  49695. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49696. */
  49697. getTypeID(): number;
  49698. /**
  49699. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49700. */
  49701. protected _setDirection(value: Vector3): void;
  49702. /**
  49703. * Overrides the position setter to recompute the projection texture view light Matrix.
  49704. */
  49705. protected _setPosition(value: Vector3): void;
  49706. /**
  49707. * 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.
  49708. * Returns the SpotLight.
  49709. */
  49710. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49711. protected _computeProjectionTextureViewLightMatrix(): void;
  49712. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49713. /**
  49714. * Main function for light texture projection matrix computing.
  49715. */
  49716. protected _computeProjectionTextureMatrix(): void;
  49717. protected _buildUniformLayout(): void;
  49718. private _computeAngleValues;
  49719. /**
  49720. * Sets the passed Effect "effect" with the Light textures.
  49721. * @param effect The effect to update
  49722. * @param lightIndex The index of the light in the effect to update
  49723. * @returns The light
  49724. */
  49725. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49726. /**
  49727. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49728. * @param effect The effect to update
  49729. * @param lightIndex The index of the light in the effect to update
  49730. * @returns The spot light
  49731. */
  49732. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49733. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49734. /**
  49735. * Disposes the light and the associated resources.
  49736. */
  49737. dispose(): void;
  49738. /**
  49739. * Prepares the list of defines specific to the light type.
  49740. * @param defines the list of defines
  49741. * @param lightIndex defines the index of the light for the effect
  49742. */
  49743. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49744. }
  49745. }
  49746. declare module BABYLON {
  49747. /**
  49748. * Gizmo that enables viewing a light
  49749. */
  49750. export class LightGizmo extends Gizmo {
  49751. private _lightMesh;
  49752. private _material;
  49753. private _cachedPosition;
  49754. private _cachedForward;
  49755. private _attachedMeshParent;
  49756. /**
  49757. * Creates a LightGizmo
  49758. * @param gizmoLayer The utility layer the gizmo will be added to
  49759. */
  49760. constructor(gizmoLayer?: UtilityLayerRenderer);
  49761. private _light;
  49762. /**
  49763. * The light that the gizmo is attached to
  49764. */
  49765. set light(light: Nullable<Light>);
  49766. get light(): Nullable<Light>;
  49767. /**
  49768. * Gets the material used to render the light gizmo
  49769. */
  49770. get material(): StandardMaterial;
  49771. /**
  49772. * @hidden
  49773. * Updates the gizmo to match the attached mesh's position/rotation
  49774. */
  49775. protected _update(): void;
  49776. private static _Scale;
  49777. /**
  49778. * Creates the lines for a light mesh
  49779. */
  49780. private static _CreateLightLines;
  49781. /**
  49782. * Disposes of the light gizmo
  49783. */
  49784. dispose(): void;
  49785. private static _CreateHemisphericLightMesh;
  49786. private static _CreatePointLightMesh;
  49787. private static _CreateSpotLightMesh;
  49788. private static _CreateDirectionalLightMesh;
  49789. }
  49790. }
  49791. declare module BABYLON {
  49792. /** @hidden */
  49793. export var backgroundFragmentDeclaration: {
  49794. name: string;
  49795. shader: string;
  49796. };
  49797. }
  49798. declare module BABYLON {
  49799. /** @hidden */
  49800. export var backgroundUboDeclaration: {
  49801. name: string;
  49802. shader: string;
  49803. };
  49804. }
  49805. declare module BABYLON {
  49806. /** @hidden */
  49807. export var backgroundPixelShader: {
  49808. name: string;
  49809. shader: string;
  49810. };
  49811. }
  49812. declare module BABYLON {
  49813. /** @hidden */
  49814. export var backgroundVertexDeclaration: {
  49815. name: string;
  49816. shader: string;
  49817. };
  49818. }
  49819. declare module BABYLON {
  49820. /** @hidden */
  49821. export var backgroundVertexShader: {
  49822. name: string;
  49823. shader: string;
  49824. };
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * Background material used to create an efficient environement around your scene.
  49829. */
  49830. export class BackgroundMaterial extends PushMaterial {
  49831. /**
  49832. * Standard reflectance value at parallel view angle.
  49833. */
  49834. static StandardReflectance0: number;
  49835. /**
  49836. * Standard reflectance value at grazing angle.
  49837. */
  49838. static StandardReflectance90: number;
  49839. protected _primaryColor: Color3;
  49840. /**
  49841. * Key light Color (multiply against the environement texture)
  49842. */
  49843. primaryColor: Color3;
  49844. protected __perceptualColor: Nullable<Color3>;
  49845. /**
  49846. * Experimental Internal Use Only.
  49847. *
  49848. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49849. * This acts as a helper to set the primary color to a more "human friendly" value.
  49850. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49851. * output color as close as possible from the chosen value.
  49852. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49853. * part of lighting setup.)
  49854. */
  49855. get _perceptualColor(): Nullable<Color3>;
  49856. set _perceptualColor(value: Nullable<Color3>);
  49857. protected _primaryColorShadowLevel: float;
  49858. /**
  49859. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49860. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49861. */
  49862. get primaryColorShadowLevel(): float;
  49863. set primaryColorShadowLevel(value: float);
  49864. protected _primaryColorHighlightLevel: float;
  49865. /**
  49866. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49867. * The primary color is used at the level chosen to define what the white area would look.
  49868. */
  49869. get primaryColorHighlightLevel(): float;
  49870. set primaryColorHighlightLevel(value: float);
  49871. protected _reflectionTexture: Nullable<BaseTexture>;
  49872. /**
  49873. * Reflection Texture used in the material.
  49874. * Should be author in a specific way for the best result (refer to the documentation).
  49875. */
  49876. reflectionTexture: Nullable<BaseTexture>;
  49877. protected _reflectionBlur: float;
  49878. /**
  49879. * Reflection Texture level of blur.
  49880. *
  49881. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49882. * texture twice.
  49883. */
  49884. reflectionBlur: float;
  49885. protected _diffuseTexture: Nullable<BaseTexture>;
  49886. /**
  49887. * Diffuse Texture used in the material.
  49888. * Should be author in a specific way for the best result (refer to the documentation).
  49889. */
  49890. diffuseTexture: Nullable<BaseTexture>;
  49891. protected _shadowLights: Nullable<IShadowLight[]>;
  49892. /**
  49893. * Specify the list of lights casting shadow on the material.
  49894. * All scene shadow lights will be included if null.
  49895. */
  49896. shadowLights: Nullable<IShadowLight[]>;
  49897. protected _shadowLevel: float;
  49898. /**
  49899. * Helps adjusting the shadow to a softer level if required.
  49900. * 0 means black shadows and 1 means no shadows.
  49901. */
  49902. shadowLevel: float;
  49903. protected _sceneCenter: Vector3;
  49904. /**
  49905. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49906. * It is usually zero but might be interesting to modify according to your setup.
  49907. */
  49908. sceneCenter: Vector3;
  49909. protected _opacityFresnel: boolean;
  49910. /**
  49911. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49912. * This helps ensuring a nice transition when the camera goes under the ground.
  49913. */
  49914. opacityFresnel: boolean;
  49915. protected _reflectionFresnel: boolean;
  49916. /**
  49917. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49918. * This helps adding a mirror texture on the ground.
  49919. */
  49920. reflectionFresnel: boolean;
  49921. protected _reflectionFalloffDistance: number;
  49922. /**
  49923. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49924. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49925. */
  49926. reflectionFalloffDistance: number;
  49927. protected _reflectionAmount: number;
  49928. /**
  49929. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49930. */
  49931. reflectionAmount: number;
  49932. protected _reflectionReflectance0: number;
  49933. /**
  49934. * This specifies the weight of the reflection at grazing angle.
  49935. */
  49936. reflectionReflectance0: number;
  49937. protected _reflectionReflectance90: number;
  49938. /**
  49939. * This specifies the weight of the reflection at a perpendicular point of view.
  49940. */
  49941. reflectionReflectance90: number;
  49942. /**
  49943. * Sets the reflection reflectance fresnel values according to the default standard
  49944. * empirically know to work well :-)
  49945. */
  49946. set reflectionStandardFresnelWeight(value: number);
  49947. protected _useRGBColor: boolean;
  49948. /**
  49949. * Helps to directly use the maps channels instead of their level.
  49950. */
  49951. useRGBColor: boolean;
  49952. protected _enableNoise: boolean;
  49953. /**
  49954. * This helps reducing the banding effect that could occur on the background.
  49955. */
  49956. enableNoise: boolean;
  49957. /**
  49958. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49959. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49960. * Recommended to be keep at 1.0 except for special cases.
  49961. */
  49962. get fovMultiplier(): number;
  49963. set fovMultiplier(value: number);
  49964. private _fovMultiplier;
  49965. /**
  49966. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49967. */
  49968. useEquirectangularFOV: boolean;
  49969. private _maxSimultaneousLights;
  49970. /**
  49971. * Number of Simultaneous lights allowed on the material.
  49972. */
  49973. maxSimultaneousLights: int;
  49974. /**
  49975. * Default configuration related to image processing available in the Background Material.
  49976. */
  49977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49978. /**
  49979. * Keep track of the image processing observer to allow dispose and replace.
  49980. */
  49981. private _imageProcessingObserver;
  49982. /**
  49983. * Attaches a new image processing configuration to the PBR Material.
  49984. * @param configuration (if null the scene configuration will be use)
  49985. */
  49986. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49987. /**
  49988. * Gets the image processing configuration used either in this material.
  49989. */
  49990. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49991. /**
  49992. * Sets the Default image processing configuration used either in the this material.
  49993. *
  49994. * If sets to null, the scene one is in use.
  49995. */
  49996. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49997. /**
  49998. * Gets wether the color curves effect is enabled.
  49999. */
  50000. get cameraColorCurvesEnabled(): boolean;
  50001. /**
  50002. * Sets wether the color curves effect is enabled.
  50003. */
  50004. set cameraColorCurvesEnabled(value: boolean);
  50005. /**
  50006. * Gets wether the color grading effect is enabled.
  50007. */
  50008. get cameraColorGradingEnabled(): boolean;
  50009. /**
  50010. * Gets wether the color grading effect is enabled.
  50011. */
  50012. set cameraColorGradingEnabled(value: boolean);
  50013. /**
  50014. * Gets wether tonemapping is enabled or not.
  50015. */
  50016. get cameraToneMappingEnabled(): boolean;
  50017. /**
  50018. * Sets wether tonemapping is enabled or not
  50019. */
  50020. set cameraToneMappingEnabled(value: boolean);
  50021. /**
  50022. * The camera exposure used on this material.
  50023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50024. * This corresponds to a photographic exposure.
  50025. */
  50026. get cameraExposure(): float;
  50027. /**
  50028. * The camera exposure used on this material.
  50029. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50030. * This corresponds to a photographic exposure.
  50031. */
  50032. set cameraExposure(value: float);
  50033. /**
  50034. * Gets The camera contrast used on this material.
  50035. */
  50036. get cameraContrast(): float;
  50037. /**
  50038. * Sets The camera contrast used on this material.
  50039. */
  50040. set cameraContrast(value: float);
  50041. /**
  50042. * Gets the Color Grading 2D Lookup Texture.
  50043. */
  50044. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50045. /**
  50046. * Sets the Color Grading 2D Lookup Texture.
  50047. */
  50048. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50049. /**
  50050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50052. * 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;
  50053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50054. */
  50055. get cameraColorCurves(): Nullable<ColorCurves>;
  50056. /**
  50057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50059. * 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;
  50060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50061. */
  50062. set cameraColorCurves(value: Nullable<ColorCurves>);
  50063. /**
  50064. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50065. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50066. */
  50067. switchToBGR: boolean;
  50068. private _renderTargets;
  50069. private _reflectionControls;
  50070. private _white;
  50071. private _primaryShadowColor;
  50072. private _primaryHighlightColor;
  50073. /**
  50074. * Instantiates a Background Material in the given scene
  50075. * @param name The friendly name of the material
  50076. * @param scene The scene to add the material to
  50077. */
  50078. constructor(name: string, scene: Scene);
  50079. /**
  50080. * Gets a boolean indicating that current material needs to register RTT
  50081. */
  50082. get hasRenderTargetTextures(): boolean;
  50083. /**
  50084. * The entire material has been created in order to prevent overdraw.
  50085. * @returns false
  50086. */
  50087. needAlphaTesting(): boolean;
  50088. /**
  50089. * The entire material has been created in order to prevent overdraw.
  50090. * @returns true if blending is enable
  50091. */
  50092. needAlphaBlending(): boolean;
  50093. /**
  50094. * Checks wether the material is ready to be rendered for a given mesh.
  50095. * @param mesh The mesh to render
  50096. * @param subMesh The submesh to check against
  50097. * @param useInstances Specify wether or not the material is used with instances
  50098. * @returns true if all the dependencies are ready (Textures, Effects...)
  50099. */
  50100. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50101. /**
  50102. * Compute the primary color according to the chosen perceptual color.
  50103. */
  50104. private _computePrimaryColorFromPerceptualColor;
  50105. /**
  50106. * Compute the highlights and shadow colors according to their chosen levels.
  50107. */
  50108. private _computePrimaryColors;
  50109. /**
  50110. * Build the uniform buffer used in the material.
  50111. */
  50112. buildUniformLayout(): void;
  50113. /**
  50114. * Unbind the material.
  50115. */
  50116. unbind(): void;
  50117. /**
  50118. * Bind only the world matrix to the material.
  50119. * @param world The world matrix to bind.
  50120. */
  50121. bindOnlyWorldMatrix(world: Matrix): void;
  50122. /**
  50123. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50124. * @param world The world matrix to bind.
  50125. * @param subMesh The submesh to bind for.
  50126. */
  50127. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50128. /**
  50129. * Checks to see if a texture is used in the material.
  50130. * @param texture - Base texture to use.
  50131. * @returns - Boolean specifying if a texture is used in the material.
  50132. */
  50133. hasTexture(texture: BaseTexture): boolean;
  50134. /**
  50135. * Dispose the material.
  50136. * @param forceDisposeEffect Force disposal of the associated effect.
  50137. * @param forceDisposeTextures Force disposal of the associated textures.
  50138. */
  50139. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50140. /**
  50141. * Clones the material.
  50142. * @param name The cloned name.
  50143. * @returns The cloned material.
  50144. */
  50145. clone(name: string): BackgroundMaterial;
  50146. /**
  50147. * Serializes the current material to its JSON representation.
  50148. * @returns The JSON representation.
  50149. */
  50150. serialize(): any;
  50151. /**
  50152. * Gets the class name of the material
  50153. * @returns "BackgroundMaterial"
  50154. */
  50155. getClassName(): string;
  50156. /**
  50157. * Parse a JSON input to create back a background material.
  50158. * @param source The JSON data to parse
  50159. * @param scene The scene to create the parsed material in
  50160. * @param rootUrl The root url of the assets the material depends upon
  50161. * @returns the instantiated BackgroundMaterial.
  50162. */
  50163. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50164. }
  50165. }
  50166. declare module BABYLON {
  50167. /**
  50168. * Represents the different options available during the creation of
  50169. * a Environment helper.
  50170. *
  50171. * This can control the default ground, skybox and image processing setup of your scene.
  50172. */
  50173. export interface IEnvironmentHelperOptions {
  50174. /**
  50175. * Specifies whether or not to create a ground.
  50176. * True by default.
  50177. */
  50178. createGround: boolean;
  50179. /**
  50180. * Specifies the ground size.
  50181. * 15 by default.
  50182. */
  50183. groundSize: number;
  50184. /**
  50185. * The texture used on the ground for the main color.
  50186. * Comes from the BabylonJS CDN by default.
  50187. *
  50188. * Remarks: Can be either a texture or a url.
  50189. */
  50190. groundTexture: string | BaseTexture;
  50191. /**
  50192. * The color mixed in the ground texture by default.
  50193. * BabylonJS clearColor by default.
  50194. */
  50195. groundColor: Color3;
  50196. /**
  50197. * Specifies the ground opacity.
  50198. * 1 by default.
  50199. */
  50200. groundOpacity: number;
  50201. /**
  50202. * Enables the ground to receive shadows.
  50203. * True by default.
  50204. */
  50205. enableGroundShadow: boolean;
  50206. /**
  50207. * Helps preventing the shadow to be fully black on the ground.
  50208. * 0.5 by default.
  50209. */
  50210. groundShadowLevel: number;
  50211. /**
  50212. * Creates a mirror texture attach to the ground.
  50213. * false by default.
  50214. */
  50215. enableGroundMirror: boolean;
  50216. /**
  50217. * Specifies the ground mirror size ratio.
  50218. * 0.3 by default as the default kernel is 64.
  50219. */
  50220. groundMirrorSizeRatio: number;
  50221. /**
  50222. * Specifies the ground mirror blur kernel size.
  50223. * 64 by default.
  50224. */
  50225. groundMirrorBlurKernel: number;
  50226. /**
  50227. * Specifies the ground mirror visibility amount.
  50228. * 1 by default
  50229. */
  50230. groundMirrorAmount: number;
  50231. /**
  50232. * Specifies the ground mirror reflectance weight.
  50233. * This uses the standard weight of the background material to setup the fresnel effect
  50234. * of the mirror.
  50235. * 1 by default.
  50236. */
  50237. groundMirrorFresnelWeight: number;
  50238. /**
  50239. * Specifies the ground mirror Falloff distance.
  50240. * This can helps reducing the size of the reflection.
  50241. * 0 by Default.
  50242. */
  50243. groundMirrorFallOffDistance: number;
  50244. /**
  50245. * Specifies the ground mirror texture type.
  50246. * Unsigned Int by Default.
  50247. */
  50248. groundMirrorTextureType: number;
  50249. /**
  50250. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50251. * the shown objects.
  50252. */
  50253. groundYBias: number;
  50254. /**
  50255. * Specifies whether or not to create a skybox.
  50256. * True by default.
  50257. */
  50258. createSkybox: boolean;
  50259. /**
  50260. * Specifies the skybox size.
  50261. * 20 by default.
  50262. */
  50263. skyboxSize: number;
  50264. /**
  50265. * The texture used on the skybox for the main color.
  50266. * Comes from the BabylonJS CDN by default.
  50267. *
  50268. * Remarks: Can be either a texture or a url.
  50269. */
  50270. skyboxTexture: string | BaseTexture;
  50271. /**
  50272. * The color mixed in the skybox texture by default.
  50273. * BabylonJS clearColor by default.
  50274. */
  50275. skyboxColor: Color3;
  50276. /**
  50277. * The background rotation around the Y axis of the scene.
  50278. * This helps aligning the key lights of your scene with the background.
  50279. * 0 by default.
  50280. */
  50281. backgroundYRotation: number;
  50282. /**
  50283. * Compute automatically the size of the elements to best fit with the scene.
  50284. */
  50285. sizeAuto: boolean;
  50286. /**
  50287. * Default position of the rootMesh if autoSize is not true.
  50288. */
  50289. rootPosition: Vector3;
  50290. /**
  50291. * Sets up the image processing in the scene.
  50292. * true by default.
  50293. */
  50294. setupImageProcessing: boolean;
  50295. /**
  50296. * The texture used as your environment texture in the scene.
  50297. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50298. *
  50299. * Remarks: Can be either a texture or a url.
  50300. */
  50301. environmentTexture: string | BaseTexture;
  50302. /**
  50303. * The value of the exposure to apply to the scene.
  50304. * 0.6 by default if setupImageProcessing is true.
  50305. */
  50306. cameraExposure: number;
  50307. /**
  50308. * The value of the contrast to apply to the scene.
  50309. * 1.6 by default if setupImageProcessing is true.
  50310. */
  50311. cameraContrast: number;
  50312. /**
  50313. * Specifies whether or not tonemapping should be enabled in the scene.
  50314. * true by default if setupImageProcessing is true.
  50315. */
  50316. toneMappingEnabled: boolean;
  50317. }
  50318. /**
  50319. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50320. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50321. * It also helps with the default setup of your imageProcessing configuration.
  50322. */
  50323. export class EnvironmentHelper {
  50324. /**
  50325. * Default ground texture URL.
  50326. */
  50327. private static _groundTextureCDNUrl;
  50328. /**
  50329. * Default skybox texture URL.
  50330. */
  50331. private static _skyboxTextureCDNUrl;
  50332. /**
  50333. * Default environment texture URL.
  50334. */
  50335. private static _environmentTextureCDNUrl;
  50336. /**
  50337. * Creates the default options for the helper.
  50338. */
  50339. private static _getDefaultOptions;
  50340. private _rootMesh;
  50341. /**
  50342. * Gets the root mesh created by the helper.
  50343. */
  50344. get rootMesh(): Mesh;
  50345. private _skybox;
  50346. /**
  50347. * Gets the skybox created by the helper.
  50348. */
  50349. get skybox(): Nullable<Mesh>;
  50350. private _skyboxTexture;
  50351. /**
  50352. * Gets the skybox texture created by the helper.
  50353. */
  50354. get skyboxTexture(): Nullable<BaseTexture>;
  50355. private _skyboxMaterial;
  50356. /**
  50357. * Gets the skybox material created by the helper.
  50358. */
  50359. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50360. private _ground;
  50361. /**
  50362. * Gets the ground mesh created by the helper.
  50363. */
  50364. get ground(): Nullable<Mesh>;
  50365. private _groundTexture;
  50366. /**
  50367. * Gets the ground texture created by the helper.
  50368. */
  50369. get groundTexture(): Nullable<BaseTexture>;
  50370. private _groundMirror;
  50371. /**
  50372. * Gets the ground mirror created by the helper.
  50373. */
  50374. get groundMirror(): Nullable<MirrorTexture>;
  50375. /**
  50376. * Gets the ground mirror render list to helps pushing the meshes
  50377. * you wish in the ground reflection.
  50378. */
  50379. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50380. private _groundMaterial;
  50381. /**
  50382. * Gets the ground material created by the helper.
  50383. */
  50384. get groundMaterial(): Nullable<BackgroundMaterial>;
  50385. /**
  50386. * Stores the creation options.
  50387. */
  50388. private readonly _scene;
  50389. private _options;
  50390. /**
  50391. * This observable will be notified with any error during the creation of the environment,
  50392. * mainly texture creation errors.
  50393. */
  50394. onErrorObservable: Observable<{
  50395. message?: string;
  50396. exception?: any;
  50397. }>;
  50398. /**
  50399. * constructor
  50400. * @param options Defines the options we want to customize the helper
  50401. * @param scene The scene to add the material to
  50402. */
  50403. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50404. /**
  50405. * Updates the background according to the new options
  50406. * @param options
  50407. */
  50408. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50409. /**
  50410. * Sets the primary color of all the available elements.
  50411. * @param color the main color to affect to the ground and the background
  50412. */
  50413. setMainColor(color: Color3): void;
  50414. /**
  50415. * Setup the image processing according to the specified options.
  50416. */
  50417. private _setupImageProcessing;
  50418. /**
  50419. * Setup the environment texture according to the specified options.
  50420. */
  50421. private _setupEnvironmentTexture;
  50422. /**
  50423. * Setup the background according to the specified options.
  50424. */
  50425. private _setupBackground;
  50426. /**
  50427. * Get the scene sizes according to the setup.
  50428. */
  50429. private _getSceneSize;
  50430. /**
  50431. * Setup the ground according to the specified options.
  50432. */
  50433. private _setupGround;
  50434. /**
  50435. * Setup the ground material according to the specified options.
  50436. */
  50437. private _setupGroundMaterial;
  50438. /**
  50439. * Setup the ground diffuse texture according to the specified options.
  50440. */
  50441. private _setupGroundDiffuseTexture;
  50442. /**
  50443. * Setup the ground mirror texture according to the specified options.
  50444. */
  50445. private _setupGroundMirrorTexture;
  50446. /**
  50447. * Setup the ground to receive the mirror texture.
  50448. */
  50449. private _setupMirrorInGroundMaterial;
  50450. /**
  50451. * Setup the skybox according to the specified options.
  50452. */
  50453. private _setupSkybox;
  50454. /**
  50455. * Setup the skybox material according to the specified options.
  50456. */
  50457. private _setupSkyboxMaterial;
  50458. /**
  50459. * Setup the skybox reflection texture according to the specified options.
  50460. */
  50461. private _setupSkyboxReflectionTexture;
  50462. private _errorHandler;
  50463. /**
  50464. * Dispose all the elements created by the Helper.
  50465. */
  50466. dispose(): void;
  50467. }
  50468. }
  50469. declare module BABYLON {
  50470. /**
  50471. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50472. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50473. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50474. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50475. */
  50476. export class PhotoDome extends TransformNode {
  50477. /**
  50478. * Define the image as a Monoscopic panoramic 360 image.
  50479. */
  50480. static readonly MODE_MONOSCOPIC: number;
  50481. /**
  50482. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50483. */
  50484. static readonly MODE_TOPBOTTOM: number;
  50485. /**
  50486. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50487. */
  50488. static readonly MODE_SIDEBYSIDE: number;
  50489. private _useDirectMapping;
  50490. /**
  50491. * The texture being displayed on the sphere
  50492. */
  50493. protected _photoTexture: Texture;
  50494. /**
  50495. * Gets or sets the texture being displayed on the sphere
  50496. */
  50497. get photoTexture(): Texture;
  50498. set photoTexture(value: Texture);
  50499. /**
  50500. * Observable raised when an error occured while loading the 360 image
  50501. */
  50502. onLoadErrorObservable: Observable<string>;
  50503. /**
  50504. * The skybox material
  50505. */
  50506. protected _material: BackgroundMaterial;
  50507. /**
  50508. * The surface used for the skybox
  50509. */
  50510. protected _mesh: Mesh;
  50511. /**
  50512. * Gets the mesh used for the skybox.
  50513. */
  50514. get mesh(): Mesh;
  50515. /**
  50516. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50517. * Also see the options.resolution property.
  50518. */
  50519. get fovMultiplier(): number;
  50520. set fovMultiplier(value: number);
  50521. private _imageMode;
  50522. /**
  50523. * Gets or set the current video mode for the video. It can be:
  50524. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50525. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50526. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50527. */
  50528. get imageMode(): number;
  50529. set imageMode(value: number);
  50530. /**
  50531. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50532. * @param name Element's name, child elements will append suffixes for their own names.
  50533. * @param urlsOfPhoto defines the url of the photo to display
  50534. * @param options defines an object containing optional or exposed sub element properties
  50535. * @param onError defines a callback called when an error occured while loading the texture
  50536. */
  50537. constructor(name: string, urlOfPhoto: string, options: {
  50538. resolution?: number;
  50539. size?: number;
  50540. useDirectMapping?: boolean;
  50541. faceForward?: boolean;
  50542. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50543. private _onBeforeCameraRenderObserver;
  50544. private _changeImageMode;
  50545. /**
  50546. * Releases resources associated with this node.
  50547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50549. */
  50550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50551. }
  50552. }
  50553. declare module BABYLON {
  50554. /**
  50555. * Class used to host RGBD texture specific utilities
  50556. */
  50557. export class RGBDTextureTools {
  50558. /**
  50559. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50560. * @param texture the texture to expand.
  50561. */
  50562. static ExpandRGBDTexture(texture: Texture): void;
  50563. }
  50564. }
  50565. declare module BABYLON {
  50566. /**
  50567. * Class used to host texture specific utilities
  50568. */
  50569. export class BRDFTextureTools {
  50570. /**
  50571. * Prevents texture cache collision
  50572. */
  50573. private static _instanceNumber;
  50574. /**
  50575. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50576. * @param scene defines the hosting scene
  50577. * @returns the environment BRDF texture
  50578. */
  50579. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50580. private static _environmentBRDFBase64Texture;
  50581. }
  50582. }
  50583. declare module BABYLON {
  50584. /**
  50585. * @hidden
  50586. */
  50587. export interface IMaterialClearCoatDefines {
  50588. CLEARCOAT: boolean;
  50589. CLEARCOAT_DEFAULTIOR: boolean;
  50590. CLEARCOAT_TEXTURE: boolean;
  50591. CLEARCOAT_TEXTUREDIRECTUV: number;
  50592. CLEARCOAT_BUMP: boolean;
  50593. CLEARCOAT_BUMPDIRECTUV: number;
  50594. CLEARCOAT_TINT: boolean;
  50595. CLEARCOAT_TINT_TEXTURE: boolean;
  50596. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50597. /** @hidden */
  50598. _areTexturesDirty: boolean;
  50599. }
  50600. /**
  50601. * Define the code related to the clear coat parameters of the pbr material.
  50602. */
  50603. export class PBRClearCoatConfiguration {
  50604. /**
  50605. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50606. * The default fits with a polyurethane material.
  50607. */
  50608. private static readonly _DefaultIndexOfRefraction;
  50609. private _isEnabled;
  50610. /**
  50611. * Defines if the clear coat is enabled in the material.
  50612. */
  50613. isEnabled: boolean;
  50614. /**
  50615. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50616. */
  50617. intensity: number;
  50618. /**
  50619. * Defines the clear coat layer roughness.
  50620. */
  50621. roughness: number;
  50622. private _indexOfRefraction;
  50623. /**
  50624. * Defines the index of refraction of the clear coat.
  50625. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50626. * The default fits with a polyurethane material.
  50627. * Changing the default value is more performance intensive.
  50628. */
  50629. indexOfRefraction: number;
  50630. private _texture;
  50631. /**
  50632. * Stores the clear coat values in a texture.
  50633. */
  50634. texture: Nullable<BaseTexture>;
  50635. private _bumpTexture;
  50636. /**
  50637. * Define the clear coat specific bump texture.
  50638. */
  50639. bumpTexture: Nullable<BaseTexture>;
  50640. private _isTintEnabled;
  50641. /**
  50642. * Defines if the clear coat tint is enabled in the material.
  50643. */
  50644. isTintEnabled: boolean;
  50645. /**
  50646. * Defines the clear coat tint of the material.
  50647. * This is only use if tint is enabled
  50648. */
  50649. tintColor: Color3;
  50650. /**
  50651. * Defines the distance at which the tint color should be found in the
  50652. * clear coat media.
  50653. * This is only use if tint is enabled
  50654. */
  50655. tintColorAtDistance: number;
  50656. /**
  50657. * Defines the clear coat layer thickness.
  50658. * This is only use if tint is enabled
  50659. */
  50660. tintThickness: number;
  50661. private _tintTexture;
  50662. /**
  50663. * Stores the clear tint values in a texture.
  50664. * rgb is tint
  50665. * a is a thickness factor
  50666. */
  50667. tintTexture: Nullable<BaseTexture>;
  50668. /** @hidden */
  50669. private _internalMarkAllSubMeshesAsTexturesDirty;
  50670. /** @hidden */
  50671. _markAllSubMeshesAsTexturesDirty(): void;
  50672. /**
  50673. * Instantiate a new istance of clear coat configuration.
  50674. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50675. */
  50676. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50677. /**
  50678. * Gets wehter the submesh is ready to be used or not.
  50679. * @param defines the list of "defines" to update.
  50680. * @param scene defines the scene the material belongs to.
  50681. * @param engine defines the engine the material belongs to.
  50682. * @param disableBumpMap defines wether the material disables bump or not.
  50683. * @returns - boolean indicating that the submesh is ready or not.
  50684. */
  50685. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50686. /**
  50687. * Checks to see if a texture is used in the material.
  50688. * @param defines the list of "defines" to update.
  50689. * @param scene defines the scene to the material belongs to.
  50690. */
  50691. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50692. /**
  50693. * Binds the material data.
  50694. * @param uniformBuffer defines the Uniform buffer to fill in.
  50695. * @param scene defines the scene the material belongs to.
  50696. * @param engine defines the engine the material belongs to.
  50697. * @param disableBumpMap defines wether the material disables bump or not.
  50698. * @param isFrozen defines wether the material is frozen or not.
  50699. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50700. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50701. */
  50702. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50703. /**
  50704. * Checks to see if a texture is used in the material.
  50705. * @param texture - Base texture to use.
  50706. * @returns - Boolean specifying if a texture is used in the material.
  50707. */
  50708. hasTexture(texture: BaseTexture): boolean;
  50709. /**
  50710. * Returns an array of the actively used textures.
  50711. * @param activeTextures Array of BaseTextures
  50712. */
  50713. getActiveTextures(activeTextures: BaseTexture[]): void;
  50714. /**
  50715. * Returns the animatable textures.
  50716. * @param animatables Array of animatable textures.
  50717. */
  50718. getAnimatables(animatables: IAnimatable[]): void;
  50719. /**
  50720. * Disposes the resources of the material.
  50721. * @param forceDisposeTextures - Forces the disposal of all textures.
  50722. */
  50723. dispose(forceDisposeTextures?: boolean): void;
  50724. /**
  50725. * Get the current class name of the texture useful for serialization or dynamic coding.
  50726. * @returns "PBRClearCoatConfiguration"
  50727. */
  50728. getClassName(): string;
  50729. /**
  50730. * Add fallbacks to the effect fallbacks list.
  50731. * @param defines defines the Base texture to use.
  50732. * @param fallbacks defines the current fallback list.
  50733. * @param currentRank defines the current fallback rank.
  50734. * @returns the new fallback rank.
  50735. */
  50736. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50737. /**
  50738. * Add the required uniforms to the current list.
  50739. * @param uniforms defines the current uniform list.
  50740. */
  50741. static AddUniforms(uniforms: string[]): void;
  50742. /**
  50743. * Add the required samplers to the current list.
  50744. * @param samplers defines the current sampler list.
  50745. */
  50746. static AddSamplers(samplers: string[]): void;
  50747. /**
  50748. * Add the required uniforms to the current buffer.
  50749. * @param uniformBuffer defines the current uniform buffer.
  50750. */
  50751. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50752. /**
  50753. * Makes a duplicate of the current configuration into another one.
  50754. * @param clearCoatConfiguration define the config where to copy the info
  50755. */
  50756. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50757. /**
  50758. * Serializes this clear coat configuration.
  50759. * @returns - An object with the serialized config.
  50760. */
  50761. serialize(): any;
  50762. /**
  50763. * Parses a anisotropy Configuration from a serialized object.
  50764. * @param source - Serialized object.
  50765. * @param scene Defines the scene we are parsing for
  50766. * @param rootUrl Defines the rootUrl to load from
  50767. */
  50768. parse(source: any, scene: Scene, rootUrl: string): void;
  50769. }
  50770. }
  50771. declare module BABYLON {
  50772. /**
  50773. * @hidden
  50774. */
  50775. export interface IMaterialAnisotropicDefines {
  50776. ANISOTROPIC: boolean;
  50777. ANISOTROPIC_TEXTURE: boolean;
  50778. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50779. MAINUV1: boolean;
  50780. _areTexturesDirty: boolean;
  50781. _needUVs: boolean;
  50782. }
  50783. /**
  50784. * Define the code related to the anisotropic parameters of the pbr material.
  50785. */
  50786. export class PBRAnisotropicConfiguration {
  50787. private _isEnabled;
  50788. /**
  50789. * Defines if the anisotropy is enabled in the material.
  50790. */
  50791. isEnabled: boolean;
  50792. /**
  50793. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50794. */
  50795. intensity: number;
  50796. /**
  50797. * Defines if the effect is along the tangents, bitangents or in between.
  50798. * By default, the effect is "strectching" the highlights along the tangents.
  50799. */
  50800. direction: Vector2;
  50801. private _texture;
  50802. /**
  50803. * Stores the anisotropy values in a texture.
  50804. * rg is direction (like normal from -1 to 1)
  50805. * b is a intensity
  50806. */
  50807. texture: Nullable<BaseTexture>;
  50808. /** @hidden */
  50809. private _internalMarkAllSubMeshesAsTexturesDirty;
  50810. /** @hidden */
  50811. _markAllSubMeshesAsTexturesDirty(): void;
  50812. /**
  50813. * Instantiate a new istance of anisotropy configuration.
  50814. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50815. */
  50816. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50817. /**
  50818. * Specifies that the submesh is ready to be used.
  50819. * @param defines the list of "defines" to update.
  50820. * @param scene defines the scene the material belongs to.
  50821. * @returns - boolean indicating that the submesh is ready or not.
  50822. */
  50823. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50824. /**
  50825. * Checks to see if a texture is used in the material.
  50826. * @param defines the list of "defines" to update.
  50827. * @param mesh the mesh we are preparing the defines for.
  50828. * @param scene defines the scene the material belongs to.
  50829. */
  50830. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50831. /**
  50832. * Binds the material data.
  50833. * @param uniformBuffer defines the Uniform buffer to fill in.
  50834. * @param scene defines the scene the material belongs to.
  50835. * @param isFrozen defines wether the material is frozen or not.
  50836. */
  50837. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50838. /**
  50839. * Checks to see if a texture is used in the material.
  50840. * @param texture - Base texture to use.
  50841. * @returns - Boolean specifying if a texture is used in the material.
  50842. */
  50843. hasTexture(texture: BaseTexture): boolean;
  50844. /**
  50845. * Returns an array of the actively used textures.
  50846. * @param activeTextures Array of BaseTextures
  50847. */
  50848. getActiveTextures(activeTextures: BaseTexture[]): void;
  50849. /**
  50850. * Returns the animatable textures.
  50851. * @param animatables Array of animatable textures.
  50852. */
  50853. getAnimatables(animatables: IAnimatable[]): void;
  50854. /**
  50855. * Disposes the resources of the material.
  50856. * @param forceDisposeTextures - Forces the disposal of all textures.
  50857. */
  50858. dispose(forceDisposeTextures?: boolean): void;
  50859. /**
  50860. * Get the current class name of the texture useful for serialization or dynamic coding.
  50861. * @returns "PBRAnisotropicConfiguration"
  50862. */
  50863. getClassName(): string;
  50864. /**
  50865. * Add fallbacks to the effect fallbacks list.
  50866. * @param defines defines the Base texture to use.
  50867. * @param fallbacks defines the current fallback list.
  50868. * @param currentRank defines the current fallback rank.
  50869. * @returns the new fallback rank.
  50870. */
  50871. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50872. /**
  50873. * Add the required uniforms to the current list.
  50874. * @param uniforms defines the current uniform list.
  50875. */
  50876. static AddUniforms(uniforms: string[]): void;
  50877. /**
  50878. * Add the required uniforms to the current buffer.
  50879. * @param uniformBuffer defines the current uniform buffer.
  50880. */
  50881. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50882. /**
  50883. * Add the required samplers to the current list.
  50884. * @param samplers defines the current sampler list.
  50885. */
  50886. static AddSamplers(samplers: string[]): void;
  50887. /**
  50888. * Makes a duplicate of the current configuration into another one.
  50889. * @param anisotropicConfiguration define the config where to copy the info
  50890. */
  50891. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50892. /**
  50893. * Serializes this anisotropy configuration.
  50894. * @returns - An object with the serialized config.
  50895. */
  50896. serialize(): any;
  50897. /**
  50898. * Parses a anisotropy Configuration from a serialized object.
  50899. * @param source - Serialized object.
  50900. * @param scene Defines the scene we are parsing for
  50901. * @param rootUrl Defines the rootUrl to load from
  50902. */
  50903. parse(source: any, scene: Scene, rootUrl: string): void;
  50904. }
  50905. }
  50906. declare module BABYLON {
  50907. /**
  50908. * @hidden
  50909. */
  50910. export interface IMaterialBRDFDefines {
  50911. BRDF_V_HEIGHT_CORRELATED: boolean;
  50912. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50913. SPHERICAL_HARMONICS: boolean;
  50914. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50915. /** @hidden */
  50916. _areMiscDirty: boolean;
  50917. }
  50918. /**
  50919. * Define the code related to the BRDF parameters of the pbr material.
  50920. */
  50921. export class PBRBRDFConfiguration {
  50922. /**
  50923. * Default value used for the energy conservation.
  50924. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50925. */
  50926. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50927. /**
  50928. * Default value used for the Smith Visibility Height Correlated mode.
  50929. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50930. */
  50931. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50932. /**
  50933. * Default value used for the IBL diffuse part.
  50934. * This can help switching back to the polynomials mode globally which is a tiny bit
  50935. * less GPU intensive at the drawback of a lower quality.
  50936. */
  50937. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50938. /**
  50939. * Default value used for activating energy conservation for the specular workflow.
  50940. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50941. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50942. */
  50943. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50944. private _useEnergyConservation;
  50945. /**
  50946. * Defines if the material uses energy conservation.
  50947. */
  50948. useEnergyConservation: boolean;
  50949. private _useSmithVisibilityHeightCorrelated;
  50950. /**
  50951. * LEGACY Mode set to false
  50952. * Defines if the material uses height smith correlated visibility term.
  50953. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50954. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50955. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50956. * Not relying on height correlated will also disable energy conservation.
  50957. */
  50958. useSmithVisibilityHeightCorrelated: boolean;
  50959. private _useSphericalHarmonics;
  50960. /**
  50961. * LEGACY Mode set to false
  50962. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50963. * diffuse part of the IBL.
  50964. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50965. * to the ground truth.
  50966. */
  50967. useSphericalHarmonics: boolean;
  50968. private _useSpecularGlossinessInputEnergyConservation;
  50969. /**
  50970. * Defines if the material uses energy conservation, when the specular workflow is active.
  50971. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50972. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50973. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50974. */
  50975. useSpecularGlossinessInputEnergyConservation: boolean;
  50976. /** @hidden */
  50977. private _internalMarkAllSubMeshesAsMiscDirty;
  50978. /** @hidden */
  50979. _markAllSubMeshesAsMiscDirty(): void;
  50980. /**
  50981. * Instantiate a new istance of clear coat configuration.
  50982. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50983. */
  50984. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50985. /**
  50986. * Checks to see if a texture is used in the material.
  50987. * @param defines the list of "defines" to update.
  50988. */
  50989. prepareDefines(defines: IMaterialBRDFDefines): void;
  50990. /**
  50991. * Get the current class name of the texture useful for serialization or dynamic coding.
  50992. * @returns "PBRClearCoatConfiguration"
  50993. */
  50994. getClassName(): string;
  50995. /**
  50996. * Makes a duplicate of the current configuration into another one.
  50997. * @param brdfConfiguration define the config where to copy the info
  50998. */
  50999. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51000. /**
  51001. * Serializes this BRDF configuration.
  51002. * @returns - An object with the serialized config.
  51003. */
  51004. serialize(): any;
  51005. /**
  51006. * Parses a anisotropy Configuration from a serialized object.
  51007. * @param source - Serialized object.
  51008. * @param scene Defines the scene we are parsing for
  51009. * @param rootUrl Defines the rootUrl to load from
  51010. */
  51011. parse(source: any, scene: Scene, rootUrl: string): void;
  51012. }
  51013. }
  51014. declare module BABYLON {
  51015. /**
  51016. * @hidden
  51017. */
  51018. export interface IMaterialSheenDefines {
  51019. SHEEN: boolean;
  51020. SHEEN_TEXTURE: boolean;
  51021. SHEEN_TEXTUREDIRECTUV: number;
  51022. SHEEN_LINKWITHALBEDO: boolean;
  51023. SHEEN_ROUGHNESS: boolean;
  51024. SHEEN_ALBEDOSCALING: boolean;
  51025. /** @hidden */
  51026. _areTexturesDirty: boolean;
  51027. }
  51028. /**
  51029. * Define the code related to the Sheen parameters of the pbr material.
  51030. */
  51031. export class PBRSheenConfiguration {
  51032. private _isEnabled;
  51033. /**
  51034. * Defines if the material uses sheen.
  51035. */
  51036. isEnabled: boolean;
  51037. private _linkSheenWithAlbedo;
  51038. /**
  51039. * Defines if the sheen is linked to the sheen color.
  51040. */
  51041. linkSheenWithAlbedo: boolean;
  51042. /**
  51043. * Defines the sheen intensity.
  51044. */
  51045. intensity: number;
  51046. /**
  51047. * Defines the sheen color.
  51048. */
  51049. color: Color3;
  51050. private _texture;
  51051. /**
  51052. * Stores the sheen tint values in a texture.
  51053. * rgb is tint
  51054. * a is a intensity
  51055. */
  51056. texture: Nullable<BaseTexture>;
  51057. private _roughness;
  51058. /**
  51059. * Defines the sheen roughness.
  51060. * It is not taken into account if linkSheenWithAlbedo is true.
  51061. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  51062. */
  51063. roughness: Nullable<number>;
  51064. private _albedoScaling;
  51065. /**
  51066. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  51067. * It allows the strength of the sheen effect to not depend on the base color of the material,
  51068. * making it easier to setup and tweak the effect
  51069. */
  51070. albedoScaling: boolean;
  51071. /** @hidden */
  51072. private _internalMarkAllSubMeshesAsTexturesDirty;
  51073. /** @hidden */
  51074. _markAllSubMeshesAsTexturesDirty(): void;
  51075. /**
  51076. * Instantiate a new istance of clear coat configuration.
  51077. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51078. */
  51079. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51080. /**
  51081. * Specifies that the submesh is ready to be used.
  51082. * @param defines the list of "defines" to update.
  51083. * @param scene defines the scene the material belongs to.
  51084. * @returns - boolean indicating that the submesh is ready or not.
  51085. */
  51086. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51087. /**
  51088. * Checks to see if a texture is used in the material.
  51089. * @param defines the list of "defines" to update.
  51090. * @param scene defines the scene the material belongs to.
  51091. */
  51092. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51093. /**
  51094. * Binds the material data.
  51095. * @param uniformBuffer defines the Uniform buffer to fill in.
  51096. * @param scene defines the scene the material belongs to.
  51097. * @param isFrozen defines wether the material is frozen or not.
  51098. */
  51099. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51100. /**
  51101. * Checks to see if a texture is used in the material.
  51102. * @param texture - Base texture to use.
  51103. * @returns - Boolean specifying if a texture is used in the material.
  51104. */
  51105. hasTexture(texture: BaseTexture): boolean;
  51106. /**
  51107. * Returns an array of the actively used textures.
  51108. * @param activeTextures Array of BaseTextures
  51109. */
  51110. getActiveTextures(activeTextures: BaseTexture[]): void;
  51111. /**
  51112. * Returns the animatable textures.
  51113. * @param animatables Array of animatable textures.
  51114. */
  51115. getAnimatables(animatables: IAnimatable[]): void;
  51116. /**
  51117. * Disposes the resources of the material.
  51118. * @param forceDisposeTextures - Forces the disposal of all textures.
  51119. */
  51120. dispose(forceDisposeTextures?: boolean): void;
  51121. /**
  51122. * Get the current class name of the texture useful for serialization or dynamic coding.
  51123. * @returns "PBRSheenConfiguration"
  51124. */
  51125. getClassName(): string;
  51126. /**
  51127. * Add fallbacks to the effect fallbacks list.
  51128. * @param defines defines the Base texture to use.
  51129. * @param fallbacks defines the current fallback list.
  51130. * @param currentRank defines the current fallback rank.
  51131. * @returns the new fallback rank.
  51132. */
  51133. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51134. /**
  51135. * Add the required uniforms to the current list.
  51136. * @param uniforms defines the current uniform list.
  51137. */
  51138. static AddUniforms(uniforms: string[]): void;
  51139. /**
  51140. * Add the required uniforms to the current buffer.
  51141. * @param uniformBuffer defines the current uniform buffer.
  51142. */
  51143. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51144. /**
  51145. * Add the required samplers to the current list.
  51146. * @param samplers defines the current sampler list.
  51147. */
  51148. static AddSamplers(samplers: string[]): void;
  51149. /**
  51150. * Makes a duplicate of the current configuration into another one.
  51151. * @param sheenConfiguration define the config where to copy the info
  51152. */
  51153. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51154. /**
  51155. * Serializes this BRDF configuration.
  51156. * @returns - An object with the serialized config.
  51157. */
  51158. serialize(): any;
  51159. /**
  51160. * Parses a anisotropy Configuration from a serialized object.
  51161. * @param source - Serialized object.
  51162. * @param scene Defines the scene we are parsing for
  51163. * @param rootUrl Defines the rootUrl to load from
  51164. */
  51165. parse(source: any, scene: Scene, rootUrl: string): void;
  51166. }
  51167. }
  51168. declare module BABYLON {
  51169. /**
  51170. * @hidden
  51171. */
  51172. export interface IMaterialSubSurfaceDefines {
  51173. SUBSURFACE: boolean;
  51174. SS_REFRACTION: boolean;
  51175. SS_TRANSLUCENCY: boolean;
  51176. SS_SCATERRING: boolean;
  51177. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51178. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51179. SS_REFRACTIONMAP_3D: boolean;
  51180. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51181. SS_LODINREFRACTIONALPHA: boolean;
  51182. SS_GAMMAREFRACTION: boolean;
  51183. SS_RGBDREFRACTION: boolean;
  51184. SS_LINEARSPECULARREFRACTION: boolean;
  51185. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51186. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51187. /** @hidden */
  51188. _areTexturesDirty: boolean;
  51189. }
  51190. /**
  51191. * Define the code related to the sub surface parameters of the pbr material.
  51192. */
  51193. export class PBRSubSurfaceConfiguration {
  51194. private _isRefractionEnabled;
  51195. /**
  51196. * Defines if the refraction is enabled in the material.
  51197. */
  51198. isRefractionEnabled: boolean;
  51199. private _isTranslucencyEnabled;
  51200. /**
  51201. * Defines if the translucency is enabled in the material.
  51202. */
  51203. isTranslucencyEnabled: boolean;
  51204. private _isScatteringEnabled;
  51205. /**
  51206. * Defines the refraction intensity of the material.
  51207. * The refraction when enabled replaces the Diffuse part of the material.
  51208. * The intensity helps transitionning between diffuse and refraction.
  51209. */
  51210. refractionIntensity: number;
  51211. /**
  51212. * Defines the translucency intensity of the material.
  51213. * When translucency has been enabled, this defines how much of the "translucency"
  51214. * is addded to the diffuse part of the material.
  51215. */
  51216. translucencyIntensity: number;
  51217. /**
  51218. * Defines the scattering intensity of the material.
  51219. * When scattering has been enabled, this defines how much of the "scattered light"
  51220. * is addded to the diffuse part of the material.
  51221. */
  51222. scatteringIntensity: number;
  51223. private _thicknessTexture;
  51224. /**
  51225. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51226. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51227. * 0 would mean minimumThickness
  51228. * 1 would mean maximumThickness
  51229. * The other channels might be use as a mask to vary the different effects intensity.
  51230. */
  51231. thicknessTexture: Nullable<BaseTexture>;
  51232. private _refractionTexture;
  51233. /**
  51234. * Defines the texture to use for refraction.
  51235. */
  51236. refractionTexture: Nullable<BaseTexture>;
  51237. private _indexOfRefraction;
  51238. /**
  51239. * Defines the index of refraction used in the material.
  51240. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51241. */
  51242. indexOfRefraction: number;
  51243. private _invertRefractionY;
  51244. /**
  51245. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51246. */
  51247. invertRefractionY: boolean;
  51248. private _linkRefractionWithTransparency;
  51249. /**
  51250. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51251. * Materials half opaque for instance using refraction could benefit from this control.
  51252. */
  51253. linkRefractionWithTransparency: boolean;
  51254. /**
  51255. * Defines the minimum thickness stored in the thickness map.
  51256. * If no thickness map is defined, this value will be used to simulate thickness.
  51257. */
  51258. minimumThickness: number;
  51259. /**
  51260. * Defines the maximum thickness stored in the thickness map.
  51261. */
  51262. maximumThickness: number;
  51263. /**
  51264. * Defines the volume tint of the material.
  51265. * This is used for both translucency and scattering.
  51266. */
  51267. tintColor: Color3;
  51268. /**
  51269. * Defines the distance at which the tint color should be found in the media.
  51270. * This is used for refraction only.
  51271. */
  51272. tintColorAtDistance: number;
  51273. /**
  51274. * Defines how far each channel transmit through the media.
  51275. * It is defined as a color to simplify it selection.
  51276. */
  51277. diffusionDistance: Color3;
  51278. private _useMaskFromThicknessTexture;
  51279. /**
  51280. * Stores the intensity of the different subsurface effects in the thickness texture.
  51281. * * the green channel is the translucency intensity.
  51282. * * the blue channel is the scattering intensity.
  51283. * * the alpha channel is the refraction intensity.
  51284. */
  51285. useMaskFromThicknessTexture: boolean;
  51286. /** @hidden */
  51287. private _internalMarkAllSubMeshesAsTexturesDirty;
  51288. /** @hidden */
  51289. _markAllSubMeshesAsTexturesDirty(): void;
  51290. /**
  51291. * Instantiate a new istance of sub surface configuration.
  51292. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51293. */
  51294. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51295. /**
  51296. * Gets wehter the submesh is ready to be used or not.
  51297. * @param defines the list of "defines" to update.
  51298. * @param scene defines the scene the material belongs to.
  51299. * @returns - boolean indicating that the submesh is ready or not.
  51300. */
  51301. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51302. /**
  51303. * Checks to see if a texture is used in the material.
  51304. * @param defines the list of "defines" to update.
  51305. * @param scene defines the scene to the material belongs to.
  51306. */
  51307. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51308. /**
  51309. * Binds the material data.
  51310. * @param uniformBuffer defines the Uniform buffer to fill in.
  51311. * @param scene defines the scene the material belongs to.
  51312. * @param engine defines the engine the material belongs to.
  51313. * @param isFrozen defines wether the material is frozen or not.
  51314. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51315. */
  51316. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51317. /**
  51318. * Unbinds the material from the mesh.
  51319. * @param activeEffect defines the effect that should be unbound from.
  51320. * @returns true if unbound, otherwise false
  51321. */
  51322. unbind(activeEffect: Effect): boolean;
  51323. /**
  51324. * Returns the texture used for refraction or null if none is used.
  51325. * @param scene defines the scene the material belongs to.
  51326. * @returns - Refraction texture if present. If no refraction texture and refraction
  51327. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51328. */
  51329. private _getRefractionTexture;
  51330. /**
  51331. * Returns true if alpha blending should be disabled.
  51332. */
  51333. get disableAlphaBlending(): boolean;
  51334. /**
  51335. * Fills the list of render target textures.
  51336. * @param renderTargets the list of render targets to update
  51337. */
  51338. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51339. /**
  51340. * Checks to see if a texture is used in the material.
  51341. * @param texture - Base texture to use.
  51342. * @returns - Boolean specifying if a texture is used in the material.
  51343. */
  51344. hasTexture(texture: BaseTexture): boolean;
  51345. /**
  51346. * Gets a boolean indicating that current material needs to register RTT
  51347. * @returns true if this uses a render target otherwise false.
  51348. */
  51349. hasRenderTargetTextures(): boolean;
  51350. /**
  51351. * Returns an array of the actively used textures.
  51352. * @param activeTextures Array of BaseTextures
  51353. */
  51354. getActiveTextures(activeTextures: BaseTexture[]): void;
  51355. /**
  51356. * Returns the animatable textures.
  51357. * @param animatables Array of animatable textures.
  51358. */
  51359. getAnimatables(animatables: IAnimatable[]): void;
  51360. /**
  51361. * Disposes the resources of the material.
  51362. * @param forceDisposeTextures - Forces the disposal of all textures.
  51363. */
  51364. dispose(forceDisposeTextures?: boolean): void;
  51365. /**
  51366. * Get the current class name of the texture useful for serialization or dynamic coding.
  51367. * @returns "PBRSubSurfaceConfiguration"
  51368. */
  51369. getClassName(): string;
  51370. /**
  51371. * Add fallbacks to the effect fallbacks list.
  51372. * @param defines defines the Base texture to use.
  51373. * @param fallbacks defines the current fallback list.
  51374. * @param currentRank defines the current fallback rank.
  51375. * @returns the new fallback rank.
  51376. */
  51377. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51378. /**
  51379. * Add the required uniforms to the current list.
  51380. * @param uniforms defines the current uniform list.
  51381. */
  51382. static AddUniforms(uniforms: string[]): void;
  51383. /**
  51384. * Add the required samplers to the current list.
  51385. * @param samplers defines the current sampler list.
  51386. */
  51387. static AddSamplers(samplers: string[]): void;
  51388. /**
  51389. * Add the required uniforms to the current buffer.
  51390. * @param uniformBuffer defines the current uniform buffer.
  51391. */
  51392. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51393. /**
  51394. * Makes a duplicate of the current configuration into another one.
  51395. * @param configuration define the config where to copy the info
  51396. */
  51397. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51398. /**
  51399. * Serializes this Sub Surface configuration.
  51400. * @returns - An object with the serialized config.
  51401. */
  51402. serialize(): any;
  51403. /**
  51404. * Parses a anisotropy Configuration from a serialized object.
  51405. * @param source - Serialized object.
  51406. * @param scene Defines the scene we are parsing for
  51407. * @param rootUrl Defines the rootUrl to load from
  51408. */
  51409. parse(source: any, scene: Scene, rootUrl: string): void;
  51410. }
  51411. }
  51412. declare module BABYLON {
  51413. /** @hidden */
  51414. export var pbrFragmentDeclaration: {
  51415. name: string;
  51416. shader: string;
  51417. };
  51418. }
  51419. declare module BABYLON {
  51420. /** @hidden */
  51421. export var pbrUboDeclaration: {
  51422. name: string;
  51423. shader: string;
  51424. };
  51425. }
  51426. declare module BABYLON {
  51427. /** @hidden */
  51428. export var pbrFragmentExtraDeclaration: {
  51429. name: string;
  51430. shader: string;
  51431. };
  51432. }
  51433. declare module BABYLON {
  51434. /** @hidden */
  51435. export var pbrFragmentSamplersDeclaration: {
  51436. name: string;
  51437. shader: string;
  51438. };
  51439. }
  51440. declare module BABYLON {
  51441. /** @hidden */
  51442. export var pbrHelperFunctions: {
  51443. name: string;
  51444. shader: string;
  51445. };
  51446. }
  51447. declare module BABYLON {
  51448. /** @hidden */
  51449. export var harmonicsFunctions: {
  51450. name: string;
  51451. shader: string;
  51452. };
  51453. }
  51454. declare module BABYLON {
  51455. /** @hidden */
  51456. export var pbrDirectLightingSetupFunctions: {
  51457. name: string;
  51458. shader: string;
  51459. };
  51460. }
  51461. declare module BABYLON {
  51462. /** @hidden */
  51463. export var pbrDirectLightingFalloffFunctions: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module BABYLON {
  51469. /** @hidden */
  51470. export var pbrBRDFFunctions: {
  51471. name: string;
  51472. shader: string;
  51473. };
  51474. }
  51475. declare module BABYLON {
  51476. /** @hidden */
  51477. export var pbrDirectLightingFunctions: {
  51478. name: string;
  51479. shader: string;
  51480. };
  51481. }
  51482. declare module BABYLON {
  51483. /** @hidden */
  51484. export var pbrIBLFunctions: {
  51485. name: string;
  51486. shader: string;
  51487. };
  51488. }
  51489. declare module BABYLON {
  51490. /** @hidden */
  51491. export var pbrBlockAlbedoOpacity: {
  51492. name: string;
  51493. shader: string;
  51494. };
  51495. }
  51496. declare module BABYLON {
  51497. /** @hidden */
  51498. export var pbrBlockReflectivity: {
  51499. name: string;
  51500. shader: string;
  51501. };
  51502. }
  51503. declare module BABYLON {
  51504. /** @hidden */
  51505. export var pbrBlockAmbientOcclusion: {
  51506. name: string;
  51507. shader: string;
  51508. };
  51509. }
  51510. declare module BABYLON {
  51511. /** @hidden */
  51512. export var pbrBlockAlphaFresnel: {
  51513. name: string;
  51514. shader: string;
  51515. };
  51516. }
  51517. declare module BABYLON {
  51518. /** @hidden */
  51519. export var pbrBlockAnisotropic: {
  51520. name: string;
  51521. shader: string;
  51522. };
  51523. }
  51524. declare module BABYLON {
  51525. /** @hidden */
  51526. export var pbrBlockReflection: {
  51527. name: string;
  51528. shader: string;
  51529. };
  51530. }
  51531. declare module BABYLON {
  51532. /** @hidden */
  51533. export var pbrBlockSheen: {
  51534. name: string;
  51535. shader: string;
  51536. };
  51537. }
  51538. declare module BABYLON {
  51539. /** @hidden */
  51540. export var pbrBlockClearcoat: {
  51541. name: string;
  51542. shader: string;
  51543. };
  51544. }
  51545. declare module BABYLON {
  51546. /** @hidden */
  51547. export var pbrBlockSubSurface: {
  51548. name: string;
  51549. shader: string;
  51550. };
  51551. }
  51552. declare module BABYLON {
  51553. /** @hidden */
  51554. export var pbrBlockNormalGeometric: {
  51555. name: string;
  51556. shader: string;
  51557. };
  51558. }
  51559. declare module BABYLON {
  51560. /** @hidden */
  51561. export var pbrBlockNormalFinal: {
  51562. name: string;
  51563. shader: string;
  51564. };
  51565. }
  51566. declare module BABYLON {
  51567. /** @hidden */
  51568. export var pbrBlockGeometryInfo: {
  51569. name: string;
  51570. shader: string;
  51571. };
  51572. }
  51573. declare module BABYLON {
  51574. /** @hidden */
  51575. export var pbrBlockReflectance0: {
  51576. name: string;
  51577. shader: string;
  51578. };
  51579. }
  51580. declare module BABYLON {
  51581. /** @hidden */
  51582. export var pbrBlockReflectance: {
  51583. name: string;
  51584. shader: string;
  51585. };
  51586. }
  51587. declare module BABYLON {
  51588. /** @hidden */
  51589. export var pbrBlockDirectLighting: {
  51590. name: string;
  51591. shader: string;
  51592. };
  51593. }
  51594. declare module BABYLON {
  51595. /** @hidden */
  51596. export var pbrBlockFinalLitComponents: {
  51597. name: string;
  51598. shader: string;
  51599. };
  51600. }
  51601. declare module BABYLON {
  51602. /** @hidden */
  51603. export var pbrBlockFinalUnlitComponents: {
  51604. name: string;
  51605. shader: string;
  51606. };
  51607. }
  51608. declare module BABYLON {
  51609. /** @hidden */
  51610. export var pbrBlockFinalColorComposition: {
  51611. name: string;
  51612. shader: string;
  51613. };
  51614. }
  51615. declare module BABYLON {
  51616. /** @hidden */
  51617. export var pbrBlockImageProcessing: {
  51618. name: string;
  51619. shader: string;
  51620. };
  51621. }
  51622. declare module BABYLON {
  51623. /** @hidden */
  51624. export var pbrDebug: {
  51625. name: string;
  51626. shader: string;
  51627. };
  51628. }
  51629. declare module BABYLON {
  51630. /** @hidden */
  51631. export var pbrPixelShader: {
  51632. name: string;
  51633. shader: string;
  51634. };
  51635. }
  51636. declare module BABYLON {
  51637. /** @hidden */
  51638. export var pbrVertexDeclaration: {
  51639. name: string;
  51640. shader: string;
  51641. };
  51642. }
  51643. declare module BABYLON {
  51644. /** @hidden */
  51645. export var pbrVertexShader: {
  51646. name: string;
  51647. shader: string;
  51648. };
  51649. }
  51650. declare module BABYLON {
  51651. /**
  51652. * Manages the defines for the PBR Material.
  51653. * @hidden
  51654. */
  51655. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51656. PBR: boolean;
  51657. MAINUV1: boolean;
  51658. MAINUV2: boolean;
  51659. UV1: boolean;
  51660. UV2: boolean;
  51661. ALBEDO: boolean;
  51662. GAMMAALBEDO: boolean;
  51663. ALBEDODIRECTUV: number;
  51664. VERTEXCOLOR: boolean;
  51665. AMBIENT: boolean;
  51666. AMBIENTDIRECTUV: number;
  51667. AMBIENTINGRAYSCALE: boolean;
  51668. OPACITY: boolean;
  51669. VERTEXALPHA: boolean;
  51670. OPACITYDIRECTUV: number;
  51671. OPACITYRGB: boolean;
  51672. ALPHATEST: boolean;
  51673. DEPTHPREPASS: boolean;
  51674. ALPHABLEND: boolean;
  51675. ALPHAFROMALBEDO: boolean;
  51676. ALPHATESTVALUE: string;
  51677. SPECULAROVERALPHA: boolean;
  51678. RADIANCEOVERALPHA: boolean;
  51679. ALPHAFRESNEL: boolean;
  51680. LINEARALPHAFRESNEL: boolean;
  51681. PREMULTIPLYALPHA: boolean;
  51682. EMISSIVE: boolean;
  51683. EMISSIVEDIRECTUV: number;
  51684. REFLECTIVITY: boolean;
  51685. REFLECTIVITYDIRECTUV: number;
  51686. SPECULARTERM: boolean;
  51687. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51688. MICROSURFACEAUTOMATIC: boolean;
  51689. LODBASEDMICROSFURACE: boolean;
  51690. MICROSURFACEMAP: boolean;
  51691. MICROSURFACEMAPDIRECTUV: number;
  51692. METALLICWORKFLOW: boolean;
  51693. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51694. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51695. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51696. AOSTOREINMETALMAPRED: boolean;
  51697. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51698. ENVIRONMENTBRDF: boolean;
  51699. ENVIRONMENTBRDF_RGBD: boolean;
  51700. NORMAL: boolean;
  51701. TANGENT: boolean;
  51702. BUMP: boolean;
  51703. BUMPDIRECTUV: number;
  51704. OBJECTSPACE_NORMALMAP: boolean;
  51705. PARALLAX: boolean;
  51706. PARALLAXOCCLUSION: boolean;
  51707. NORMALXYSCALE: boolean;
  51708. LIGHTMAP: boolean;
  51709. LIGHTMAPDIRECTUV: number;
  51710. USELIGHTMAPASSHADOWMAP: boolean;
  51711. GAMMALIGHTMAP: boolean;
  51712. RGBDLIGHTMAP: boolean;
  51713. REFLECTION: boolean;
  51714. REFLECTIONMAP_3D: boolean;
  51715. REFLECTIONMAP_SPHERICAL: boolean;
  51716. REFLECTIONMAP_PLANAR: boolean;
  51717. REFLECTIONMAP_CUBIC: boolean;
  51718. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51719. REFLECTIONMAP_PROJECTION: boolean;
  51720. REFLECTIONMAP_SKYBOX: boolean;
  51721. REFLECTIONMAP_EXPLICIT: boolean;
  51722. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51723. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51724. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51725. INVERTCUBICMAP: boolean;
  51726. USESPHERICALFROMREFLECTIONMAP: boolean;
  51727. USEIRRADIANCEMAP: boolean;
  51728. SPHERICAL_HARMONICS: boolean;
  51729. USESPHERICALINVERTEX: boolean;
  51730. REFLECTIONMAP_OPPOSITEZ: boolean;
  51731. LODINREFLECTIONALPHA: boolean;
  51732. GAMMAREFLECTION: boolean;
  51733. RGBDREFLECTION: boolean;
  51734. LINEARSPECULARREFLECTION: boolean;
  51735. RADIANCEOCCLUSION: boolean;
  51736. HORIZONOCCLUSION: boolean;
  51737. INSTANCES: boolean;
  51738. NUM_BONE_INFLUENCERS: number;
  51739. BonesPerMesh: number;
  51740. BONETEXTURE: boolean;
  51741. NONUNIFORMSCALING: boolean;
  51742. MORPHTARGETS: boolean;
  51743. MORPHTARGETS_NORMAL: boolean;
  51744. MORPHTARGETS_TANGENT: boolean;
  51745. MORPHTARGETS_UV: boolean;
  51746. NUM_MORPH_INFLUENCERS: number;
  51747. IMAGEPROCESSING: boolean;
  51748. VIGNETTE: boolean;
  51749. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51750. VIGNETTEBLENDMODEOPAQUE: boolean;
  51751. TONEMAPPING: boolean;
  51752. TONEMAPPING_ACES: boolean;
  51753. CONTRAST: boolean;
  51754. COLORCURVES: boolean;
  51755. COLORGRADING: boolean;
  51756. COLORGRADING3D: boolean;
  51757. SAMPLER3DGREENDEPTH: boolean;
  51758. SAMPLER3DBGRMAP: boolean;
  51759. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51760. EXPOSURE: boolean;
  51761. MULTIVIEW: boolean;
  51762. USEPHYSICALLIGHTFALLOFF: boolean;
  51763. USEGLTFLIGHTFALLOFF: boolean;
  51764. TWOSIDEDLIGHTING: boolean;
  51765. SHADOWFLOAT: boolean;
  51766. CLIPPLANE: boolean;
  51767. CLIPPLANE2: boolean;
  51768. CLIPPLANE3: boolean;
  51769. CLIPPLANE4: boolean;
  51770. CLIPPLANE5: boolean;
  51771. CLIPPLANE6: boolean;
  51772. POINTSIZE: boolean;
  51773. FOG: boolean;
  51774. LOGARITHMICDEPTH: boolean;
  51775. FORCENORMALFORWARD: boolean;
  51776. SPECULARAA: boolean;
  51777. CLEARCOAT: boolean;
  51778. CLEARCOAT_DEFAULTIOR: boolean;
  51779. CLEARCOAT_TEXTURE: boolean;
  51780. CLEARCOAT_TEXTUREDIRECTUV: number;
  51781. CLEARCOAT_BUMP: boolean;
  51782. CLEARCOAT_BUMPDIRECTUV: number;
  51783. CLEARCOAT_TINT: boolean;
  51784. CLEARCOAT_TINT_TEXTURE: boolean;
  51785. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51786. ANISOTROPIC: boolean;
  51787. ANISOTROPIC_TEXTURE: boolean;
  51788. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51789. BRDF_V_HEIGHT_CORRELATED: boolean;
  51790. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51791. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51792. SHEEN: boolean;
  51793. SHEEN_TEXTURE: boolean;
  51794. SHEEN_TEXTUREDIRECTUV: number;
  51795. SHEEN_LINKWITHALBEDO: boolean;
  51796. SHEEN_ROUGHNESS: boolean;
  51797. SHEEN_ALBEDOSCALING: boolean;
  51798. SUBSURFACE: boolean;
  51799. SS_REFRACTION: boolean;
  51800. SS_TRANSLUCENCY: boolean;
  51801. SS_SCATERRING: boolean;
  51802. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51803. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51804. SS_REFRACTIONMAP_3D: boolean;
  51805. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51806. SS_LODINREFRACTIONALPHA: boolean;
  51807. SS_GAMMAREFRACTION: boolean;
  51808. SS_RGBDREFRACTION: boolean;
  51809. SS_LINEARSPECULARREFRACTION: boolean;
  51810. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51811. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51812. UNLIT: boolean;
  51813. DEBUGMODE: number;
  51814. /**
  51815. * Initializes the PBR Material defines.
  51816. */
  51817. constructor();
  51818. /**
  51819. * Resets the PBR Material defines.
  51820. */
  51821. reset(): void;
  51822. }
  51823. /**
  51824. * The Physically based material base class of BJS.
  51825. *
  51826. * This offers the main features of a standard PBR material.
  51827. * For more information, please refer to the documentation :
  51828. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51829. */
  51830. export abstract class PBRBaseMaterial extends PushMaterial {
  51831. /**
  51832. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51833. */
  51834. static readonly PBRMATERIAL_OPAQUE: number;
  51835. /**
  51836. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51837. */
  51838. static readonly PBRMATERIAL_ALPHATEST: number;
  51839. /**
  51840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51841. */
  51842. static readonly PBRMATERIAL_ALPHABLEND: number;
  51843. /**
  51844. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51845. * They are also discarded below the alpha cutoff threshold to improve performances.
  51846. */
  51847. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51848. /**
  51849. * Defines the default value of how much AO map is occluding the analytical lights
  51850. * (point spot...).
  51851. */
  51852. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51853. /**
  51854. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51855. */
  51856. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51857. /**
  51858. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51859. * to enhance interoperability with other engines.
  51860. */
  51861. static readonly LIGHTFALLOFF_GLTF: number;
  51862. /**
  51863. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51864. * to enhance interoperability with other materials.
  51865. */
  51866. static readonly LIGHTFALLOFF_STANDARD: number;
  51867. /**
  51868. * Intensity of the direct lights e.g. the four lights available in your scene.
  51869. * This impacts both the direct diffuse and specular highlights.
  51870. */
  51871. protected _directIntensity: number;
  51872. /**
  51873. * Intensity of the emissive part of the material.
  51874. * This helps controlling the emissive effect without modifying the emissive color.
  51875. */
  51876. protected _emissiveIntensity: number;
  51877. /**
  51878. * Intensity of the environment e.g. how much the environment will light the object
  51879. * either through harmonics for rough material or through the refelction for shiny ones.
  51880. */
  51881. protected _environmentIntensity: number;
  51882. /**
  51883. * This is a special control allowing the reduction of the specular highlights coming from the
  51884. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51885. */
  51886. protected _specularIntensity: number;
  51887. /**
  51888. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51889. */
  51890. private _lightingInfos;
  51891. /**
  51892. * Debug Control allowing disabling the bump map on this material.
  51893. */
  51894. protected _disableBumpMap: boolean;
  51895. /**
  51896. * AKA Diffuse Texture in standard nomenclature.
  51897. */
  51898. protected _albedoTexture: Nullable<BaseTexture>;
  51899. /**
  51900. * AKA Occlusion Texture in other nomenclature.
  51901. */
  51902. protected _ambientTexture: Nullable<BaseTexture>;
  51903. /**
  51904. * AKA Occlusion Texture Intensity in other nomenclature.
  51905. */
  51906. protected _ambientTextureStrength: number;
  51907. /**
  51908. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51909. * 1 means it completely occludes it
  51910. * 0 mean it has no impact
  51911. */
  51912. protected _ambientTextureImpactOnAnalyticalLights: number;
  51913. /**
  51914. * Stores the alpha values in a texture.
  51915. */
  51916. protected _opacityTexture: Nullable<BaseTexture>;
  51917. /**
  51918. * Stores the reflection values in a texture.
  51919. */
  51920. protected _reflectionTexture: Nullable<BaseTexture>;
  51921. /**
  51922. * Stores the emissive values in a texture.
  51923. */
  51924. protected _emissiveTexture: Nullable<BaseTexture>;
  51925. /**
  51926. * AKA Specular texture in other nomenclature.
  51927. */
  51928. protected _reflectivityTexture: Nullable<BaseTexture>;
  51929. /**
  51930. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51931. */
  51932. protected _metallicTexture: Nullable<BaseTexture>;
  51933. /**
  51934. * Specifies the metallic scalar of the metallic/roughness workflow.
  51935. * Can also be used to scale the metalness values of the metallic texture.
  51936. */
  51937. protected _metallic: Nullable<number>;
  51938. /**
  51939. * Specifies the roughness scalar of the metallic/roughness workflow.
  51940. * Can also be used to scale the roughness values of the metallic texture.
  51941. */
  51942. protected _roughness: Nullable<number>;
  51943. /**
  51944. * Specifies the an F0 factor to help configuring the material F0.
  51945. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51946. * to 0.5 the previously hard coded value stays the same.
  51947. * Can also be used to scale the F0 values of the metallic texture.
  51948. */
  51949. protected _metallicF0Factor: number;
  51950. /**
  51951. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51952. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51953. * your expectation as it multiplies with the texture data.
  51954. */
  51955. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51956. /**
  51957. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51958. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51959. */
  51960. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51961. /**
  51962. * Stores surface normal data used to displace a mesh in a texture.
  51963. */
  51964. protected _bumpTexture: Nullable<BaseTexture>;
  51965. /**
  51966. * Stores the pre-calculated light information of a mesh in a texture.
  51967. */
  51968. protected _lightmapTexture: Nullable<BaseTexture>;
  51969. /**
  51970. * The color of a material in ambient lighting.
  51971. */
  51972. protected _ambientColor: Color3;
  51973. /**
  51974. * AKA Diffuse Color in other nomenclature.
  51975. */
  51976. protected _albedoColor: Color3;
  51977. /**
  51978. * AKA Specular Color in other nomenclature.
  51979. */
  51980. protected _reflectivityColor: Color3;
  51981. /**
  51982. * The color applied when light is reflected from a material.
  51983. */
  51984. protected _reflectionColor: Color3;
  51985. /**
  51986. * The color applied when light is emitted from a material.
  51987. */
  51988. protected _emissiveColor: Color3;
  51989. /**
  51990. * AKA Glossiness in other nomenclature.
  51991. */
  51992. protected _microSurface: number;
  51993. /**
  51994. * Specifies that the material will use the light map as a show map.
  51995. */
  51996. protected _useLightmapAsShadowmap: boolean;
  51997. /**
  51998. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51999. * makes the reflect vector face the model (under horizon).
  52000. */
  52001. protected _useHorizonOcclusion: boolean;
  52002. /**
  52003. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52004. * too much the area relying on ambient texture to define their ambient occlusion.
  52005. */
  52006. protected _useRadianceOcclusion: boolean;
  52007. /**
  52008. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52009. */
  52010. protected _useAlphaFromAlbedoTexture: boolean;
  52011. /**
  52012. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52013. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52014. */
  52015. protected _useSpecularOverAlpha: boolean;
  52016. /**
  52017. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52018. */
  52019. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52020. /**
  52021. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52022. */
  52023. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52024. /**
  52025. * Specifies if the metallic texture contains the roughness information in its green channel.
  52026. */
  52027. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52028. /**
  52029. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52030. */
  52031. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52032. /**
  52033. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52034. */
  52035. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52036. /**
  52037. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52038. */
  52039. protected _useAmbientInGrayScale: boolean;
  52040. /**
  52041. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52042. * The material will try to infer what glossiness each pixel should be.
  52043. */
  52044. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52045. /**
  52046. * Defines the falloff type used in this material.
  52047. * It by default is Physical.
  52048. */
  52049. protected _lightFalloff: number;
  52050. /**
  52051. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52052. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52053. */
  52054. protected _useRadianceOverAlpha: boolean;
  52055. /**
  52056. * Allows using an object space normal map (instead of tangent space).
  52057. */
  52058. protected _useObjectSpaceNormalMap: boolean;
  52059. /**
  52060. * Allows using the bump map in parallax mode.
  52061. */
  52062. protected _useParallax: boolean;
  52063. /**
  52064. * Allows using the bump map in parallax occlusion mode.
  52065. */
  52066. protected _useParallaxOcclusion: boolean;
  52067. /**
  52068. * Controls the scale bias of the parallax mode.
  52069. */
  52070. protected _parallaxScaleBias: number;
  52071. /**
  52072. * If sets to true, disables all the lights affecting the material.
  52073. */
  52074. protected _disableLighting: boolean;
  52075. /**
  52076. * Number of Simultaneous lights allowed on the material.
  52077. */
  52078. protected _maxSimultaneousLights: number;
  52079. /**
  52080. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52081. */
  52082. protected _invertNormalMapX: boolean;
  52083. /**
  52084. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52085. */
  52086. protected _invertNormalMapY: boolean;
  52087. /**
  52088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52089. */
  52090. protected _twoSidedLighting: boolean;
  52091. /**
  52092. * Defines the alpha limits in alpha test mode.
  52093. */
  52094. protected _alphaCutOff: number;
  52095. /**
  52096. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52097. */
  52098. protected _forceAlphaTest: boolean;
  52099. /**
  52100. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52101. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52102. */
  52103. protected _useAlphaFresnel: boolean;
  52104. /**
  52105. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52106. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52107. */
  52108. protected _useLinearAlphaFresnel: boolean;
  52109. /**
  52110. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52111. * from cos thetav and roughness:
  52112. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52113. */
  52114. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52115. /**
  52116. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52117. */
  52118. protected _forceIrradianceInFragment: boolean;
  52119. /**
  52120. * Force normal to face away from face.
  52121. */
  52122. protected _forceNormalForward: boolean;
  52123. /**
  52124. * Enables specular anti aliasing in the PBR shader.
  52125. * It will both interacts on the Geometry for analytical and IBL lighting.
  52126. * It also prefilter the roughness map based on the bump values.
  52127. */
  52128. protected _enableSpecularAntiAliasing: boolean;
  52129. /**
  52130. * Default configuration related to image processing available in the PBR Material.
  52131. */
  52132. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52133. /**
  52134. * Keep track of the image processing observer to allow dispose and replace.
  52135. */
  52136. private _imageProcessingObserver;
  52137. /**
  52138. * Attaches a new image processing configuration to the PBR Material.
  52139. * @param configuration
  52140. */
  52141. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52142. /**
  52143. * Stores the available render targets.
  52144. */
  52145. private _renderTargets;
  52146. /**
  52147. * Sets the global ambient color for the material used in lighting calculations.
  52148. */
  52149. private _globalAmbientColor;
  52150. /**
  52151. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52152. */
  52153. private _useLogarithmicDepth;
  52154. /**
  52155. * If set to true, no lighting calculations will be applied.
  52156. */
  52157. private _unlit;
  52158. private _debugMode;
  52159. /**
  52160. * @hidden
  52161. * This is reserved for the inspector.
  52162. * Defines the material debug mode.
  52163. * It helps seeing only some components of the material while troubleshooting.
  52164. */
  52165. debugMode: number;
  52166. /**
  52167. * @hidden
  52168. * This is reserved for the inspector.
  52169. * Specify from where on screen the debug mode should start.
  52170. * The value goes from -1 (full screen) to 1 (not visible)
  52171. * It helps with side by side comparison against the final render
  52172. * This defaults to -1
  52173. */
  52174. private debugLimit;
  52175. /**
  52176. * @hidden
  52177. * This is reserved for the inspector.
  52178. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52179. * You can use the factor to better multiply the final value.
  52180. */
  52181. private debugFactor;
  52182. /**
  52183. * Defines the clear coat layer parameters for the material.
  52184. */
  52185. readonly clearCoat: PBRClearCoatConfiguration;
  52186. /**
  52187. * Defines the anisotropic parameters for the material.
  52188. */
  52189. readonly anisotropy: PBRAnisotropicConfiguration;
  52190. /**
  52191. * Defines the BRDF parameters for the material.
  52192. */
  52193. readonly brdf: PBRBRDFConfiguration;
  52194. /**
  52195. * Defines the Sheen parameters for the material.
  52196. */
  52197. readonly sheen: PBRSheenConfiguration;
  52198. /**
  52199. * Defines the SubSurface parameters for the material.
  52200. */
  52201. readonly subSurface: PBRSubSurfaceConfiguration;
  52202. protected _rebuildInParallel: boolean;
  52203. /**
  52204. * Instantiates a new PBRMaterial instance.
  52205. *
  52206. * @param name The material name
  52207. * @param scene The scene the material will be use in.
  52208. */
  52209. constructor(name: string, scene: Scene);
  52210. /**
  52211. * Gets a boolean indicating that current material needs to register RTT
  52212. */
  52213. get hasRenderTargetTextures(): boolean;
  52214. /**
  52215. * Gets the name of the material class.
  52216. */
  52217. getClassName(): string;
  52218. /**
  52219. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52220. */
  52221. get useLogarithmicDepth(): boolean;
  52222. /**
  52223. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52224. */
  52225. set useLogarithmicDepth(value: boolean);
  52226. /**
  52227. * Returns true if alpha blending should be disabled.
  52228. */
  52229. protected get _disableAlphaBlending(): boolean;
  52230. /**
  52231. * Specifies whether or not this material should be rendered in alpha blend mode.
  52232. */
  52233. needAlphaBlending(): boolean;
  52234. /**
  52235. * Specifies whether or not this material should be rendered in alpha test mode.
  52236. */
  52237. needAlphaTesting(): boolean;
  52238. /**
  52239. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52240. */
  52241. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52242. /**
  52243. * Gets the texture used for the alpha test.
  52244. */
  52245. getAlphaTestTexture(): Nullable<BaseTexture>;
  52246. /**
  52247. * Specifies that the submesh is ready to be used.
  52248. * @param mesh - BJS mesh.
  52249. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52250. * @param useInstances - Specifies that instances should be used.
  52251. * @returns - boolean indicating that the submesh is ready or not.
  52252. */
  52253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52254. /**
  52255. * Specifies if the material uses metallic roughness workflow.
  52256. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52257. */
  52258. isMetallicWorkflow(): boolean;
  52259. private _prepareEffect;
  52260. private _prepareDefines;
  52261. /**
  52262. * Force shader compilation
  52263. */
  52264. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52265. /**
  52266. * Initializes the uniform buffer layout for the shader.
  52267. */
  52268. buildUniformLayout(): void;
  52269. /**
  52270. * Unbinds the material from the mesh
  52271. */
  52272. unbind(): void;
  52273. /**
  52274. * Binds the submesh data.
  52275. * @param world - The world matrix.
  52276. * @param mesh - The BJS mesh.
  52277. * @param subMesh - A submesh of the BJS mesh.
  52278. */
  52279. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52280. /**
  52281. * Returns the animatable textures.
  52282. * @returns - Array of animatable textures.
  52283. */
  52284. getAnimatables(): IAnimatable[];
  52285. /**
  52286. * Returns the texture used for reflections.
  52287. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52288. */
  52289. private _getReflectionTexture;
  52290. /**
  52291. * Returns an array of the actively used textures.
  52292. * @returns - Array of BaseTextures
  52293. */
  52294. getActiveTextures(): BaseTexture[];
  52295. /**
  52296. * Checks to see if a texture is used in the material.
  52297. * @param texture - Base texture to use.
  52298. * @returns - Boolean specifying if a texture is used in the material.
  52299. */
  52300. hasTexture(texture: BaseTexture): boolean;
  52301. /**
  52302. * Disposes the resources of the material.
  52303. * @param forceDisposeEffect - Forces the disposal of effects.
  52304. * @param forceDisposeTextures - Forces the disposal of all textures.
  52305. */
  52306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52307. }
  52308. }
  52309. declare module BABYLON {
  52310. /**
  52311. * The Physically based material of BJS.
  52312. *
  52313. * This offers the main features of a standard PBR material.
  52314. * For more information, please refer to the documentation :
  52315. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52316. */
  52317. export class PBRMaterial extends PBRBaseMaterial {
  52318. /**
  52319. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52320. */
  52321. static readonly PBRMATERIAL_OPAQUE: number;
  52322. /**
  52323. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52324. */
  52325. static readonly PBRMATERIAL_ALPHATEST: number;
  52326. /**
  52327. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52328. */
  52329. static readonly PBRMATERIAL_ALPHABLEND: number;
  52330. /**
  52331. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52332. * They are also discarded below the alpha cutoff threshold to improve performances.
  52333. */
  52334. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52335. /**
  52336. * Defines the default value of how much AO map is occluding the analytical lights
  52337. * (point spot...).
  52338. */
  52339. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52340. /**
  52341. * Intensity of the direct lights e.g. the four lights available in your scene.
  52342. * This impacts both the direct diffuse and specular highlights.
  52343. */
  52344. directIntensity: number;
  52345. /**
  52346. * Intensity of the emissive part of the material.
  52347. * This helps controlling the emissive effect without modifying the emissive color.
  52348. */
  52349. emissiveIntensity: number;
  52350. /**
  52351. * Intensity of the environment e.g. how much the environment will light the object
  52352. * either through harmonics for rough material or through the refelction for shiny ones.
  52353. */
  52354. environmentIntensity: number;
  52355. /**
  52356. * This is a special control allowing the reduction of the specular highlights coming from the
  52357. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52358. */
  52359. specularIntensity: number;
  52360. /**
  52361. * Debug Control allowing disabling the bump map on this material.
  52362. */
  52363. disableBumpMap: boolean;
  52364. /**
  52365. * AKA Diffuse Texture in standard nomenclature.
  52366. */
  52367. albedoTexture: BaseTexture;
  52368. /**
  52369. * AKA Occlusion Texture in other nomenclature.
  52370. */
  52371. ambientTexture: BaseTexture;
  52372. /**
  52373. * AKA Occlusion Texture Intensity in other nomenclature.
  52374. */
  52375. ambientTextureStrength: number;
  52376. /**
  52377. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52378. * 1 means it completely occludes it
  52379. * 0 mean it has no impact
  52380. */
  52381. ambientTextureImpactOnAnalyticalLights: number;
  52382. /**
  52383. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52384. */
  52385. opacityTexture: BaseTexture;
  52386. /**
  52387. * Stores the reflection values in a texture.
  52388. */
  52389. reflectionTexture: Nullable<BaseTexture>;
  52390. /**
  52391. * Stores the emissive values in a texture.
  52392. */
  52393. emissiveTexture: BaseTexture;
  52394. /**
  52395. * AKA Specular texture in other nomenclature.
  52396. */
  52397. reflectivityTexture: BaseTexture;
  52398. /**
  52399. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52400. */
  52401. metallicTexture: BaseTexture;
  52402. /**
  52403. * Specifies the metallic scalar of the metallic/roughness workflow.
  52404. * Can also be used to scale the metalness values of the metallic texture.
  52405. */
  52406. metallic: Nullable<number>;
  52407. /**
  52408. * Specifies the roughness scalar of the metallic/roughness workflow.
  52409. * Can also be used to scale the roughness values of the metallic texture.
  52410. */
  52411. roughness: Nullable<number>;
  52412. /**
  52413. * Specifies the an F0 factor to help configuring the material F0.
  52414. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52415. * to 0.5 the previously hard coded value stays the same.
  52416. * Can also be used to scale the F0 values of the metallic texture.
  52417. */
  52418. metallicF0Factor: number;
  52419. /**
  52420. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52421. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52422. * your expectation as it multiplies with the texture data.
  52423. */
  52424. useMetallicF0FactorFromMetallicTexture: boolean;
  52425. /**
  52426. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52427. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52428. */
  52429. microSurfaceTexture: BaseTexture;
  52430. /**
  52431. * Stores surface normal data used to displace a mesh in a texture.
  52432. */
  52433. bumpTexture: BaseTexture;
  52434. /**
  52435. * Stores the pre-calculated light information of a mesh in a texture.
  52436. */
  52437. lightmapTexture: BaseTexture;
  52438. /**
  52439. * Stores the refracted light information in a texture.
  52440. */
  52441. get refractionTexture(): Nullable<BaseTexture>;
  52442. set refractionTexture(value: Nullable<BaseTexture>);
  52443. /**
  52444. * The color of a material in ambient lighting.
  52445. */
  52446. ambientColor: Color3;
  52447. /**
  52448. * AKA Diffuse Color in other nomenclature.
  52449. */
  52450. albedoColor: Color3;
  52451. /**
  52452. * AKA Specular Color in other nomenclature.
  52453. */
  52454. reflectivityColor: Color3;
  52455. /**
  52456. * The color reflected from the material.
  52457. */
  52458. reflectionColor: Color3;
  52459. /**
  52460. * The color emitted from the material.
  52461. */
  52462. emissiveColor: Color3;
  52463. /**
  52464. * AKA Glossiness in other nomenclature.
  52465. */
  52466. microSurface: number;
  52467. /**
  52468. * source material index of refraction (IOR)' / 'destination material IOR.
  52469. */
  52470. get indexOfRefraction(): number;
  52471. set indexOfRefraction(value: number);
  52472. /**
  52473. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52474. */
  52475. get invertRefractionY(): boolean;
  52476. set invertRefractionY(value: boolean);
  52477. /**
  52478. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52479. * Materials half opaque for instance using refraction could benefit from this control.
  52480. */
  52481. get linkRefractionWithTransparency(): boolean;
  52482. set linkRefractionWithTransparency(value: boolean);
  52483. /**
  52484. * If true, the light map contains occlusion information instead of lighting info.
  52485. */
  52486. useLightmapAsShadowmap: boolean;
  52487. /**
  52488. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52489. */
  52490. useAlphaFromAlbedoTexture: boolean;
  52491. /**
  52492. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52493. */
  52494. forceAlphaTest: boolean;
  52495. /**
  52496. * Defines the alpha limits in alpha test mode.
  52497. */
  52498. alphaCutOff: number;
  52499. /**
  52500. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52501. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52502. */
  52503. useSpecularOverAlpha: boolean;
  52504. /**
  52505. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52506. */
  52507. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52508. /**
  52509. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52510. */
  52511. useRoughnessFromMetallicTextureAlpha: boolean;
  52512. /**
  52513. * Specifies if the metallic texture contains the roughness information in its green channel.
  52514. */
  52515. useRoughnessFromMetallicTextureGreen: boolean;
  52516. /**
  52517. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52518. */
  52519. useMetallnessFromMetallicTextureBlue: boolean;
  52520. /**
  52521. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52522. */
  52523. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52524. /**
  52525. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52526. */
  52527. useAmbientInGrayScale: boolean;
  52528. /**
  52529. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52530. * The material will try to infer what glossiness each pixel should be.
  52531. */
  52532. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52533. /**
  52534. * BJS is using an harcoded light falloff based on a manually sets up range.
  52535. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52536. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52537. */
  52538. get usePhysicalLightFalloff(): boolean;
  52539. /**
  52540. * BJS is using an harcoded light falloff based on a manually sets up range.
  52541. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52542. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52543. */
  52544. set usePhysicalLightFalloff(value: boolean);
  52545. /**
  52546. * In order to support the falloff compatibility with gltf, a special mode has been added
  52547. * to reproduce the gltf light falloff.
  52548. */
  52549. get useGLTFLightFalloff(): boolean;
  52550. /**
  52551. * In order to support the falloff compatibility with gltf, a special mode has been added
  52552. * to reproduce the gltf light falloff.
  52553. */
  52554. set useGLTFLightFalloff(value: boolean);
  52555. /**
  52556. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52557. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52558. */
  52559. useRadianceOverAlpha: boolean;
  52560. /**
  52561. * Allows using an object space normal map (instead of tangent space).
  52562. */
  52563. useObjectSpaceNormalMap: boolean;
  52564. /**
  52565. * Allows using the bump map in parallax mode.
  52566. */
  52567. useParallax: boolean;
  52568. /**
  52569. * Allows using the bump map in parallax occlusion mode.
  52570. */
  52571. useParallaxOcclusion: boolean;
  52572. /**
  52573. * Controls the scale bias of the parallax mode.
  52574. */
  52575. parallaxScaleBias: number;
  52576. /**
  52577. * If sets to true, disables all the lights affecting the material.
  52578. */
  52579. disableLighting: boolean;
  52580. /**
  52581. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52582. */
  52583. forceIrradianceInFragment: boolean;
  52584. /**
  52585. * Number of Simultaneous lights allowed on the material.
  52586. */
  52587. maxSimultaneousLights: number;
  52588. /**
  52589. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52590. */
  52591. invertNormalMapX: boolean;
  52592. /**
  52593. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52594. */
  52595. invertNormalMapY: boolean;
  52596. /**
  52597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52598. */
  52599. twoSidedLighting: boolean;
  52600. /**
  52601. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52602. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52603. */
  52604. useAlphaFresnel: boolean;
  52605. /**
  52606. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52607. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52608. */
  52609. useLinearAlphaFresnel: boolean;
  52610. /**
  52611. * Let user defines the brdf lookup texture used for IBL.
  52612. * A default 8bit version is embedded but you could point at :
  52613. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52614. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52615. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52616. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52617. */
  52618. environmentBRDFTexture: Nullable<BaseTexture>;
  52619. /**
  52620. * Force normal to face away from face.
  52621. */
  52622. forceNormalForward: boolean;
  52623. /**
  52624. * Enables specular anti aliasing in the PBR shader.
  52625. * It will both interacts on the Geometry for analytical and IBL lighting.
  52626. * It also prefilter the roughness map based on the bump values.
  52627. */
  52628. enableSpecularAntiAliasing: boolean;
  52629. /**
  52630. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52631. * makes the reflect vector face the model (under horizon).
  52632. */
  52633. useHorizonOcclusion: boolean;
  52634. /**
  52635. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52636. * too much the area relying on ambient texture to define their ambient occlusion.
  52637. */
  52638. useRadianceOcclusion: boolean;
  52639. /**
  52640. * If set to true, no lighting calculations will be applied.
  52641. */
  52642. unlit: boolean;
  52643. /**
  52644. * Gets the image processing configuration used either in this material.
  52645. */
  52646. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52647. /**
  52648. * Sets the Default image processing configuration used either in the this material.
  52649. *
  52650. * If sets to null, the scene one is in use.
  52651. */
  52652. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52653. /**
  52654. * Gets wether the color curves effect is enabled.
  52655. */
  52656. get cameraColorCurvesEnabled(): boolean;
  52657. /**
  52658. * Sets wether the color curves effect is enabled.
  52659. */
  52660. set cameraColorCurvesEnabled(value: boolean);
  52661. /**
  52662. * Gets wether the color grading effect is enabled.
  52663. */
  52664. get cameraColorGradingEnabled(): boolean;
  52665. /**
  52666. * Gets wether the color grading effect is enabled.
  52667. */
  52668. set cameraColorGradingEnabled(value: boolean);
  52669. /**
  52670. * Gets wether tonemapping is enabled or not.
  52671. */
  52672. get cameraToneMappingEnabled(): boolean;
  52673. /**
  52674. * Sets wether tonemapping is enabled or not
  52675. */
  52676. set cameraToneMappingEnabled(value: boolean);
  52677. /**
  52678. * The camera exposure used on this material.
  52679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52680. * This corresponds to a photographic exposure.
  52681. */
  52682. get cameraExposure(): number;
  52683. /**
  52684. * The camera exposure used on this material.
  52685. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52686. * This corresponds to a photographic exposure.
  52687. */
  52688. set cameraExposure(value: number);
  52689. /**
  52690. * Gets The camera contrast used on this material.
  52691. */
  52692. get cameraContrast(): number;
  52693. /**
  52694. * Sets The camera contrast used on this material.
  52695. */
  52696. set cameraContrast(value: number);
  52697. /**
  52698. * Gets the Color Grading 2D Lookup Texture.
  52699. */
  52700. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52701. /**
  52702. * Sets the Color Grading 2D Lookup Texture.
  52703. */
  52704. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52705. /**
  52706. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52707. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52708. * 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;
  52709. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52710. */
  52711. get cameraColorCurves(): Nullable<ColorCurves>;
  52712. /**
  52713. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52714. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52715. * 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;
  52716. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52717. */
  52718. set cameraColorCurves(value: Nullable<ColorCurves>);
  52719. /**
  52720. * Instantiates a new PBRMaterial instance.
  52721. *
  52722. * @param name The material name
  52723. * @param scene The scene the material will be use in.
  52724. */
  52725. constructor(name: string, scene: Scene);
  52726. /**
  52727. * Returns the name of this material class.
  52728. */
  52729. getClassName(): string;
  52730. /**
  52731. * Makes a duplicate of the current material.
  52732. * @param name - name to use for the new material.
  52733. */
  52734. clone(name: string): PBRMaterial;
  52735. /**
  52736. * Serializes this PBR Material.
  52737. * @returns - An object with the serialized material.
  52738. */
  52739. serialize(): any;
  52740. /**
  52741. * Parses a PBR Material from a serialized object.
  52742. * @param source - Serialized object.
  52743. * @param scene - BJS scene instance.
  52744. * @param rootUrl - url for the scene object
  52745. * @returns - PBRMaterial
  52746. */
  52747. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52748. }
  52749. }
  52750. declare module BABYLON {
  52751. /**
  52752. * Direct draw surface info
  52753. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52754. */
  52755. export interface DDSInfo {
  52756. /**
  52757. * Width of the texture
  52758. */
  52759. width: number;
  52760. /**
  52761. * Width of the texture
  52762. */
  52763. height: number;
  52764. /**
  52765. * Number of Mipmaps for the texture
  52766. * @see https://en.wikipedia.org/wiki/Mipmap
  52767. */
  52768. mipmapCount: number;
  52769. /**
  52770. * If the textures format is a known fourCC format
  52771. * @see https://www.fourcc.org/
  52772. */
  52773. isFourCC: boolean;
  52774. /**
  52775. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52776. */
  52777. isRGB: boolean;
  52778. /**
  52779. * If the texture is a lumincance format
  52780. */
  52781. isLuminance: boolean;
  52782. /**
  52783. * If this is a cube texture
  52784. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52785. */
  52786. isCube: boolean;
  52787. /**
  52788. * If the texture is a compressed format eg. FOURCC_DXT1
  52789. */
  52790. isCompressed: boolean;
  52791. /**
  52792. * The dxgiFormat of the texture
  52793. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52794. */
  52795. dxgiFormat: number;
  52796. /**
  52797. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52798. */
  52799. textureType: number;
  52800. /**
  52801. * Sphericle polynomial created for the dds texture
  52802. */
  52803. sphericalPolynomial?: SphericalPolynomial;
  52804. }
  52805. /**
  52806. * Class used to provide DDS decompression tools
  52807. */
  52808. export class DDSTools {
  52809. /**
  52810. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52811. */
  52812. static StoreLODInAlphaChannel: boolean;
  52813. /**
  52814. * Gets DDS information from an array buffer
  52815. * @param data defines the array buffer view to read data from
  52816. * @returns the DDS information
  52817. */
  52818. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52819. private static _FloatView;
  52820. private static _Int32View;
  52821. private static _ToHalfFloat;
  52822. private static _FromHalfFloat;
  52823. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52824. private static _GetHalfFloatRGBAArrayBuffer;
  52825. private static _GetFloatRGBAArrayBuffer;
  52826. private static _GetFloatAsUIntRGBAArrayBuffer;
  52827. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52828. private static _GetRGBAArrayBuffer;
  52829. private static _ExtractLongWordOrder;
  52830. private static _GetRGBArrayBuffer;
  52831. private static _GetLuminanceArrayBuffer;
  52832. /**
  52833. * Uploads DDS Levels to a Babylon Texture
  52834. * @hidden
  52835. */
  52836. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52837. }
  52838. interface ThinEngine {
  52839. /**
  52840. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52841. * @param rootUrl defines the url where the file to load is located
  52842. * @param scene defines the current scene
  52843. * @param lodScale defines scale to apply to the mip map selection
  52844. * @param lodOffset defines offset to apply to the mip map selection
  52845. * @param onLoad defines an optional callback raised when the texture is loaded
  52846. * @param onError defines an optional callback raised if there is an issue to load the texture
  52847. * @param format defines the format of the data
  52848. * @param forcedExtension defines the extension to use to pick the right loader
  52849. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52850. * @returns the cube texture as an InternalTexture
  52851. */
  52852. 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;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. /**
  52857. * Implementation of the DDS Texture Loader.
  52858. * @hidden
  52859. */
  52860. export class _DDSTextureLoader implements IInternalTextureLoader {
  52861. /**
  52862. * Defines wether the loader supports cascade loading the different faces.
  52863. */
  52864. readonly supportCascades: boolean;
  52865. /**
  52866. * This returns if the loader support the current file information.
  52867. * @param extension defines the file extension of the file being loaded
  52868. * @returns true if the loader can load the specified file
  52869. */
  52870. canLoad(extension: string): boolean;
  52871. /**
  52872. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52873. * @param data contains the texture data
  52874. * @param texture defines the BabylonJS internal texture
  52875. * @param createPolynomials will be true if polynomials have been requested
  52876. * @param onLoad defines the callback to trigger once the texture is ready
  52877. * @param onError defines the callback to trigger in case of error
  52878. */
  52879. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52880. /**
  52881. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52882. * @param data contains the texture data
  52883. * @param texture defines the BabylonJS internal texture
  52884. * @param callback defines the method to call once ready to upload
  52885. */
  52886. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52887. }
  52888. }
  52889. declare module BABYLON {
  52890. /**
  52891. * Implementation of the ENV Texture Loader.
  52892. * @hidden
  52893. */
  52894. export class _ENVTextureLoader implements IInternalTextureLoader {
  52895. /**
  52896. * Defines wether the loader supports cascade loading the different faces.
  52897. */
  52898. readonly supportCascades: boolean;
  52899. /**
  52900. * This returns if the loader support the current file information.
  52901. * @param extension defines the file extension of the file being loaded
  52902. * @returns true if the loader can load the specified file
  52903. */
  52904. canLoad(extension: string): boolean;
  52905. /**
  52906. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52907. * @param data contains the texture data
  52908. * @param texture defines the BabylonJS internal texture
  52909. * @param createPolynomials will be true if polynomials have been requested
  52910. * @param onLoad defines the callback to trigger once the texture is ready
  52911. * @param onError defines the callback to trigger in case of error
  52912. */
  52913. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52914. /**
  52915. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52916. * @param data contains the texture data
  52917. * @param texture defines the BabylonJS internal texture
  52918. * @param callback defines the method to call once ready to upload
  52919. */
  52920. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52921. }
  52922. }
  52923. declare module BABYLON {
  52924. /**
  52925. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52926. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52927. */
  52928. export class KhronosTextureContainer {
  52929. /** contents of the KTX container file */
  52930. data: ArrayBufferView;
  52931. private static HEADER_LEN;
  52932. private static COMPRESSED_2D;
  52933. private static COMPRESSED_3D;
  52934. private static TEX_2D;
  52935. private static TEX_3D;
  52936. /**
  52937. * Gets the openGL type
  52938. */
  52939. glType: number;
  52940. /**
  52941. * Gets the openGL type size
  52942. */
  52943. glTypeSize: number;
  52944. /**
  52945. * Gets the openGL format
  52946. */
  52947. glFormat: number;
  52948. /**
  52949. * Gets the openGL internal format
  52950. */
  52951. glInternalFormat: number;
  52952. /**
  52953. * Gets the base internal format
  52954. */
  52955. glBaseInternalFormat: number;
  52956. /**
  52957. * Gets image width in pixel
  52958. */
  52959. pixelWidth: number;
  52960. /**
  52961. * Gets image height in pixel
  52962. */
  52963. pixelHeight: number;
  52964. /**
  52965. * Gets image depth in pixels
  52966. */
  52967. pixelDepth: number;
  52968. /**
  52969. * Gets the number of array elements
  52970. */
  52971. numberOfArrayElements: number;
  52972. /**
  52973. * Gets the number of faces
  52974. */
  52975. numberOfFaces: number;
  52976. /**
  52977. * Gets the number of mipmap levels
  52978. */
  52979. numberOfMipmapLevels: number;
  52980. /**
  52981. * Gets the bytes of key value data
  52982. */
  52983. bytesOfKeyValueData: number;
  52984. /**
  52985. * Gets the load type
  52986. */
  52987. loadType: number;
  52988. /**
  52989. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52990. */
  52991. isInvalid: boolean;
  52992. /**
  52993. * Creates a new KhronosTextureContainer
  52994. * @param data contents of the KTX container file
  52995. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52996. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52997. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52998. */
  52999. constructor(
  53000. /** contents of the KTX container file */
  53001. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53002. /**
  53003. * Uploads KTX content to a Babylon Texture.
  53004. * It is assumed that the texture has already been created & is currently bound
  53005. * @hidden
  53006. */
  53007. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53008. private _upload2DCompressedLevels;
  53009. /**
  53010. * Checks if the given data starts with a KTX file identifier.
  53011. * @param data the data to check
  53012. * @returns true if the data is a KTX file or false otherwise
  53013. */
  53014. static IsValid(data: ArrayBufferView): boolean;
  53015. }
  53016. }
  53017. declare module BABYLON {
  53018. /**
  53019. * Class for loading KTX2 files
  53020. * !!! Experimental Extension Subject to Changes !!!
  53021. * @hidden
  53022. */
  53023. export class KhronosTextureContainer2 {
  53024. private static _ModulePromise;
  53025. private static _TranscodeFormat;
  53026. constructor(engine: ThinEngine);
  53027. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  53028. private _determineTranscodeFormat;
  53029. /**
  53030. * Checks if the given data starts with a KTX2 file identifier.
  53031. * @param data the data to check
  53032. * @returns true if the data is a KTX2 file or false otherwise
  53033. */
  53034. static IsValid(data: ArrayBufferView): boolean;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /**
  53039. * Implementation of the KTX Texture Loader.
  53040. * @hidden
  53041. */
  53042. export class _KTXTextureLoader implements IInternalTextureLoader {
  53043. /**
  53044. * Defines wether the loader supports cascade loading the different faces.
  53045. */
  53046. readonly supportCascades: boolean;
  53047. /**
  53048. * This returns if the loader support the current file information.
  53049. * @param extension defines the file extension of the file being loaded
  53050. * @returns true if the loader can load the specified file
  53051. */
  53052. canLoad(extension: string): boolean;
  53053. /**
  53054. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  53055. * @param data contains the texture data
  53056. * @param texture defines the BabylonJS internal texture
  53057. * @param createPolynomials will be true if polynomials have been requested
  53058. * @param onLoad defines the callback to trigger once the texture is ready
  53059. * @param onError defines the callback to trigger in case of error
  53060. */
  53061. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53062. /**
  53063. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  53064. * @param data contains the texture data
  53065. * @param texture defines the BabylonJS internal texture
  53066. * @param callback defines the method to call once ready to upload
  53067. */
  53068. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53069. }
  53070. }
  53071. declare module BABYLON {
  53072. /** @hidden */
  53073. export var _forceSceneHelpersToBundle: boolean;
  53074. interface Scene {
  53075. /**
  53076. * Creates a default light for the scene.
  53077. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53078. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53079. */
  53080. createDefaultLight(replace?: boolean): void;
  53081. /**
  53082. * Creates a default camera for the scene.
  53083. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53084. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53085. * @param replace has default false, when true replaces the active camera in the scene
  53086. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53087. */
  53088. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53089. /**
  53090. * Creates a default camera and a default light.
  53091. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53092. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53093. * @param replace has the default false, when true replaces the active camera/light in the scene
  53094. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53095. */
  53096. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53097. /**
  53098. * Creates a new sky box
  53099. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53100. * @param environmentTexture defines the texture to use as environment texture
  53101. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53102. * @param scale defines the overall scale of the skybox
  53103. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53104. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53105. * @returns a new mesh holding the sky box
  53106. */
  53107. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53108. /**
  53109. * Creates a new environment
  53110. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53111. * @param options defines the options you can use to configure the environment
  53112. * @returns the new EnvironmentHelper
  53113. */
  53114. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53115. /**
  53116. * Creates a new VREXperienceHelper
  53117. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53118. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53119. * @returns a new VREXperienceHelper
  53120. */
  53121. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53122. /**
  53123. * Creates a new WebXRDefaultExperience
  53124. * @see http://doc.babylonjs.com/how_to/webxr
  53125. * @param options experience options
  53126. * @returns a promise for a new WebXRDefaultExperience
  53127. */
  53128. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53129. }
  53130. }
  53131. declare module BABYLON {
  53132. /**
  53133. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53134. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53135. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53136. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53137. */
  53138. export class VideoDome extends TransformNode {
  53139. /**
  53140. * Define the video source as a Monoscopic panoramic 360 video.
  53141. */
  53142. static readonly MODE_MONOSCOPIC: number;
  53143. /**
  53144. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53145. */
  53146. static readonly MODE_TOPBOTTOM: number;
  53147. /**
  53148. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53149. */
  53150. static readonly MODE_SIDEBYSIDE: number;
  53151. private _halfDome;
  53152. private _useDirectMapping;
  53153. /**
  53154. * The video texture being displayed on the sphere
  53155. */
  53156. protected _videoTexture: VideoTexture;
  53157. /**
  53158. * Gets the video texture being displayed on the sphere
  53159. */
  53160. get videoTexture(): VideoTexture;
  53161. /**
  53162. * The skybox material
  53163. */
  53164. protected _material: BackgroundMaterial;
  53165. /**
  53166. * The surface used for the skybox
  53167. */
  53168. protected _mesh: Mesh;
  53169. /**
  53170. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53171. */
  53172. private _halfDomeMask;
  53173. /**
  53174. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53175. * Also see the options.resolution property.
  53176. */
  53177. get fovMultiplier(): number;
  53178. set fovMultiplier(value: number);
  53179. private _videoMode;
  53180. /**
  53181. * Gets or set the current video mode for the video. It can be:
  53182. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53183. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53184. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53185. */
  53186. get videoMode(): number;
  53187. set videoMode(value: number);
  53188. /**
  53189. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53190. *
  53191. */
  53192. get halfDome(): boolean;
  53193. /**
  53194. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53195. */
  53196. set halfDome(enabled: boolean);
  53197. /**
  53198. * Oberserver used in Stereoscopic VR Mode.
  53199. */
  53200. private _onBeforeCameraRenderObserver;
  53201. /**
  53202. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53203. * @param name Element's name, child elements will append suffixes for their own names.
  53204. * @param urlsOrVideo defines the url(s) or the video element to use
  53205. * @param options An object containing optional or exposed sub element properties
  53206. */
  53207. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53208. resolution?: number;
  53209. clickToPlay?: boolean;
  53210. autoPlay?: boolean;
  53211. loop?: boolean;
  53212. size?: number;
  53213. poster?: string;
  53214. faceForward?: boolean;
  53215. useDirectMapping?: boolean;
  53216. halfDomeMode?: boolean;
  53217. }, scene: Scene);
  53218. private _changeVideoMode;
  53219. /**
  53220. * Releases resources associated with this node.
  53221. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53222. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53223. */
  53224. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53225. }
  53226. }
  53227. declare module BABYLON {
  53228. /**
  53229. * This class can be used to get instrumentation data from a Babylon engine
  53230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53231. */
  53232. export class EngineInstrumentation implements IDisposable {
  53233. /**
  53234. * Define the instrumented engine.
  53235. */
  53236. engine: Engine;
  53237. private _captureGPUFrameTime;
  53238. private _gpuFrameTimeToken;
  53239. private _gpuFrameTime;
  53240. private _captureShaderCompilationTime;
  53241. private _shaderCompilationTime;
  53242. private _onBeginFrameObserver;
  53243. private _onEndFrameObserver;
  53244. private _onBeforeShaderCompilationObserver;
  53245. private _onAfterShaderCompilationObserver;
  53246. /**
  53247. * Gets the perf counter used for GPU frame time
  53248. */
  53249. get gpuFrameTimeCounter(): PerfCounter;
  53250. /**
  53251. * Gets the GPU frame time capture status
  53252. */
  53253. get captureGPUFrameTime(): boolean;
  53254. /**
  53255. * Enable or disable the GPU frame time capture
  53256. */
  53257. set captureGPUFrameTime(value: boolean);
  53258. /**
  53259. * Gets the perf counter used for shader compilation time
  53260. */
  53261. get shaderCompilationTimeCounter(): PerfCounter;
  53262. /**
  53263. * Gets the shader compilation time capture status
  53264. */
  53265. get captureShaderCompilationTime(): boolean;
  53266. /**
  53267. * Enable or disable the shader compilation time capture
  53268. */
  53269. set captureShaderCompilationTime(value: boolean);
  53270. /**
  53271. * Instantiates a new engine instrumentation.
  53272. * This class can be used to get instrumentation data from a Babylon engine
  53273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53274. * @param engine Defines the engine to instrument
  53275. */
  53276. constructor(
  53277. /**
  53278. * Define the instrumented engine.
  53279. */
  53280. engine: Engine);
  53281. /**
  53282. * Dispose and release associated resources.
  53283. */
  53284. dispose(): void;
  53285. }
  53286. }
  53287. declare module BABYLON {
  53288. /**
  53289. * This class can be used to get instrumentation data from a Babylon engine
  53290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53291. */
  53292. export class SceneInstrumentation implements IDisposable {
  53293. /**
  53294. * Defines the scene to instrument
  53295. */
  53296. scene: Scene;
  53297. private _captureActiveMeshesEvaluationTime;
  53298. private _activeMeshesEvaluationTime;
  53299. private _captureRenderTargetsRenderTime;
  53300. private _renderTargetsRenderTime;
  53301. private _captureFrameTime;
  53302. private _frameTime;
  53303. private _captureRenderTime;
  53304. private _renderTime;
  53305. private _captureInterFrameTime;
  53306. private _interFrameTime;
  53307. private _captureParticlesRenderTime;
  53308. private _particlesRenderTime;
  53309. private _captureSpritesRenderTime;
  53310. private _spritesRenderTime;
  53311. private _capturePhysicsTime;
  53312. private _physicsTime;
  53313. private _captureAnimationsTime;
  53314. private _animationsTime;
  53315. private _captureCameraRenderTime;
  53316. private _cameraRenderTime;
  53317. private _onBeforeActiveMeshesEvaluationObserver;
  53318. private _onAfterActiveMeshesEvaluationObserver;
  53319. private _onBeforeRenderTargetsRenderObserver;
  53320. private _onAfterRenderTargetsRenderObserver;
  53321. private _onAfterRenderObserver;
  53322. private _onBeforeDrawPhaseObserver;
  53323. private _onAfterDrawPhaseObserver;
  53324. private _onBeforeAnimationsObserver;
  53325. private _onBeforeParticlesRenderingObserver;
  53326. private _onAfterParticlesRenderingObserver;
  53327. private _onBeforeSpritesRenderingObserver;
  53328. private _onAfterSpritesRenderingObserver;
  53329. private _onBeforePhysicsObserver;
  53330. private _onAfterPhysicsObserver;
  53331. private _onAfterAnimationsObserver;
  53332. private _onBeforeCameraRenderObserver;
  53333. private _onAfterCameraRenderObserver;
  53334. /**
  53335. * Gets the perf counter used for active meshes evaluation time
  53336. */
  53337. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53338. /**
  53339. * Gets the active meshes evaluation time capture status
  53340. */
  53341. get captureActiveMeshesEvaluationTime(): boolean;
  53342. /**
  53343. * Enable or disable the active meshes evaluation time capture
  53344. */
  53345. set captureActiveMeshesEvaluationTime(value: boolean);
  53346. /**
  53347. * Gets the perf counter used for render targets render time
  53348. */
  53349. get renderTargetsRenderTimeCounter(): PerfCounter;
  53350. /**
  53351. * Gets the render targets render time capture status
  53352. */
  53353. get captureRenderTargetsRenderTime(): boolean;
  53354. /**
  53355. * Enable or disable the render targets render time capture
  53356. */
  53357. set captureRenderTargetsRenderTime(value: boolean);
  53358. /**
  53359. * Gets the perf counter used for particles render time
  53360. */
  53361. get particlesRenderTimeCounter(): PerfCounter;
  53362. /**
  53363. * Gets the particles render time capture status
  53364. */
  53365. get captureParticlesRenderTime(): boolean;
  53366. /**
  53367. * Enable or disable the particles render time capture
  53368. */
  53369. set captureParticlesRenderTime(value: boolean);
  53370. /**
  53371. * Gets the perf counter used for sprites render time
  53372. */
  53373. get spritesRenderTimeCounter(): PerfCounter;
  53374. /**
  53375. * Gets the sprites render time capture status
  53376. */
  53377. get captureSpritesRenderTime(): boolean;
  53378. /**
  53379. * Enable or disable the sprites render time capture
  53380. */
  53381. set captureSpritesRenderTime(value: boolean);
  53382. /**
  53383. * Gets the perf counter used for physics time
  53384. */
  53385. get physicsTimeCounter(): PerfCounter;
  53386. /**
  53387. * Gets the physics time capture status
  53388. */
  53389. get capturePhysicsTime(): boolean;
  53390. /**
  53391. * Enable or disable the physics time capture
  53392. */
  53393. set capturePhysicsTime(value: boolean);
  53394. /**
  53395. * Gets the perf counter used for animations time
  53396. */
  53397. get animationsTimeCounter(): PerfCounter;
  53398. /**
  53399. * Gets the animations time capture status
  53400. */
  53401. get captureAnimationsTime(): boolean;
  53402. /**
  53403. * Enable or disable the animations time capture
  53404. */
  53405. set captureAnimationsTime(value: boolean);
  53406. /**
  53407. * Gets the perf counter used for frame time capture
  53408. */
  53409. get frameTimeCounter(): PerfCounter;
  53410. /**
  53411. * Gets the frame time capture status
  53412. */
  53413. get captureFrameTime(): boolean;
  53414. /**
  53415. * Enable or disable the frame time capture
  53416. */
  53417. set captureFrameTime(value: boolean);
  53418. /**
  53419. * Gets the perf counter used for inter-frames time capture
  53420. */
  53421. get interFrameTimeCounter(): PerfCounter;
  53422. /**
  53423. * Gets the inter-frames time capture status
  53424. */
  53425. get captureInterFrameTime(): boolean;
  53426. /**
  53427. * Enable or disable the inter-frames time capture
  53428. */
  53429. set captureInterFrameTime(value: boolean);
  53430. /**
  53431. * Gets the perf counter used for render time capture
  53432. */
  53433. get renderTimeCounter(): PerfCounter;
  53434. /**
  53435. * Gets the render time capture status
  53436. */
  53437. get captureRenderTime(): boolean;
  53438. /**
  53439. * Enable or disable the render time capture
  53440. */
  53441. set captureRenderTime(value: boolean);
  53442. /**
  53443. * Gets the perf counter used for camera render time capture
  53444. */
  53445. get cameraRenderTimeCounter(): PerfCounter;
  53446. /**
  53447. * Gets the camera render time capture status
  53448. */
  53449. get captureCameraRenderTime(): boolean;
  53450. /**
  53451. * Enable or disable the camera render time capture
  53452. */
  53453. set captureCameraRenderTime(value: boolean);
  53454. /**
  53455. * Gets the perf counter used for draw calls
  53456. */
  53457. get drawCallsCounter(): PerfCounter;
  53458. /**
  53459. * Instantiates a new scene instrumentation.
  53460. * This class can be used to get instrumentation data from a Babylon engine
  53461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53462. * @param scene Defines the scene to instrument
  53463. */
  53464. constructor(
  53465. /**
  53466. * Defines the scene to instrument
  53467. */
  53468. scene: Scene);
  53469. /**
  53470. * Dispose and release associated resources.
  53471. */
  53472. dispose(): void;
  53473. }
  53474. }
  53475. declare module BABYLON {
  53476. /** @hidden */
  53477. export var glowMapGenerationPixelShader: {
  53478. name: string;
  53479. shader: string;
  53480. };
  53481. }
  53482. declare module BABYLON {
  53483. /** @hidden */
  53484. export var glowMapGenerationVertexShader: {
  53485. name: string;
  53486. shader: string;
  53487. };
  53488. }
  53489. declare module BABYLON {
  53490. /**
  53491. * Effect layer options. This helps customizing the behaviour
  53492. * of the effect layer.
  53493. */
  53494. export interface IEffectLayerOptions {
  53495. /**
  53496. * Multiplication factor apply to the canvas size to compute the render target size
  53497. * used to generated the objects (the smaller the faster).
  53498. */
  53499. mainTextureRatio: number;
  53500. /**
  53501. * Enforces a fixed size texture to ensure effect stability across devices.
  53502. */
  53503. mainTextureFixedSize?: number;
  53504. /**
  53505. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53506. */
  53507. alphaBlendingMode: number;
  53508. /**
  53509. * The camera attached to the layer.
  53510. */
  53511. camera: Nullable<Camera>;
  53512. /**
  53513. * The rendering group to draw the layer in.
  53514. */
  53515. renderingGroupId: number;
  53516. }
  53517. /**
  53518. * The effect layer Helps adding post process effect blended with the main pass.
  53519. *
  53520. * This can be for instance use to generate glow or higlight effects on the scene.
  53521. *
  53522. * The effect layer class can not be used directly and is intented to inherited from to be
  53523. * customized per effects.
  53524. */
  53525. export abstract class EffectLayer {
  53526. private _vertexBuffers;
  53527. private _indexBuffer;
  53528. private _cachedDefines;
  53529. private _effectLayerMapGenerationEffect;
  53530. private _effectLayerOptions;
  53531. private _mergeEffect;
  53532. protected _scene: Scene;
  53533. protected _engine: Engine;
  53534. protected _maxSize: number;
  53535. protected _mainTextureDesiredSize: ISize;
  53536. protected _mainTexture: RenderTargetTexture;
  53537. protected _shouldRender: boolean;
  53538. protected _postProcesses: PostProcess[];
  53539. protected _textures: BaseTexture[];
  53540. protected _emissiveTextureAndColor: {
  53541. texture: Nullable<BaseTexture>;
  53542. color: Color4;
  53543. };
  53544. /**
  53545. * The name of the layer
  53546. */
  53547. name: string;
  53548. /**
  53549. * The clear color of the texture used to generate the glow map.
  53550. */
  53551. neutralColor: Color4;
  53552. /**
  53553. * Specifies whether the highlight layer is enabled or not.
  53554. */
  53555. isEnabled: boolean;
  53556. /**
  53557. * Gets the camera attached to the layer.
  53558. */
  53559. get camera(): Nullable<Camera>;
  53560. /**
  53561. * Gets the rendering group id the layer should render in.
  53562. */
  53563. get renderingGroupId(): number;
  53564. set renderingGroupId(renderingGroupId: number);
  53565. /**
  53566. * An event triggered when the effect layer has been disposed.
  53567. */
  53568. onDisposeObservable: Observable<EffectLayer>;
  53569. /**
  53570. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53571. */
  53572. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53573. /**
  53574. * An event triggered when the generated texture is being merged in the scene.
  53575. */
  53576. onBeforeComposeObservable: Observable<EffectLayer>;
  53577. /**
  53578. * An event triggered when the mesh is rendered into the effect render target.
  53579. */
  53580. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53581. /**
  53582. * An event triggered after the mesh has been rendered into the effect render target.
  53583. */
  53584. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53585. /**
  53586. * An event triggered when the generated texture has been merged in the scene.
  53587. */
  53588. onAfterComposeObservable: Observable<EffectLayer>;
  53589. /**
  53590. * An event triggered when the efffect layer changes its size.
  53591. */
  53592. onSizeChangedObservable: Observable<EffectLayer>;
  53593. /** @hidden */
  53594. static _SceneComponentInitialization: (scene: Scene) => void;
  53595. /**
  53596. * Instantiates a new effect Layer and references it in the scene.
  53597. * @param name The name of the layer
  53598. * @param scene The scene to use the layer in
  53599. */
  53600. constructor(
  53601. /** The Friendly of the effect in the scene */
  53602. name: string, scene: Scene);
  53603. /**
  53604. * Get the effect name of the layer.
  53605. * @return The effect name
  53606. */
  53607. abstract getEffectName(): string;
  53608. /**
  53609. * Checks for the readiness of the element composing the layer.
  53610. * @param subMesh the mesh to check for
  53611. * @param useInstances specify whether or not to use instances to render the mesh
  53612. * @return true if ready otherwise, false
  53613. */
  53614. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53615. /**
  53616. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53617. * @returns true if the effect requires stencil during the main canvas render pass.
  53618. */
  53619. abstract needStencil(): boolean;
  53620. /**
  53621. * Create the merge effect. This is the shader use to blit the information back
  53622. * to the main canvas at the end of the scene rendering.
  53623. * @returns The effect containing the shader used to merge the effect on the main canvas
  53624. */
  53625. protected abstract _createMergeEffect(): Effect;
  53626. /**
  53627. * Creates the render target textures and post processes used in the effect layer.
  53628. */
  53629. protected abstract _createTextureAndPostProcesses(): void;
  53630. /**
  53631. * Implementation specific of rendering the generating effect on the main canvas.
  53632. * @param effect The effect used to render through
  53633. */
  53634. protected abstract _internalRender(effect: Effect): void;
  53635. /**
  53636. * Sets the required values for both the emissive texture and and the main color.
  53637. */
  53638. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53639. /**
  53640. * Free any resources and references associated to a mesh.
  53641. * Internal use
  53642. * @param mesh The mesh to free.
  53643. */
  53644. abstract _disposeMesh(mesh: Mesh): void;
  53645. /**
  53646. * Serializes this layer (Glow or Highlight for example)
  53647. * @returns a serialized layer object
  53648. */
  53649. abstract serialize?(): any;
  53650. /**
  53651. * Initializes the effect layer with the required options.
  53652. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53653. */
  53654. protected _init(options: Partial<IEffectLayerOptions>): void;
  53655. /**
  53656. * Generates the index buffer of the full screen quad blending to the main canvas.
  53657. */
  53658. private _generateIndexBuffer;
  53659. /**
  53660. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53661. */
  53662. private _generateVertexBuffer;
  53663. /**
  53664. * Sets the main texture desired size which is the closest power of two
  53665. * of the engine canvas size.
  53666. */
  53667. private _setMainTextureSize;
  53668. /**
  53669. * Creates the main texture for the effect layer.
  53670. */
  53671. protected _createMainTexture(): void;
  53672. /**
  53673. * Adds specific effects defines.
  53674. * @param defines The defines to add specifics to.
  53675. */
  53676. protected _addCustomEffectDefines(defines: string[]): void;
  53677. /**
  53678. * Checks for the readiness of the element composing the layer.
  53679. * @param subMesh the mesh to check for
  53680. * @param useInstances specify whether or not to use instances to render the mesh
  53681. * @param emissiveTexture the associated emissive texture used to generate the glow
  53682. * @return true if ready otherwise, false
  53683. */
  53684. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53685. /**
  53686. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53687. */
  53688. render(): void;
  53689. /**
  53690. * Determine if a given mesh will be used in the current effect.
  53691. * @param mesh mesh to test
  53692. * @returns true if the mesh will be used
  53693. */
  53694. hasMesh(mesh: AbstractMesh): boolean;
  53695. /**
  53696. * Returns true if the layer contains information to display, otherwise false.
  53697. * @returns true if the glow layer should be rendered
  53698. */
  53699. shouldRender(): boolean;
  53700. /**
  53701. * Returns true if the mesh should render, otherwise false.
  53702. * @param mesh The mesh to render
  53703. * @returns true if it should render otherwise false
  53704. */
  53705. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53706. /**
  53707. * Returns true if the mesh can be rendered, otherwise false.
  53708. * @param mesh The mesh to render
  53709. * @param material The material used on the mesh
  53710. * @returns true if it can be rendered otherwise false
  53711. */
  53712. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53713. /**
  53714. * Returns true if the mesh should render, otherwise false.
  53715. * @param mesh The mesh to render
  53716. * @returns true if it should render otherwise false
  53717. */
  53718. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53719. /**
  53720. * Renders the submesh passed in parameter to the generation map.
  53721. */
  53722. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53723. /**
  53724. * Defines whether the current material of the mesh should be use to render the effect.
  53725. * @param mesh defines the current mesh to render
  53726. */
  53727. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53728. /**
  53729. * Rebuild the required buffers.
  53730. * @hidden Internal use only.
  53731. */
  53732. _rebuild(): void;
  53733. /**
  53734. * Dispose only the render target textures and post process.
  53735. */
  53736. private _disposeTextureAndPostProcesses;
  53737. /**
  53738. * Dispose the highlight layer and free resources.
  53739. */
  53740. dispose(): void;
  53741. /**
  53742. * Gets the class name of the effect layer
  53743. * @returns the string with the class name of the effect layer
  53744. */
  53745. getClassName(): string;
  53746. /**
  53747. * Creates an effect layer from parsed effect layer data
  53748. * @param parsedEffectLayer defines effect layer data
  53749. * @param scene defines the current scene
  53750. * @param rootUrl defines the root URL containing the effect layer information
  53751. * @returns a parsed effect Layer
  53752. */
  53753. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53754. }
  53755. }
  53756. declare module BABYLON {
  53757. interface AbstractScene {
  53758. /**
  53759. * The list of effect layers (highlights/glow) added to the scene
  53760. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53761. * @see http://doc.babylonjs.com/how_to/glow_layer
  53762. */
  53763. effectLayers: Array<EffectLayer>;
  53764. /**
  53765. * Removes the given effect layer from this scene.
  53766. * @param toRemove defines the effect layer to remove
  53767. * @returns the index of the removed effect layer
  53768. */
  53769. removeEffectLayer(toRemove: EffectLayer): number;
  53770. /**
  53771. * Adds the given effect layer to this scene
  53772. * @param newEffectLayer defines the effect layer to add
  53773. */
  53774. addEffectLayer(newEffectLayer: EffectLayer): void;
  53775. }
  53776. /**
  53777. * Defines the layer scene component responsible to manage any effect layers
  53778. * in a given scene.
  53779. */
  53780. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53781. /**
  53782. * The component name helpfull to identify the component in the list of scene components.
  53783. */
  53784. readonly name: string;
  53785. /**
  53786. * The scene the component belongs to.
  53787. */
  53788. scene: Scene;
  53789. private _engine;
  53790. private _renderEffects;
  53791. private _needStencil;
  53792. private _previousStencilState;
  53793. /**
  53794. * Creates a new instance of the component for the given scene
  53795. * @param scene Defines the scene to register the component in
  53796. */
  53797. constructor(scene: Scene);
  53798. /**
  53799. * Registers the component in a given scene
  53800. */
  53801. register(): void;
  53802. /**
  53803. * Rebuilds the elements related to this component in case of
  53804. * context lost for instance.
  53805. */
  53806. rebuild(): void;
  53807. /**
  53808. * Serializes the component data to the specified json object
  53809. * @param serializationObject The object to serialize to
  53810. */
  53811. serialize(serializationObject: any): void;
  53812. /**
  53813. * Adds all the elements from the container to the scene
  53814. * @param container the container holding the elements
  53815. */
  53816. addFromContainer(container: AbstractScene): void;
  53817. /**
  53818. * Removes all the elements in the container from the scene
  53819. * @param container contains the elements to remove
  53820. * @param dispose if the removed element should be disposed (default: false)
  53821. */
  53822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53823. /**
  53824. * Disposes the component and the associated ressources.
  53825. */
  53826. dispose(): void;
  53827. private _isReadyForMesh;
  53828. private _renderMainTexture;
  53829. private _setStencil;
  53830. private _setStencilBack;
  53831. private _draw;
  53832. private _drawCamera;
  53833. private _drawRenderingGroup;
  53834. }
  53835. }
  53836. declare module BABYLON {
  53837. /** @hidden */
  53838. export var glowMapMergePixelShader: {
  53839. name: string;
  53840. shader: string;
  53841. };
  53842. }
  53843. declare module BABYLON {
  53844. /** @hidden */
  53845. export var glowMapMergeVertexShader: {
  53846. name: string;
  53847. shader: string;
  53848. };
  53849. }
  53850. declare module BABYLON {
  53851. interface AbstractScene {
  53852. /**
  53853. * Return a the first highlight layer of the scene with a given name.
  53854. * @param name The name of the highlight layer to look for.
  53855. * @return The highlight layer if found otherwise null.
  53856. */
  53857. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53858. }
  53859. /**
  53860. * Glow layer options. This helps customizing the behaviour
  53861. * of the glow layer.
  53862. */
  53863. export interface IGlowLayerOptions {
  53864. /**
  53865. * Multiplication factor apply to the canvas size to compute the render target size
  53866. * used to generated the glowing objects (the smaller the faster).
  53867. */
  53868. mainTextureRatio: number;
  53869. /**
  53870. * Enforces a fixed size texture to ensure resize independant blur.
  53871. */
  53872. mainTextureFixedSize?: number;
  53873. /**
  53874. * How big is the kernel of the blur texture.
  53875. */
  53876. blurKernelSize: number;
  53877. /**
  53878. * The camera attached to the layer.
  53879. */
  53880. camera: Nullable<Camera>;
  53881. /**
  53882. * Enable MSAA by chosing the number of samples.
  53883. */
  53884. mainTextureSamples?: number;
  53885. /**
  53886. * The rendering group to draw the layer in.
  53887. */
  53888. renderingGroupId: number;
  53889. }
  53890. /**
  53891. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53892. *
  53893. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53894. *
  53895. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53896. */
  53897. export class GlowLayer extends EffectLayer {
  53898. /**
  53899. * Effect Name of the layer.
  53900. */
  53901. static readonly EffectName: string;
  53902. /**
  53903. * The default blur kernel size used for the glow.
  53904. */
  53905. static DefaultBlurKernelSize: number;
  53906. /**
  53907. * The default texture size ratio used for the glow.
  53908. */
  53909. static DefaultTextureRatio: number;
  53910. /**
  53911. * Sets the kernel size of the blur.
  53912. */
  53913. set blurKernelSize(value: number);
  53914. /**
  53915. * Gets the kernel size of the blur.
  53916. */
  53917. get blurKernelSize(): number;
  53918. /**
  53919. * Sets the glow intensity.
  53920. */
  53921. set intensity(value: number);
  53922. /**
  53923. * Gets the glow intensity.
  53924. */
  53925. get intensity(): number;
  53926. private _options;
  53927. private _intensity;
  53928. private _horizontalBlurPostprocess1;
  53929. private _verticalBlurPostprocess1;
  53930. private _horizontalBlurPostprocess2;
  53931. private _verticalBlurPostprocess2;
  53932. private _blurTexture1;
  53933. private _blurTexture2;
  53934. private _postProcesses1;
  53935. private _postProcesses2;
  53936. private _includedOnlyMeshes;
  53937. private _excludedMeshes;
  53938. private _meshesUsingTheirOwnMaterials;
  53939. /**
  53940. * Callback used to let the user override the color selection on a per mesh basis
  53941. */
  53942. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53943. /**
  53944. * Callback used to let the user override the texture selection on a per mesh basis
  53945. */
  53946. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53947. /**
  53948. * Instantiates a new glow Layer and references it to the scene.
  53949. * @param name The name of the layer
  53950. * @param scene The scene to use the layer in
  53951. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53952. */
  53953. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53954. /**
  53955. * Get the effect name of the layer.
  53956. * @return The effect name
  53957. */
  53958. getEffectName(): string;
  53959. /**
  53960. * Create the merge effect. This is the shader use to blit the information back
  53961. * to the main canvas at the end of the scene rendering.
  53962. */
  53963. protected _createMergeEffect(): Effect;
  53964. /**
  53965. * Creates the render target textures and post processes used in the glow layer.
  53966. */
  53967. protected _createTextureAndPostProcesses(): void;
  53968. /**
  53969. * Checks for the readiness of the element composing the layer.
  53970. * @param subMesh the mesh to check for
  53971. * @param useInstances specify wether or not to use instances to render the mesh
  53972. * @param emissiveTexture the associated emissive texture used to generate the glow
  53973. * @return true if ready otherwise, false
  53974. */
  53975. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53976. /**
  53977. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53978. */
  53979. needStencil(): boolean;
  53980. /**
  53981. * Returns true if the mesh can be rendered, otherwise false.
  53982. * @param mesh The mesh to render
  53983. * @param material The material used on the mesh
  53984. * @returns true if it can be rendered otherwise false
  53985. */
  53986. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53987. /**
  53988. * Implementation specific of rendering the generating effect on the main canvas.
  53989. * @param effect The effect used to render through
  53990. */
  53991. protected _internalRender(effect: Effect): void;
  53992. /**
  53993. * Sets the required values for both the emissive texture and and the main color.
  53994. */
  53995. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53996. /**
  53997. * Returns true if the mesh should render, otherwise false.
  53998. * @param mesh The mesh to render
  53999. * @returns true if it should render otherwise false
  54000. */
  54001. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54002. /**
  54003. * Adds specific effects defines.
  54004. * @param defines The defines to add specifics to.
  54005. */
  54006. protected _addCustomEffectDefines(defines: string[]): void;
  54007. /**
  54008. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54009. * @param mesh The mesh to exclude from the glow layer
  54010. */
  54011. addExcludedMesh(mesh: Mesh): void;
  54012. /**
  54013. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54014. * @param mesh The mesh to remove
  54015. */
  54016. removeExcludedMesh(mesh: Mesh): void;
  54017. /**
  54018. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54019. * @param mesh The mesh to include in the glow layer
  54020. */
  54021. addIncludedOnlyMesh(mesh: Mesh): void;
  54022. /**
  54023. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54024. * @param mesh The mesh to remove
  54025. */
  54026. removeIncludedOnlyMesh(mesh: Mesh): void;
  54027. /**
  54028. * Determine if a given mesh will be used in the glow layer
  54029. * @param mesh The mesh to test
  54030. * @returns true if the mesh will be highlighted by the current glow layer
  54031. */
  54032. hasMesh(mesh: AbstractMesh): boolean;
  54033. /**
  54034. * Defines whether the current material of the mesh should be use to render the effect.
  54035. * @param mesh defines the current mesh to render
  54036. */
  54037. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54038. /**
  54039. * Add a mesh to be rendered through its own material and not with emissive only.
  54040. * @param mesh The mesh for which we need to use its material
  54041. */
  54042. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54043. /**
  54044. * Remove a mesh from being rendered through its own material and not with emissive only.
  54045. * @param mesh The mesh for which we need to not use its material
  54046. */
  54047. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54048. /**
  54049. * Free any resources and references associated to a mesh.
  54050. * Internal use
  54051. * @param mesh The mesh to free.
  54052. * @hidden
  54053. */
  54054. _disposeMesh(mesh: Mesh): void;
  54055. /**
  54056. * Gets the class name of the effect layer
  54057. * @returns the string with the class name of the effect layer
  54058. */
  54059. getClassName(): string;
  54060. /**
  54061. * Serializes this glow layer
  54062. * @returns a serialized glow layer object
  54063. */
  54064. serialize(): any;
  54065. /**
  54066. * Creates a Glow Layer from parsed glow layer data
  54067. * @param parsedGlowLayer defines glow layer data
  54068. * @param scene defines the current scene
  54069. * @param rootUrl defines the root URL containing the glow layer information
  54070. * @returns a parsed Glow Layer
  54071. */
  54072. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54073. }
  54074. }
  54075. declare module BABYLON {
  54076. /** @hidden */
  54077. export var glowBlurPostProcessPixelShader: {
  54078. name: string;
  54079. shader: string;
  54080. };
  54081. }
  54082. declare module BABYLON {
  54083. interface AbstractScene {
  54084. /**
  54085. * Return a the first highlight layer of the scene with a given name.
  54086. * @param name The name of the highlight layer to look for.
  54087. * @return The highlight layer if found otherwise null.
  54088. */
  54089. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54090. }
  54091. /**
  54092. * Highlight layer options. This helps customizing the behaviour
  54093. * of the highlight layer.
  54094. */
  54095. export interface IHighlightLayerOptions {
  54096. /**
  54097. * Multiplication factor apply to the canvas size to compute the render target size
  54098. * used to generated the glowing objects (the smaller the faster).
  54099. */
  54100. mainTextureRatio: number;
  54101. /**
  54102. * Enforces a fixed size texture to ensure resize independant blur.
  54103. */
  54104. mainTextureFixedSize?: number;
  54105. /**
  54106. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54107. * of the picture to blur (the smaller the faster).
  54108. */
  54109. blurTextureSizeRatio: number;
  54110. /**
  54111. * How big in texel of the blur texture is the vertical blur.
  54112. */
  54113. blurVerticalSize: number;
  54114. /**
  54115. * How big in texel of the blur texture is the horizontal blur.
  54116. */
  54117. blurHorizontalSize: number;
  54118. /**
  54119. * Alpha blending mode used to apply the blur. Default is combine.
  54120. */
  54121. alphaBlendingMode: number;
  54122. /**
  54123. * The camera attached to the layer.
  54124. */
  54125. camera: Nullable<Camera>;
  54126. /**
  54127. * Should we display highlight as a solid stroke?
  54128. */
  54129. isStroke?: boolean;
  54130. /**
  54131. * The rendering group to draw the layer in.
  54132. */
  54133. renderingGroupId: number;
  54134. }
  54135. /**
  54136. * The highlight layer Helps adding a glow effect around a mesh.
  54137. *
  54138. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54139. * glowy meshes to your scene.
  54140. *
  54141. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54142. */
  54143. export class HighlightLayer extends EffectLayer {
  54144. name: string;
  54145. /**
  54146. * Effect Name of the highlight layer.
  54147. */
  54148. static readonly EffectName: string;
  54149. /**
  54150. * The neutral color used during the preparation of the glow effect.
  54151. * This is black by default as the blend operation is a blend operation.
  54152. */
  54153. static NeutralColor: Color4;
  54154. /**
  54155. * Stencil value used for glowing meshes.
  54156. */
  54157. static GlowingMeshStencilReference: number;
  54158. /**
  54159. * Stencil value used for the other meshes in the scene.
  54160. */
  54161. static NormalMeshStencilReference: number;
  54162. /**
  54163. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54164. */
  54165. innerGlow: boolean;
  54166. /**
  54167. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54168. */
  54169. outerGlow: boolean;
  54170. /**
  54171. * Specifies the horizontal size of the blur.
  54172. */
  54173. set blurHorizontalSize(value: number);
  54174. /**
  54175. * Specifies the vertical size of the blur.
  54176. */
  54177. set blurVerticalSize(value: number);
  54178. /**
  54179. * Gets the horizontal size of the blur.
  54180. */
  54181. get blurHorizontalSize(): number;
  54182. /**
  54183. * Gets the vertical size of the blur.
  54184. */
  54185. get blurVerticalSize(): number;
  54186. /**
  54187. * An event triggered when the highlight layer is being blurred.
  54188. */
  54189. onBeforeBlurObservable: Observable<HighlightLayer>;
  54190. /**
  54191. * An event triggered when the highlight layer has been blurred.
  54192. */
  54193. onAfterBlurObservable: Observable<HighlightLayer>;
  54194. private _instanceGlowingMeshStencilReference;
  54195. private _options;
  54196. private _downSamplePostprocess;
  54197. private _horizontalBlurPostprocess;
  54198. private _verticalBlurPostprocess;
  54199. private _blurTexture;
  54200. private _meshes;
  54201. private _excludedMeshes;
  54202. /**
  54203. * Instantiates a new highlight Layer and references it to the scene..
  54204. * @param name The name of the layer
  54205. * @param scene The scene to use the layer in
  54206. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54207. */
  54208. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54209. /**
  54210. * Get the effect name of the layer.
  54211. * @return The effect name
  54212. */
  54213. getEffectName(): string;
  54214. /**
  54215. * Create the merge effect. This is the shader use to blit the information back
  54216. * to the main canvas at the end of the scene rendering.
  54217. */
  54218. protected _createMergeEffect(): Effect;
  54219. /**
  54220. * Creates the render target textures and post processes used in the highlight layer.
  54221. */
  54222. protected _createTextureAndPostProcesses(): void;
  54223. /**
  54224. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54225. */
  54226. needStencil(): boolean;
  54227. /**
  54228. * Checks for the readiness of the element composing the layer.
  54229. * @param subMesh the mesh to check for
  54230. * @param useInstances specify wether or not to use instances to render the mesh
  54231. * @param emissiveTexture the associated emissive texture used to generate the glow
  54232. * @return true if ready otherwise, false
  54233. */
  54234. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54235. /**
  54236. * Implementation specific of rendering the generating effect on the main canvas.
  54237. * @param effect The effect used to render through
  54238. */
  54239. protected _internalRender(effect: Effect): void;
  54240. /**
  54241. * Returns true if the layer contains information to display, otherwise false.
  54242. */
  54243. shouldRender(): boolean;
  54244. /**
  54245. * Returns true if the mesh should render, otherwise false.
  54246. * @param mesh The mesh to render
  54247. * @returns true if it should render otherwise false
  54248. */
  54249. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54250. /**
  54251. * Adds specific effects defines.
  54252. * @param defines The defines to add specifics to.
  54253. */
  54254. protected _addCustomEffectDefines(defines: string[]): void;
  54255. /**
  54256. * Sets the required values for both the emissive texture and and the main color.
  54257. */
  54258. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54259. /**
  54260. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54261. * @param mesh The mesh to exclude from the highlight layer
  54262. */
  54263. addExcludedMesh(mesh: Mesh): void;
  54264. /**
  54265. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54266. * @param mesh The mesh to highlight
  54267. */
  54268. removeExcludedMesh(mesh: Mesh): void;
  54269. /**
  54270. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54271. * @param mesh mesh to test
  54272. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54273. */
  54274. hasMesh(mesh: AbstractMesh): boolean;
  54275. /**
  54276. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54277. * @param mesh The mesh to highlight
  54278. * @param color The color of the highlight
  54279. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54280. */
  54281. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54282. /**
  54283. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54284. * @param mesh The mesh to highlight
  54285. */
  54286. removeMesh(mesh: Mesh): void;
  54287. /**
  54288. * Remove all the meshes currently referenced in the highlight layer
  54289. */
  54290. removeAllMeshes(): void;
  54291. /**
  54292. * Force the stencil to the normal expected value for none glowing parts
  54293. */
  54294. private _defaultStencilReference;
  54295. /**
  54296. * Free any resources and references associated to a mesh.
  54297. * Internal use
  54298. * @param mesh The mesh to free.
  54299. * @hidden
  54300. */
  54301. _disposeMesh(mesh: Mesh): void;
  54302. /**
  54303. * Dispose the highlight layer and free resources.
  54304. */
  54305. dispose(): void;
  54306. /**
  54307. * Gets the class name of the effect layer
  54308. * @returns the string with the class name of the effect layer
  54309. */
  54310. getClassName(): string;
  54311. /**
  54312. * Serializes this Highlight layer
  54313. * @returns a serialized Highlight layer object
  54314. */
  54315. serialize(): any;
  54316. /**
  54317. * Creates a Highlight layer from parsed Highlight layer data
  54318. * @param parsedHightlightLayer defines the Highlight layer data
  54319. * @param scene defines the current scene
  54320. * @param rootUrl defines the root URL containing the Highlight layer information
  54321. * @returns a parsed Highlight layer
  54322. */
  54323. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54324. }
  54325. }
  54326. declare module BABYLON {
  54327. interface AbstractScene {
  54328. /**
  54329. * The list of layers (background and foreground) of the scene
  54330. */
  54331. layers: Array<Layer>;
  54332. }
  54333. /**
  54334. * Defines the layer scene component responsible to manage any layers
  54335. * in a given scene.
  54336. */
  54337. export class LayerSceneComponent implements ISceneComponent {
  54338. /**
  54339. * The component name helpfull to identify the component in the list of scene components.
  54340. */
  54341. readonly name: string;
  54342. /**
  54343. * The scene the component belongs to.
  54344. */
  54345. scene: Scene;
  54346. private _engine;
  54347. /**
  54348. * Creates a new instance of the component for the given scene
  54349. * @param scene Defines the scene to register the component in
  54350. */
  54351. constructor(scene: Scene);
  54352. /**
  54353. * Registers the component in a given scene
  54354. */
  54355. register(): void;
  54356. /**
  54357. * Rebuilds the elements related to this component in case of
  54358. * context lost for instance.
  54359. */
  54360. rebuild(): void;
  54361. /**
  54362. * Disposes the component and the associated ressources.
  54363. */
  54364. dispose(): void;
  54365. private _draw;
  54366. private _drawCameraPredicate;
  54367. private _drawCameraBackground;
  54368. private _drawCameraForeground;
  54369. private _drawRenderTargetPredicate;
  54370. private _drawRenderTargetBackground;
  54371. private _drawRenderTargetForeground;
  54372. /**
  54373. * Adds all the elements from the container to the scene
  54374. * @param container the container holding the elements
  54375. */
  54376. addFromContainer(container: AbstractScene): void;
  54377. /**
  54378. * Removes all the elements in the container from the scene
  54379. * @param container contains the elements to remove
  54380. * @param dispose if the removed element should be disposed (default: false)
  54381. */
  54382. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54383. }
  54384. }
  54385. declare module BABYLON {
  54386. /** @hidden */
  54387. export var layerPixelShader: {
  54388. name: string;
  54389. shader: string;
  54390. };
  54391. }
  54392. declare module BABYLON {
  54393. /** @hidden */
  54394. export var layerVertexShader: {
  54395. name: string;
  54396. shader: string;
  54397. };
  54398. }
  54399. declare module BABYLON {
  54400. /**
  54401. * This represents a full screen 2d layer.
  54402. * This can be useful to display a picture in the background of your scene for instance.
  54403. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54404. */
  54405. export class Layer {
  54406. /**
  54407. * Define the name of the layer.
  54408. */
  54409. name: string;
  54410. /**
  54411. * Define the texture the layer should display.
  54412. */
  54413. texture: Nullable<Texture>;
  54414. /**
  54415. * Is the layer in background or foreground.
  54416. */
  54417. isBackground: boolean;
  54418. /**
  54419. * Define the color of the layer (instead of texture).
  54420. */
  54421. color: Color4;
  54422. /**
  54423. * Define the scale of the layer in order to zoom in out of the texture.
  54424. */
  54425. scale: Vector2;
  54426. /**
  54427. * Define an offset for the layer in order to shift the texture.
  54428. */
  54429. offset: Vector2;
  54430. /**
  54431. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54432. */
  54433. alphaBlendingMode: number;
  54434. /**
  54435. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54436. * Alpha test will not mix with the background color in case of transparency.
  54437. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54438. */
  54439. alphaTest: boolean;
  54440. /**
  54441. * Define a mask to restrict the layer to only some of the scene cameras.
  54442. */
  54443. layerMask: number;
  54444. /**
  54445. * Define the list of render target the layer is visible into.
  54446. */
  54447. renderTargetTextures: RenderTargetTexture[];
  54448. /**
  54449. * Define if the layer is only used in renderTarget or if it also
  54450. * renders in the main frame buffer of the canvas.
  54451. */
  54452. renderOnlyInRenderTargetTextures: boolean;
  54453. private _scene;
  54454. private _vertexBuffers;
  54455. private _indexBuffer;
  54456. private _effect;
  54457. private _previousDefines;
  54458. /**
  54459. * An event triggered when the layer is disposed.
  54460. */
  54461. onDisposeObservable: Observable<Layer>;
  54462. private _onDisposeObserver;
  54463. /**
  54464. * Back compatibility with callback before the onDisposeObservable existed.
  54465. * The set callback will be triggered when the layer has been disposed.
  54466. */
  54467. set onDispose(callback: () => void);
  54468. /**
  54469. * An event triggered before rendering the scene
  54470. */
  54471. onBeforeRenderObservable: Observable<Layer>;
  54472. private _onBeforeRenderObserver;
  54473. /**
  54474. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54475. * The set callback will be triggered just before rendering the layer.
  54476. */
  54477. set onBeforeRender(callback: () => void);
  54478. /**
  54479. * An event triggered after rendering the scene
  54480. */
  54481. onAfterRenderObservable: Observable<Layer>;
  54482. private _onAfterRenderObserver;
  54483. /**
  54484. * Back compatibility with callback before the onAfterRenderObservable existed.
  54485. * The set callback will be triggered just after rendering the layer.
  54486. */
  54487. set onAfterRender(callback: () => void);
  54488. /**
  54489. * Instantiates a new layer.
  54490. * This represents a full screen 2d layer.
  54491. * This can be useful to display a picture in the background of your scene for instance.
  54492. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54493. * @param name Define the name of the layer in the scene
  54494. * @param imgUrl Define the url of the texture to display in the layer
  54495. * @param scene Define the scene the layer belongs to
  54496. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54497. * @param color Defines a color for the layer
  54498. */
  54499. constructor(
  54500. /**
  54501. * Define the name of the layer.
  54502. */
  54503. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54504. private _createIndexBuffer;
  54505. /** @hidden */
  54506. _rebuild(): void;
  54507. /**
  54508. * Renders the layer in the scene.
  54509. */
  54510. render(): void;
  54511. /**
  54512. * Disposes and releases the associated ressources.
  54513. */
  54514. dispose(): void;
  54515. }
  54516. }
  54517. declare module BABYLON {
  54518. /** @hidden */
  54519. export var lensFlarePixelShader: {
  54520. name: string;
  54521. shader: string;
  54522. };
  54523. }
  54524. declare module BABYLON {
  54525. /** @hidden */
  54526. export var lensFlareVertexShader: {
  54527. name: string;
  54528. shader: string;
  54529. };
  54530. }
  54531. declare module BABYLON {
  54532. /**
  54533. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54534. * It is usually composed of several `lensFlare`.
  54535. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54536. */
  54537. export class LensFlareSystem {
  54538. /**
  54539. * Define the name of the lens flare system
  54540. */
  54541. name: string;
  54542. /**
  54543. * List of lens flares used in this system.
  54544. */
  54545. lensFlares: LensFlare[];
  54546. /**
  54547. * Define a limit from the border the lens flare can be visible.
  54548. */
  54549. borderLimit: number;
  54550. /**
  54551. * Define a viewport border we do not want to see the lens flare in.
  54552. */
  54553. viewportBorder: number;
  54554. /**
  54555. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54556. */
  54557. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54558. /**
  54559. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54560. */
  54561. layerMask: number;
  54562. /**
  54563. * Define the id of the lens flare system in the scene.
  54564. * (equal to name by default)
  54565. */
  54566. id: string;
  54567. private _scene;
  54568. private _emitter;
  54569. private _vertexBuffers;
  54570. private _indexBuffer;
  54571. private _effect;
  54572. private _positionX;
  54573. private _positionY;
  54574. private _isEnabled;
  54575. /** @hidden */
  54576. static _SceneComponentInitialization: (scene: Scene) => void;
  54577. /**
  54578. * Instantiates a lens flare system.
  54579. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54580. * It is usually composed of several `lensFlare`.
  54581. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54582. * @param name Define the name of the lens flare system in the scene
  54583. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54584. * @param scene Define the scene the lens flare system belongs to
  54585. */
  54586. constructor(
  54587. /**
  54588. * Define the name of the lens flare system
  54589. */
  54590. name: string, emitter: any, scene: Scene);
  54591. /**
  54592. * Define if the lens flare system is enabled.
  54593. */
  54594. get isEnabled(): boolean;
  54595. set isEnabled(value: boolean);
  54596. /**
  54597. * Get the scene the effects belongs to.
  54598. * @returns the scene holding the lens flare system
  54599. */
  54600. getScene(): Scene;
  54601. /**
  54602. * Get the emitter of the lens flare system.
  54603. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54604. * @returns the emitter of the lens flare system
  54605. */
  54606. getEmitter(): any;
  54607. /**
  54608. * Set the emitter of the lens flare system.
  54609. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54610. * @param newEmitter Define the new emitter of the system
  54611. */
  54612. setEmitter(newEmitter: any): void;
  54613. /**
  54614. * Get the lens flare system emitter position.
  54615. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54616. * @returns the position
  54617. */
  54618. getEmitterPosition(): Vector3;
  54619. /**
  54620. * @hidden
  54621. */
  54622. computeEffectivePosition(globalViewport: Viewport): boolean;
  54623. /** @hidden */
  54624. _isVisible(): boolean;
  54625. /**
  54626. * @hidden
  54627. */
  54628. render(): boolean;
  54629. /**
  54630. * Dispose and release the lens flare with its associated resources.
  54631. */
  54632. dispose(): void;
  54633. /**
  54634. * Parse a lens flare system from a JSON repressentation
  54635. * @param parsedLensFlareSystem Define the JSON to parse
  54636. * @param scene Define the scene the parsed system should be instantiated in
  54637. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54638. * @returns the parsed system
  54639. */
  54640. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54641. /**
  54642. * Serialize the current Lens Flare System into a JSON representation.
  54643. * @returns the serialized JSON
  54644. */
  54645. serialize(): any;
  54646. }
  54647. }
  54648. declare module BABYLON {
  54649. /**
  54650. * This represents one of the lens effect in a `lensFlareSystem`.
  54651. * It controls one of the indiviual texture used in the effect.
  54652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54653. */
  54654. export class LensFlare {
  54655. /**
  54656. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54657. */
  54658. size: number;
  54659. /**
  54660. * 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.
  54661. */
  54662. position: number;
  54663. /**
  54664. * Define the lens color.
  54665. */
  54666. color: Color3;
  54667. /**
  54668. * Define the lens texture.
  54669. */
  54670. texture: Nullable<Texture>;
  54671. /**
  54672. * Define the alpha mode to render this particular lens.
  54673. */
  54674. alphaMode: number;
  54675. private _system;
  54676. /**
  54677. * Creates a new Lens Flare.
  54678. * This represents one of the lens effect in a `lensFlareSystem`.
  54679. * It controls one of the indiviual texture used in the effect.
  54680. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54681. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54682. * @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.
  54683. * @param color Define the lens color
  54684. * @param imgUrl Define the lens texture url
  54685. * @param system Define the `lensFlareSystem` this flare is part of
  54686. * @returns The newly created Lens Flare
  54687. */
  54688. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54689. /**
  54690. * Instantiates a new Lens Flare.
  54691. * This represents one of the lens effect in a `lensFlareSystem`.
  54692. * It controls one of the indiviual texture used in the effect.
  54693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54694. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54695. * @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.
  54696. * @param color Define the lens color
  54697. * @param imgUrl Define the lens texture url
  54698. * @param system Define the `lensFlareSystem` this flare is part of
  54699. */
  54700. constructor(
  54701. /**
  54702. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54703. */
  54704. size: number,
  54705. /**
  54706. * 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.
  54707. */
  54708. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54709. /**
  54710. * Dispose and release the lens flare with its associated resources.
  54711. */
  54712. dispose(): void;
  54713. }
  54714. }
  54715. declare module BABYLON {
  54716. interface AbstractScene {
  54717. /**
  54718. * The list of lens flare system added to the scene
  54719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54720. */
  54721. lensFlareSystems: Array<LensFlareSystem>;
  54722. /**
  54723. * Removes the given lens flare system from this scene.
  54724. * @param toRemove The lens flare system to remove
  54725. * @returns The index of the removed lens flare system
  54726. */
  54727. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54728. /**
  54729. * Adds the given lens flare system to this scene
  54730. * @param newLensFlareSystem The lens flare system to add
  54731. */
  54732. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54733. /**
  54734. * Gets a lens flare system using its name
  54735. * @param name defines the name to look for
  54736. * @returns the lens flare system or null if not found
  54737. */
  54738. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54739. /**
  54740. * Gets a lens flare system using its id
  54741. * @param id defines the id to look for
  54742. * @returns the lens flare system or null if not found
  54743. */
  54744. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54745. }
  54746. /**
  54747. * Defines the lens flare scene component responsible to manage any lens flares
  54748. * in a given scene.
  54749. */
  54750. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54751. /**
  54752. * The component name helpfull to identify the component in the list of scene components.
  54753. */
  54754. readonly name: string;
  54755. /**
  54756. * The scene the component belongs to.
  54757. */
  54758. scene: Scene;
  54759. /**
  54760. * Creates a new instance of the component for the given scene
  54761. * @param scene Defines the scene to register the component in
  54762. */
  54763. constructor(scene: Scene);
  54764. /**
  54765. * Registers the component in a given scene
  54766. */
  54767. register(): void;
  54768. /**
  54769. * Rebuilds the elements related to this component in case of
  54770. * context lost for instance.
  54771. */
  54772. rebuild(): void;
  54773. /**
  54774. * Adds all the elements from the container to the scene
  54775. * @param container the container holding the elements
  54776. */
  54777. addFromContainer(container: AbstractScene): void;
  54778. /**
  54779. * Removes all the elements in the container from the scene
  54780. * @param container contains the elements to remove
  54781. * @param dispose if the removed element should be disposed (default: false)
  54782. */
  54783. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54784. /**
  54785. * Serializes the component data to the specified json object
  54786. * @param serializationObject The object to serialize to
  54787. */
  54788. serialize(serializationObject: any): void;
  54789. /**
  54790. * Disposes the component and the associated ressources.
  54791. */
  54792. dispose(): void;
  54793. private _draw;
  54794. }
  54795. }
  54796. declare module BABYLON {
  54797. /** @hidden */
  54798. export var depthPixelShader: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module BABYLON {
  54804. /** @hidden */
  54805. export var depthVertexShader: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module BABYLON {
  54811. /**
  54812. * This represents a depth renderer in Babylon.
  54813. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54814. */
  54815. export class DepthRenderer {
  54816. private _scene;
  54817. private _depthMap;
  54818. private _effect;
  54819. private readonly _storeNonLinearDepth;
  54820. private readonly _clearColor;
  54821. /** Get if the depth renderer is using packed depth or not */
  54822. readonly isPacked: boolean;
  54823. private _cachedDefines;
  54824. private _camera;
  54825. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54826. enabled: boolean;
  54827. /**
  54828. * Specifiess that the depth renderer will only be used within
  54829. * the camera it is created for.
  54830. * This can help forcing its rendering during the camera processing.
  54831. */
  54832. useOnlyInActiveCamera: boolean;
  54833. /** @hidden */
  54834. static _SceneComponentInitialization: (scene: Scene) => void;
  54835. /**
  54836. * Instantiates a depth renderer
  54837. * @param scene The scene the renderer belongs to
  54838. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54839. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54840. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54841. */
  54842. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54843. /**
  54844. * Creates the depth rendering effect and checks if the effect is ready.
  54845. * @param subMesh The submesh to be used to render the depth map of
  54846. * @param useInstances If multiple world instances should be used
  54847. * @returns if the depth renderer is ready to render the depth map
  54848. */
  54849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54850. /**
  54851. * Gets the texture which the depth map will be written to.
  54852. * @returns The depth map texture
  54853. */
  54854. getDepthMap(): RenderTargetTexture;
  54855. /**
  54856. * Disposes of the depth renderer.
  54857. */
  54858. dispose(): void;
  54859. }
  54860. }
  54861. declare module BABYLON {
  54862. /** @hidden */
  54863. export var minmaxReduxPixelShader: {
  54864. name: string;
  54865. shader: string;
  54866. };
  54867. }
  54868. declare module BABYLON {
  54869. /**
  54870. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54871. * and maximum values from all values of the texture.
  54872. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54873. * The source values are read from the red channel of the texture.
  54874. */
  54875. export class MinMaxReducer {
  54876. /**
  54877. * Observable triggered when the computation has been performed
  54878. */
  54879. onAfterReductionPerformed: Observable<{
  54880. min: number;
  54881. max: number;
  54882. }>;
  54883. protected _camera: Camera;
  54884. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54885. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54886. protected _postProcessManager: PostProcessManager;
  54887. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54888. protected _forceFullscreenViewport: boolean;
  54889. /**
  54890. * Creates a min/max reducer
  54891. * @param camera The camera to use for the post processes
  54892. */
  54893. constructor(camera: Camera);
  54894. /**
  54895. * Gets the texture used to read the values from.
  54896. */
  54897. get sourceTexture(): Nullable<RenderTargetTexture>;
  54898. /**
  54899. * Sets the source texture to read the values from.
  54900. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54901. * because in such textures '1' value must not be taken into account to compute the maximum
  54902. * as this value is used to clear the texture.
  54903. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54904. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54905. * @param depthRedux Indicates if the texture is a depth texture or not
  54906. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54907. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54908. */
  54909. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54910. /**
  54911. * Defines the refresh rate of the computation.
  54912. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54913. */
  54914. get refreshRate(): number;
  54915. set refreshRate(value: number);
  54916. protected _activated: boolean;
  54917. /**
  54918. * Gets the activation status of the reducer
  54919. */
  54920. get activated(): boolean;
  54921. /**
  54922. * Activates the reduction computation.
  54923. * When activated, the observers registered in onAfterReductionPerformed are
  54924. * called after the compuation is performed
  54925. */
  54926. activate(): void;
  54927. /**
  54928. * Deactivates the reduction computation.
  54929. */
  54930. deactivate(): void;
  54931. /**
  54932. * Disposes the min/max reducer
  54933. * @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.
  54934. */
  54935. dispose(disposeAll?: boolean): void;
  54936. }
  54937. }
  54938. declare module BABYLON {
  54939. /**
  54940. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54941. */
  54942. export class DepthReducer extends MinMaxReducer {
  54943. private _depthRenderer;
  54944. private _depthRendererId;
  54945. /**
  54946. * Gets the depth renderer used for the computation.
  54947. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54948. */
  54949. get depthRenderer(): Nullable<DepthRenderer>;
  54950. /**
  54951. * Creates a depth reducer
  54952. * @param camera The camera used to render the depth texture
  54953. */
  54954. constructor(camera: Camera);
  54955. /**
  54956. * Sets the depth renderer to use to generate the depth map
  54957. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54958. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54959. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54960. */
  54961. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54962. /** @hidden */
  54963. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54964. /**
  54965. * Activates the reduction computation.
  54966. * When activated, the observers registered in onAfterReductionPerformed are
  54967. * called after the compuation is performed
  54968. */
  54969. activate(): void;
  54970. /**
  54971. * Deactivates the reduction computation.
  54972. */
  54973. deactivate(): void;
  54974. /**
  54975. * Disposes the depth reducer
  54976. * @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.
  54977. */
  54978. dispose(disposeAll?: boolean): void;
  54979. }
  54980. }
  54981. declare module BABYLON {
  54982. /**
  54983. * A CSM implementation allowing casting shadows on large scenes.
  54984. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54985. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54986. */
  54987. export class CascadedShadowGenerator extends ShadowGenerator {
  54988. private static readonly frustumCornersNDCSpace;
  54989. /**
  54990. * Name of the CSM class
  54991. */
  54992. static CLASSNAME: string;
  54993. /**
  54994. * Defines the default number of cascades used by the CSM.
  54995. */
  54996. static readonly DEFAULT_CASCADES_COUNT: number;
  54997. /**
  54998. * Defines the minimum number of cascades used by the CSM.
  54999. */
  55000. static readonly MIN_CASCADES_COUNT: number;
  55001. /**
  55002. * Defines the maximum number of cascades used by the CSM.
  55003. */
  55004. static readonly MAX_CASCADES_COUNT: number;
  55005. protected _validateFilter(filter: number): number;
  55006. /**
  55007. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  55008. */
  55009. penumbraDarkness: number;
  55010. private _numCascades;
  55011. /**
  55012. * Gets or set the number of cascades used by the CSM.
  55013. */
  55014. get numCascades(): number;
  55015. set numCascades(value: number);
  55016. /**
  55017. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  55018. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  55019. */
  55020. stabilizeCascades: boolean;
  55021. private _freezeShadowCastersBoundingInfo;
  55022. private _freezeShadowCastersBoundingInfoObservable;
  55023. /**
  55024. * Enables or disables the shadow casters bounding info computation.
  55025. * If your shadow casters don't move, you can disable this feature.
  55026. * If it is enabled, the bounding box computation is done every frame.
  55027. */
  55028. get freezeShadowCastersBoundingInfo(): boolean;
  55029. set freezeShadowCastersBoundingInfo(freeze: boolean);
  55030. private _scbiMin;
  55031. private _scbiMax;
  55032. protected _computeShadowCastersBoundingInfo(): void;
  55033. protected _shadowCastersBoundingInfo: BoundingInfo;
  55034. /**
  55035. * Gets or sets the shadow casters bounding info.
  55036. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  55037. * so that the system won't overwrite the bounds you provide
  55038. */
  55039. get shadowCastersBoundingInfo(): BoundingInfo;
  55040. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  55041. protected _breaksAreDirty: boolean;
  55042. protected _minDistance: number;
  55043. protected _maxDistance: number;
  55044. /**
  55045. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  55046. *
  55047. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  55048. * If you don't know these values, simply leave them to their defaults and don't call this function.
  55049. * @param min minimal distance for the breaks (default to 0.)
  55050. * @param max maximal distance for the breaks (default to 1.)
  55051. */
  55052. setMinMaxDistance(min: number, max: number): void;
  55053. /** Gets the minimal distance used in the cascade break computation */
  55054. get minDistance(): number;
  55055. /** Gets the maximal distance used in the cascade break computation */
  55056. get maxDistance(): number;
  55057. /**
  55058. * Gets the class name of that object
  55059. * @returns "CascadedShadowGenerator"
  55060. */
  55061. getClassName(): string;
  55062. private _cascadeMinExtents;
  55063. private _cascadeMaxExtents;
  55064. /**
  55065. * Gets a cascade minimum extents
  55066. * @param cascadeIndex index of the cascade
  55067. * @returns the minimum cascade extents
  55068. */
  55069. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  55070. /**
  55071. * Gets a cascade maximum extents
  55072. * @param cascadeIndex index of the cascade
  55073. * @returns the maximum cascade extents
  55074. */
  55075. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55076. private _cascades;
  55077. private _currentLayer;
  55078. private _viewSpaceFrustumsZ;
  55079. private _viewMatrices;
  55080. private _projectionMatrices;
  55081. private _transformMatrices;
  55082. private _transformMatricesAsArray;
  55083. private _frustumLengths;
  55084. private _lightSizeUVCorrection;
  55085. private _depthCorrection;
  55086. private _frustumCornersWorldSpace;
  55087. private _frustumCenter;
  55088. private _shadowCameraPos;
  55089. private _shadowMaxZ;
  55090. /**
  55091. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55092. * It defaults to camera.maxZ
  55093. */
  55094. get shadowMaxZ(): number;
  55095. /**
  55096. * Sets the shadow max z distance.
  55097. */
  55098. set shadowMaxZ(value: number);
  55099. protected _debug: boolean;
  55100. /**
  55101. * Gets or sets the debug flag.
  55102. * When enabled, the cascades are materialized by different colors on the screen.
  55103. */
  55104. get debug(): boolean;
  55105. set debug(dbg: boolean);
  55106. private _depthClamp;
  55107. /**
  55108. * Gets or sets the depth clamping value.
  55109. *
  55110. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55111. * to account for the shadow casters far away.
  55112. *
  55113. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55114. */
  55115. get depthClamp(): boolean;
  55116. set depthClamp(value: boolean);
  55117. private _cascadeBlendPercentage;
  55118. /**
  55119. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55120. * It defaults to 0.1 (10% blending).
  55121. */
  55122. get cascadeBlendPercentage(): number;
  55123. set cascadeBlendPercentage(value: number);
  55124. private _lambda;
  55125. /**
  55126. * Gets or set the lambda parameter.
  55127. * This parameter is used to split the camera frustum and create the cascades.
  55128. * 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.
  55129. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55130. */
  55131. get lambda(): number;
  55132. set lambda(value: number);
  55133. /**
  55134. * Gets the view matrix corresponding to a given cascade
  55135. * @param cascadeNum cascade to retrieve the view matrix from
  55136. * @returns the cascade view matrix
  55137. */
  55138. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55139. /**
  55140. * Gets the projection matrix corresponding to a given cascade
  55141. * @param cascadeNum cascade to retrieve the projection matrix from
  55142. * @returns the cascade projection matrix
  55143. */
  55144. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55145. /**
  55146. * Gets the transformation matrix corresponding to a given cascade
  55147. * @param cascadeNum cascade to retrieve the transformation matrix from
  55148. * @returns the cascade transformation matrix
  55149. */
  55150. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55151. private _depthRenderer;
  55152. /**
  55153. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55154. *
  55155. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55156. *
  55157. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55158. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55159. * @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
  55160. */
  55161. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55162. private _depthReducer;
  55163. private _autoCalcDepthBounds;
  55164. /**
  55165. * Gets or sets the autoCalcDepthBounds property.
  55166. *
  55167. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55168. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55169. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55170. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55171. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55172. */
  55173. get autoCalcDepthBounds(): boolean;
  55174. set autoCalcDepthBounds(value: boolean);
  55175. /**
  55176. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55177. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55178. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55179. * for setting the refresh rate on the renderer yourself!
  55180. */
  55181. get autoCalcDepthBoundsRefreshRate(): number;
  55182. set autoCalcDepthBoundsRefreshRate(value: number);
  55183. /**
  55184. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55185. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55186. * you change the camera near/far planes!
  55187. */
  55188. splitFrustum(): void;
  55189. private _splitFrustum;
  55190. private _computeMatrices;
  55191. private _computeFrustumInWorldSpace;
  55192. private _computeCascadeFrustum;
  55193. /**
  55194. * Support test.
  55195. */
  55196. static get IsSupported(): boolean;
  55197. /** @hidden */
  55198. static _SceneComponentInitialization: (scene: Scene) => void;
  55199. /**
  55200. * Creates a Cascaded Shadow Generator object.
  55201. * A ShadowGenerator is the required tool to use the shadows.
  55202. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55203. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55204. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55205. * @param light The directional light object generating the shadows.
  55206. * @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.
  55207. */
  55208. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55209. protected _initializeGenerator(): void;
  55210. protected _createTargetRenderTexture(): void;
  55211. protected _initializeShadowMap(): void;
  55212. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55213. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55214. /**
  55215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55216. * @param defines Defines of the material we want to update
  55217. * @param lightIndex Index of the light in the enabled light list of the material
  55218. */
  55219. prepareDefines(defines: any, lightIndex: number): void;
  55220. /**
  55221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55222. * defined in the generator but impacting the effect).
  55223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55224. * @param effect The effect we are binfing the information for
  55225. */
  55226. bindShadowLight(lightIndex: string, effect: Effect): void;
  55227. /**
  55228. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55229. * (eq to view projection * shadow projection matrices)
  55230. * @returns The transform matrix used to create the shadow map
  55231. */
  55232. getTransformMatrix(): Matrix;
  55233. /**
  55234. * Disposes the ShadowGenerator.
  55235. * Returns nothing.
  55236. */
  55237. dispose(): void;
  55238. /**
  55239. * Serializes the shadow generator setup to a json object.
  55240. * @returns The serialized JSON object
  55241. */
  55242. serialize(): any;
  55243. /**
  55244. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55245. * @param parsedShadowGenerator The JSON object to parse
  55246. * @param scene The scene to create the shadow map for
  55247. * @returns The parsed shadow generator
  55248. */
  55249. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55250. }
  55251. }
  55252. declare module BABYLON {
  55253. /**
  55254. * Defines the shadow generator component responsible to manage any shadow generators
  55255. * in a given scene.
  55256. */
  55257. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55258. /**
  55259. * The component name helpfull to identify the component in the list of scene components.
  55260. */
  55261. readonly name: string;
  55262. /**
  55263. * The scene the component belongs to.
  55264. */
  55265. scene: Scene;
  55266. /**
  55267. * Creates a new instance of the component for the given scene
  55268. * @param scene Defines the scene to register the component in
  55269. */
  55270. constructor(scene: Scene);
  55271. /**
  55272. * Registers the component in a given scene
  55273. */
  55274. register(): void;
  55275. /**
  55276. * Rebuilds the elements related to this component in case of
  55277. * context lost for instance.
  55278. */
  55279. rebuild(): void;
  55280. /**
  55281. * Serializes the component data to the specified json object
  55282. * @param serializationObject The object to serialize to
  55283. */
  55284. serialize(serializationObject: any): void;
  55285. /**
  55286. * Adds all the elements from the container to the scene
  55287. * @param container the container holding the elements
  55288. */
  55289. addFromContainer(container: AbstractScene): void;
  55290. /**
  55291. * Removes all the elements in the container from the scene
  55292. * @param container contains the elements to remove
  55293. * @param dispose if the removed element should be disposed (default: false)
  55294. */
  55295. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55296. /**
  55297. * Rebuilds the elements related to this component in case of
  55298. * context lost for instance.
  55299. */
  55300. dispose(): void;
  55301. private _gatherRenderTargets;
  55302. }
  55303. }
  55304. declare module BABYLON {
  55305. /**
  55306. * A point light is a light defined by an unique point in world space.
  55307. * The light is emitted in every direction from this point.
  55308. * A good example of a point light is a standard light bulb.
  55309. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55310. */
  55311. export class PointLight extends ShadowLight {
  55312. private _shadowAngle;
  55313. /**
  55314. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55315. * This specifies what angle the shadow will use to be created.
  55316. *
  55317. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55318. */
  55319. get shadowAngle(): number;
  55320. /**
  55321. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55322. * This specifies what angle the shadow will use to be created.
  55323. *
  55324. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55325. */
  55326. set shadowAngle(value: number);
  55327. /**
  55328. * Gets the direction if it has been set.
  55329. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55330. */
  55331. get direction(): Vector3;
  55332. /**
  55333. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55334. */
  55335. set direction(value: Vector3);
  55336. /**
  55337. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55338. * A PointLight emits the light in every direction.
  55339. * It can cast shadows.
  55340. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55341. * ```javascript
  55342. * var pointLight = new PointLight("pl", camera.position, scene);
  55343. * ```
  55344. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55345. * @param name The light friendly name
  55346. * @param position The position of the point light in the scene
  55347. * @param scene The scene the lights belongs to
  55348. */
  55349. constructor(name: string, position: Vector3, scene: Scene);
  55350. /**
  55351. * Returns the string "PointLight"
  55352. * @returns the class name
  55353. */
  55354. getClassName(): string;
  55355. /**
  55356. * Returns the integer 0.
  55357. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55358. */
  55359. getTypeID(): number;
  55360. /**
  55361. * Specifies wether or not the shadowmap should be a cube texture.
  55362. * @returns true if the shadowmap needs to be a cube texture.
  55363. */
  55364. needCube(): boolean;
  55365. /**
  55366. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55367. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55368. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55369. */
  55370. getShadowDirection(faceIndex?: number): Vector3;
  55371. /**
  55372. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55373. * - fov = PI / 2
  55374. * - aspect ratio : 1.0
  55375. * - z-near and far equal to the active camera minZ and maxZ.
  55376. * Returns the PointLight.
  55377. */
  55378. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55379. protected _buildUniformLayout(): void;
  55380. /**
  55381. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55382. * @param effect The effect to update
  55383. * @param lightIndex The index of the light in the effect to update
  55384. * @returns The point light
  55385. */
  55386. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55387. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55388. /**
  55389. * Prepares the list of defines specific to the light type.
  55390. * @param defines the list of defines
  55391. * @param lightIndex defines the index of the light for the effect
  55392. */
  55393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55394. }
  55395. }
  55396. declare module BABYLON {
  55397. /**
  55398. * Header information of HDR texture files.
  55399. */
  55400. export interface HDRInfo {
  55401. /**
  55402. * The height of the texture in pixels.
  55403. */
  55404. height: number;
  55405. /**
  55406. * The width of the texture in pixels.
  55407. */
  55408. width: number;
  55409. /**
  55410. * The index of the beginning of the data in the binary file.
  55411. */
  55412. dataPosition: number;
  55413. }
  55414. /**
  55415. * This groups tools to convert HDR texture to native colors array.
  55416. */
  55417. export class HDRTools {
  55418. private static Ldexp;
  55419. private static Rgbe2float;
  55420. private static readStringLine;
  55421. /**
  55422. * Reads header information from an RGBE texture stored in a native array.
  55423. * More information on this format are available here:
  55424. * https://en.wikipedia.org/wiki/RGBE_image_format
  55425. *
  55426. * @param uint8array The binary file stored in native array.
  55427. * @return The header information.
  55428. */
  55429. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55430. /**
  55431. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55432. * This RGBE texture needs to store the information as a panorama.
  55433. *
  55434. * More information on this format are available here:
  55435. * https://en.wikipedia.org/wiki/RGBE_image_format
  55436. *
  55437. * @param buffer The binary file stored in an array buffer.
  55438. * @param size The expected size of the extracted cubemap.
  55439. * @return The Cube Map information.
  55440. */
  55441. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55442. /**
  55443. * Returns the pixels data extracted from an RGBE texture.
  55444. * This pixels will be stored left to right up to down in the R G B order in one array.
  55445. *
  55446. * More information on this format are available here:
  55447. * https://en.wikipedia.org/wiki/RGBE_image_format
  55448. *
  55449. * @param uint8array The binary file stored in an array buffer.
  55450. * @param hdrInfo The header information of the file.
  55451. * @return The pixels data in RGB right to left up to down order.
  55452. */
  55453. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55454. private static RGBE_ReadPixels_RLE;
  55455. }
  55456. }
  55457. declare module BABYLON {
  55458. /**
  55459. * This represents a texture coming from an HDR input.
  55460. *
  55461. * The only supported format is currently panorama picture stored in RGBE format.
  55462. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55463. */
  55464. export class HDRCubeTexture extends BaseTexture {
  55465. private static _facesMapping;
  55466. private _generateHarmonics;
  55467. private _noMipmap;
  55468. private _textureMatrix;
  55469. private _size;
  55470. private _onLoad;
  55471. private _onError;
  55472. /**
  55473. * The texture URL.
  55474. */
  55475. url: string;
  55476. /**
  55477. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55478. */
  55479. coordinatesMode: number;
  55480. protected _isBlocking: boolean;
  55481. /**
  55482. * Sets wether or not the texture is blocking during loading.
  55483. */
  55484. set isBlocking(value: boolean);
  55485. /**
  55486. * Gets wether or not the texture is blocking during loading.
  55487. */
  55488. get isBlocking(): boolean;
  55489. protected _rotationY: number;
  55490. /**
  55491. * Sets texture matrix rotation angle around Y axis in radians.
  55492. */
  55493. set rotationY(value: number);
  55494. /**
  55495. * Gets texture matrix rotation angle around Y axis radians.
  55496. */
  55497. get rotationY(): number;
  55498. /**
  55499. * Gets or sets the center of the bounding box associated with the cube texture
  55500. * It must define where the camera used to render the texture was set
  55501. */
  55502. boundingBoxPosition: Vector3;
  55503. private _boundingBoxSize;
  55504. /**
  55505. * Gets or sets the size of the bounding box associated with the cube texture
  55506. * When defined, the cubemap will switch to local mode
  55507. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55508. * @example https://www.babylonjs-playground.com/#RNASML
  55509. */
  55510. set boundingBoxSize(value: Vector3);
  55511. get boundingBoxSize(): Vector3;
  55512. /**
  55513. * Instantiates an HDRTexture from the following parameters.
  55514. *
  55515. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55516. * @param scene The scene the texture will be used in
  55517. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55518. * @param noMipmap Forces to not generate the mipmap if true
  55519. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55520. * @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)
  55521. * @param reserved Reserved flag for internal use.
  55522. */
  55523. 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>);
  55524. /**
  55525. * Get the current class name of the texture useful for serialization or dynamic coding.
  55526. * @returns "HDRCubeTexture"
  55527. */
  55528. getClassName(): string;
  55529. /**
  55530. * Occurs when the file is raw .hdr file.
  55531. */
  55532. private loadTexture;
  55533. clone(): HDRCubeTexture;
  55534. delayLoad(): void;
  55535. /**
  55536. * Get the texture reflection matrix used to rotate/transform the reflection.
  55537. * @returns the reflection matrix
  55538. */
  55539. getReflectionTextureMatrix(): Matrix;
  55540. /**
  55541. * Set the texture reflection matrix used to rotate/transform the reflection.
  55542. * @param value Define the reflection matrix to set
  55543. */
  55544. setReflectionTextureMatrix(value: Matrix): void;
  55545. /**
  55546. * Parses a JSON representation of an HDR Texture in order to create the texture
  55547. * @param parsedTexture Define the JSON representation
  55548. * @param scene Define the scene the texture should be created in
  55549. * @param rootUrl Define the root url in case we need to load relative dependencies
  55550. * @returns the newly created texture after parsing
  55551. */
  55552. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55553. serialize(): any;
  55554. }
  55555. }
  55556. declare module BABYLON {
  55557. /**
  55558. * Class used to control physics engine
  55559. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55560. */
  55561. export class PhysicsEngine implements IPhysicsEngine {
  55562. private _physicsPlugin;
  55563. /**
  55564. * Global value used to control the smallest number supported by the simulation
  55565. */
  55566. static Epsilon: number;
  55567. private _impostors;
  55568. private _joints;
  55569. private _subTimeStep;
  55570. /**
  55571. * Gets the gravity vector used by the simulation
  55572. */
  55573. gravity: Vector3;
  55574. /**
  55575. * Factory used to create the default physics plugin.
  55576. * @returns The default physics plugin
  55577. */
  55578. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55579. /**
  55580. * Creates a new Physics Engine
  55581. * @param gravity defines the gravity vector used by the simulation
  55582. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55583. */
  55584. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55585. /**
  55586. * Sets the gravity vector used by the simulation
  55587. * @param gravity defines the gravity vector to use
  55588. */
  55589. setGravity(gravity: Vector3): void;
  55590. /**
  55591. * Set the time step of the physics engine.
  55592. * Default is 1/60.
  55593. * To slow it down, enter 1/600 for example.
  55594. * To speed it up, 1/30
  55595. * @param newTimeStep defines the new timestep to apply to this world.
  55596. */
  55597. setTimeStep(newTimeStep?: number): void;
  55598. /**
  55599. * Get the time step of the physics engine.
  55600. * @returns the current time step
  55601. */
  55602. getTimeStep(): number;
  55603. /**
  55604. * Set the sub time step of the physics engine.
  55605. * Default is 0 meaning there is no sub steps
  55606. * To increase physics resolution precision, set a small value (like 1 ms)
  55607. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55608. */
  55609. setSubTimeStep(subTimeStep?: number): void;
  55610. /**
  55611. * Get the sub time step of the physics engine.
  55612. * @returns the current sub time step
  55613. */
  55614. getSubTimeStep(): number;
  55615. /**
  55616. * Release all resources
  55617. */
  55618. dispose(): void;
  55619. /**
  55620. * Gets the name of the current physics plugin
  55621. * @returns the name of the plugin
  55622. */
  55623. getPhysicsPluginName(): string;
  55624. /**
  55625. * Adding a new impostor for the impostor tracking.
  55626. * This will be done by the impostor itself.
  55627. * @param impostor the impostor to add
  55628. */
  55629. addImpostor(impostor: PhysicsImpostor): void;
  55630. /**
  55631. * Remove an impostor from the engine.
  55632. * This impostor and its mesh will not longer be updated by the physics engine.
  55633. * @param impostor the impostor to remove
  55634. */
  55635. removeImpostor(impostor: PhysicsImpostor): void;
  55636. /**
  55637. * Add a joint to the physics engine
  55638. * @param mainImpostor defines the main impostor to which the joint is added.
  55639. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55640. * @param joint defines the joint that will connect both impostors.
  55641. */
  55642. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55643. /**
  55644. * Removes a joint from the simulation
  55645. * @param mainImpostor defines the impostor used with the joint
  55646. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55647. * @param joint defines the joint to remove
  55648. */
  55649. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55650. /**
  55651. * Called by the scene. No need to call it.
  55652. * @param delta defines the timespam between frames
  55653. */
  55654. _step(delta: number): void;
  55655. /**
  55656. * Gets the current plugin used to run the simulation
  55657. * @returns current plugin
  55658. */
  55659. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55660. /**
  55661. * Gets the list of physic impostors
  55662. * @returns an array of PhysicsImpostor
  55663. */
  55664. getImpostors(): Array<PhysicsImpostor>;
  55665. /**
  55666. * Gets the impostor for a physics enabled object
  55667. * @param object defines the object impersonated by the impostor
  55668. * @returns the PhysicsImpostor or null if not found
  55669. */
  55670. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55671. /**
  55672. * Gets the impostor for a physics body object
  55673. * @param body defines physics body used by the impostor
  55674. * @returns the PhysicsImpostor or null if not found
  55675. */
  55676. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55677. /**
  55678. * Does a raycast in the physics world
  55679. * @param from when should the ray start?
  55680. * @param to when should the ray end?
  55681. * @returns PhysicsRaycastResult
  55682. */
  55683. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55684. }
  55685. }
  55686. declare module BABYLON {
  55687. /** @hidden */
  55688. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55689. private _useDeltaForWorldStep;
  55690. world: any;
  55691. name: string;
  55692. private _physicsMaterials;
  55693. private _fixedTimeStep;
  55694. private _cannonRaycastResult;
  55695. private _raycastResult;
  55696. private _physicsBodysToRemoveAfterStep;
  55697. BJSCANNON: any;
  55698. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55699. setGravity(gravity: Vector3): void;
  55700. setTimeStep(timeStep: number): void;
  55701. getTimeStep(): number;
  55702. executeStep(delta: number): void;
  55703. private _removeMarkedPhysicsBodiesFromWorld;
  55704. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55705. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55706. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55707. private _processChildMeshes;
  55708. removePhysicsBody(impostor: PhysicsImpostor): void;
  55709. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55710. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55711. private _addMaterial;
  55712. private _checkWithEpsilon;
  55713. private _createShape;
  55714. private _createHeightmap;
  55715. private _minus90X;
  55716. private _plus90X;
  55717. private _tmpPosition;
  55718. private _tmpDeltaPosition;
  55719. private _tmpUnityRotation;
  55720. private _updatePhysicsBodyTransformation;
  55721. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55722. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55723. isSupported(): boolean;
  55724. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55725. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55726. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55727. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55728. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55729. getBodyMass(impostor: PhysicsImpostor): number;
  55730. getBodyFriction(impostor: PhysicsImpostor): number;
  55731. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55732. getBodyRestitution(impostor: PhysicsImpostor): number;
  55733. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55734. sleepBody(impostor: PhysicsImpostor): void;
  55735. wakeUpBody(impostor: PhysicsImpostor): void;
  55736. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55737. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55738. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55739. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55740. getRadius(impostor: PhysicsImpostor): number;
  55741. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55742. dispose(): void;
  55743. private _extendNamespace;
  55744. /**
  55745. * Does a raycast in the physics world
  55746. * @param from when should the ray start?
  55747. * @param to when should the ray end?
  55748. * @returns PhysicsRaycastResult
  55749. */
  55750. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55751. }
  55752. }
  55753. declare module BABYLON {
  55754. /** @hidden */
  55755. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55756. private _useDeltaForWorldStep;
  55757. world: any;
  55758. name: string;
  55759. BJSOIMO: any;
  55760. private _raycastResult;
  55761. private _fixedTimeStep;
  55762. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55763. setGravity(gravity: Vector3): void;
  55764. setTimeStep(timeStep: number): void;
  55765. getTimeStep(): number;
  55766. private _tmpImpostorsArray;
  55767. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55768. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55769. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55770. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55771. private _tmpPositionVector;
  55772. removePhysicsBody(impostor: PhysicsImpostor): void;
  55773. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55774. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55775. isSupported(): boolean;
  55776. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55777. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55778. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55779. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55780. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55781. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55782. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55783. getBodyMass(impostor: PhysicsImpostor): number;
  55784. getBodyFriction(impostor: PhysicsImpostor): number;
  55785. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55786. getBodyRestitution(impostor: PhysicsImpostor): number;
  55787. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55788. sleepBody(impostor: PhysicsImpostor): void;
  55789. wakeUpBody(impostor: PhysicsImpostor): void;
  55790. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55791. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55792. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55793. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55794. getRadius(impostor: PhysicsImpostor): number;
  55795. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55796. dispose(): void;
  55797. /**
  55798. * Does a raycast in the physics world
  55799. * @param from when should the ray start?
  55800. * @param to when should the ray end?
  55801. * @returns PhysicsRaycastResult
  55802. */
  55803. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55804. }
  55805. }
  55806. declare module BABYLON {
  55807. /**
  55808. * Class containing static functions to help procedurally build meshes
  55809. */
  55810. export class RibbonBuilder {
  55811. /**
  55812. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55813. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55814. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55815. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55816. * * 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
  55817. * * 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
  55818. * * 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
  55819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55820. * * 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
  55821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55822. * * 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
  55823. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55824. * * 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
  55825. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55827. * @param name defines the name of the mesh
  55828. * @param options defines the options used to create the mesh
  55829. * @param scene defines the hosting scene
  55830. * @returns the ribbon mesh
  55831. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55833. */
  55834. static CreateRibbon(name: string, options: {
  55835. pathArray: Vector3[][];
  55836. closeArray?: boolean;
  55837. closePath?: boolean;
  55838. offset?: number;
  55839. updatable?: boolean;
  55840. sideOrientation?: number;
  55841. frontUVs?: Vector4;
  55842. backUVs?: Vector4;
  55843. instance?: Mesh;
  55844. invertUV?: boolean;
  55845. uvs?: Vector2[];
  55846. colors?: Color4[];
  55847. }, scene?: Nullable<Scene>): Mesh;
  55848. }
  55849. }
  55850. declare module BABYLON {
  55851. /**
  55852. * Class containing static functions to help procedurally build meshes
  55853. */
  55854. export class ShapeBuilder {
  55855. /**
  55856. * 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.
  55857. * * 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.
  55858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55859. * * 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.
  55860. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55861. * * 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
  55862. * * 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
  55863. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55865. * * 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
  55866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55868. * @param name defines the name of the mesh
  55869. * @param options defines the options used to create the mesh
  55870. * @param scene defines the hosting scene
  55871. * @returns the extruded shape mesh
  55872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55874. */
  55875. static ExtrudeShape(name: string, options: {
  55876. shape: Vector3[];
  55877. path: Vector3[];
  55878. scale?: number;
  55879. rotation?: number;
  55880. cap?: number;
  55881. updatable?: boolean;
  55882. sideOrientation?: number;
  55883. frontUVs?: Vector4;
  55884. backUVs?: Vector4;
  55885. instance?: Mesh;
  55886. invertUV?: boolean;
  55887. }, scene?: Nullable<Scene>): Mesh;
  55888. /**
  55889. * Creates an custom extruded shape mesh.
  55890. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55891. * * 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.
  55892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55893. * * 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
  55894. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55895. * * 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
  55896. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55897. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55898. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55899. * * 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
  55900. * * 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
  55901. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55903. * * 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
  55904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55906. * @param name defines the name of the mesh
  55907. * @param options defines the options used to create the mesh
  55908. * @param scene defines the hosting scene
  55909. * @returns the custom extruded shape mesh
  55910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55913. */
  55914. static ExtrudeShapeCustom(name: string, options: {
  55915. shape: Vector3[];
  55916. path: Vector3[];
  55917. scaleFunction?: any;
  55918. rotationFunction?: any;
  55919. ribbonCloseArray?: boolean;
  55920. ribbonClosePath?: boolean;
  55921. cap?: number;
  55922. updatable?: boolean;
  55923. sideOrientation?: number;
  55924. frontUVs?: Vector4;
  55925. backUVs?: Vector4;
  55926. instance?: Mesh;
  55927. invertUV?: boolean;
  55928. }, scene?: Nullable<Scene>): Mesh;
  55929. private static _ExtrudeShapeGeneric;
  55930. }
  55931. }
  55932. declare module BABYLON {
  55933. /**
  55934. * AmmoJS Physics plugin
  55935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55936. * @see https://github.com/kripken/ammo.js/
  55937. */
  55938. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55939. private _useDeltaForWorldStep;
  55940. /**
  55941. * Reference to the Ammo library
  55942. */
  55943. bjsAMMO: any;
  55944. /**
  55945. * Created ammoJS world which physics bodies are added to
  55946. */
  55947. world: any;
  55948. /**
  55949. * Name of the plugin
  55950. */
  55951. name: string;
  55952. private _timeStep;
  55953. private _fixedTimeStep;
  55954. private _maxSteps;
  55955. private _tmpQuaternion;
  55956. private _tmpAmmoTransform;
  55957. private _tmpAmmoQuaternion;
  55958. private _tmpAmmoConcreteContactResultCallback;
  55959. private _collisionConfiguration;
  55960. private _dispatcher;
  55961. private _overlappingPairCache;
  55962. private _solver;
  55963. private _softBodySolver;
  55964. private _tmpAmmoVectorA;
  55965. private _tmpAmmoVectorB;
  55966. private _tmpAmmoVectorC;
  55967. private _tmpAmmoVectorD;
  55968. private _tmpContactCallbackResult;
  55969. private _tmpAmmoVectorRCA;
  55970. private _tmpAmmoVectorRCB;
  55971. private _raycastResult;
  55972. private static readonly DISABLE_COLLISION_FLAG;
  55973. private static readonly KINEMATIC_FLAG;
  55974. private static readonly DISABLE_DEACTIVATION_FLAG;
  55975. /**
  55976. * Initializes the ammoJS plugin
  55977. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55978. * @param ammoInjection can be used to inject your own ammo reference
  55979. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55980. */
  55981. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55982. /**
  55983. * Sets the gravity of the physics world (m/(s^2))
  55984. * @param gravity Gravity to set
  55985. */
  55986. setGravity(gravity: Vector3): void;
  55987. /**
  55988. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55989. * @param timeStep timestep to use in seconds
  55990. */
  55991. setTimeStep(timeStep: number): void;
  55992. /**
  55993. * 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)
  55994. * @param fixedTimeStep fixedTimeStep to use in seconds
  55995. */
  55996. setFixedTimeStep(fixedTimeStep: number): void;
  55997. /**
  55998. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55999. * @param maxSteps the maximum number of steps by the physics engine per frame
  56000. */
  56001. setMaxSteps(maxSteps: number): void;
  56002. /**
  56003. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56004. * @returns the current timestep in seconds
  56005. */
  56006. getTimeStep(): number;
  56007. /**
  56008. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56009. */
  56010. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56011. private _isImpostorInContact;
  56012. private _isImpostorPairInContact;
  56013. private _stepSimulation;
  56014. /**
  56015. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56016. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56017. * After the step the babylon meshes are set to the position of the physics imposters
  56018. * @param delta amount of time to step forward
  56019. * @param impostors array of imposters to update before/after the step
  56020. */
  56021. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56022. /**
  56023. * Update babylon mesh to match physics world object
  56024. * @param impostor imposter to match
  56025. */
  56026. private _afterSoftStep;
  56027. /**
  56028. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56029. * @param impostor imposter to match
  56030. */
  56031. private _ropeStep;
  56032. /**
  56033. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56034. * @param impostor imposter to match
  56035. */
  56036. private _softbodyOrClothStep;
  56037. private _tmpMatrix;
  56038. /**
  56039. * Applies an impulse on the imposter
  56040. * @param impostor imposter to apply impulse to
  56041. * @param force amount of force to be applied to the imposter
  56042. * @param contactPoint the location to apply the impulse on the imposter
  56043. */
  56044. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56045. /**
  56046. * Applies a force on the imposter
  56047. * @param impostor imposter to apply force
  56048. * @param force amount of force to be applied to the imposter
  56049. * @param contactPoint the location to apply the force on the imposter
  56050. */
  56051. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56052. /**
  56053. * Creates a physics body using the plugin
  56054. * @param impostor the imposter to create the physics body on
  56055. */
  56056. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56057. /**
  56058. * Removes the physics body from the imposter and disposes of the body's memory
  56059. * @param impostor imposter to remove the physics body from
  56060. */
  56061. removePhysicsBody(impostor: PhysicsImpostor): void;
  56062. /**
  56063. * Generates a joint
  56064. * @param impostorJoint the imposter joint to create the joint with
  56065. */
  56066. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56067. /**
  56068. * Removes a joint
  56069. * @param impostorJoint the imposter joint to remove the joint from
  56070. */
  56071. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56072. private _addMeshVerts;
  56073. /**
  56074. * Initialise the soft body vertices to match its object's (mesh) vertices
  56075. * Softbody vertices (nodes) are in world space and to match this
  56076. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56077. * @param impostor to create the softbody for
  56078. */
  56079. private _softVertexData;
  56080. /**
  56081. * Create an impostor's soft body
  56082. * @param impostor to create the softbody for
  56083. */
  56084. private _createSoftbody;
  56085. /**
  56086. * Create cloth for an impostor
  56087. * @param impostor to create the softbody for
  56088. */
  56089. private _createCloth;
  56090. /**
  56091. * Create rope for an impostor
  56092. * @param impostor to create the softbody for
  56093. */
  56094. private _createRope;
  56095. /**
  56096. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56097. * @param impostor to create the custom physics shape for
  56098. */
  56099. private _createCustom;
  56100. private _addHullVerts;
  56101. private _createShape;
  56102. /**
  56103. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56104. * @param impostor imposter containing the physics body and babylon object
  56105. */
  56106. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56107. /**
  56108. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56109. * @param impostor imposter containing the physics body and babylon object
  56110. * @param newPosition new position
  56111. * @param newRotation new rotation
  56112. */
  56113. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56114. /**
  56115. * If this plugin is supported
  56116. * @returns true if its supported
  56117. */
  56118. isSupported(): boolean;
  56119. /**
  56120. * Sets the linear velocity of the physics body
  56121. * @param impostor imposter to set the velocity on
  56122. * @param velocity velocity to set
  56123. */
  56124. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56125. /**
  56126. * Sets the angular velocity of the physics body
  56127. * @param impostor imposter to set the velocity on
  56128. * @param velocity velocity to set
  56129. */
  56130. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56131. /**
  56132. * gets the linear velocity
  56133. * @param impostor imposter to get linear velocity from
  56134. * @returns linear velocity
  56135. */
  56136. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56137. /**
  56138. * gets the angular velocity
  56139. * @param impostor imposter to get angular velocity from
  56140. * @returns angular velocity
  56141. */
  56142. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56143. /**
  56144. * Sets the mass of physics body
  56145. * @param impostor imposter to set the mass on
  56146. * @param mass mass to set
  56147. */
  56148. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56149. /**
  56150. * Gets the mass of the physics body
  56151. * @param impostor imposter to get the mass from
  56152. * @returns mass
  56153. */
  56154. getBodyMass(impostor: PhysicsImpostor): number;
  56155. /**
  56156. * Gets friction of the impostor
  56157. * @param impostor impostor to get friction from
  56158. * @returns friction value
  56159. */
  56160. getBodyFriction(impostor: PhysicsImpostor): number;
  56161. /**
  56162. * Sets friction of the impostor
  56163. * @param impostor impostor to set friction on
  56164. * @param friction friction value
  56165. */
  56166. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56167. /**
  56168. * Gets restitution of the impostor
  56169. * @param impostor impostor to get restitution from
  56170. * @returns restitution value
  56171. */
  56172. getBodyRestitution(impostor: PhysicsImpostor): number;
  56173. /**
  56174. * Sets resitution of the impostor
  56175. * @param impostor impostor to set resitution on
  56176. * @param restitution resitution value
  56177. */
  56178. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56179. /**
  56180. * Gets pressure inside the impostor
  56181. * @param impostor impostor to get pressure from
  56182. * @returns pressure value
  56183. */
  56184. getBodyPressure(impostor: PhysicsImpostor): number;
  56185. /**
  56186. * Sets pressure inside a soft body impostor
  56187. * Cloth and rope must remain 0 pressure
  56188. * @param impostor impostor to set pressure on
  56189. * @param pressure pressure value
  56190. */
  56191. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56192. /**
  56193. * Gets stiffness of the impostor
  56194. * @param impostor impostor to get stiffness from
  56195. * @returns pressure value
  56196. */
  56197. getBodyStiffness(impostor: PhysicsImpostor): number;
  56198. /**
  56199. * Sets stiffness of the impostor
  56200. * @param impostor impostor to set stiffness on
  56201. * @param stiffness stiffness value from 0 to 1
  56202. */
  56203. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56204. /**
  56205. * Gets velocityIterations of the impostor
  56206. * @param impostor impostor to get velocity iterations from
  56207. * @returns velocityIterations value
  56208. */
  56209. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56210. /**
  56211. * Sets velocityIterations of the impostor
  56212. * @param impostor impostor to set velocity iterations on
  56213. * @param velocityIterations velocityIterations value
  56214. */
  56215. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56216. /**
  56217. * Gets positionIterations of the impostor
  56218. * @param impostor impostor to get position iterations from
  56219. * @returns positionIterations value
  56220. */
  56221. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56222. /**
  56223. * Sets positionIterations of the impostor
  56224. * @param impostor impostor to set position on
  56225. * @param positionIterations positionIterations value
  56226. */
  56227. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56228. /**
  56229. * Append an anchor to a cloth object
  56230. * @param impostor is the cloth impostor to add anchor to
  56231. * @param otherImpostor is the rigid impostor to anchor to
  56232. * @param width ratio across width from 0 to 1
  56233. * @param height ratio up height from 0 to 1
  56234. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56235. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56236. */
  56237. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56238. /**
  56239. * Append an hook to a rope object
  56240. * @param impostor is the rope impostor to add hook to
  56241. * @param otherImpostor is the rigid impostor to hook to
  56242. * @param length ratio along the rope from 0 to 1
  56243. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56244. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56245. */
  56246. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56247. /**
  56248. * Sleeps the physics body and stops it from being active
  56249. * @param impostor impostor to sleep
  56250. */
  56251. sleepBody(impostor: PhysicsImpostor): void;
  56252. /**
  56253. * Activates the physics body
  56254. * @param impostor impostor to activate
  56255. */
  56256. wakeUpBody(impostor: PhysicsImpostor): void;
  56257. /**
  56258. * Updates the distance parameters of the joint
  56259. * @param joint joint to update
  56260. * @param maxDistance maximum distance of the joint
  56261. * @param minDistance minimum distance of the joint
  56262. */
  56263. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56264. /**
  56265. * Sets a motor on the joint
  56266. * @param joint joint to set motor on
  56267. * @param speed speed of the motor
  56268. * @param maxForce maximum force of the motor
  56269. * @param motorIndex index of the motor
  56270. */
  56271. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56272. /**
  56273. * Sets the motors limit
  56274. * @param joint joint to set limit on
  56275. * @param upperLimit upper limit
  56276. * @param lowerLimit lower limit
  56277. */
  56278. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56279. /**
  56280. * Syncs the position and rotation of a mesh with the impostor
  56281. * @param mesh mesh to sync
  56282. * @param impostor impostor to update the mesh with
  56283. */
  56284. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56285. /**
  56286. * Gets the radius of the impostor
  56287. * @param impostor impostor to get radius from
  56288. * @returns the radius
  56289. */
  56290. getRadius(impostor: PhysicsImpostor): number;
  56291. /**
  56292. * Gets the box size of the impostor
  56293. * @param impostor impostor to get box size from
  56294. * @param result the resulting box size
  56295. */
  56296. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56297. /**
  56298. * Disposes of the impostor
  56299. */
  56300. dispose(): void;
  56301. /**
  56302. * Does a raycast in the physics world
  56303. * @param from when should the ray start?
  56304. * @param to when should the ray end?
  56305. * @returns PhysicsRaycastResult
  56306. */
  56307. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56308. }
  56309. }
  56310. declare module BABYLON {
  56311. interface AbstractScene {
  56312. /**
  56313. * The list of reflection probes added to the scene
  56314. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56315. */
  56316. reflectionProbes: Array<ReflectionProbe>;
  56317. /**
  56318. * Removes the given reflection probe from this scene.
  56319. * @param toRemove The reflection probe to remove
  56320. * @returns The index of the removed reflection probe
  56321. */
  56322. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56323. /**
  56324. * Adds the given reflection probe to this scene.
  56325. * @param newReflectionProbe The reflection probe to add
  56326. */
  56327. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56328. }
  56329. /**
  56330. * Class used to generate realtime reflection / refraction cube textures
  56331. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56332. */
  56333. export class ReflectionProbe {
  56334. /** defines the name of the probe */
  56335. name: string;
  56336. private _scene;
  56337. private _renderTargetTexture;
  56338. private _projectionMatrix;
  56339. private _viewMatrix;
  56340. private _target;
  56341. private _add;
  56342. private _attachedMesh;
  56343. private _invertYAxis;
  56344. /** Gets or sets probe position (center of the cube map) */
  56345. position: Vector3;
  56346. /**
  56347. * Creates a new reflection probe
  56348. * @param name defines the name of the probe
  56349. * @param size defines the texture resolution (for each face)
  56350. * @param scene defines the hosting scene
  56351. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56352. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56353. */
  56354. constructor(
  56355. /** defines the name of the probe */
  56356. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56357. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56358. get samples(): number;
  56359. set samples(value: number);
  56360. /** Gets or sets the refresh rate to use (on every frame by default) */
  56361. get refreshRate(): number;
  56362. set refreshRate(value: number);
  56363. /**
  56364. * Gets the hosting scene
  56365. * @returns a Scene
  56366. */
  56367. getScene(): Scene;
  56368. /** Gets the internal CubeTexture used to render to */
  56369. get cubeTexture(): RenderTargetTexture;
  56370. /** Gets the list of meshes to render */
  56371. get renderList(): Nullable<AbstractMesh[]>;
  56372. /**
  56373. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56374. * @param mesh defines the mesh to attach to
  56375. */
  56376. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56377. /**
  56378. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56379. * @param renderingGroupId The rendering group id corresponding to its index
  56380. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56381. */
  56382. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56383. /**
  56384. * Clean all associated resources
  56385. */
  56386. dispose(): void;
  56387. /**
  56388. * Converts the reflection probe information to a readable string for debug purpose.
  56389. * @param fullDetails Supports for multiple levels of logging within scene loading
  56390. * @returns the human readable reflection probe info
  56391. */
  56392. toString(fullDetails?: boolean): string;
  56393. /**
  56394. * Get the class name of the relfection probe.
  56395. * @returns "ReflectionProbe"
  56396. */
  56397. getClassName(): string;
  56398. /**
  56399. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56400. * @returns The JSON representation of the texture
  56401. */
  56402. serialize(): any;
  56403. /**
  56404. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56405. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56406. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56407. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56408. * @returns The parsed reflection probe if successful
  56409. */
  56410. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56411. }
  56412. }
  56413. declare module BABYLON {
  56414. /** @hidden */
  56415. export var _BabylonLoaderRegistered: boolean;
  56416. /**
  56417. * Helps setting up some configuration for the babylon file loader.
  56418. */
  56419. export class BabylonFileLoaderConfiguration {
  56420. /**
  56421. * The loader does not allow injecting custom physix engine into the plugins.
  56422. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56423. * So you could set this variable to your engine import to make it work.
  56424. */
  56425. static LoaderInjectedPhysicsEngine: any;
  56426. }
  56427. }
  56428. declare module BABYLON {
  56429. /**
  56430. * The Physically based simple base material of BJS.
  56431. *
  56432. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56433. * It is used as the base class for both the specGloss and metalRough conventions.
  56434. */
  56435. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56436. /**
  56437. * Number of Simultaneous lights allowed on the material.
  56438. */
  56439. maxSimultaneousLights: number;
  56440. /**
  56441. * If sets to true, disables all the lights affecting the material.
  56442. */
  56443. disableLighting: boolean;
  56444. /**
  56445. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56446. */
  56447. environmentTexture: BaseTexture;
  56448. /**
  56449. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56450. */
  56451. invertNormalMapX: boolean;
  56452. /**
  56453. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56454. */
  56455. invertNormalMapY: boolean;
  56456. /**
  56457. * Normal map used in the model.
  56458. */
  56459. normalTexture: BaseTexture;
  56460. /**
  56461. * Emissivie color used to self-illuminate the model.
  56462. */
  56463. emissiveColor: Color3;
  56464. /**
  56465. * Emissivie texture used to self-illuminate the model.
  56466. */
  56467. emissiveTexture: BaseTexture;
  56468. /**
  56469. * Occlusion Channel Strenght.
  56470. */
  56471. occlusionStrength: number;
  56472. /**
  56473. * Occlusion Texture of the material (adding extra occlusion effects).
  56474. */
  56475. occlusionTexture: BaseTexture;
  56476. /**
  56477. * Defines the alpha limits in alpha test mode.
  56478. */
  56479. alphaCutOff: number;
  56480. /**
  56481. * Gets the current double sided mode.
  56482. */
  56483. get doubleSided(): boolean;
  56484. /**
  56485. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56486. */
  56487. set doubleSided(value: boolean);
  56488. /**
  56489. * Stores the pre-calculated light information of a mesh in a texture.
  56490. */
  56491. lightmapTexture: BaseTexture;
  56492. /**
  56493. * If true, the light map contains occlusion information instead of lighting info.
  56494. */
  56495. useLightmapAsShadowmap: boolean;
  56496. /**
  56497. * Instantiates a new PBRMaterial instance.
  56498. *
  56499. * @param name The material name
  56500. * @param scene The scene the material will be use in.
  56501. */
  56502. constructor(name: string, scene: Scene);
  56503. getClassName(): string;
  56504. }
  56505. }
  56506. declare module BABYLON {
  56507. /**
  56508. * The PBR material of BJS following the metal roughness convention.
  56509. *
  56510. * This fits to the PBR convention in the GLTF definition:
  56511. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56512. */
  56513. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56514. /**
  56515. * The base color has two different interpretations depending on the value of metalness.
  56516. * When the material is a metal, the base color is the specific measured reflectance value
  56517. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56518. * of the material.
  56519. */
  56520. baseColor: Color3;
  56521. /**
  56522. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56523. * well as opacity information in the alpha channel.
  56524. */
  56525. baseTexture: BaseTexture;
  56526. /**
  56527. * Specifies the metallic scalar value of the material.
  56528. * Can also be used to scale the metalness values of the metallic texture.
  56529. */
  56530. metallic: number;
  56531. /**
  56532. * Specifies the roughness scalar value of the material.
  56533. * Can also be used to scale the roughness values of the metallic texture.
  56534. */
  56535. roughness: number;
  56536. /**
  56537. * Texture containing both the metallic value in the B channel and the
  56538. * roughness value in the G channel to keep better precision.
  56539. */
  56540. metallicRoughnessTexture: BaseTexture;
  56541. /**
  56542. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56543. *
  56544. * @param name The material name
  56545. * @param scene The scene the material will be use in.
  56546. */
  56547. constructor(name: string, scene: Scene);
  56548. /**
  56549. * Return the currrent class name of the material.
  56550. */
  56551. getClassName(): string;
  56552. /**
  56553. * Makes a duplicate of the current material.
  56554. * @param name - name to use for the new material.
  56555. */
  56556. clone(name: string): PBRMetallicRoughnessMaterial;
  56557. /**
  56558. * Serialize the material to a parsable JSON object.
  56559. */
  56560. serialize(): any;
  56561. /**
  56562. * Parses a JSON object correponding to the serialize function.
  56563. */
  56564. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56565. }
  56566. }
  56567. declare module BABYLON {
  56568. /**
  56569. * The PBR material of BJS following the specular glossiness convention.
  56570. *
  56571. * This fits to the PBR convention in the GLTF definition:
  56572. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56573. */
  56574. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56575. /**
  56576. * Specifies the diffuse color of the material.
  56577. */
  56578. diffuseColor: Color3;
  56579. /**
  56580. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56581. * channel.
  56582. */
  56583. diffuseTexture: BaseTexture;
  56584. /**
  56585. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56586. */
  56587. specularColor: Color3;
  56588. /**
  56589. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56590. */
  56591. glossiness: number;
  56592. /**
  56593. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56594. */
  56595. specularGlossinessTexture: BaseTexture;
  56596. /**
  56597. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56598. *
  56599. * @param name The material name
  56600. * @param scene The scene the material will be use in.
  56601. */
  56602. constructor(name: string, scene: Scene);
  56603. /**
  56604. * Return the currrent class name of the material.
  56605. */
  56606. getClassName(): string;
  56607. /**
  56608. * Makes a duplicate of the current material.
  56609. * @param name - name to use for the new material.
  56610. */
  56611. clone(name: string): PBRSpecularGlossinessMaterial;
  56612. /**
  56613. * Serialize the material to a parsable JSON object.
  56614. */
  56615. serialize(): any;
  56616. /**
  56617. * Parses a JSON object correponding to the serialize function.
  56618. */
  56619. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56620. }
  56621. }
  56622. declare module BABYLON {
  56623. /**
  56624. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56625. * It can help converting any input color in a desired output one. This can then be used to create effects
  56626. * from sepia, black and white to sixties or futuristic rendering...
  56627. *
  56628. * The only supported format is currently 3dl.
  56629. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56630. */
  56631. export class ColorGradingTexture extends BaseTexture {
  56632. /**
  56633. * The texture URL.
  56634. */
  56635. url: string;
  56636. /**
  56637. * Empty line regex stored for GC.
  56638. */
  56639. private static _noneEmptyLineRegex;
  56640. private _textureMatrix;
  56641. private _engine;
  56642. private _onLoad;
  56643. /**
  56644. * Instantiates a ColorGradingTexture from the following parameters.
  56645. *
  56646. * @param url The location of the color gradind data (currently only supporting 3dl)
  56647. * @param sceneOrEngine The scene or engine the texture will be used in
  56648. * @param onLoad defines a callback triggered when the texture has been loaded
  56649. */
  56650. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56651. /**
  56652. * Fires the onload event from the constructor if requested.
  56653. */
  56654. private _triggerOnLoad;
  56655. /**
  56656. * Returns the texture matrix used in most of the material.
  56657. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56658. */
  56659. getTextureMatrix(): Matrix;
  56660. /**
  56661. * Occurs when the file being loaded is a .3dl LUT file.
  56662. */
  56663. private load3dlTexture;
  56664. /**
  56665. * Starts the loading process of the texture.
  56666. */
  56667. private loadTexture;
  56668. /**
  56669. * Clones the color gradind texture.
  56670. */
  56671. clone(): ColorGradingTexture;
  56672. /**
  56673. * Called during delayed load for textures.
  56674. */
  56675. delayLoad(): void;
  56676. /**
  56677. * Parses a color grading texture serialized by Babylon.
  56678. * @param parsedTexture The texture information being parsedTexture
  56679. * @param scene The scene to load the texture in
  56680. * @param rootUrl The root url of the data assets to load
  56681. * @return A color gradind texture
  56682. */
  56683. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56684. /**
  56685. * Serializes the LUT texture to json format.
  56686. */
  56687. serialize(): any;
  56688. /**
  56689. * Returns true if the passed parameter is a scene object (can be use for typings)
  56690. * @param sceneOrEngine The object to test.
  56691. */
  56692. private static _isScene;
  56693. }
  56694. }
  56695. declare module BABYLON {
  56696. /**
  56697. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56698. */
  56699. export class EquiRectangularCubeTexture extends BaseTexture {
  56700. /** The six faces of the cube. */
  56701. private static _FacesMapping;
  56702. private _noMipmap;
  56703. private _onLoad;
  56704. private _onError;
  56705. /** The size of the cubemap. */
  56706. private _size;
  56707. /** The buffer of the image. */
  56708. private _buffer;
  56709. /** The width of the input image. */
  56710. private _width;
  56711. /** The height of the input image. */
  56712. private _height;
  56713. /** The URL to the image. */
  56714. url: string;
  56715. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56716. coordinatesMode: number;
  56717. /**
  56718. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56719. * @param url The location of the image
  56720. * @param scene The scene the texture will be used in
  56721. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56722. * @param noMipmap Forces to not generate the mipmap if true
  56723. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56724. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56725. * @param onLoad — defines a callback called when texture is loaded
  56726. * @param onError — defines a callback called if there is an error
  56727. */
  56728. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56729. /**
  56730. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56731. */
  56732. private loadImage;
  56733. /**
  56734. * Convert the image buffer into a cubemap and create a CubeTexture.
  56735. */
  56736. private loadTexture;
  56737. /**
  56738. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56739. * @param buffer The ArrayBuffer that should be converted.
  56740. * @returns The buffer as Float32Array.
  56741. */
  56742. private getFloat32ArrayFromArrayBuffer;
  56743. /**
  56744. * Get the current class name of the texture useful for serialization or dynamic coding.
  56745. * @returns "EquiRectangularCubeTexture"
  56746. */
  56747. getClassName(): string;
  56748. /**
  56749. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56750. * @returns A clone of the current EquiRectangularCubeTexture.
  56751. */
  56752. clone(): EquiRectangularCubeTexture;
  56753. }
  56754. }
  56755. declare module BABYLON {
  56756. /**
  56757. * Based on jsTGALoader - Javascript loader for TGA file
  56758. * By Vincent Thibault
  56759. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56760. */
  56761. export class TGATools {
  56762. private static _TYPE_INDEXED;
  56763. private static _TYPE_RGB;
  56764. private static _TYPE_GREY;
  56765. private static _TYPE_RLE_INDEXED;
  56766. private static _TYPE_RLE_RGB;
  56767. private static _TYPE_RLE_GREY;
  56768. private static _ORIGIN_MASK;
  56769. private static _ORIGIN_SHIFT;
  56770. private static _ORIGIN_BL;
  56771. private static _ORIGIN_BR;
  56772. private static _ORIGIN_UL;
  56773. private static _ORIGIN_UR;
  56774. /**
  56775. * Gets the header of a TGA file
  56776. * @param data defines the TGA data
  56777. * @returns the header
  56778. */
  56779. static GetTGAHeader(data: Uint8Array): any;
  56780. /**
  56781. * Uploads TGA content to a Babylon Texture
  56782. * @hidden
  56783. */
  56784. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56785. /** @hidden */
  56786. 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;
  56787. /** @hidden */
  56788. 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;
  56789. /** @hidden */
  56790. 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;
  56791. /** @hidden */
  56792. 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;
  56793. /** @hidden */
  56794. 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;
  56795. /** @hidden */
  56796. 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;
  56797. }
  56798. }
  56799. declare module BABYLON {
  56800. /**
  56801. * Implementation of the TGA Texture Loader.
  56802. * @hidden
  56803. */
  56804. export class _TGATextureLoader implements IInternalTextureLoader {
  56805. /**
  56806. * Defines wether the loader supports cascade loading the different faces.
  56807. */
  56808. readonly supportCascades: boolean;
  56809. /**
  56810. * This returns if the loader support the current file information.
  56811. * @param extension defines the file extension of the file being loaded
  56812. * @returns true if the loader can load the specified file
  56813. */
  56814. canLoad(extension: string): boolean;
  56815. /**
  56816. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56817. * @param data contains the texture data
  56818. * @param texture defines the BabylonJS internal texture
  56819. * @param createPolynomials will be true if polynomials have been requested
  56820. * @param onLoad defines the callback to trigger once the texture is ready
  56821. * @param onError defines the callback to trigger in case of error
  56822. */
  56823. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56824. /**
  56825. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56826. * @param data contains the texture data
  56827. * @param texture defines the BabylonJS internal texture
  56828. * @param callback defines the method to call once ready to upload
  56829. */
  56830. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Info about the .basis files
  56836. */
  56837. class BasisFileInfo {
  56838. /**
  56839. * If the file has alpha
  56840. */
  56841. hasAlpha: boolean;
  56842. /**
  56843. * Info about each image of the basis file
  56844. */
  56845. images: Array<{
  56846. levels: Array<{
  56847. width: number;
  56848. height: number;
  56849. transcodedPixels: ArrayBufferView;
  56850. }>;
  56851. }>;
  56852. }
  56853. /**
  56854. * Result of transcoding a basis file
  56855. */
  56856. class TranscodeResult {
  56857. /**
  56858. * Info about the .basis file
  56859. */
  56860. fileInfo: BasisFileInfo;
  56861. /**
  56862. * Format to use when loading the file
  56863. */
  56864. format: number;
  56865. }
  56866. /**
  56867. * Configuration options for the Basis transcoder
  56868. */
  56869. export class BasisTranscodeConfiguration {
  56870. /**
  56871. * Supported compression formats used to determine the supported output format of the transcoder
  56872. */
  56873. supportedCompressionFormats?: {
  56874. /**
  56875. * etc1 compression format
  56876. */
  56877. etc1?: boolean;
  56878. /**
  56879. * s3tc compression format
  56880. */
  56881. s3tc?: boolean;
  56882. /**
  56883. * pvrtc compression format
  56884. */
  56885. pvrtc?: boolean;
  56886. /**
  56887. * etc2 compression format
  56888. */
  56889. etc2?: boolean;
  56890. };
  56891. /**
  56892. * If mipmap levels should be loaded for transcoded images (Default: true)
  56893. */
  56894. loadMipmapLevels?: boolean;
  56895. /**
  56896. * Index of a single image to load (Default: all images)
  56897. */
  56898. loadSingleImage?: number;
  56899. }
  56900. /**
  56901. * Used to load .Basis files
  56902. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56903. */
  56904. export class BasisTools {
  56905. private static _IgnoreSupportedFormats;
  56906. /**
  56907. * URL to use when loading the basis transcoder
  56908. */
  56909. static JSModuleURL: string;
  56910. /**
  56911. * URL to use when loading the wasm module for the transcoder
  56912. */
  56913. static WasmModuleURL: string;
  56914. /**
  56915. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56916. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56917. * @returns internal format corresponding to the Basis format
  56918. */
  56919. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56920. private static _WorkerPromise;
  56921. private static _Worker;
  56922. private static _actionId;
  56923. private static _CreateWorkerAsync;
  56924. /**
  56925. * Transcodes a loaded image file to compressed pixel data
  56926. * @param data image data to transcode
  56927. * @param config configuration options for the transcoding
  56928. * @returns a promise resulting in the transcoded image
  56929. */
  56930. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56931. /**
  56932. * Loads a texture from the transcode result
  56933. * @param texture texture load to
  56934. * @param transcodeResult the result of transcoding the basis file to load from
  56935. */
  56936. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56937. }
  56938. }
  56939. declare module BABYLON {
  56940. /**
  56941. * Loader for .basis file format
  56942. */
  56943. export class _BasisTextureLoader implements IInternalTextureLoader {
  56944. /**
  56945. * Defines whether the loader supports cascade loading the different faces.
  56946. */
  56947. readonly supportCascades: boolean;
  56948. /**
  56949. * This returns if the loader support the current file information.
  56950. * @param extension defines the file extension of the file being loaded
  56951. * @returns true if the loader can load the specified file
  56952. */
  56953. canLoad(extension: string): boolean;
  56954. /**
  56955. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56956. * @param data contains the texture data
  56957. * @param texture defines the BabylonJS internal texture
  56958. * @param createPolynomials will be true if polynomials have been requested
  56959. * @param onLoad defines the callback to trigger once the texture is ready
  56960. * @param onError defines the callback to trigger in case of error
  56961. */
  56962. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56963. /**
  56964. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56965. * @param data contains the texture data
  56966. * @param texture defines the BabylonJS internal texture
  56967. * @param callback defines the method to call once ready to upload
  56968. */
  56969. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56970. }
  56971. }
  56972. declare module BABYLON {
  56973. /**
  56974. * 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.
  56975. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56976. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56977. */
  56978. export class CustomProceduralTexture extends ProceduralTexture {
  56979. private _animate;
  56980. private _time;
  56981. private _config;
  56982. private _texturePath;
  56983. /**
  56984. * Instantiates a new Custom Procedural Texture.
  56985. * 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.
  56986. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56987. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56988. * @param name Define the name of the texture
  56989. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56990. * @param size Define the size of the texture to create
  56991. * @param scene Define the scene the texture belongs to
  56992. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56993. * @param generateMipMaps Define if the texture should creates mip maps or not
  56994. */
  56995. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56996. private _loadJson;
  56997. /**
  56998. * Is the texture ready to be used ? (rendered at least once)
  56999. * @returns true if ready, otherwise, false.
  57000. */
  57001. isReady(): boolean;
  57002. /**
  57003. * Render the texture to its associated render target.
  57004. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57005. */
  57006. render(useCameraPostProcess?: boolean): void;
  57007. /**
  57008. * Update the list of dependant textures samplers in the shader.
  57009. */
  57010. updateTextures(): void;
  57011. /**
  57012. * Update the uniform values of the procedural texture in the shader.
  57013. */
  57014. updateShaderUniforms(): void;
  57015. /**
  57016. * Define if the texture animates or not.
  57017. */
  57018. get animate(): boolean;
  57019. set animate(value: boolean);
  57020. }
  57021. }
  57022. declare module BABYLON {
  57023. /** @hidden */
  57024. export var noisePixelShader: {
  57025. name: string;
  57026. shader: string;
  57027. };
  57028. }
  57029. declare module BABYLON {
  57030. /**
  57031. * Class used to generate noise procedural textures
  57032. */
  57033. export class NoiseProceduralTexture extends ProceduralTexture {
  57034. private _time;
  57035. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57036. brightness: number;
  57037. /** Defines the number of octaves to process */
  57038. octaves: number;
  57039. /** Defines the level of persistence (0.8 by default) */
  57040. persistence: number;
  57041. /** Gets or sets animation speed factor (default is 1) */
  57042. animationSpeedFactor: number;
  57043. /**
  57044. * Creates a new NoiseProceduralTexture
  57045. * @param name defines the name fo the texture
  57046. * @param size defines the size of the texture (default is 256)
  57047. * @param scene defines the hosting scene
  57048. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57049. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57050. */
  57051. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57052. private _updateShaderUniforms;
  57053. protected _getDefines(): string;
  57054. /** Generate the current state of the procedural texture */
  57055. render(useCameraPostProcess?: boolean): void;
  57056. /**
  57057. * Serializes this noise procedural texture
  57058. * @returns a serialized noise procedural texture object
  57059. */
  57060. serialize(): any;
  57061. /**
  57062. * Clone the texture.
  57063. * @returns the cloned texture
  57064. */
  57065. clone(): NoiseProceduralTexture;
  57066. /**
  57067. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57068. * @param parsedTexture defines parsed texture data
  57069. * @param scene defines the current scene
  57070. * @param rootUrl defines the root URL containing noise procedural texture information
  57071. * @returns a parsed NoiseProceduralTexture
  57072. */
  57073. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57074. }
  57075. }
  57076. declare module BABYLON {
  57077. /**
  57078. * Raw cube texture where the raw buffers are passed in
  57079. */
  57080. export class RawCubeTexture extends CubeTexture {
  57081. /**
  57082. * Creates a cube texture where the raw buffers are passed in.
  57083. * @param scene defines the scene the texture is attached to
  57084. * @param data defines the array of data to use to create each face
  57085. * @param size defines the size of the textures
  57086. * @param format defines the format of the data
  57087. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57088. * @param generateMipMaps defines if the engine should generate the mip levels
  57089. * @param invertY defines if data must be stored with Y axis inverted
  57090. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57091. * @param compression defines the compression used (null by default)
  57092. */
  57093. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57094. /**
  57095. * Updates the raw cube texture.
  57096. * @param data defines the data to store
  57097. * @param format defines the data format
  57098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57099. * @param invertY defines if data must be stored with Y axis inverted
  57100. * @param compression defines the compression used (null by default)
  57101. * @param level defines which level of the texture to update
  57102. */
  57103. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57104. /**
  57105. * Updates a raw cube texture with RGBD encoded data.
  57106. * @param data defines the array of data [mipmap][face] to use to create each face
  57107. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57108. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57109. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57110. * @returns a promsie that resolves when the operation is complete
  57111. */
  57112. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57113. /**
  57114. * Clones the raw cube texture.
  57115. * @return a new cube texture
  57116. */
  57117. clone(): CubeTexture;
  57118. /** @hidden */
  57119. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57120. }
  57121. }
  57122. declare module BABYLON {
  57123. /**
  57124. * Class used to store 3D textures containing user data
  57125. */
  57126. export class RawTexture3D extends Texture {
  57127. /** Gets or sets the texture format to use */
  57128. format: number;
  57129. private _engine;
  57130. /**
  57131. * Create a new RawTexture3D
  57132. * @param data defines the data of the texture
  57133. * @param width defines the width of the texture
  57134. * @param height defines the height of the texture
  57135. * @param depth defines the depth of the texture
  57136. * @param format defines the texture format to use
  57137. * @param scene defines the hosting scene
  57138. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57139. * @param invertY defines if texture must be stored with Y axis inverted
  57140. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57141. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57142. */
  57143. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57144. /** Gets or sets the texture format to use */
  57145. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57146. /**
  57147. * Update the texture with new data
  57148. * @param data defines the data to store in the texture
  57149. */
  57150. update(data: ArrayBufferView): void;
  57151. }
  57152. }
  57153. declare module BABYLON {
  57154. /**
  57155. * Class used to store 2D array textures containing user data
  57156. */
  57157. export class RawTexture2DArray extends Texture {
  57158. /** Gets or sets the texture format to use */
  57159. format: number;
  57160. private _engine;
  57161. /**
  57162. * Create a new RawTexture2DArray
  57163. * @param data defines the data of the texture
  57164. * @param width defines the width of the texture
  57165. * @param height defines the height of the texture
  57166. * @param depth defines the number of layers of the texture
  57167. * @param format defines the texture format to use
  57168. * @param scene defines the hosting scene
  57169. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57170. * @param invertY defines if texture must be stored with Y axis inverted
  57171. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57172. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57173. */
  57174. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57175. /** Gets or sets the texture format to use */
  57176. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57177. /**
  57178. * Update the texture with new data
  57179. * @param data defines the data to store in the texture
  57180. */
  57181. update(data: ArrayBufferView): void;
  57182. }
  57183. }
  57184. declare module BABYLON {
  57185. /**
  57186. * Creates a refraction texture used by refraction channel of the standard material.
  57187. * It is like a mirror but to see through a material.
  57188. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57189. */
  57190. export class RefractionTexture extends RenderTargetTexture {
  57191. /**
  57192. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57193. * 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.
  57194. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57195. */
  57196. refractionPlane: Plane;
  57197. /**
  57198. * Define how deep under the surface we should see.
  57199. */
  57200. depth: number;
  57201. /**
  57202. * Creates a refraction texture used by refraction channel of the standard material.
  57203. * It is like a mirror but to see through a material.
  57204. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57205. * @param name Define the texture name
  57206. * @param size Define the size of the underlying texture
  57207. * @param scene Define the scene the refraction belongs to
  57208. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57209. */
  57210. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57211. /**
  57212. * Clone the refraction texture.
  57213. * @returns the cloned texture
  57214. */
  57215. clone(): RefractionTexture;
  57216. /**
  57217. * Serialize the texture to a JSON representation you could use in Parse later on
  57218. * @returns the serialized JSON representation
  57219. */
  57220. serialize(): any;
  57221. }
  57222. }
  57223. declare module BABYLON {
  57224. /**
  57225. * Defines the options related to the creation of an HtmlElementTexture
  57226. */
  57227. export interface IHtmlElementTextureOptions {
  57228. /**
  57229. * Defines wether mip maps should be created or not.
  57230. */
  57231. generateMipMaps?: boolean;
  57232. /**
  57233. * Defines the sampling mode of the texture.
  57234. */
  57235. samplingMode?: number;
  57236. /**
  57237. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57238. */
  57239. engine: Nullable<ThinEngine>;
  57240. /**
  57241. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57242. */
  57243. scene: Nullable<Scene>;
  57244. }
  57245. /**
  57246. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57247. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57248. * is automatically managed.
  57249. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57250. * in your application.
  57251. *
  57252. * As the update is not automatic, you need to call them manually.
  57253. */
  57254. export class HtmlElementTexture extends BaseTexture {
  57255. /**
  57256. * The texture URL.
  57257. */
  57258. element: HTMLVideoElement | HTMLCanvasElement;
  57259. private static readonly DefaultOptions;
  57260. private _textureMatrix;
  57261. private _engine;
  57262. private _isVideo;
  57263. private _generateMipMaps;
  57264. private _samplingMode;
  57265. /**
  57266. * Instantiates a HtmlElementTexture from the following parameters.
  57267. *
  57268. * @param name Defines the name of the texture
  57269. * @param element Defines the video or canvas the texture is filled with
  57270. * @param options Defines the other none mandatory texture creation options
  57271. */
  57272. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57273. private _createInternalTexture;
  57274. /**
  57275. * Returns the texture matrix used in most of the material.
  57276. */
  57277. getTextureMatrix(): Matrix;
  57278. /**
  57279. * Updates the content of the texture.
  57280. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57281. */
  57282. update(invertY?: Nullable<boolean>): void;
  57283. }
  57284. }
  57285. declare module BABYLON {
  57286. /**
  57287. * Defines the basic options interface of a TexturePacker Frame
  57288. */
  57289. export interface ITexturePackerFrame {
  57290. /**
  57291. * The frame ID
  57292. */
  57293. id: number;
  57294. /**
  57295. * The frames Scale
  57296. */
  57297. scale: Vector2;
  57298. /**
  57299. * The Frames offset
  57300. */
  57301. offset: Vector2;
  57302. }
  57303. /**
  57304. * This is a support class for frame Data on texture packer sets.
  57305. */
  57306. export class TexturePackerFrame implements ITexturePackerFrame {
  57307. /**
  57308. * The frame ID
  57309. */
  57310. id: number;
  57311. /**
  57312. * The frames Scale
  57313. */
  57314. scale: Vector2;
  57315. /**
  57316. * The Frames offset
  57317. */
  57318. offset: Vector2;
  57319. /**
  57320. * Initializes a texture package frame.
  57321. * @param id The numerical frame identifier
  57322. * @param scale Scalar Vector2 for UV frame
  57323. * @param offset Vector2 for the frame position in UV units.
  57324. * @returns TexturePackerFrame
  57325. */
  57326. constructor(id: number, scale: Vector2, offset: Vector2);
  57327. }
  57328. }
  57329. declare module BABYLON {
  57330. /**
  57331. * Defines the basic options interface of a TexturePacker
  57332. */
  57333. export interface ITexturePackerOptions {
  57334. /**
  57335. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57336. */
  57337. map?: string[];
  57338. /**
  57339. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57340. */
  57341. uvsIn?: string;
  57342. /**
  57343. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57344. */
  57345. uvsOut?: string;
  57346. /**
  57347. * number representing the layout style. Defaults to LAYOUT_STRIP
  57348. */
  57349. layout?: number;
  57350. /**
  57351. * number of columns if using custom column count layout(2). This defaults to 4.
  57352. */
  57353. colnum?: number;
  57354. /**
  57355. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57356. */
  57357. updateInputMeshes?: boolean;
  57358. /**
  57359. * boolean flag to dispose all the source textures. Defaults to true.
  57360. */
  57361. disposeSources?: boolean;
  57362. /**
  57363. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57364. */
  57365. fillBlanks?: boolean;
  57366. /**
  57367. * string value representing the context fill style color. Defaults to 'black'.
  57368. */
  57369. customFillColor?: string;
  57370. /**
  57371. * Width and Height Value of each Frame in the TexturePacker Sets
  57372. */
  57373. frameSize?: number;
  57374. /**
  57375. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57376. */
  57377. paddingRatio?: number;
  57378. /**
  57379. * Number that declares the fill method for the padding gutter.
  57380. */
  57381. paddingMode?: number;
  57382. /**
  57383. * If in SUBUV_COLOR padding mode what color to use.
  57384. */
  57385. paddingColor?: Color3 | Color4;
  57386. }
  57387. /**
  57388. * Defines the basic interface of a TexturePacker JSON File
  57389. */
  57390. export interface ITexturePackerJSON {
  57391. /**
  57392. * The frame ID
  57393. */
  57394. name: string;
  57395. /**
  57396. * The base64 channel data
  57397. */
  57398. sets: any;
  57399. /**
  57400. * The options of the Packer
  57401. */
  57402. options: ITexturePackerOptions;
  57403. /**
  57404. * The frame data of the Packer
  57405. */
  57406. frames: Array<number>;
  57407. }
  57408. /**
  57409. * This is a support class that generates a series of packed texture sets.
  57410. * @see https://doc.babylonjs.com/babylon101/materials
  57411. */
  57412. export class TexturePacker {
  57413. /** Packer Layout Constant 0 */
  57414. static readonly LAYOUT_STRIP: number;
  57415. /** Packer Layout Constant 1 */
  57416. static readonly LAYOUT_POWER2: number;
  57417. /** Packer Layout Constant 2 */
  57418. static readonly LAYOUT_COLNUM: number;
  57419. /** Packer Layout Constant 0 */
  57420. static readonly SUBUV_WRAP: number;
  57421. /** Packer Layout Constant 1 */
  57422. static readonly SUBUV_EXTEND: number;
  57423. /** Packer Layout Constant 2 */
  57424. static readonly SUBUV_COLOR: number;
  57425. /** The Name of the Texture Package */
  57426. name: string;
  57427. /** The scene scope of the TexturePacker */
  57428. scene: Scene;
  57429. /** The Meshes to target */
  57430. meshes: AbstractMesh[];
  57431. /** Arguments passed with the Constructor */
  57432. options: ITexturePackerOptions;
  57433. /** The promise that is started upon initialization */
  57434. promise: Nullable<Promise<TexturePacker | string>>;
  57435. /** The Container object for the channel sets that are generated */
  57436. sets: object;
  57437. /** The Container array for the frames that are generated */
  57438. frames: TexturePackerFrame[];
  57439. /** The expected number of textures the system is parsing. */
  57440. private _expecting;
  57441. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57442. private _paddingValue;
  57443. /**
  57444. * Initializes a texture package series from an array of meshes or a single mesh.
  57445. * @param name The name of the package
  57446. * @param meshes The target meshes to compose the package from
  57447. * @param options The arguments that texture packer should follow while building.
  57448. * @param scene The scene which the textures are scoped to.
  57449. * @returns TexturePacker
  57450. */
  57451. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57452. /**
  57453. * Starts the package process
  57454. * @param resolve The promises resolution function
  57455. * @returns TexturePacker
  57456. */
  57457. private _createFrames;
  57458. /**
  57459. * Calculates the Size of the Channel Sets
  57460. * @returns Vector2
  57461. */
  57462. private _calculateSize;
  57463. /**
  57464. * Calculates the UV data for the frames.
  57465. * @param baseSize the base frameSize
  57466. * @param padding the base frame padding
  57467. * @param dtSize size of the Dynamic Texture for that channel
  57468. * @param dtUnits is 1/dtSize
  57469. * @param update flag to update the input meshes
  57470. */
  57471. private _calculateMeshUVFrames;
  57472. /**
  57473. * Calculates the frames Offset.
  57474. * @param index of the frame
  57475. * @returns Vector2
  57476. */
  57477. private _getFrameOffset;
  57478. /**
  57479. * Updates a Mesh to the frame data
  57480. * @param mesh that is the target
  57481. * @param frameID or the frame index
  57482. */
  57483. private _updateMeshUV;
  57484. /**
  57485. * Updates a Meshes materials to use the texture packer channels
  57486. * @param m is the mesh to target
  57487. * @param force all channels on the packer to be set.
  57488. */
  57489. private _updateTextureReferences;
  57490. /**
  57491. * Public method to set a Mesh to a frame
  57492. * @param m that is the target
  57493. * @param frameID or the frame index
  57494. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57495. */
  57496. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57497. /**
  57498. * Starts the async promise to compile the texture packer.
  57499. * @returns Promise<void>
  57500. */
  57501. processAsync(): Promise<void>;
  57502. /**
  57503. * Disposes all textures associated with this packer
  57504. */
  57505. dispose(): void;
  57506. /**
  57507. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57508. * @param imageType is the image type to use.
  57509. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57510. */
  57511. download(imageType?: string, quality?: number): void;
  57512. /**
  57513. * Public method to load a texturePacker JSON file.
  57514. * @param data of the JSON file in string format.
  57515. */
  57516. updateFromJSON(data: string): void;
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * Enum used to define the target of a block
  57522. */
  57523. export enum NodeMaterialBlockTargets {
  57524. /** Vertex shader */
  57525. Vertex = 1,
  57526. /** Fragment shader */
  57527. Fragment = 2,
  57528. /** Neutral */
  57529. Neutral = 4,
  57530. /** Vertex and Fragment */
  57531. VertexAndFragment = 3
  57532. }
  57533. }
  57534. declare module BABYLON {
  57535. /**
  57536. * Defines the kind of connection point for node based material
  57537. */
  57538. export enum NodeMaterialBlockConnectionPointTypes {
  57539. /** Float */
  57540. Float = 1,
  57541. /** Int */
  57542. Int = 2,
  57543. /** Vector2 */
  57544. Vector2 = 4,
  57545. /** Vector3 */
  57546. Vector3 = 8,
  57547. /** Vector4 */
  57548. Vector4 = 16,
  57549. /** Color3 */
  57550. Color3 = 32,
  57551. /** Color4 */
  57552. Color4 = 64,
  57553. /** Matrix */
  57554. Matrix = 128,
  57555. /** Custom object */
  57556. Object = 256,
  57557. /** Detect type based on connection */
  57558. AutoDetect = 1024,
  57559. /** Output type that will be defined by input type */
  57560. BasedOnInput = 2048
  57561. }
  57562. }
  57563. declare module BABYLON {
  57564. /**
  57565. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57566. */
  57567. export enum NodeMaterialBlockConnectionPointMode {
  57568. /** Value is an uniform */
  57569. Uniform = 0,
  57570. /** Value is a mesh attribute */
  57571. Attribute = 1,
  57572. /** Value is a varying between vertex and fragment shaders */
  57573. Varying = 2,
  57574. /** Mode is undefined */
  57575. Undefined = 3
  57576. }
  57577. }
  57578. declare module BABYLON {
  57579. /**
  57580. * Enum used to define system values e.g. values automatically provided by the system
  57581. */
  57582. export enum NodeMaterialSystemValues {
  57583. /** World */
  57584. World = 1,
  57585. /** View */
  57586. View = 2,
  57587. /** Projection */
  57588. Projection = 3,
  57589. /** ViewProjection */
  57590. ViewProjection = 4,
  57591. /** WorldView */
  57592. WorldView = 5,
  57593. /** WorldViewProjection */
  57594. WorldViewProjection = 6,
  57595. /** CameraPosition */
  57596. CameraPosition = 7,
  57597. /** Fog Color */
  57598. FogColor = 8,
  57599. /** Delta time */
  57600. DeltaTime = 9
  57601. }
  57602. }
  57603. declare module BABYLON {
  57604. /**
  57605. * Root class for all node material optimizers
  57606. */
  57607. export class NodeMaterialOptimizer {
  57608. /**
  57609. * Function used to optimize a NodeMaterial graph
  57610. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57611. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57612. */
  57613. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57614. }
  57615. }
  57616. declare module BABYLON {
  57617. /**
  57618. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57619. */
  57620. export class TransformBlock extends NodeMaterialBlock {
  57621. /**
  57622. * Defines the value to use to complement W value to transform it to a Vector4
  57623. */
  57624. complementW: number;
  57625. /**
  57626. * Defines the value to use to complement z value to transform it to a Vector4
  57627. */
  57628. complementZ: number;
  57629. /**
  57630. * Creates a new TransformBlock
  57631. * @param name defines the block name
  57632. */
  57633. constructor(name: string);
  57634. /**
  57635. * Gets the current class name
  57636. * @returns the class name
  57637. */
  57638. getClassName(): string;
  57639. /**
  57640. * Gets the vector input
  57641. */
  57642. get vector(): NodeMaterialConnectionPoint;
  57643. /**
  57644. * Gets the output component
  57645. */
  57646. get output(): NodeMaterialConnectionPoint;
  57647. /**
  57648. * Gets the xyz output component
  57649. */
  57650. get xyz(): NodeMaterialConnectionPoint;
  57651. /**
  57652. * Gets the matrix transform input
  57653. */
  57654. get transform(): NodeMaterialConnectionPoint;
  57655. protected _buildBlock(state: NodeMaterialBuildState): this;
  57656. serialize(): any;
  57657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57658. protected _dumpPropertiesCode(): string;
  57659. }
  57660. }
  57661. declare module BABYLON {
  57662. /**
  57663. * Block used to output the vertex position
  57664. */
  57665. export class VertexOutputBlock extends NodeMaterialBlock {
  57666. /**
  57667. * Creates a new VertexOutputBlock
  57668. * @param name defines the block name
  57669. */
  57670. constructor(name: string);
  57671. /**
  57672. * Gets the current class name
  57673. * @returns the class name
  57674. */
  57675. getClassName(): string;
  57676. /**
  57677. * Gets the vector input component
  57678. */
  57679. get vector(): NodeMaterialConnectionPoint;
  57680. protected _buildBlock(state: NodeMaterialBuildState): this;
  57681. }
  57682. }
  57683. declare module BABYLON {
  57684. /**
  57685. * Block used to output the final color
  57686. */
  57687. export class FragmentOutputBlock extends NodeMaterialBlock {
  57688. /**
  57689. * Create a new FragmentOutputBlock
  57690. * @param name defines the block name
  57691. */
  57692. constructor(name: string);
  57693. /**
  57694. * Gets the current class name
  57695. * @returns the class name
  57696. */
  57697. getClassName(): string;
  57698. /**
  57699. * Gets the rgba input component
  57700. */
  57701. get rgba(): NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the rgb input component
  57704. */
  57705. get rgb(): NodeMaterialConnectionPoint;
  57706. /**
  57707. * Gets the a input component
  57708. */
  57709. get a(): NodeMaterialConnectionPoint;
  57710. protected _buildBlock(state: NodeMaterialBuildState): this;
  57711. }
  57712. }
  57713. declare module BABYLON {
  57714. /**
  57715. * Base block used to read a reflection texture from a sampler
  57716. */
  57717. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  57718. /** @hidden */
  57719. _define3DName: string;
  57720. /** @hidden */
  57721. _defineCubicName: string;
  57722. /** @hidden */
  57723. _defineExplicitName: string;
  57724. /** @hidden */
  57725. _defineProjectionName: string;
  57726. /** @hidden */
  57727. _defineLocalCubicName: string;
  57728. /** @hidden */
  57729. _defineSphericalName: string;
  57730. /** @hidden */
  57731. _definePlanarName: string;
  57732. /** @hidden */
  57733. _defineEquirectangularName: string;
  57734. /** @hidden */
  57735. _defineMirroredEquirectangularFixedName: string;
  57736. /** @hidden */
  57737. _defineEquirectangularFixedName: string;
  57738. /** @hidden */
  57739. _defineSkyboxName: string;
  57740. /** @hidden */
  57741. _defineOppositeZ: string;
  57742. /** @hidden */
  57743. _cubeSamplerName: string;
  57744. /** @hidden */
  57745. _2DSamplerName: string;
  57746. protected _positionUVWName: string;
  57747. protected _directionWName: string;
  57748. protected _reflectionVectorName: string;
  57749. /** @hidden */
  57750. _reflectionCoordsName: string;
  57751. /** @hidden */
  57752. _reflectionMatrixName: string;
  57753. protected _reflectionColorName: string;
  57754. /**
  57755. * Gets or sets the texture associated with the node
  57756. */
  57757. texture: Nullable<BaseTexture>;
  57758. /**
  57759. * Create a new ReflectionTextureBaseBlock
  57760. * @param name defines the block name
  57761. */
  57762. constructor(name: string);
  57763. /**
  57764. * Gets the current class name
  57765. * @returns the class name
  57766. */
  57767. getClassName(): string;
  57768. /**
  57769. * Gets the world position input component
  57770. */
  57771. abstract get position(): NodeMaterialConnectionPoint;
  57772. /**
  57773. * Gets the world position input component
  57774. */
  57775. abstract get worldPosition(): NodeMaterialConnectionPoint;
  57776. /**
  57777. * Gets the world normal input component
  57778. */
  57779. abstract get worldNormal(): NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the world input component
  57782. */
  57783. abstract get world(): NodeMaterialConnectionPoint;
  57784. /**
  57785. * Gets the camera (or eye) position component
  57786. */
  57787. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  57788. /**
  57789. * Gets the view input component
  57790. */
  57791. abstract get view(): NodeMaterialConnectionPoint;
  57792. protected _getTexture(): Nullable<BaseTexture>;
  57793. autoConfigure(material: NodeMaterial): void;
  57794. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57795. isReady(): boolean;
  57796. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57797. /**
  57798. * Gets the code to inject in the vertex shader
  57799. * @param state current state of the node material building
  57800. * @returns the shader code
  57801. */
  57802. handleVertexSide(state: NodeMaterialBuildState): string;
  57803. /**
  57804. * Handles the inits for the fragment code path
  57805. * @param state node material build state
  57806. */
  57807. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  57808. /**
  57809. * Generates the reflection coords code for the fragment code path
  57810. * @param worldNormalVarName name of the world normal variable
  57811. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  57812. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  57813. * @returns the shader code
  57814. */
  57815. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  57816. /**
  57817. * Generates the reflection color code for the fragment code path
  57818. * @param lodVarName name of the lod variable
  57819. * @param swizzleLookupTexture swizzle to use for the final color variable
  57820. * @returns the shader code
  57821. */
  57822. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  57823. /**
  57824. * Generates the code corresponding to the connected output points
  57825. * @param state node material build state
  57826. * @param varName name of the variable to output
  57827. * @returns the shader code
  57828. */
  57829. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  57830. protected _buildBlock(state: NodeMaterialBuildState): this;
  57831. protected _dumpPropertiesCode(): string;
  57832. serialize(): any;
  57833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57834. }
  57835. }
  57836. declare module BABYLON {
  57837. /**
  57838. * Defines a connection point to be used for points with a custom object type
  57839. */
  57840. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  57841. private _blockType;
  57842. private _blockName;
  57843. private _nameForCheking?;
  57844. /**
  57845. * Creates a new connection point
  57846. * @param name defines the connection point name
  57847. * @param ownerBlock defines the block hosting this connection point
  57848. * @param direction defines the direction of the connection point
  57849. */
  57850. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  57851. /**
  57852. * Gets a number indicating if the current point can be connected to another point
  57853. * @param connectionPoint defines the other connection point
  57854. * @returns a number defining the compatibility state
  57855. */
  57856. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57857. /**
  57858. * Creates a block suitable to be used as an input for this input point.
  57859. * If null is returned, a block based on the point type will be created.
  57860. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  57861. */
  57862. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  57863. }
  57864. }
  57865. declare module BABYLON {
  57866. /**
  57867. * Enum defining the type of properties that can be edited in the property pages in the NME
  57868. */
  57869. export enum PropertyTypeForEdition {
  57870. /** property is a boolean */
  57871. Boolean = 0,
  57872. /** property is a float */
  57873. Float = 1,
  57874. /** property is a Vector2 */
  57875. Vector2 = 2,
  57876. /** property is a list of values */
  57877. List = 3
  57878. }
  57879. /**
  57880. * Interface that defines an option in a variable of type list
  57881. */
  57882. export interface IEditablePropertyListOption {
  57883. /** label of the option */
  57884. "label": string;
  57885. /** value of the option */
  57886. "value": number;
  57887. }
  57888. /**
  57889. * Interface that defines the options available for an editable property
  57890. */
  57891. export interface IEditablePropertyOption {
  57892. /** min value */
  57893. "min"?: number;
  57894. /** max value */
  57895. "max"?: number;
  57896. /** notifiers: indicates which actions to take when the property is changed */
  57897. "notifiers"?: {
  57898. /** the material should be rebuilt */
  57899. "rebuild"?: boolean;
  57900. /** the preview should be updated */
  57901. "update"?: boolean;
  57902. };
  57903. /** list of the options for a variable of type list */
  57904. "options"?: IEditablePropertyListOption[];
  57905. }
  57906. /**
  57907. * Interface that describes an editable property
  57908. */
  57909. export interface IPropertyDescriptionForEdition {
  57910. /** name of the property */
  57911. "propertyName": string;
  57912. /** display name of the property */
  57913. "displayName": string;
  57914. /** type of the property */
  57915. "type": PropertyTypeForEdition;
  57916. /** group of the property - all properties with the same group value will be displayed in a specific section */
  57917. "groupName": string;
  57918. /** options for the property */
  57919. "options": IEditablePropertyOption;
  57920. }
  57921. /**
  57922. * Decorator that flags a property in a node material block as being editable
  57923. */
  57924. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  57925. }
  57926. declare module BABYLON {
  57927. /**
  57928. * Block used to implement the refraction part of the sub surface module of the PBR material
  57929. */
  57930. export class RefractionBlock extends NodeMaterialBlock {
  57931. /** @hidden */
  57932. _define3DName: string;
  57933. /** @hidden */
  57934. _refractionMatrixName: string;
  57935. /** @hidden */
  57936. _defineLODRefractionAlpha: string;
  57937. /** @hidden */
  57938. _defineLinearSpecularRefraction: string;
  57939. /** @hidden */
  57940. _defineOppositeZ: string;
  57941. /** @hidden */
  57942. _cubeSamplerName: string;
  57943. /** @hidden */
  57944. _2DSamplerName: string;
  57945. /** @hidden */
  57946. _vRefractionMicrosurfaceInfosName: string;
  57947. /** @hidden */
  57948. _vRefractionInfosName: string;
  57949. private _scene;
  57950. /**
  57951. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57952. * Materials half opaque for instance using refraction could benefit from this control.
  57953. */
  57954. linkRefractionWithTransparency: boolean;
  57955. /**
  57956. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57957. */
  57958. invertRefractionY: boolean;
  57959. /**
  57960. * Gets or sets the texture associated with the node
  57961. */
  57962. texture: Nullable<BaseTexture>;
  57963. /**
  57964. * Create a new RefractionBlock
  57965. * @param name defines the block name
  57966. */
  57967. constructor(name: string);
  57968. /**
  57969. * Gets the current class name
  57970. * @returns the class name
  57971. */
  57972. getClassName(): string;
  57973. /**
  57974. * Gets the intensity input component
  57975. */
  57976. get intensity(): NodeMaterialConnectionPoint;
  57977. /**
  57978. * Gets the index of refraction input component
  57979. */
  57980. get indexOfRefraction(): NodeMaterialConnectionPoint;
  57981. /**
  57982. * Gets the tint at distance input component
  57983. */
  57984. get tintAtDistance(): NodeMaterialConnectionPoint;
  57985. /**
  57986. * Gets the view input component
  57987. */
  57988. get view(): NodeMaterialConnectionPoint;
  57989. /**
  57990. * Gets the refraction object output component
  57991. */
  57992. get refraction(): NodeMaterialConnectionPoint;
  57993. /**
  57994. * Returns true if the block has a texture
  57995. */
  57996. get hasTexture(): boolean;
  57997. protected _getTexture(): Nullable<BaseTexture>;
  57998. autoConfigure(material: NodeMaterial): void;
  57999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58000. isReady(): boolean;
  58001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58002. /**
  58003. * Gets the main code of the block (fragment side)
  58004. * @param state current state of the node material building
  58005. * @returns the shader code
  58006. */
  58007. getCode(state: NodeMaterialBuildState): string;
  58008. protected _buildBlock(state: NodeMaterialBuildState): this;
  58009. protected _dumpPropertiesCode(): string;
  58010. serialize(): any;
  58011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58012. }
  58013. }
  58014. declare module BABYLON {
  58015. /**
  58016. * Interface used to configure the node material editor
  58017. */
  58018. export interface INodeMaterialEditorOptions {
  58019. /** Define the URl to load node editor script */
  58020. editorURL?: string;
  58021. }
  58022. /** @hidden */
  58023. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58024. NORMAL: boolean;
  58025. TANGENT: boolean;
  58026. UV1: boolean;
  58027. /** BONES */
  58028. NUM_BONE_INFLUENCERS: number;
  58029. BonesPerMesh: number;
  58030. BONETEXTURE: boolean;
  58031. /** MORPH TARGETS */
  58032. MORPHTARGETS: boolean;
  58033. MORPHTARGETS_NORMAL: boolean;
  58034. MORPHTARGETS_TANGENT: boolean;
  58035. MORPHTARGETS_UV: boolean;
  58036. NUM_MORPH_INFLUENCERS: number;
  58037. /** IMAGE PROCESSING */
  58038. IMAGEPROCESSING: boolean;
  58039. VIGNETTE: boolean;
  58040. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58041. VIGNETTEBLENDMODEOPAQUE: boolean;
  58042. TONEMAPPING: boolean;
  58043. TONEMAPPING_ACES: boolean;
  58044. CONTRAST: boolean;
  58045. EXPOSURE: boolean;
  58046. COLORCURVES: boolean;
  58047. COLORGRADING: boolean;
  58048. COLORGRADING3D: boolean;
  58049. SAMPLER3DGREENDEPTH: boolean;
  58050. SAMPLER3DBGRMAP: boolean;
  58051. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58052. /** MISC. */
  58053. BUMPDIRECTUV: number;
  58054. constructor();
  58055. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  58056. }
  58057. /**
  58058. * Class used to configure NodeMaterial
  58059. */
  58060. export interface INodeMaterialOptions {
  58061. /**
  58062. * Defines if blocks should emit comments
  58063. */
  58064. emitComments: boolean;
  58065. }
  58066. /**
  58067. * Class used to create a node based material built by assembling shader blocks
  58068. */
  58069. export class NodeMaterial extends PushMaterial {
  58070. private static _BuildIdGenerator;
  58071. private _options;
  58072. private _vertexCompilationState;
  58073. private _fragmentCompilationState;
  58074. private _sharedData;
  58075. private _buildId;
  58076. private _buildWasSuccessful;
  58077. private _cachedWorldViewMatrix;
  58078. private _cachedWorldViewProjectionMatrix;
  58079. private _optimizers;
  58080. private _animationFrame;
  58081. /** Define the Url to load node editor script */
  58082. static EditorURL: string;
  58083. /** Define the Url to load snippets */
  58084. static SnippetUrl: string;
  58085. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  58086. static IgnoreTexturesAtLoadTime: boolean;
  58087. private BJSNODEMATERIALEDITOR;
  58088. /** Get the inspector from bundle or global */
  58089. private _getGlobalNodeMaterialEditor;
  58090. /**
  58091. * Snippet ID if the material was created from the snippet server
  58092. */
  58093. snippetId: string;
  58094. /**
  58095. * Gets or sets data used by visual editor
  58096. * @see https://nme.babylonjs.com
  58097. */
  58098. editorData: any;
  58099. /**
  58100. * 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)
  58101. */
  58102. ignoreAlpha: boolean;
  58103. /**
  58104. * Defines the maximum number of lights that can be used in the material
  58105. */
  58106. maxSimultaneousLights: number;
  58107. /**
  58108. * Observable raised when the material is built
  58109. */
  58110. onBuildObservable: Observable<NodeMaterial>;
  58111. /**
  58112. * Gets or sets the root nodes of the material vertex shader
  58113. */
  58114. _vertexOutputNodes: NodeMaterialBlock[];
  58115. /**
  58116. * Gets or sets the root nodes of the material fragment (pixel) shader
  58117. */
  58118. _fragmentOutputNodes: NodeMaterialBlock[];
  58119. /** Gets or sets options to control the node material overall behavior */
  58120. get options(): INodeMaterialOptions;
  58121. set options(options: INodeMaterialOptions);
  58122. /**
  58123. * Default configuration related to image processing available in the standard Material.
  58124. */
  58125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58126. /**
  58127. * Gets the image processing configuration used either in this material.
  58128. */
  58129. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58130. /**
  58131. * Sets the Default image processing configuration used either in the this material.
  58132. *
  58133. * If sets to null, the scene one is in use.
  58134. */
  58135. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58136. /**
  58137. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58138. */
  58139. attachedBlocks: NodeMaterialBlock[];
  58140. /**
  58141. * Create a new node based material
  58142. * @param name defines the material name
  58143. * @param scene defines the hosting scene
  58144. * @param options defines creation option
  58145. */
  58146. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58147. /**
  58148. * Gets the current class name of the material e.g. "NodeMaterial"
  58149. * @returns the class name
  58150. */
  58151. getClassName(): string;
  58152. /**
  58153. * Keep track of the image processing observer to allow dispose and replace.
  58154. */
  58155. private _imageProcessingObserver;
  58156. /**
  58157. * Attaches a new image processing configuration to the Standard Material.
  58158. * @param configuration
  58159. */
  58160. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58161. /**
  58162. * Get a block by its name
  58163. * @param name defines the name of the block to retrieve
  58164. * @returns the required block or null if not found
  58165. */
  58166. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58167. /**
  58168. * Get a block by its name
  58169. * @param predicate defines the predicate used to find the good candidate
  58170. * @returns the required block or null if not found
  58171. */
  58172. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58173. /**
  58174. * Get an input block by its name
  58175. * @param predicate defines the predicate used to find the good candidate
  58176. * @returns the required input block or null if not found
  58177. */
  58178. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58179. /**
  58180. * Gets the list of input blocks attached to this material
  58181. * @returns an array of InputBlocks
  58182. */
  58183. getInputBlocks(): InputBlock[];
  58184. /**
  58185. * Adds a new optimizer to the list of optimizers
  58186. * @param optimizer defines the optimizers to add
  58187. * @returns the current material
  58188. */
  58189. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58190. /**
  58191. * Remove an optimizer from the list of optimizers
  58192. * @param optimizer defines the optimizers to remove
  58193. * @returns the current material
  58194. */
  58195. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58196. /**
  58197. * Add a new block to the list of output nodes
  58198. * @param node defines the node to add
  58199. * @returns the current material
  58200. */
  58201. addOutputNode(node: NodeMaterialBlock): this;
  58202. /**
  58203. * Remove a block from the list of root nodes
  58204. * @param node defines the node to remove
  58205. * @returns the current material
  58206. */
  58207. removeOutputNode(node: NodeMaterialBlock): this;
  58208. private _addVertexOutputNode;
  58209. private _removeVertexOutputNode;
  58210. private _addFragmentOutputNode;
  58211. private _removeFragmentOutputNode;
  58212. /**
  58213. * Specifies if the material will require alpha blending
  58214. * @returns a boolean specifying if alpha blending is needed
  58215. */
  58216. needAlphaBlending(): boolean;
  58217. /**
  58218. * Specifies if this material should be rendered in alpha test mode
  58219. * @returns a boolean specifying if an alpha test is needed.
  58220. */
  58221. needAlphaTesting(): boolean;
  58222. private _initializeBlock;
  58223. private _resetDualBlocks;
  58224. /**
  58225. * Remove a block from the current node material
  58226. * @param block defines the block to remove
  58227. */
  58228. removeBlock(block: NodeMaterialBlock): void;
  58229. /**
  58230. * Build the material and generates the inner effect
  58231. * @param verbose defines if the build should log activity
  58232. */
  58233. build(verbose?: boolean): void;
  58234. /**
  58235. * Runs an otpimization phase to try to improve the shader code
  58236. */
  58237. optimize(): void;
  58238. private _prepareDefinesForAttributes;
  58239. /**
  58240. * Get if the submesh is ready to be used and all its information available.
  58241. * Child classes can use it to update shaders
  58242. * @param mesh defines the mesh to check
  58243. * @param subMesh defines which submesh to check
  58244. * @param useInstances specifies that instances should be used
  58245. * @returns a boolean indicating that the submesh is ready or not
  58246. */
  58247. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58248. /**
  58249. * Get a string representing the shaders built by the current node graph
  58250. */
  58251. get compiledShaders(): string;
  58252. /**
  58253. * Binds the world matrix to the material
  58254. * @param world defines the world transformation matrix
  58255. */
  58256. bindOnlyWorldMatrix(world: Matrix): void;
  58257. /**
  58258. * Binds the submesh to this material by preparing the effect and shader to draw
  58259. * @param world defines the world transformation matrix
  58260. * @param mesh defines the mesh containing the submesh
  58261. * @param subMesh defines the submesh to bind the material to
  58262. */
  58263. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58264. /**
  58265. * Gets the active textures from the material
  58266. * @returns an array of textures
  58267. */
  58268. getActiveTextures(): BaseTexture[];
  58269. /**
  58270. * Gets the list of texture blocks
  58271. * @returns an array of texture blocks
  58272. */
  58273. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock)[];
  58274. /**
  58275. * Specifies if the material uses a texture
  58276. * @param texture defines the texture to check against the material
  58277. * @returns a boolean specifying if the material uses the texture
  58278. */
  58279. hasTexture(texture: BaseTexture): boolean;
  58280. /**
  58281. * Disposes the material
  58282. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58283. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58284. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58285. */
  58286. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58287. /** Creates the node editor window. */
  58288. private _createNodeEditor;
  58289. /**
  58290. * Launch the node material editor
  58291. * @param config Define the configuration of the editor
  58292. * @return a promise fulfilled when the node editor is visible
  58293. */
  58294. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58295. /**
  58296. * Clear the current material
  58297. */
  58298. clear(): void;
  58299. /**
  58300. * Clear the current material and set it to a default state
  58301. */
  58302. setToDefault(): void;
  58303. /**
  58304. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58305. * @param url defines the url to load from
  58306. * @returns a promise that will fullfil when the material is fully loaded
  58307. */
  58308. loadAsync(url: string): Promise<void>;
  58309. private _gatherBlocks;
  58310. /**
  58311. * Generate a string containing the code declaration required to create an equivalent of this material
  58312. * @returns a string
  58313. */
  58314. generateCode(): string;
  58315. /**
  58316. * Serializes this material in a JSON representation
  58317. * @returns the serialized material object
  58318. */
  58319. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58320. private _restoreConnections;
  58321. /**
  58322. * Clear the current graph and load a new one from a serialization object
  58323. * @param source defines the JSON representation of the material
  58324. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58325. */
  58326. loadFromSerialization(source: any, rootUrl?: string): void;
  58327. /**
  58328. * Makes a duplicate of the current material.
  58329. * @param name - name to use for the new material.
  58330. */
  58331. clone(name: string): NodeMaterial;
  58332. /**
  58333. * Creates a node material from parsed material data
  58334. * @param source defines the JSON representation of the material
  58335. * @param scene defines the hosting scene
  58336. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58337. * @returns a new node material
  58338. */
  58339. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58340. /**
  58341. * Creates a node material from a snippet saved in a remote file
  58342. * @param name defines the name of the material to create
  58343. * @param url defines the url to load from
  58344. * @param scene defines the hosting scene
  58345. * @returns a promise that will resolve to the new node material
  58346. */
  58347. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58348. /**
  58349. * Creates a node material from a snippet saved by the node material editor
  58350. * @param snippetId defines the snippet to load
  58351. * @param scene defines the hosting scene
  58352. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58353. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58354. * @returns a promise that will resolve to the new node material
  58355. */
  58356. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58357. /**
  58358. * Creates a new node material set to default basic configuration
  58359. * @param name defines the name of the material
  58360. * @param scene defines the hosting scene
  58361. * @returns a new NodeMaterial
  58362. */
  58363. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58364. }
  58365. }
  58366. declare module BABYLON {
  58367. /**
  58368. * Block used to read a texture from a sampler
  58369. */
  58370. export class TextureBlock extends NodeMaterialBlock {
  58371. private _defineName;
  58372. private _linearDefineName;
  58373. private _gammaDefineName;
  58374. private _tempTextureRead;
  58375. private _samplerName;
  58376. private _transformedUVName;
  58377. private _textureTransformName;
  58378. private _textureInfoName;
  58379. private _mainUVName;
  58380. private _mainUVDefineName;
  58381. /**
  58382. * Gets or sets the texture associated with the node
  58383. */
  58384. texture: Nullable<Texture>;
  58385. /**
  58386. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58387. */
  58388. convertToGammaSpace: boolean;
  58389. /**
  58390. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58391. */
  58392. convertToLinearSpace: boolean;
  58393. /**
  58394. * Create a new TextureBlock
  58395. * @param name defines the block name
  58396. */
  58397. constructor(name: string);
  58398. /**
  58399. * Gets the current class name
  58400. * @returns the class name
  58401. */
  58402. getClassName(): string;
  58403. /**
  58404. * Gets the uv input component
  58405. */
  58406. get uv(): NodeMaterialConnectionPoint;
  58407. /**
  58408. * Gets the rgba output component
  58409. */
  58410. get rgba(): NodeMaterialConnectionPoint;
  58411. /**
  58412. * Gets the rgb output component
  58413. */
  58414. get rgb(): NodeMaterialConnectionPoint;
  58415. /**
  58416. * Gets the r output component
  58417. */
  58418. get r(): NodeMaterialConnectionPoint;
  58419. /**
  58420. * Gets the g output component
  58421. */
  58422. get g(): NodeMaterialConnectionPoint;
  58423. /**
  58424. * Gets the b output component
  58425. */
  58426. get b(): NodeMaterialConnectionPoint;
  58427. /**
  58428. * Gets the a output component
  58429. */
  58430. get a(): NodeMaterialConnectionPoint;
  58431. get target(): NodeMaterialBlockTargets;
  58432. autoConfigure(material: NodeMaterial): void;
  58433. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58435. isReady(): boolean;
  58436. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58437. private get _isMixed();
  58438. private _injectVertexCode;
  58439. private _writeTextureRead;
  58440. private _writeOutput;
  58441. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58442. protected _dumpPropertiesCode(): string;
  58443. serialize(): any;
  58444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58445. }
  58446. }
  58447. declare module BABYLON {
  58448. /**
  58449. * Class used to store shared data between 2 NodeMaterialBuildState
  58450. */
  58451. export class NodeMaterialBuildStateSharedData {
  58452. /**
  58453. * Gets the list of emitted varyings
  58454. */
  58455. temps: string[];
  58456. /**
  58457. * Gets the list of emitted varyings
  58458. */
  58459. varyings: string[];
  58460. /**
  58461. * Gets the varying declaration string
  58462. */
  58463. varyingDeclaration: string;
  58464. /**
  58465. * Input blocks
  58466. */
  58467. inputBlocks: InputBlock[];
  58468. /**
  58469. * Input blocks
  58470. */
  58471. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock)[];
  58472. /**
  58473. * Bindable blocks (Blocks that need to set data to the effect)
  58474. */
  58475. bindableBlocks: NodeMaterialBlock[];
  58476. /**
  58477. * List of blocks that can provide a compilation fallback
  58478. */
  58479. blocksWithFallbacks: NodeMaterialBlock[];
  58480. /**
  58481. * List of blocks that can provide a define update
  58482. */
  58483. blocksWithDefines: NodeMaterialBlock[];
  58484. /**
  58485. * List of blocks that can provide a repeatable content
  58486. */
  58487. repeatableContentBlocks: NodeMaterialBlock[];
  58488. /**
  58489. * List of blocks that can provide a dynamic list of uniforms
  58490. */
  58491. dynamicUniformBlocks: NodeMaterialBlock[];
  58492. /**
  58493. * List of blocks that can block the isReady function for the material
  58494. */
  58495. blockingBlocks: NodeMaterialBlock[];
  58496. /**
  58497. * Gets the list of animated inputs
  58498. */
  58499. animatedInputs: InputBlock[];
  58500. /**
  58501. * Build Id used to avoid multiple recompilations
  58502. */
  58503. buildId: number;
  58504. /** List of emitted variables */
  58505. variableNames: {
  58506. [key: string]: number;
  58507. };
  58508. /** List of emitted defines */
  58509. defineNames: {
  58510. [key: string]: number;
  58511. };
  58512. /** Should emit comments? */
  58513. emitComments: boolean;
  58514. /** Emit build activity */
  58515. verbose: boolean;
  58516. /** Gets or sets the hosting scene */
  58517. scene: Scene;
  58518. /**
  58519. * Gets the compilation hints emitted at compilation time
  58520. */
  58521. hints: {
  58522. needWorldViewMatrix: boolean;
  58523. needWorldViewProjectionMatrix: boolean;
  58524. needAlphaBlending: boolean;
  58525. needAlphaTesting: boolean;
  58526. };
  58527. /**
  58528. * List of compilation checks
  58529. */
  58530. checks: {
  58531. emitVertex: boolean;
  58532. emitFragment: boolean;
  58533. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58534. };
  58535. /** Creates a new shared data */
  58536. constructor();
  58537. /**
  58538. * Emits console errors and exceptions if there is a failing check
  58539. */
  58540. emitErrors(): void;
  58541. }
  58542. }
  58543. declare module BABYLON {
  58544. /**
  58545. * Class used to store node based material build state
  58546. */
  58547. export class NodeMaterialBuildState {
  58548. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58549. supportUniformBuffers: boolean;
  58550. /**
  58551. * Gets the list of emitted attributes
  58552. */
  58553. attributes: string[];
  58554. /**
  58555. * Gets the list of emitted uniforms
  58556. */
  58557. uniforms: string[];
  58558. /**
  58559. * Gets the list of emitted constants
  58560. */
  58561. constants: string[];
  58562. /**
  58563. * Gets the list of emitted samplers
  58564. */
  58565. samplers: string[];
  58566. /**
  58567. * Gets the list of emitted functions
  58568. */
  58569. functions: {
  58570. [key: string]: string;
  58571. };
  58572. /**
  58573. * Gets the list of emitted extensions
  58574. */
  58575. extensions: {
  58576. [key: string]: string;
  58577. };
  58578. /**
  58579. * Gets the target of the compilation state
  58580. */
  58581. target: NodeMaterialBlockTargets;
  58582. /**
  58583. * Gets the list of emitted counters
  58584. */
  58585. counters: {
  58586. [key: string]: number;
  58587. };
  58588. /**
  58589. * Shared data between multiple NodeMaterialBuildState instances
  58590. */
  58591. sharedData: NodeMaterialBuildStateSharedData;
  58592. /** @hidden */
  58593. _vertexState: NodeMaterialBuildState;
  58594. /** @hidden */
  58595. _attributeDeclaration: string;
  58596. /** @hidden */
  58597. _uniformDeclaration: string;
  58598. /** @hidden */
  58599. _constantDeclaration: string;
  58600. /** @hidden */
  58601. _samplerDeclaration: string;
  58602. /** @hidden */
  58603. _varyingTransfer: string;
  58604. /** @hidden */
  58605. _injectAtEnd: string;
  58606. private _repeatableContentAnchorIndex;
  58607. /** @hidden */
  58608. _builtCompilationString: string;
  58609. /**
  58610. * Gets the emitted compilation strings
  58611. */
  58612. compilationString: string;
  58613. /**
  58614. * Finalize the compilation strings
  58615. * @param state defines the current compilation state
  58616. */
  58617. finalize(state: NodeMaterialBuildState): void;
  58618. /** @hidden */
  58619. get _repeatableContentAnchor(): string;
  58620. /** @hidden */
  58621. _getFreeVariableName(prefix: string): string;
  58622. /** @hidden */
  58623. _getFreeDefineName(prefix: string): string;
  58624. /** @hidden */
  58625. _excludeVariableName(name: string): void;
  58626. /** @hidden */
  58627. _emit2DSampler(name: string): void;
  58628. /** @hidden */
  58629. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58630. /** @hidden */
  58631. _emitExtension(name: string, extension: string, define?: string): void;
  58632. /** @hidden */
  58633. _emitFunction(name: string, code: string, comments: string): void;
  58634. /** @hidden */
  58635. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58636. replaceStrings?: {
  58637. search: RegExp;
  58638. replace: string;
  58639. }[];
  58640. repeatKey?: string;
  58641. }): string;
  58642. /** @hidden */
  58643. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58644. repeatKey?: string;
  58645. removeAttributes?: boolean;
  58646. removeUniforms?: boolean;
  58647. removeVaryings?: boolean;
  58648. removeIfDef?: boolean;
  58649. replaceStrings?: {
  58650. search: RegExp;
  58651. replace: string;
  58652. }[];
  58653. }, storeKey?: string): void;
  58654. /** @hidden */
  58655. _registerTempVariable(name: string): boolean;
  58656. /** @hidden */
  58657. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58658. /** @hidden */
  58659. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58660. /** @hidden */
  58661. _emitFloat(value: number): string;
  58662. }
  58663. }
  58664. declare module BABYLON {
  58665. /**
  58666. * Defines a block that can be used inside a node based material
  58667. */
  58668. export class NodeMaterialBlock {
  58669. private _buildId;
  58670. private _buildTarget;
  58671. private _target;
  58672. private _isFinalMerger;
  58673. private _isInput;
  58674. protected _isUnique: boolean;
  58675. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58676. inputsAreExclusive: boolean;
  58677. /** @hidden */
  58678. _codeVariableName: string;
  58679. /** @hidden */
  58680. _inputs: NodeMaterialConnectionPoint[];
  58681. /** @hidden */
  58682. _outputs: NodeMaterialConnectionPoint[];
  58683. /** @hidden */
  58684. _preparationId: number;
  58685. /**
  58686. * Gets or sets the name of the block
  58687. */
  58688. name: string;
  58689. /**
  58690. * Gets or sets the unique id of the node
  58691. */
  58692. uniqueId: number;
  58693. /**
  58694. * Gets or sets the comments associated with this block
  58695. */
  58696. comments: string;
  58697. /**
  58698. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58699. */
  58700. get isUnique(): boolean;
  58701. /**
  58702. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58703. */
  58704. get isFinalMerger(): boolean;
  58705. /**
  58706. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58707. */
  58708. get isInput(): boolean;
  58709. /**
  58710. * Gets or sets the build Id
  58711. */
  58712. get buildId(): number;
  58713. set buildId(value: number);
  58714. /**
  58715. * Gets or sets the target of the block
  58716. */
  58717. get target(): NodeMaterialBlockTargets;
  58718. set target(value: NodeMaterialBlockTargets);
  58719. /**
  58720. * Gets the list of input points
  58721. */
  58722. get inputs(): NodeMaterialConnectionPoint[];
  58723. /** Gets the list of output points */
  58724. get outputs(): NodeMaterialConnectionPoint[];
  58725. /**
  58726. * Find an input by its name
  58727. * @param name defines the name of the input to look for
  58728. * @returns the input or null if not found
  58729. */
  58730. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58731. /**
  58732. * Find an output by its name
  58733. * @param name defines the name of the outputto look for
  58734. * @returns the output or null if not found
  58735. */
  58736. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58737. /**
  58738. * Creates a new NodeMaterialBlock
  58739. * @param name defines the block name
  58740. * @param target defines the target of that block (Vertex by default)
  58741. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58742. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58743. */
  58744. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58745. /**
  58746. * Initialize the block and prepare the context for build
  58747. * @param state defines the state that will be used for the build
  58748. */
  58749. initialize(state: NodeMaterialBuildState): void;
  58750. /**
  58751. * Bind data to effect. Will only be called for blocks with isBindable === true
  58752. * @param effect defines the effect to bind data to
  58753. * @param nodeMaterial defines the hosting NodeMaterial
  58754. * @param mesh defines the mesh that will be rendered
  58755. * @param subMesh defines the submesh that will be rendered
  58756. */
  58757. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58758. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58759. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58760. protected _writeFloat(value: number): string;
  58761. /**
  58762. * Gets the current class name e.g. "NodeMaterialBlock"
  58763. * @returns the class name
  58764. */
  58765. getClassName(): string;
  58766. /**
  58767. * Register a new input. Must be called inside a block constructor
  58768. * @param name defines the connection point name
  58769. * @param type defines the connection point type
  58770. * @param isOptional defines a boolean indicating that this input can be omitted
  58771. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58772. * @param point an already created connection point. If not provided, create a new one
  58773. * @returns the current block
  58774. */
  58775. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  58776. /**
  58777. * Register a new output. Must be called inside a block constructor
  58778. * @param name defines the connection point name
  58779. * @param type defines the connection point type
  58780. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58781. * @param point an already created connection point. If not provided, create a new one
  58782. * @returns the current block
  58783. */
  58784. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  58785. /**
  58786. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58787. * @param forOutput defines an optional connection point to check compatibility with
  58788. * @returns the first available input or null
  58789. */
  58790. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58791. /**
  58792. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58793. * @param forBlock defines an optional block to check compatibility with
  58794. * @returns the first available input or null
  58795. */
  58796. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58797. /**
  58798. * Gets the sibling of the given output
  58799. * @param current defines the current output
  58800. * @returns the next output in the list or null
  58801. */
  58802. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58803. /**
  58804. * Connect current block with another block
  58805. * @param other defines the block to connect with
  58806. * @param options define the various options to help pick the right connections
  58807. * @returns the current block
  58808. */
  58809. connectTo(other: NodeMaterialBlock, options?: {
  58810. input?: string;
  58811. output?: string;
  58812. outputSwizzle?: string;
  58813. }): this | undefined;
  58814. protected _buildBlock(state: NodeMaterialBuildState): void;
  58815. /**
  58816. * Add uniforms, samplers and uniform buffers at compilation time
  58817. * @param state defines the state to update
  58818. * @param nodeMaterial defines the node material requesting the update
  58819. * @param defines defines the material defines to update
  58820. * @param uniformBuffers defines the list of uniform buffer names
  58821. */
  58822. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58823. /**
  58824. * Add potential fallbacks if shader compilation fails
  58825. * @param mesh defines the mesh to be rendered
  58826. * @param fallbacks defines the current prioritized list of fallbacks
  58827. */
  58828. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58829. /**
  58830. * Initialize defines for shader compilation
  58831. * @param mesh defines the mesh to be rendered
  58832. * @param nodeMaterial defines the node material requesting the update
  58833. * @param defines defines the material defines to update
  58834. * @param useInstances specifies that instances should be used
  58835. */
  58836. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58837. /**
  58838. * Update defines for shader compilation
  58839. * @param mesh defines the mesh to be rendered
  58840. * @param nodeMaterial defines the node material requesting the update
  58841. * @param defines defines the material defines to update
  58842. * @param useInstances specifies that instances should be used
  58843. */
  58844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58845. /**
  58846. * Lets the block try to connect some inputs automatically
  58847. * @param material defines the hosting NodeMaterial
  58848. */
  58849. autoConfigure(material: NodeMaterial): void;
  58850. /**
  58851. * Function called when a block is declared as repeatable content generator
  58852. * @param vertexShaderState defines the current compilation state for the vertex shader
  58853. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58854. * @param mesh defines the mesh to be rendered
  58855. * @param defines defines the material defines to update
  58856. */
  58857. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58858. /**
  58859. * Checks if the block is ready
  58860. * @param mesh defines the mesh to be rendered
  58861. * @param nodeMaterial defines the node material requesting the update
  58862. * @param defines defines the material defines to update
  58863. * @param useInstances specifies that instances should be used
  58864. * @returns true if the block is ready
  58865. */
  58866. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58867. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58868. private _processBuild;
  58869. /**
  58870. * Compile the current node and generate the shader code
  58871. * @param state defines the current compilation state (uniforms, samplers, current string)
  58872. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58873. * @returns true if already built
  58874. */
  58875. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58876. protected _inputRename(name: string): string;
  58877. protected _outputRename(name: string): string;
  58878. protected _dumpPropertiesCode(): string;
  58879. /** @hidden */
  58880. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58881. /** @hidden */
  58882. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58883. /**
  58884. * Clone the current block to a new identical block
  58885. * @param scene defines the hosting scene
  58886. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58887. * @returns a copy of the current block
  58888. */
  58889. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58890. /**
  58891. * Serializes this block in a JSON representation
  58892. * @returns the serialized block object
  58893. */
  58894. serialize(): any;
  58895. /** @hidden */
  58896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58897. private _deserializePortDisplayNames;
  58898. /**
  58899. * Release resources
  58900. */
  58901. dispose(): void;
  58902. }
  58903. }
  58904. declare module BABYLON {
  58905. /**
  58906. * Enum defining the type of animations supported by InputBlock
  58907. */
  58908. export enum AnimatedInputBlockTypes {
  58909. /** No animation */
  58910. None = 0,
  58911. /** Time based animation. Will only work for floats */
  58912. Time = 1
  58913. }
  58914. }
  58915. declare module BABYLON {
  58916. /**
  58917. * Block used to expose an input value
  58918. */
  58919. export class InputBlock extends NodeMaterialBlock {
  58920. private _mode;
  58921. private _associatedVariableName;
  58922. private _storedValue;
  58923. private _valueCallback;
  58924. private _type;
  58925. private _animationType;
  58926. /** Gets or set a value used to limit the range of float values */
  58927. min: number;
  58928. /** Gets or set a value used to limit the range of float values */
  58929. max: number;
  58930. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58931. isBoolean: boolean;
  58932. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58933. matrixMode: number;
  58934. /** @hidden */
  58935. _systemValue: Nullable<NodeMaterialSystemValues>;
  58936. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58937. visibleInInspector: boolean;
  58938. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58939. isConstant: boolean;
  58940. /** Gets or sets the group to use to display this block in the Inspector */
  58941. groupInInspector: string;
  58942. /** Gets an observable raised when the value is changed */
  58943. onValueChangedObservable: Observable<InputBlock>;
  58944. /**
  58945. * Gets or sets the connection point type (default is float)
  58946. */
  58947. get type(): NodeMaterialBlockConnectionPointTypes;
  58948. /**
  58949. * Creates a new InputBlock
  58950. * @param name defines the block name
  58951. * @param target defines the target of that block (Vertex by default)
  58952. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58953. */
  58954. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58955. /**
  58956. * Gets the output component
  58957. */
  58958. get output(): NodeMaterialConnectionPoint;
  58959. /**
  58960. * Set the source of this connection point to a vertex attribute
  58961. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58962. * @returns the current connection point
  58963. */
  58964. setAsAttribute(attributeName?: string): InputBlock;
  58965. /**
  58966. * Set the source of this connection point to a system value
  58967. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58968. * @returns the current connection point
  58969. */
  58970. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58971. /**
  58972. * Gets or sets the value of that point.
  58973. * Please note that this value will be ignored if valueCallback is defined
  58974. */
  58975. get value(): any;
  58976. set value(value: any);
  58977. /**
  58978. * Gets or sets a callback used to get the value of that point.
  58979. * Please note that setting this value will force the connection point to ignore the value property
  58980. */
  58981. get valueCallback(): () => any;
  58982. set valueCallback(value: () => any);
  58983. /**
  58984. * Gets or sets the associated variable name in the shader
  58985. */
  58986. get associatedVariableName(): string;
  58987. set associatedVariableName(value: string);
  58988. /** Gets or sets the type of animation applied to the input */
  58989. get animationType(): AnimatedInputBlockTypes;
  58990. set animationType(value: AnimatedInputBlockTypes);
  58991. /**
  58992. * Gets a boolean indicating that this connection point not defined yet
  58993. */
  58994. get isUndefined(): boolean;
  58995. /**
  58996. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58997. * In this case the connection point name must be the name of the uniform to use.
  58998. * Can only be set on inputs
  58999. */
  59000. get isUniform(): boolean;
  59001. set isUniform(value: boolean);
  59002. /**
  59003. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59004. * In this case the connection point name must be the name of the attribute to use
  59005. * Can only be set on inputs
  59006. */
  59007. get isAttribute(): boolean;
  59008. set isAttribute(value: boolean);
  59009. /**
  59010. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59011. * Can only be set on exit points
  59012. */
  59013. get isVarying(): boolean;
  59014. set isVarying(value: boolean);
  59015. /**
  59016. * Gets a boolean indicating that the current connection point is a system value
  59017. */
  59018. get isSystemValue(): boolean;
  59019. /**
  59020. * Gets or sets the current well known value or null if not defined as a system value
  59021. */
  59022. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59023. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59024. /**
  59025. * Gets the current class name
  59026. * @returns the class name
  59027. */
  59028. getClassName(): string;
  59029. /**
  59030. * Animate the input if animationType !== None
  59031. * @param scene defines the rendering scene
  59032. */
  59033. animate(scene: Scene): void;
  59034. private _emitDefine;
  59035. initialize(state: NodeMaterialBuildState): void;
  59036. /**
  59037. * Set the input block to its default value (based on its type)
  59038. */
  59039. setDefaultValue(): void;
  59040. private _emitConstant;
  59041. private _emit;
  59042. /** @hidden */
  59043. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59044. /** @hidden */
  59045. _transmit(effect: Effect, scene: Scene): void;
  59046. protected _buildBlock(state: NodeMaterialBuildState): void;
  59047. protected _dumpPropertiesCode(): string;
  59048. dispose(): void;
  59049. serialize(): any;
  59050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59051. }
  59052. }
  59053. declare module BABYLON {
  59054. /**
  59055. * Enum used to define the compatibility state between two connection points
  59056. */
  59057. export enum NodeMaterialConnectionPointCompatibilityStates {
  59058. /** Points are compatibles */
  59059. Compatible = 0,
  59060. /** Points are incompatible because of their types */
  59061. TypeIncompatible = 1,
  59062. /** Points are incompatible because of their targets (vertex vs fragment) */
  59063. TargetIncompatible = 2
  59064. }
  59065. /**
  59066. * Defines the direction of a connection point
  59067. */
  59068. export enum NodeMaterialConnectionPointDirection {
  59069. /** Input */
  59070. Input = 0,
  59071. /** Output */
  59072. Output = 1
  59073. }
  59074. /**
  59075. * Defines a connection point for a block
  59076. */
  59077. export class NodeMaterialConnectionPoint {
  59078. /** @hidden */
  59079. _ownerBlock: NodeMaterialBlock;
  59080. /** @hidden */
  59081. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59082. private _endpoints;
  59083. private _associatedVariableName;
  59084. private _direction;
  59085. /** @hidden */
  59086. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59087. /** @hidden */
  59088. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59089. private _type;
  59090. /** @hidden */
  59091. _enforceAssociatedVariableName: boolean;
  59092. /** Gets the direction of the point */
  59093. get direction(): NodeMaterialConnectionPointDirection;
  59094. /** Indicates that this connection point needs dual validation before being connected to another point */
  59095. needDualDirectionValidation: boolean;
  59096. /**
  59097. * Gets or sets the additional types supported by this connection point
  59098. */
  59099. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59100. /**
  59101. * Gets or sets the additional types excluded by this connection point
  59102. */
  59103. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59104. /**
  59105. * Observable triggered when this point is connected
  59106. */
  59107. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59108. /**
  59109. * Gets or sets the associated variable name in the shader
  59110. */
  59111. get associatedVariableName(): string;
  59112. set associatedVariableName(value: string);
  59113. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  59114. get innerType(): NodeMaterialBlockConnectionPointTypes;
  59115. /**
  59116. * Gets or sets the connection point type (default is float)
  59117. */
  59118. get type(): NodeMaterialBlockConnectionPointTypes;
  59119. set type(value: NodeMaterialBlockConnectionPointTypes);
  59120. /**
  59121. * Gets or sets the connection point name
  59122. */
  59123. name: string;
  59124. /**
  59125. * Gets or sets the connection point name
  59126. */
  59127. displayName: string;
  59128. /**
  59129. * Gets or sets a boolean indicating that this connection point can be omitted
  59130. */
  59131. isOptional: boolean;
  59132. /**
  59133. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59134. */
  59135. define: string;
  59136. /** @hidden */
  59137. _prioritizeVertex: boolean;
  59138. private _target;
  59139. /** Gets or sets the target of that connection point */
  59140. get target(): NodeMaterialBlockTargets;
  59141. set target(value: NodeMaterialBlockTargets);
  59142. /**
  59143. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  59144. */
  59145. get isConnected(): boolean;
  59146. /**
  59147. * Gets a boolean indicating that the current point is connected to an input block
  59148. */
  59149. get isConnectedToInputBlock(): boolean;
  59150. /**
  59151. * Gets a the connected input block (if any)
  59152. */
  59153. get connectInputBlock(): Nullable<InputBlock>;
  59154. /** Get the other side of the connection (if any) */
  59155. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59156. /** Get the block that owns this connection point */
  59157. get ownerBlock(): NodeMaterialBlock;
  59158. /** Get the block connected on the other side of this connection (if any) */
  59159. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59160. /** Get the block connected on the endpoints of this connection (if any) */
  59161. get connectedBlocks(): Array<NodeMaterialBlock>;
  59162. /** Gets the list of connected endpoints */
  59163. get endpoints(): NodeMaterialConnectionPoint[];
  59164. /** Gets a boolean indicating if that output point is connected to at least one input */
  59165. get hasEndpoints(): boolean;
  59166. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59167. get isConnectedInVertexShader(): boolean;
  59168. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59169. get isConnectedInFragmentShader(): boolean;
  59170. /**
  59171. * Creates a block suitable to be used as an input for this input point.
  59172. * If null is returned, a block based on the point type will be created.
  59173. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  59174. */
  59175. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  59176. /**
  59177. * Creates a new connection point
  59178. * @param name defines the connection point name
  59179. * @param ownerBlock defines the block hosting this connection point
  59180. * @param direction defines the direction of the connection point
  59181. */
  59182. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59183. /**
  59184. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59185. * @returns the class name
  59186. */
  59187. getClassName(): string;
  59188. /**
  59189. * Gets a boolean indicating if the current point can be connected to another point
  59190. * @param connectionPoint defines the other connection point
  59191. * @returns a boolean
  59192. */
  59193. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59194. /**
  59195. * Gets a number indicating if the current point can be connected to another point
  59196. * @param connectionPoint defines the other connection point
  59197. * @returns a number defining the compatibility state
  59198. */
  59199. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59200. /**
  59201. * Connect this point to another connection point
  59202. * @param connectionPoint defines the other connection point
  59203. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59204. * @returns the current connection point
  59205. */
  59206. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59207. /**
  59208. * Disconnect this point from one of his endpoint
  59209. * @param endpoint defines the other connection point
  59210. * @returns the current connection point
  59211. */
  59212. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59213. /**
  59214. * Serializes this point in a JSON representation
  59215. * @param isInput defines if the connection point is an input (default is true)
  59216. * @returns the serialized point object
  59217. */
  59218. serialize(isInput?: boolean): any;
  59219. /**
  59220. * Release resources
  59221. */
  59222. dispose(): void;
  59223. }
  59224. }
  59225. declare module BABYLON {
  59226. /**
  59227. * Block used to add support for vertex skinning (bones)
  59228. */
  59229. export class BonesBlock extends NodeMaterialBlock {
  59230. /**
  59231. * Creates a new BonesBlock
  59232. * @param name defines the block name
  59233. */
  59234. constructor(name: string);
  59235. /**
  59236. * Initialize the block and prepare the context for build
  59237. * @param state defines the state that will be used for the build
  59238. */
  59239. initialize(state: NodeMaterialBuildState): void;
  59240. /**
  59241. * Gets the current class name
  59242. * @returns the class name
  59243. */
  59244. getClassName(): string;
  59245. /**
  59246. * Gets the matrix indices input component
  59247. */
  59248. get matricesIndices(): NodeMaterialConnectionPoint;
  59249. /**
  59250. * Gets the matrix weights input component
  59251. */
  59252. get matricesWeights(): NodeMaterialConnectionPoint;
  59253. /**
  59254. * Gets the extra matrix indices input component
  59255. */
  59256. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59257. /**
  59258. * Gets the extra matrix weights input component
  59259. */
  59260. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59261. /**
  59262. * Gets the world input component
  59263. */
  59264. get world(): NodeMaterialConnectionPoint;
  59265. /**
  59266. * Gets the output component
  59267. */
  59268. get output(): NodeMaterialConnectionPoint;
  59269. autoConfigure(material: NodeMaterial): void;
  59270. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59271. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59273. protected _buildBlock(state: NodeMaterialBuildState): this;
  59274. }
  59275. }
  59276. declare module BABYLON {
  59277. /**
  59278. * Block used to add support for instances
  59279. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59280. */
  59281. export class InstancesBlock extends NodeMaterialBlock {
  59282. /**
  59283. * Creates a new InstancesBlock
  59284. * @param name defines the block name
  59285. */
  59286. constructor(name: string);
  59287. /**
  59288. * Gets the current class name
  59289. * @returns the class name
  59290. */
  59291. getClassName(): string;
  59292. /**
  59293. * Gets the first world row input component
  59294. */
  59295. get world0(): NodeMaterialConnectionPoint;
  59296. /**
  59297. * Gets the second world row input component
  59298. */
  59299. get world1(): NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the third world row input component
  59302. */
  59303. get world2(): NodeMaterialConnectionPoint;
  59304. /**
  59305. * Gets the forth world row input component
  59306. */
  59307. get world3(): NodeMaterialConnectionPoint;
  59308. /**
  59309. * Gets the world input component
  59310. */
  59311. get world(): NodeMaterialConnectionPoint;
  59312. /**
  59313. * Gets the output component
  59314. */
  59315. get output(): NodeMaterialConnectionPoint;
  59316. /**
  59317. * Gets the isntanceID component
  59318. */
  59319. get instanceID(): NodeMaterialConnectionPoint;
  59320. autoConfigure(material: NodeMaterial): void;
  59321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59322. protected _buildBlock(state: NodeMaterialBuildState): this;
  59323. }
  59324. }
  59325. declare module BABYLON {
  59326. /**
  59327. * Block used to add morph targets support to vertex shader
  59328. */
  59329. export class MorphTargetsBlock extends NodeMaterialBlock {
  59330. private _repeatableContentAnchor;
  59331. /**
  59332. * Create a new MorphTargetsBlock
  59333. * @param name defines the block name
  59334. */
  59335. constructor(name: string);
  59336. /**
  59337. * Gets the current class name
  59338. * @returns the class name
  59339. */
  59340. getClassName(): string;
  59341. /**
  59342. * Gets the position input component
  59343. */
  59344. get position(): NodeMaterialConnectionPoint;
  59345. /**
  59346. * Gets the normal input component
  59347. */
  59348. get normal(): NodeMaterialConnectionPoint;
  59349. /**
  59350. * Gets the tangent input component
  59351. */
  59352. get tangent(): NodeMaterialConnectionPoint;
  59353. /**
  59354. * Gets the tangent input component
  59355. */
  59356. get uv(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the position output component
  59359. */
  59360. get positionOutput(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the normal output component
  59363. */
  59364. get normalOutput(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the tangent output component
  59367. */
  59368. get tangentOutput(): NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the tangent output component
  59371. */
  59372. get uvOutput(): NodeMaterialConnectionPoint;
  59373. initialize(state: NodeMaterialBuildState): void;
  59374. autoConfigure(material: NodeMaterial): void;
  59375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59376. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59377. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59378. protected _buildBlock(state: NodeMaterialBuildState): this;
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /**
  59383. * Block used to get data information from a light
  59384. */
  59385. export class LightInformationBlock extends NodeMaterialBlock {
  59386. private _lightDataUniformName;
  59387. private _lightColorUniformName;
  59388. private _lightTypeDefineName;
  59389. /**
  59390. * Gets or sets the light associated with this block
  59391. */
  59392. light: Nullable<Light>;
  59393. /**
  59394. * Creates a new LightInformationBlock
  59395. * @param name defines the block name
  59396. */
  59397. constructor(name: string);
  59398. /**
  59399. * Gets the current class name
  59400. * @returns the class name
  59401. */
  59402. getClassName(): string;
  59403. /**
  59404. * Gets the world position input component
  59405. */
  59406. get worldPosition(): NodeMaterialConnectionPoint;
  59407. /**
  59408. * Gets the direction output component
  59409. */
  59410. get direction(): NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the direction output component
  59413. */
  59414. get color(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the direction output component
  59417. */
  59418. get intensity(): NodeMaterialConnectionPoint;
  59419. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59421. protected _buildBlock(state: NodeMaterialBuildState): this;
  59422. serialize(): any;
  59423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59424. }
  59425. }
  59426. declare module BABYLON {
  59427. /**
  59428. * Block used to add image processing support to fragment shader
  59429. */
  59430. export class ImageProcessingBlock extends NodeMaterialBlock {
  59431. /**
  59432. * Create a new ImageProcessingBlock
  59433. * @param name defines the block name
  59434. */
  59435. constructor(name: string);
  59436. /**
  59437. * Gets the current class name
  59438. * @returns the class name
  59439. */
  59440. getClassName(): string;
  59441. /**
  59442. * Gets the color input component
  59443. */
  59444. get color(): NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the output component
  59447. */
  59448. get output(): NodeMaterialConnectionPoint;
  59449. /**
  59450. * Initialize the block and prepare the context for build
  59451. * @param state defines the state that will be used for the build
  59452. */
  59453. initialize(state: NodeMaterialBuildState): void;
  59454. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59456. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59457. protected _buildBlock(state: NodeMaterialBuildState): this;
  59458. }
  59459. }
  59460. declare module BABYLON {
  59461. /**
  59462. * Block used to pertub normals based on a normal map
  59463. */
  59464. export class PerturbNormalBlock extends NodeMaterialBlock {
  59465. private _tangentSpaceParameterName;
  59466. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59467. invertX: boolean;
  59468. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59469. invertY: boolean;
  59470. /**
  59471. * Create a new PerturbNormalBlock
  59472. * @param name defines the block name
  59473. */
  59474. constructor(name: string);
  59475. /**
  59476. * Gets the current class name
  59477. * @returns the class name
  59478. */
  59479. getClassName(): string;
  59480. /**
  59481. * Gets the world position input component
  59482. */
  59483. get worldPosition(): NodeMaterialConnectionPoint;
  59484. /**
  59485. * Gets the world normal input component
  59486. */
  59487. get worldNormal(): NodeMaterialConnectionPoint;
  59488. /**
  59489. * Gets the world tangent input component
  59490. */
  59491. get worldTangent(): NodeMaterialConnectionPoint;
  59492. /**
  59493. * Gets the uv input component
  59494. */
  59495. get uv(): NodeMaterialConnectionPoint;
  59496. /**
  59497. * Gets the normal map color input component
  59498. */
  59499. get normalMapColor(): NodeMaterialConnectionPoint;
  59500. /**
  59501. * Gets the strength input component
  59502. */
  59503. get strength(): NodeMaterialConnectionPoint;
  59504. /**
  59505. * Gets the output component
  59506. */
  59507. get output(): NodeMaterialConnectionPoint;
  59508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59510. autoConfigure(material: NodeMaterial): void;
  59511. protected _buildBlock(state: NodeMaterialBuildState): this;
  59512. protected _dumpPropertiesCode(): string;
  59513. serialize(): any;
  59514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59515. }
  59516. }
  59517. declare module BABYLON {
  59518. /**
  59519. * Block used to discard a pixel if a value is smaller than a cutoff
  59520. */
  59521. export class DiscardBlock extends NodeMaterialBlock {
  59522. /**
  59523. * Create a new DiscardBlock
  59524. * @param name defines the block name
  59525. */
  59526. constructor(name: string);
  59527. /**
  59528. * Gets the current class name
  59529. * @returns the class name
  59530. */
  59531. getClassName(): string;
  59532. /**
  59533. * Gets the color input component
  59534. */
  59535. get value(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the cutoff input component
  59538. */
  59539. get cutoff(): NodeMaterialConnectionPoint;
  59540. protected _buildBlock(state: NodeMaterialBuildState): this;
  59541. }
  59542. }
  59543. declare module BABYLON {
  59544. /**
  59545. * Block used to test if the fragment shader is front facing
  59546. */
  59547. export class FrontFacingBlock extends NodeMaterialBlock {
  59548. /**
  59549. * Creates a new FrontFacingBlock
  59550. * @param name defines the block name
  59551. */
  59552. constructor(name: string);
  59553. /**
  59554. * Gets the current class name
  59555. * @returns the class name
  59556. */
  59557. getClassName(): string;
  59558. /**
  59559. * Gets the output component
  59560. */
  59561. get output(): NodeMaterialConnectionPoint;
  59562. protected _buildBlock(state: NodeMaterialBuildState): this;
  59563. }
  59564. }
  59565. declare module BABYLON {
  59566. /**
  59567. * Block used to get the derivative value on x and y of a given input
  59568. */
  59569. export class DerivativeBlock extends NodeMaterialBlock {
  59570. /**
  59571. * Create a new DerivativeBlock
  59572. * @param name defines the block name
  59573. */
  59574. constructor(name: string);
  59575. /**
  59576. * Gets the current class name
  59577. * @returns the class name
  59578. */
  59579. getClassName(): string;
  59580. /**
  59581. * Gets the input component
  59582. */
  59583. get input(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the derivative output on x
  59586. */
  59587. get dx(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the derivative output on y
  59590. */
  59591. get dy(): NodeMaterialConnectionPoint;
  59592. protected _buildBlock(state: NodeMaterialBuildState): this;
  59593. }
  59594. }
  59595. declare module BABYLON {
  59596. /**
  59597. * Block used to add support for scene fog
  59598. */
  59599. export class FogBlock extends NodeMaterialBlock {
  59600. private _fogDistanceName;
  59601. private _fogParameters;
  59602. /**
  59603. * Create a new FogBlock
  59604. * @param name defines the block name
  59605. */
  59606. constructor(name: string);
  59607. /**
  59608. * Gets the current class name
  59609. * @returns the class name
  59610. */
  59611. getClassName(): string;
  59612. /**
  59613. * Gets the world position input component
  59614. */
  59615. get worldPosition(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the view input component
  59618. */
  59619. get view(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the color input component
  59622. */
  59623. get input(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the fog color input component
  59626. */
  59627. get fogColor(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the output component
  59630. */
  59631. get output(): NodeMaterialConnectionPoint;
  59632. autoConfigure(material: NodeMaterial): void;
  59633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59635. protected _buildBlock(state: NodeMaterialBuildState): this;
  59636. }
  59637. }
  59638. declare module BABYLON {
  59639. /**
  59640. * Block used to add light in the fragment shader
  59641. */
  59642. export class LightBlock extends NodeMaterialBlock {
  59643. private _lightId;
  59644. /**
  59645. * Gets or sets the light associated with this block
  59646. */
  59647. light: Nullable<Light>;
  59648. /**
  59649. * Create a new LightBlock
  59650. * @param name defines the block name
  59651. */
  59652. constructor(name: string);
  59653. /**
  59654. * Gets the current class name
  59655. * @returns the class name
  59656. */
  59657. getClassName(): string;
  59658. /**
  59659. * Gets the world position input component
  59660. */
  59661. get worldPosition(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the world normal input component
  59664. */
  59665. get worldNormal(): NodeMaterialConnectionPoint;
  59666. /**
  59667. * Gets the camera (or eye) position component
  59668. */
  59669. get cameraPosition(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the glossiness component
  59672. */
  59673. get glossiness(): NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the glossinness power component
  59676. */
  59677. get glossPower(): NodeMaterialConnectionPoint;
  59678. /**
  59679. * Gets the diffuse color component
  59680. */
  59681. get diffuseColor(): NodeMaterialConnectionPoint;
  59682. /**
  59683. * Gets the specular color component
  59684. */
  59685. get specularColor(): NodeMaterialConnectionPoint;
  59686. /**
  59687. * Gets the diffuse output component
  59688. */
  59689. get diffuseOutput(): NodeMaterialConnectionPoint;
  59690. /**
  59691. * Gets the specular output component
  59692. */
  59693. get specularOutput(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the shadow output component
  59696. */
  59697. get shadow(): NodeMaterialConnectionPoint;
  59698. autoConfigure(material: NodeMaterial): void;
  59699. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59700. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59701. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59702. private _injectVertexCode;
  59703. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59704. serialize(): any;
  59705. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59706. }
  59707. }
  59708. declare module BABYLON {
  59709. /**
  59710. * Block used to read a reflection texture from a sampler
  59711. */
  59712. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  59713. /**
  59714. * Create a new ReflectionTextureBlock
  59715. * @param name defines the block name
  59716. */
  59717. constructor(name: string);
  59718. /**
  59719. * Gets the current class name
  59720. * @returns the class name
  59721. */
  59722. getClassName(): string;
  59723. /**
  59724. * Gets the world position input component
  59725. */
  59726. get position(): NodeMaterialConnectionPoint;
  59727. /**
  59728. * Gets the world position input component
  59729. */
  59730. get worldPosition(): NodeMaterialConnectionPoint;
  59731. /**
  59732. * Gets the world normal input component
  59733. */
  59734. get worldNormal(): NodeMaterialConnectionPoint;
  59735. /**
  59736. * Gets the world input component
  59737. */
  59738. get world(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the camera (or eye) position component
  59741. */
  59742. get cameraPosition(): NodeMaterialConnectionPoint;
  59743. /**
  59744. * Gets the view input component
  59745. */
  59746. get view(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the rgb output component
  59749. */
  59750. get rgb(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the r output component
  59753. */
  59754. get r(): NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the g output component
  59757. */
  59758. get g(): NodeMaterialConnectionPoint;
  59759. /**
  59760. * Gets the b output component
  59761. */
  59762. get b(): NodeMaterialConnectionPoint;
  59763. autoConfigure(material: NodeMaterial): void;
  59764. protected _buildBlock(state: NodeMaterialBuildState): this;
  59765. }
  59766. }
  59767. declare module BABYLON {
  59768. /**
  59769. * Block used to multiply 2 values
  59770. */
  59771. export class MultiplyBlock extends NodeMaterialBlock {
  59772. /**
  59773. * Creates a new MultiplyBlock
  59774. * @param name defines the block name
  59775. */
  59776. constructor(name: string);
  59777. /**
  59778. * Gets the current class name
  59779. * @returns the class name
  59780. */
  59781. getClassName(): string;
  59782. /**
  59783. * Gets the left operand input component
  59784. */
  59785. get left(): NodeMaterialConnectionPoint;
  59786. /**
  59787. * Gets the right operand input component
  59788. */
  59789. get right(): NodeMaterialConnectionPoint;
  59790. /**
  59791. * Gets the output component
  59792. */
  59793. get output(): NodeMaterialConnectionPoint;
  59794. protected _buildBlock(state: NodeMaterialBuildState): this;
  59795. }
  59796. }
  59797. declare module BABYLON {
  59798. /**
  59799. * Block used to add 2 vectors
  59800. */
  59801. export class AddBlock extends NodeMaterialBlock {
  59802. /**
  59803. * Creates a new AddBlock
  59804. * @param name defines the block name
  59805. */
  59806. constructor(name: string);
  59807. /**
  59808. * Gets the current class name
  59809. * @returns the class name
  59810. */
  59811. getClassName(): string;
  59812. /**
  59813. * Gets the left operand input component
  59814. */
  59815. get left(): NodeMaterialConnectionPoint;
  59816. /**
  59817. * Gets the right operand input component
  59818. */
  59819. get right(): NodeMaterialConnectionPoint;
  59820. /**
  59821. * Gets the output component
  59822. */
  59823. get output(): NodeMaterialConnectionPoint;
  59824. protected _buildBlock(state: NodeMaterialBuildState): this;
  59825. }
  59826. }
  59827. declare module BABYLON {
  59828. /**
  59829. * Block used to scale a vector by a float
  59830. */
  59831. export class ScaleBlock extends NodeMaterialBlock {
  59832. /**
  59833. * Creates a new ScaleBlock
  59834. * @param name defines the block name
  59835. */
  59836. constructor(name: string);
  59837. /**
  59838. * Gets the current class name
  59839. * @returns the class name
  59840. */
  59841. getClassName(): string;
  59842. /**
  59843. * Gets the input component
  59844. */
  59845. get input(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the factor input component
  59848. */
  59849. get factor(): NodeMaterialConnectionPoint;
  59850. /**
  59851. * Gets the output component
  59852. */
  59853. get output(): NodeMaterialConnectionPoint;
  59854. protected _buildBlock(state: NodeMaterialBuildState): this;
  59855. }
  59856. }
  59857. declare module BABYLON {
  59858. /**
  59859. * Block used to clamp a float
  59860. */
  59861. export class ClampBlock extends NodeMaterialBlock {
  59862. /** Gets or sets the minimum range */
  59863. minimum: number;
  59864. /** Gets or sets the maximum range */
  59865. maximum: number;
  59866. /**
  59867. * Creates a new ClampBlock
  59868. * @param name defines the block name
  59869. */
  59870. constructor(name: string);
  59871. /**
  59872. * Gets the current class name
  59873. * @returns the class name
  59874. */
  59875. getClassName(): string;
  59876. /**
  59877. * Gets the value input component
  59878. */
  59879. get value(): NodeMaterialConnectionPoint;
  59880. /**
  59881. * Gets the output component
  59882. */
  59883. get output(): NodeMaterialConnectionPoint;
  59884. protected _buildBlock(state: NodeMaterialBuildState): this;
  59885. protected _dumpPropertiesCode(): string;
  59886. serialize(): any;
  59887. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59888. }
  59889. }
  59890. declare module BABYLON {
  59891. /**
  59892. * Block used to apply a cross product between 2 vectors
  59893. */
  59894. export class CrossBlock extends NodeMaterialBlock {
  59895. /**
  59896. * Creates a new CrossBlock
  59897. * @param name defines the block name
  59898. */
  59899. constructor(name: string);
  59900. /**
  59901. * Gets the current class name
  59902. * @returns the class name
  59903. */
  59904. getClassName(): string;
  59905. /**
  59906. * Gets the left operand input component
  59907. */
  59908. get left(): NodeMaterialConnectionPoint;
  59909. /**
  59910. * Gets the right operand input component
  59911. */
  59912. get right(): NodeMaterialConnectionPoint;
  59913. /**
  59914. * Gets the output component
  59915. */
  59916. get output(): NodeMaterialConnectionPoint;
  59917. protected _buildBlock(state: NodeMaterialBuildState): this;
  59918. }
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * Block used to apply a dot product between 2 vectors
  59923. */
  59924. export class DotBlock extends NodeMaterialBlock {
  59925. /**
  59926. * Creates a new DotBlock
  59927. * @param name defines the block name
  59928. */
  59929. constructor(name: string);
  59930. /**
  59931. * Gets the current class name
  59932. * @returns the class name
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Gets the left operand input component
  59937. */
  59938. get left(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the right operand input component
  59941. */
  59942. get right(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the output component
  59945. */
  59946. get output(): NodeMaterialConnectionPoint;
  59947. protected _buildBlock(state: NodeMaterialBuildState): this;
  59948. }
  59949. }
  59950. declare module BABYLON {
  59951. /**
  59952. * Block used to remap a float from a range to a new one
  59953. */
  59954. export class RemapBlock extends NodeMaterialBlock {
  59955. /**
  59956. * Gets or sets the source range
  59957. */
  59958. sourceRange: Vector2;
  59959. /**
  59960. * Gets or sets the target range
  59961. */
  59962. targetRange: Vector2;
  59963. /**
  59964. * Creates a new RemapBlock
  59965. * @param name defines the block name
  59966. */
  59967. constructor(name: string);
  59968. /**
  59969. * Gets the current class name
  59970. * @returns the class name
  59971. */
  59972. getClassName(): string;
  59973. /**
  59974. * Gets the input component
  59975. */
  59976. get input(): NodeMaterialConnectionPoint;
  59977. /**
  59978. * Gets the source min input component
  59979. */
  59980. get sourceMin(): NodeMaterialConnectionPoint;
  59981. /**
  59982. * Gets the source max input component
  59983. */
  59984. get sourceMax(): NodeMaterialConnectionPoint;
  59985. /**
  59986. * Gets the target min input component
  59987. */
  59988. get targetMin(): NodeMaterialConnectionPoint;
  59989. /**
  59990. * Gets the target max input component
  59991. */
  59992. get targetMax(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the output component
  59995. */
  59996. get output(): NodeMaterialConnectionPoint;
  59997. protected _buildBlock(state: NodeMaterialBuildState): this;
  59998. protected _dumpPropertiesCode(): string;
  59999. serialize(): any;
  60000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60001. }
  60002. }
  60003. declare module BABYLON {
  60004. /**
  60005. * Block used to normalize a vector
  60006. */
  60007. export class NormalizeBlock extends NodeMaterialBlock {
  60008. /**
  60009. * Creates a new NormalizeBlock
  60010. * @param name defines the block name
  60011. */
  60012. constructor(name: string);
  60013. /**
  60014. * Gets the current class name
  60015. * @returns the class name
  60016. */
  60017. getClassName(): string;
  60018. /**
  60019. * Gets the input component
  60020. */
  60021. get input(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the output component
  60024. */
  60025. get output(): NodeMaterialConnectionPoint;
  60026. protected _buildBlock(state: NodeMaterialBuildState): this;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * Operations supported by the Trigonometry block
  60032. */
  60033. export enum TrigonometryBlockOperations {
  60034. /** Cos */
  60035. Cos = 0,
  60036. /** Sin */
  60037. Sin = 1,
  60038. /** Abs */
  60039. Abs = 2,
  60040. /** Exp */
  60041. Exp = 3,
  60042. /** Exp2 */
  60043. Exp2 = 4,
  60044. /** Round */
  60045. Round = 5,
  60046. /** Floor */
  60047. Floor = 6,
  60048. /** Ceiling */
  60049. Ceiling = 7,
  60050. /** Square root */
  60051. Sqrt = 8,
  60052. /** Log */
  60053. Log = 9,
  60054. /** Tangent */
  60055. Tan = 10,
  60056. /** Arc tangent */
  60057. ArcTan = 11,
  60058. /** Arc cosinus */
  60059. ArcCos = 12,
  60060. /** Arc sinus */
  60061. ArcSin = 13,
  60062. /** Fraction */
  60063. Fract = 14,
  60064. /** Sign */
  60065. Sign = 15,
  60066. /** To radians (from degrees) */
  60067. Radians = 16,
  60068. /** To degrees (from radians) */
  60069. Degrees = 17
  60070. }
  60071. /**
  60072. * Block used to apply trigonometry operation to floats
  60073. */
  60074. export class TrigonometryBlock extends NodeMaterialBlock {
  60075. /**
  60076. * Gets or sets the operation applied by the block
  60077. */
  60078. operation: TrigonometryBlockOperations;
  60079. /**
  60080. * Creates a new TrigonometryBlock
  60081. * @param name defines the block name
  60082. */
  60083. constructor(name: string);
  60084. /**
  60085. * Gets the current class name
  60086. * @returns the class name
  60087. */
  60088. getClassName(): string;
  60089. /**
  60090. * Gets the input component
  60091. */
  60092. get input(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the output component
  60095. */
  60096. get output(): NodeMaterialConnectionPoint;
  60097. protected _buildBlock(state: NodeMaterialBuildState): this;
  60098. serialize(): any;
  60099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60100. protected _dumpPropertiesCode(): string;
  60101. }
  60102. }
  60103. declare module BABYLON {
  60104. /**
  60105. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60106. */
  60107. export class ColorMergerBlock extends NodeMaterialBlock {
  60108. /**
  60109. * Create a new ColorMergerBlock
  60110. * @param name defines the block name
  60111. */
  60112. constructor(name: string);
  60113. /**
  60114. * Gets the current class name
  60115. * @returns the class name
  60116. */
  60117. getClassName(): string;
  60118. /**
  60119. * Gets the rgb component (input)
  60120. */
  60121. get rgbIn(): NodeMaterialConnectionPoint;
  60122. /**
  60123. * Gets the r component (input)
  60124. */
  60125. get r(): NodeMaterialConnectionPoint;
  60126. /**
  60127. * Gets the g component (input)
  60128. */
  60129. get g(): NodeMaterialConnectionPoint;
  60130. /**
  60131. * Gets the b component (input)
  60132. */
  60133. get b(): NodeMaterialConnectionPoint;
  60134. /**
  60135. * Gets the a component (input)
  60136. */
  60137. get a(): NodeMaterialConnectionPoint;
  60138. /**
  60139. * Gets the rgba component (output)
  60140. */
  60141. get rgba(): NodeMaterialConnectionPoint;
  60142. /**
  60143. * Gets the rgb component (output)
  60144. */
  60145. get rgbOut(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the rgb component (output)
  60148. * @deprecated Please use rgbOut instead.
  60149. */
  60150. get rgb(): NodeMaterialConnectionPoint;
  60151. protected _buildBlock(state: NodeMaterialBuildState): this;
  60152. }
  60153. }
  60154. declare module BABYLON {
  60155. /**
  60156. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60157. */
  60158. export class VectorMergerBlock extends NodeMaterialBlock {
  60159. /**
  60160. * Create a new VectorMergerBlock
  60161. * @param name defines the block name
  60162. */
  60163. constructor(name: string);
  60164. /**
  60165. * Gets the current class name
  60166. * @returns the class name
  60167. */
  60168. getClassName(): string;
  60169. /**
  60170. * Gets the xyz component (input)
  60171. */
  60172. get xyzIn(): NodeMaterialConnectionPoint;
  60173. /**
  60174. * Gets the xy component (input)
  60175. */
  60176. get xyIn(): NodeMaterialConnectionPoint;
  60177. /**
  60178. * Gets the x component (input)
  60179. */
  60180. get x(): NodeMaterialConnectionPoint;
  60181. /**
  60182. * Gets the y component (input)
  60183. */
  60184. get y(): NodeMaterialConnectionPoint;
  60185. /**
  60186. * Gets the z component (input)
  60187. */
  60188. get z(): NodeMaterialConnectionPoint;
  60189. /**
  60190. * Gets the w component (input)
  60191. */
  60192. get w(): NodeMaterialConnectionPoint;
  60193. /**
  60194. * Gets the xyzw component (output)
  60195. */
  60196. get xyzw(): NodeMaterialConnectionPoint;
  60197. /**
  60198. * Gets the xyz component (output)
  60199. */
  60200. get xyzOut(): NodeMaterialConnectionPoint;
  60201. /**
  60202. * Gets the xy component (output)
  60203. */
  60204. get xyOut(): NodeMaterialConnectionPoint;
  60205. /**
  60206. * Gets the xy component (output)
  60207. * @deprecated Please use xyOut instead.
  60208. */
  60209. get xy(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the xyz component (output)
  60212. * @deprecated Please use xyzOut instead.
  60213. */
  60214. get xyz(): NodeMaterialConnectionPoint;
  60215. protected _buildBlock(state: NodeMaterialBuildState): this;
  60216. }
  60217. }
  60218. declare module BABYLON {
  60219. /**
  60220. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60221. */
  60222. export class ColorSplitterBlock extends NodeMaterialBlock {
  60223. /**
  60224. * Create a new ColorSplitterBlock
  60225. * @param name defines the block name
  60226. */
  60227. constructor(name: string);
  60228. /**
  60229. * Gets the current class name
  60230. * @returns the class name
  60231. */
  60232. getClassName(): string;
  60233. /**
  60234. * Gets the rgba component (input)
  60235. */
  60236. get rgba(): NodeMaterialConnectionPoint;
  60237. /**
  60238. * Gets the rgb component (input)
  60239. */
  60240. get rgbIn(): NodeMaterialConnectionPoint;
  60241. /**
  60242. * Gets the rgb component (output)
  60243. */
  60244. get rgbOut(): NodeMaterialConnectionPoint;
  60245. /**
  60246. * Gets the r component (output)
  60247. */
  60248. get r(): NodeMaterialConnectionPoint;
  60249. /**
  60250. * Gets the g component (output)
  60251. */
  60252. get g(): NodeMaterialConnectionPoint;
  60253. /**
  60254. * Gets the b component (output)
  60255. */
  60256. get b(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the a component (output)
  60259. */
  60260. get a(): NodeMaterialConnectionPoint;
  60261. protected _inputRename(name: string): string;
  60262. protected _outputRename(name: string): string;
  60263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60264. }
  60265. }
  60266. declare module BABYLON {
  60267. /**
  60268. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60269. */
  60270. export class VectorSplitterBlock extends NodeMaterialBlock {
  60271. /**
  60272. * Create a new VectorSplitterBlock
  60273. * @param name defines the block name
  60274. */
  60275. constructor(name: string);
  60276. /**
  60277. * Gets the current class name
  60278. * @returns the class name
  60279. */
  60280. getClassName(): string;
  60281. /**
  60282. * Gets the xyzw component (input)
  60283. */
  60284. get xyzw(): NodeMaterialConnectionPoint;
  60285. /**
  60286. * Gets the xyz component (input)
  60287. */
  60288. get xyzIn(): NodeMaterialConnectionPoint;
  60289. /**
  60290. * Gets the xy component (input)
  60291. */
  60292. get xyIn(): NodeMaterialConnectionPoint;
  60293. /**
  60294. * Gets the xyz component (output)
  60295. */
  60296. get xyzOut(): NodeMaterialConnectionPoint;
  60297. /**
  60298. * Gets the xy component (output)
  60299. */
  60300. get xyOut(): NodeMaterialConnectionPoint;
  60301. /**
  60302. * Gets the x component (output)
  60303. */
  60304. get x(): NodeMaterialConnectionPoint;
  60305. /**
  60306. * Gets the y component (output)
  60307. */
  60308. get y(): NodeMaterialConnectionPoint;
  60309. /**
  60310. * Gets the z component (output)
  60311. */
  60312. get z(): NodeMaterialConnectionPoint;
  60313. /**
  60314. * Gets the w component (output)
  60315. */
  60316. get w(): NodeMaterialConnectionPoint;
  60317. protected _inputRename(name: string): string;
  60318. protected _outputRename(name: string): string;
  60319. protected _buildBlock(state: NodeMaterialBuildState): this;
  60320. }
  60321. }
  60322. declare module BABYLON {
  60323. /**
  60324. * Block used to lerp between 2 values
  60325. */
  60326. export class LerpBlock extends NodeMaterialBlock {
  60327. /**
  60328. * Creates a new LerpBlock
  60329. * @param name defines the block name
  60330. */
  60331. constructor(name: string);
  60332. /**
  60333. * Gets the current class name
  60334. * @returns the class name
  60335. */
  60336. getClassName(): string;
  60337. /**
  60338. * Gets the left operand input component
  60339. */
  60340. get left(): NodeMaterialConnectionPoint;
  60341. /**
  60342. * Gets the right operand input component
  60343. */
  60344. get right(): NodeMaterialConnectionPoint;
  60345. /**
  60346. * Gets the gradient operand input component
  60347. */
  60348. get gradient(): NodeMaterialConnectionPoint;
  60349. /**
  60350. * Gets the output component
  60351. */
  60352. get output(): NodeMaterialConnectionPoint;
  60353. protected _buildBlock(state: NodeMaterialBuildState): this;
  60354. }
  60355. }
  60356. declare module BABYLON {
  60357. /**
  60358. * Block used to divide 2 vectors
  60359. */
  60360. export class DivideBlock extends NodeMaterialBlock {
  60361. /**
  60362. * Creates a new DivideBlock
  60363. * @param name defines the block name
  60364. */
  60365. constructor(name: string);
  60366. /**
  60367. * Gets the current class name
  60368. * @returns the class name
  60369. */
  60370. getClassName(): string;
  60371. /**
  60372. * Gets the left operand input component
  60373. */
  60374. get left(): NodeMaterialConnectionPoint;
  60375. /**
  60376. * Gets the right operand input component
  60377. */
  60378. get right(): NodeMaterialConnectionPoint;
  60379. /**
  60380. * Gets the output component
  60381. */
  60382. get output(): NodeMaterialConnectionPoint;
  60383. protected _buildBlock(state: NodeMaterialBuildState): this;
  60384. }
  60385. }
  60386. declare module BABYLON {
  60387. /**
  60388. * Block used to subtract 2 vectors
  60389. */
  60390. export class SubtractBlock extends NodeMaterialBlock {
  60391. /**
  60392. * Creates a new SubtractBlock
  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 left operand input component
  60403. */
  60404. get left(): NodeMaterialConnectionPoint;
  60405. /**
  60406. * Gets the right operand input component
  60407. */
  60408. get right(): NodeMaterialConnectionPoint;
  60409. /**
  60410. * Gets the output component
  60411. */
  60412. get output(): NodeMaterialConnectionPoint;
  60413. protected _buildBlock(state: NodeMaterialBuildState): this;
  60414. }
  60415. }
  60416. declare module BABYLON {
  60417. /**
  60418. * Block used to step a value
  60419. */
  60420. export class StepBlock extends NodeMaterialBlock {
  60421. /**
  60422. * Creates a new StepBlock
  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 value operand input component
  60433. */
  60434. get value(): NodeMaterialConnectionPoint;
  60435. /**
  60436. * Gets the edge operand input component
  60437. */
  60438. get edge(): NodeMaterialConnectionPoint;
  60439. /**
  60440. * Gets the output component
  60441. */
  60442. get output(): NodeMaterialConnectionPoint;
  60443. protected _buildBlock(state: NodeMaterialBuildState): this;
  60444. }
  60445. }
  60446. declare module BABYLON {
  60447. /**
  60448. * Block used to get the opposite (1 - x) of a value
  60449. */
  60450. export class OneMinusBlock extends NodeMaterialBlock {
  60451. /**
  60452. * Creates a new OneMinusBlock
  60453. * @param name defines the block name
  60454. */
  60455. constructor(name: string);
  60456. /**
  60457. * Gets the current class name
  60458. * @returns the class name
  60459. */
  60460. getClassName(): string;
  60461. /**
  60462. * Gets the input component
  60463. */
  60464. get input(): NodeMaterialConnectionPoint;
  60465. /**
  60466. * Gets the output component
  60467. */
  60468. get output(): NodeMaterialConnectionPoint;
  60469. protected _buildBlock(state: NodeMaterialBuildState): this;
  60470. }
  60471. }
  60472. declare module BABYLON {
  60473. /**
  60474. * Block used to get the view direction
  60475. */
  60476. export class ViewDirectionBlock extends NodeMaterialBlock {
  60477. /**
  60478. * Creates a new ViewDirectionBlock
  60479. * @param name defines the block name
  60480. */
  60481. constructor(name: string);
  60482. /**
  60483. * Gets the current class name
  60484. * @returns the class name
  60485. */
  60486. getClassName(): string;
  60487. /**
  60488. * Gets the world position component
  60489. */
  60490. get worldPosition(): NodeMaterialConnectionPoint;
  60491. /**
  60492. * Gets the camera position component
  60493. */
  60494. get cameraPosition(): NodeMaterialConnectionPoint;
  60495. /**
  60496. * Gets the output component
  60497. */
  60498. get output(): NodeMaterialConnectionPoint;
  60499. autoConfigure(material: NodeMaterial): void;
  60500. protected _buildBlock(state: NodeMaterialBuildState): this;
  60501. }
  60502. }
  60503. declare module BABYLON {
  60504. /**
  60505. * Block used to compute fresnel value
  60506. */
  60507. export class FresnelBlock extends NodeMaterialBlock {
  60508. /**
  60509. * Create a new FresnelBlock
  60510. * @param name defines the block name
  60511. */
  60512. constructor(name: string);
  60513. /**
  60514. * Gets the current class name
  60515. * @returns the class name
  60516. */
  60517. getClassName(): string;
  60518. /**
  60519. * Gets the world normal input component
  60520. */
  60521. get worldNormal(): NodeMaterialConnectionPoint;
  60522. /**
  60523. * Gets the view direction input component
  60524. */
  60525. get viewDirection(): NodeMaterialConnectionPoint;
  60526. /**
  60527. * Gets the bias input component
  60528. */
  60529. get bias(): NodeMaterialConnectionPoint;
  60530. /**
  60531. * Gets the camera (or eye) position component
  60532. */
  60533. get power(): NodeMaterialConnectionPoint;
  60534. /**
  60535. * Gets the fresnel output component
  60536. */
  60537. get fresnel(): NodeMaterialConnectionPoint;
  60538. autoConfigure(material: NodeMaterial): void;
  60539. protected _buildBlock(state: NodeMaterialBuildState): this;
  60540. }
  60541. }
  60542. declare module BABYLON {
  60543. /**
  60544. * Block used to get the max of 2 values
  60545. */
  60546. export class MaxBlock extends NodeMaterialBlock {
  60547. /**
  60548. * Creates a new MaxBlock
  60549. * @param name defines the block name
  60550. */
  60551. constructor(name: string);
  60552. /**
  60553. * Gets the current class name
  60554. * @returns the class name
  60555. */
  60556. getClassName(): string;
  60557. /**
  60558. * Gets the left operand input component
  60559. */
  60560. get left(): NodeMaterialConnectionPoint;
  60561. /**
  60562. * Gets the right operand input component
  60563. */
  60564. get right(): NodeMaterialConnectionPoint;
  60565. /**
  60566. * Gets the output component
  60567. */
  60568. get output(): NodeMaterialConnectionPoint;
  60569. protected _buildBlock(state: NodeMaterialBuildState): this;
  60570. }
  60571. }
  60572. declare module BABYLON {
  60573. /**
  60574. * Block used to get the min of 2 values
  60575. */
  60576. export class MinBlock extends NodeMaterialBlock {
  60577. /**
  60578. * Creates a new MinBlock
  60579. * @param name defines the block name
  60580. */
  60581. constructor(name: string);
  60582. /**
  60583. * Gets the current class name
  60584. * @returns the class name
  60585. */
  60586. getClassName(): string;
  60587. /**
  60588. * Gets the left operand input component
  60589. */
  60590. get left(): NodeMaterialConnectionPoint;
  60591. /**
  60592. * Gets the right operand input component
  60593. */
  60594. get right(): NodeMaterialConnectionPoint;
  60595. /**
  60596. * Gets the output component
  60597. */
  60598. get output(): NodeMaterialConnectionPoint;
  60599. protected _buildBlock(state: NodeMaterialBuildState): this;
  60600. }
  60601. }
  60602. declare module BABYLON {
  60603. /**
  60604. * Block used to get the distance between 2 values
  60605. */
  60606. export class DistanceBlock extends NodeMaterialBlock {
  60607. /**
  60608. * Creates a new DistanceBlock
  60609. * @param name defines the block name
  60610. */
  60611. constructor(name: string);
  60612. /**
  60613. * Gets the current class name
  60614. * @returns the class name
  60615. */
  60616. getClassName(): string;
  60617. /**
  60618. * Gets the left operand input component
  60619. */
  60620. get left(): NodeMaterialConnectionPoint;
  60621. /**
  60622. * Gets the right operand input component
  60623. */
  60624. get right(): NodeMaterialConnectionPoint;
  60625. /**
  60626. * Gets the output component
  60627. */
  60628. get output(): NodeMaterialConnectionPoint;
  60629. protected _buildBlock(state: NodeMaterialBuildState): this;
  60630. }
  60631. }
  60632. declare module BABYLON {
  60633. /**
  60634. * Block used to get the length of a vector
  60635. */
  60636. export class LengthBlock extends NodeMaterialBlock {
  60637. /**
  60638. * Creates a new LengthBlock
  60639. * @param name defines the block name
  60640. */
  60641. constructor(name: string);
  60642. /**
  60643. * Gets the current class name
  60644. * @returns the class name
  60645. */
  60646. getClassName(): string;
  60647. /**
  60648. * Gets the value input component
  60649. */
  60650. get value(): NodeMaterialConnectionPoint;
  60651. /**
  60652. * Gets the output component
  60653. */
  60654. get output(): NodeMaterialConnectionPoint;
  60655. protected _buildBlock(state: NodeMaterialBuildState): this;
  60656. }
  60657. }
  60658. declare module BABYLON {
  60659. /**
  60660. * Block used to get negative version of a value (i.e. x * -1)
  60661. */
  60662. export class NegateBlock extends NodeMaterialBlock {
  60663. /**
  60664. * Creates a new NegateBlock
  60665. * @param name defines the block name
  60666. */
  60667. constructor(name: string);
  60668. /**
  60669. * Gets the current class name
  60670. * @returns the class name
  60671. */
  60672. getClassName(): string;
  60673. /**
  60674. * Gets the value input component
  60675. */
  60676. get value(): NodeMaterialConnectionPoint;
  60677. /**
  60678. * Gets the output component
  60679. */
  60680. get output(): NodeMaterialConnectionPoint;
  60681. protected _buildBlock(state: NodeMaterialBuildState): this;
  60682. }
  60683. }
  60684. declare module BABYLON {
  60685. /**
  60686. * Block used to get the value of the first parameter raised to the power of the second
  60687. */
  60688. export class PowBlock extends NodeMaterialBlock {
  60689. /**
  60690. * Creates a new PowBlock
  60691. * @param name defines the block name
  60692. */
  60693. constructor(name: string);
  60694. /**
  60695. * Gets the current class name
  60696. * @returns the class name
  60697. */
  60698. getClassName(): string;
  60699. /**
  60700. * Gets the value operand input component
  60701. */
  60702. get value(): NodeMaterialConnectionPoint;
  60703. /**
  60704. * Gets the power operand input component
  60705. */
  60706. get power(): NodeMaterialConnectionPoint;
  60707. /**
  60708. * Gets the output component
  60709. */
  60710. get output(): NodeMaterialConnectionPoint;
  60711. protected _buildBlock(state: NodeMaterialBuildState): this;
  60712. }
  60713. }
  60714. declare module BABYLON {
  60715. /**
  60716. * Block used to get a random number
  60717. */
  60718. export class RandomNumberBlock extends NodeMaterialBlock {
  60719. /**
  60720. * Creates a new RandomNumberBlock
  60721. * @param name defines the block name
  60722. */
  60723. constructor(name: string);
  60724. /**
  60725. * Gets the current class name
  60726. * @returns the class name
  60727. */
  60728. getClassName(): string;
  60729. /**
  60730. * Gets the seed input component
  60731. */
  60732. get seed(): NodeMaterialConnectionPoint;
  60733. /**
  60734. * Gets the output component
  60735. */
  60736. get output(): NodeMaterialConnectionPoint;
  60737. protected _buildBlock(state: NodeMaterialBuildState): this;
  60738. }
  60739. }
  60740. declare module BABYLON {
  60741. /**
  60742. * Block used to compute arc tangent of 2 values
  60743. */
  60744. export class ArcTan2Block extends NodeMaterialBlock {
  60745. /**
  60746. * Creates a new ArcTan2Block
  60747. * @param name defines the block name
  60748. */
  60749. constructor(name: string);
  60750. /**
  60751. * Gets the current class name
  60752. * @returns the class name
  60753. */
  60754. getClassName(): string;
  60755. /**
  60756. * Gets the x operand input component
  60757. */
  60758. get x(): NodeMaterialConnectionPoint;
  60759. /**
  60760. * Gets the y operand input component
  60761. */
  60762. get y(): NodeMaterialConnectionPoint;
  60763. /**
  60764. * Gets the output component
  60765. */
  60766. get output(): NodeMaterialConnectionPoint;
  60767. protected _buildBlock(state: NodeMaterialBuildState): this;
  60768. }
  60769. }
  60770. declare module BABYLON {
  60771. /**
  60772. * Block used to smooth step a value
  60773. */
  60774. export class SmoothStepBlock extends NodeMaterialBlock {
  60775. /**
  60776. * Creates a new SmoothStepBlock
  60777. * @param name defines the block name
  60778. */
  60779. constructor(name: string);
  60780. /**
  60781. * Gets the current class name
  60782. * @returns the class name
  60783. */
  60784. getClassName(): string;
  60785. /**
  60786. * Gets the value operand input component
  60787. */
  60788. get value(): NodeMaterialConnectionPoint;
  60789. /**
  60790. * Gets the first edge operand input component
  60791. */
  60792. get edge0(): NodeMaterialConnectionPoint;
  60793. /**
  60794. * Gets the second edge operand input component
  60795. */
  60796. get edge1(): NodeMaterialConnectionPoint;
  60797. /**
  60798. * Gets the output component
  60799. */
  60800. get output(): NodeMaterialConnectionPoint;
  60801. protected _buildBlock(state: NodeMaterialBuildState): this;
  60802. }
  60803. }
  60804. declare module BABYLON {
  60805. /**
  60806. * Block used to get the reciprocal (1 / x) of a value
  60807. */
  60808. export class ReciprocalBlock extends NodeMaterialBlock {
  60809. /**
  60810. * Creates a new ReciprocalBlock
  60811. * @param name defines the block name
  60812. */
  60813. constructor(name: string);
  60814. /**
  60815. * Gets the current class name
  60816. * @returns the class name
  60817. */
  60818. getClassName(): string;
  60819. /**
  60820. * Gets the input component
  60821. */
  60822. get input(): NodeMaterialConnectionPoint;
  60823. /**
  60824. * Gets the output component
  60825. */
  60826. get output(): NodeMaterialConnectionPoint;
  60827. protected _buildBlock(state: NodeMaterialBuildState): this;
  60828. }
  60829. }
  60830. declare module BABYLON {
  60831. /**
  60832. * Block used to replace a color by another one
  60833. */
  60834. export class ReplaceColorBlock extends NodeMaterialBlock {
  60835. /**
  60836. * Creates a new ReplaceColorBlock
  60837. * @param name defines the block name
  60838. */
  60839. constructor(name: string);
  60840. /**
  60841. * Gets the current class name
  60842. * @returns the class name
  60843. */
  60844. getClassName(): string;
  60845. /**
  60846. * Gets the value input component
  60847. */
  60848. get value(): NodeMaterialConnectionPoint;
  60849. /**
  60850. * Gets the reference input component
  60851. */
  60852. get reference(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the distance input component
  60855. */
  60856. get distance(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the replacement input component
  60859. */
  60860. get replacement(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the output component
  60863. */
  60864. get output(): NodeMaterialConnectionPoint;
  60865. protected _buildBlock(state: NodeMaterialBuildState): this;
  60866. }
  60867. }
  60868. declare module BABYLON {
  60869. /**
  60870. * Block used to posterize a value
  60871. * @see https://en.wikipedia.org/wiki/Posterization
  60872. */
  60873. export class PosterizeBlock extends NodeMaterialBlock {
  60874. /**
  60875. * Creates a new PosterizeBlock
  60876. * @param name defines the block name
  60877. */
  60878. constructor(name: string);
  60879. /**
  60880. * Gets the current class name
  60881. * @returns the class name
  60882. */
  60883. getClassName(): string;
  60884. /**
  60885. * Gets the value input component
  60886. */
  60887. get value(): NodeMaterialConnectionPoint;
  60888. /**
  60889. * Gets the steps input component
  60890. */
  60891. get steps(): NodeMaterialConnectionPoint;
  60892. /**
  60893. * Gets the output component
  60894. */
  60895. get output(): NodeMaterialConnectionPoint;
  60896. protected _buildBlock(state: NodeMaterialBuildState): this;
  60897. }
  60898. }
  60899. declare module BABYLON {
  60900. /**
  60901. * Operations supported by the Wave block
  60902. */
  60903. export enum WaveBlockKind {
  60904. /** SawTooth */
  60905. SawTooth = 0,
  60906. /** Square */
  60907. Square = 1,
  60908. /** Triangle */
  60909. Triangle = 2
  60910. }
  60911. /**
  60912. * Block used to apply wave operation to floats
  60913. */
  60914. export class WaveBlock extends NodeMaterialBlock {
  60915. /**
  60916. * Gets or sets the kibnd of wave to be applied by the block
  60917. */
  60918. kind: WaveBlockKind;
  60919. /**
  60920. * Creates a new WaveBlock
  60921. * @param name defines the block name
  60922. */
  60923. constructor(name: string);
  60924. /**
  60925. * Gets the current class name
  60926. * @returns the class name
  60927. */
  60928. getClassName(): string;
  60929. /**
  60930. * Gets the input component
  60931. */
  60932. get input(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the output component
  60935. */
  60936. get output(): NodeMaterialConnectionPoint;
  60937. protected _buildBlock(state: NodeMaterialBuildState): this;
  60938. serialize(): any;
  60939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60940. }
  60941. }
  60942. declare module BABYLON {
  60943. /**
  60944. * Class used to store a color step for the GradientBlock
  60945. */
  60946. export class GradientBlockColorStep {
  60947. /**
  60948. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60949. */
  60950. step: number;
  60951. /**
  60952. * Gets or sets the color associated with this step
  60953. */
  60954. color: Color3;
  60955. /**
  60956. * Creates a new GradientBlockColorStep
  60957. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60958. * @param color defines the color associated with this step
  60959. */
  60960. constructor(
  60961. /**
  60962. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60963. */
  60964. step: number,
  60965. /**
  60966. * Gets or sets the color associated with this step
  60967. */
  60968. color: Color3);
  60969. }
  60970. /**
  60971. * Block used to return a color from a gradient based on an input value between 0 and 1
  60972. */
  60973. export class GradientBlock extends NodeMaterialBlock {
  60974. /**
  60975. * Gets or sets the list of color steps
  60976. */
  60977. colorSteps: GradientBlockColorStep[];
  60978. /**
  60979. * Creates a new GradientBlock
  60980. * @param name defines the block name
  60981. */
  60982. constructor(name: string);
  60983. /**
  60984. * Gets the current class name
  60985. * @returns the class name
  60986. */
  60987. getClassName(): string;
  60988. /**
  60989. * Gets the gradient input component
  60990. */
  60991. get gradient(): NodeMaterialConnectionPoint;
  60992. /**
  60993. * Gets the output component
  60994. */
  60995. get output(): NodeMaterialConnectionPoint;
  60996. private _writeColorConstant;
  60997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60998. serialize(): any;
  60999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61000. protected _dumpPropertiesCode(): string;
  61001. }
  61002. }
  61003. declare module BABYLON {
  61004. /**
  61005. * Block used to normalize lerp between 2 values
  61006. */
  61007. export class NLerpBlock extends NodeMaterialBlock {
  61008. /**
  61009. * Creates a new NLerpBlock
  61010. * @param name defines the block name
  61011. */
  61012. constructor(name: string);
  61013. /**
  61014. * Gets the current class name
  61015. * @returns the class name
  61016. */
  61017. getClassName(): string;
  61018. /**
  61019. * Gets the left operand input component
  61020. */
  61021. get left(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the right operand input component
  61024. */
  61025. get right(): NodeMaterialConnectionPoint;
  61026. /**
  61027. * Gets the gradient operand input component
  61028. */
  61029. get gradient(): NodeMaterialConnectionPoint;
  61030. /**
  61031. * Gets the output component
  61032. */
  61033. get output(): NodeMaterialConnectionPoint;
  61034. protected _buildBlock(state: NodeMaterialBuildState): this;
  61035. }
  61036. }
  61037. declare module BABYLON {
  61038. /**
  61039. * block used to Generate a Worley Noise 3D Noise Pattern
  61040. */
  61041. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61042. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61043. manhattanDistance: boolean;
  61044. /**
  61045. * Creates a new WorleyNoise3DBlock
  61046. * @param name defines the block name
  61047. */
  61048. constructor(name: string);
  61049. /**
  61050. * Gets the current class name
  61051. * @returns the class name
  61052. */
  61053. getClassName(): string;
  61054. /**
  61055. * Gets the seed input component
  61056. */
  61057. get seed(): NodeMaterialConnectionPoint;
  61058. /**
  61059. * Gets the jitter input component
  61060. */
  61061. get jitter(): NodeMaterialConnectionPoint;
  61062. /**
  61063. * Gets the output component
  61064. */
  61065. get output(): NodeMaterialConnectionPoint;
  61066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61067. /**
  61068. * Exposes the properties to the UI?
  61069. */
  61070. protected _dumpPropertiesCode(): string;
  61071. /**
  61072. * Exposes the properties to the Seralize?
  61073. */
  61074. serialize(): any;
  61075. /**
  61076. * Exposes the properties to the deseralize?
  61077. */
  61078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61079. }
  61080. }
  61081. declare module BABYLON {
  61082. /**
  61083. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61084. */
  61085. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61086. /**
  61087. * Creates a new SimplexPerlin3DBlock
  61088. * @param name defines the block name
  61089. */
  61090. constructor(name: string);
  61091. /**
  61092. * Gets the current class name
  61093. * @returns the class name
  61094. */
  61095. getClassName(): string;
  61096. /**
  61097. * Gets the seed operand input component
  61098. */
  61099. get seed(): NodeMaterialConnectionPoint;
  61100. /**
  61101. * Gets the output component
  61102. */
  61103. get output(): NodeMaterialConnectionPoint;
  61104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61105. }
  61106. }
  61107. declare module BABYLON {
  61108. /**
  61109. * Block used to blend normals
  61110. */
  61111. export class NormalBlendBlock extends NodeMaterialBlock {
  61112. /**
  61113. * Creates a new NormalBlendBlock
  61114. * @param name defines the block name
  61115. */
  61116. constructor(name: string);
  61117. /**
  61118. * Gets the current class name
  61119. * @returns the class name
  61120. */
  61121. getClassName(): string;
  61122. /**
  61123. * Gets the first input component
  61124. */
  61125. get normalMap0(): NodeMaterialConnectionPoint;
  61126. /**
  61127. * Gets the second input component
  61128. */
  61129. get normalMap1(): NodeMaterialConnectionPoint;
  61130. /**
  61131. * Gets the output component
  61132. */
  61133. get output(): NodeMaterialConnectionPoint;
  61134. protected _buildBlock(state: NodeMaterialBuildState): this;
  61135. }
  61136. }
  61137. declare module BABYLON {
  61138. /**
  61139. * Block used to rotate a 2d vector by a given angle
  61140. */
  61141. export class Rotate2dBlock extends NodeMaterialBlock {
  61142. /**
  61143. * Creates a new Rotate2dBlock
  61144. * @param name defines the block name
  61145. */
  61146. constructor(name: string);
  61147. /**
  61148. * Gets the current class name
  61149. * @returns the class name
  61150. */
  61151. getClassName(): string;
  61152. /**
  61153. * Gets the input vector
  61154. */
  61155. get input(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the input angle
  61158. */
  61159. get angle(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the output component
  61162. */
  61163. get output(): NodeMaterialConnectionPoint;
  61164. autoConfigure(material: NodeMaterial): void;
  61165. protected _buildBlock(state: NodeMaterialBuildState): this;
  61166. }
  61167. }
  61168. declare module BABYLON {
  61169. /**
  61170. * Block used to get the reflected vector from a direction and a normal
  61171. */
  61172. export class ReflectBlock extends NodeMaterialBlock {
  61173. /**
  61174. * Creates a new ReflectBlock
  61175. * @param name defines the block name
  61176. */
  61177. constructor(name: string);
  61178. /**
  61179. * Gets the current class name
  61180. * @returns the class name
  61181. */
  61182. getClassName(): string;
  61183. /**
  61184. * Gets the incident component
  61185. */
  61186. get incident(): NodeMaterialConnectionPoint;
  61187. /**
  61188. * Gets the normal component
  61189. */
  61190. get normal(): NodeMaterialConnectionPoint;
  61191. /**
  61192. * Gets the output component
  61193. */
  61194. get output(): NodeMaterialConnectionPoint;
  61195. protected _buildBlock(state: NodeMaterialBuildState): this;
  61196. }
  61197. }
  61198. declare module BABYLON {
  61199. /**
  61200. * Block used to get the refracted vector from a direction and a normal
  61201. */
  61202. export class RefractBlock extends NodeMaterialBlock {
  61203. /**
  61204. * Creates a new RefractBlock
  61205. * @param name defines the block name
  61206. */
  61207. constructor(name: string);
  61208. /**
  61209. * Gets the current class name
  61210. * @returns the class name
  61211. */
  61212. getClassName(): string;
  61213. /**
  61214. * Gets the incident component
  61215. */
  61216. get incident(): NodeMaterialConnectionPoint;
  61217. /**
  61218. * Gets the normal component
  61219. */
  61220. get normal(): NodeMaterialConnectionPoint;
  61221. /**
  61222. * Gets the index of refraction component
  61223. */
  61224. get ior(): NodeMaterialConnectionPoint;
  61225. /**
  61226. * Gets the output component
  61227. */
  61228. get output(): NodeMaterialConnectionPoint;
  61229. protected _buildBlock(state: NodeMaterialBuildState): this;
  61230. }
  61231. }
  61232. declare module BABYLON {
  61233. /**
  61234. * Block used to desaturate a color
  61235. */
  61236. export class DesaturateBlock extends NodeMaterialBlock {
  61237. /**
  61238. * Creates a new DesaturateBlock
  61239. * @param name defines the block name
  61240. */
  61241. constructor(name: string);
  61242. /**
  61243. * Gets the current class name
  61244. * @returns the class name
  61245. */
  61246. getClassName(): string;
  61247. /**
  61248. * Gets the color operand input component
  61249. */
  61250. get color(): NodeMaterialConnectionPoint;
  61251. /**
  61252. * Gets the level operand input component
  61253. */
  61254. get level(): NodeMaterialConnectionPoint;
  61255. /**
  61256. * Gets the output component
  61257. */
  61258. get output(): NodeMaterialConnectionPoint;
  61259. protected _buildBlock(state: NodeMaterialBuildState): this;
  61260. }
  61261. }
  61262. declare module BABYLON {
  61263. /**
  61264. * Block used to implement the ambient occlusion module of the PBR material
  61265. */
  61266. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  61267. /**
  61268. * Create a new AmbientOcclusionBlock
  61269. * @param name defines the block name
  61270. */
  61271. constructor(name: string);
  61272. /**
  61273. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  61274. */
  61275. useAmbientInGrayScale: boolean;
  61276. /**
  61277. * Initialize the block and prepare the context for build
  61278. * @param state defines the state that will be used for the build
  61279. */
  61280. initialize(state: NodeMaterialBuildState): void;
  61281. /**
  61282. * Gets the current class name
  61283. * @returns the class name
  61284. */
  61285. getClassName(): string;
  61286. /**
  61287. * Gets the texture input component
  61288. */
  61289. get texture(): NodeMaterialConnectionPoint;
  61290. /**
  61291. * Gets the texture intensity component
  61292. */
  61293. get intensity(): NodeMaterialConnectionPoint;
  61294. /**
  61295. * Gets the direct light intensity input component
  61296. */
  61297. get directLightIntensity(): NodeMaterialConnectionPoint;
  61298. /**
  61299. * Gets the ambient occlusion object output component
  61300. */
  61301. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61302. /**
  61303. * Gets the main code of the block (fragment side)
  61304. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  61305. * @returns the shader code
  61306. */
  61307. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  61308. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61309. protected _buildBlock(state: NodeMaterialBuildState): this;
  61310. protected _dumpPropertiesCode(): string;
  61311. serialize(): any;
  61312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61313. }
  61314. }
  61315. declare module BABYLON {
  61316. /**
  61317. * Block used to implement the reflection module of the PBR material
  61318. */
  61319. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  61320. /** @hidden */
  61321. _defineLODReflectionAlpha: string;
  61322. /** @hidden */
  61323. _defineLinearSpecularReflection: string;
  61324. private _vEnvironmentIrradianceName;
  61325. /** @hidden */
  61326. _vReflectionMicrosurfaceInfosName: string;
  61327. /** @hidden */
  61328. _vReflectionInfosName: string;
  61329. private _scene;
  61330. /**
  61331. * The three properties below are set by the main PBR block prior to calling methods of this class.
  61332. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61333. * It's less burden on the user side in the editor part.
  61334. */
  61335. /** @hidden */
  61336. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61337. /** @hidden */
  61338. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61339. /** @hidden */
  61340. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  61341. /**
  61342. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  61343. * diffuse part of the IBL.
  61344. */
  61345. useSphericalHarmonics: boolean;
  61346. /**
  61347. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  61348. */
  61349. forceIrradianceInFragment: boolean;
  61350. /**
  61351. * Create a new ReflectionBlock
  61352. * @param name defines the block name
  61353. */
  61354. constructor(name: string);
  61355. /**
  61356. * Gets the current class name
  61357. * @returns the class name
  61358. */
  61359. getClassName(): string;
  61360. /**
  61361. * Gets the position input component
  61362. */
  61363. get position(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the world position input component
  61366. */
  61367. get worldPosition(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the world normal input component
  61370. */
  61371. get worldNormal(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the world input component
  61374. */
  61375. get world(): NodeMaterialConnectionPoint;
  61376. /**
  61377. * Gets the camera (or eye) position component
  61378. */
  61379. get cameraPosition(): NodeMaterialConnectionPoint;
  61380. /**
  61381. * Gets the view input component
  61382. */
  61383. get view(): NodeMaterialConnectionPoint;
  61384. /**
  61385. * Gets the color input component
  61386. */
  61387. get color(): NodeMaterialConnectionPoint;
  61388. /**
  61389. * Gets the reflection object output component
  61390. */
  61391. get reflection(): NodeMaterialConnectionPoint;
  61392. /**
  61393. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  61394. */
  61395. get hasTexture(): boolean;
  61396. /**
  61397. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  61398. */
  61399. get reflectionColor(): string;
  61400. protected _getTexture(): Nullable<BaseTexture>;
  61401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61403. /**
  61404. * Gets the code to inject in the vertex shader
  61405. * @param state current state of the node material building
  61406. * @returns the shader code
  61407. */
  61408. handleVertexSide(state: NodeMaterialBuildState): string;
  61409. /**
  61410. * Gets the main code of the block (fragment side)
  61411. * @param state current state of the node material building
  61412. * @param normalVarName name of the existing variable corresponding to the normal
  61413. * @returns the shader code
  61414. */
  61415. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  61416. protected _buildBlock(state: NodeMaterialBuildState): this;
  61417. protected _dumpPropertiesCode(): string;
  61418. serialize(): any;
  61419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61420. }
  61421. }
  61422. declare module BABYLON {
  61423. /**
  61424. * Block used to implement the sheen module of the PBR material
  61425. */
  61426. export class SheenBlock extends NodeMaterialBlock {
  61427. /**
  61428. * Create a new SheenBlock
  61429. * @param name defines the block name
  61430. */
  61431. constructor(name: string);
  61432. /**
  61433. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  61434. * It allows the strength of the sheen effect to not depend on the base color of the material,
  61435. * making it easier to setup and tweak the effect
  61436. */
  61437. albedoScaling: boolean;
  61438. /**
  61439. * Defines if the sheen is linked to the sheen color.
  61440. */
  61441. linkSheenWithAlbedo: boolean;
  61442. /**
  61443. * Initialize the block and prepare the context for build
  61444. * @param state defines the state that will be used for the build
  61445. */
  61446. initialize(state: NodeMaterialBuildState): void;
  61447. /**
  61448. * Gets the current class name
  61449. * @returns the class name
  61450. */
  61451. getClassName(): string;
  61452. /**
  61453. * Gets the intensity input component
  61454. */
  61455. get intensity(): NodeMaterialConnectionPoint;
  61456. /**
  61457. * Gets the color input component
  61458. */
  61459. get color(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the roughness input component
  61462. */
  61463. get roughness(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the texture input component
  61466. */
  61467. get texture(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the sheen object output component
  61470. */
  61471. get sheen(): NodeMaterialConnectionPoint;
  61472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61473. /**
  61474. * Gets the main code of the block (fragment side)
  61475. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61476. * @returns the shader code
  61477. */
  61478. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  61479. protected _buildBlock(state: NodeMaterialBuildState): this;
  61480. protected _dumpPropertiesCode(): string;
  61481. serialize(): any;
  61482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61483. }
  61484. }
  61485. declare module BABYLON {
  61486. /**
  61487. * Block used to implement the reflectivity module of the PBR material
  61488. */
  61489. export class ReflectivityBlock extends NodeMaterialBlock {
  61490. /**
  61491. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  61492. */
  61493. useAmbientOcclusionFromMetallicTextureRed: boolean;
  61494. /**
  61495. * Specifies if the metallic texture contains the metallness information in its blue channel.
  61496. */
  61497. useMetallnessFromMetallicTextureBlue: boolean;
  61498. /**
  61499. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  61500. */
  61501. useRoughnessFromMetallicTextureAlpha: boolean;
  61502. /**
  61503. * Specifies if the metallic texture contains the roughness information in its green channel.
  61504. */
  61505. useRoughnessFromMetallicTextureGreen: boolean;
  61506. /**
  61507. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  61508. */
  61509. useMetallicF0FactorFromMetallicTexture: boolean;
  61510. /**
  61511. * Create a new ReflectivityBlock
  61512. * @param name defines the block name
  61513. */
  61514. constructor(name: string);
  61515. /**
  61516. * Initialize the block and prepare the context for build
  61517. * @param state defines the state that will be used for the build
  61518. */
  61519. initialize(state: NodeMaterialBuildState): void;
  61520. /**
  61521. * Gets the current class name
  61522. * @returns the class name
  61523. */
  61524. getClassName(): string;
  61525. /**
  61526. * Gets the metallic input component
  61527. */
  61528. get metallic(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the roughness input component
  61531. */
  61532. get roughness(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Gets the texture input component
  61535. */
  61536. get texture(): NodeMaterialConnectionPoint;
  61537. /**
  61538. * Gets the reflectivity object output component
  61539. */
  61540. get reflectivity(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Gets the main code of the block (fragment side)
  61543. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  61544. * @returns the shader code
  61545. */
  61546. getCode(aoIntensityVarName: string): string;
  61547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61548. protected _buildBlock(state: NodeMaterialBuildState): this;
  61549. protected _dumpPropertiesCode(): string;
  61550. serialize(): any;
  61551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61552. }
  61553. }
  61554. declare module BABYLON {
  61555. /**
  61556. * Block used to implement the anisotropy module of the PBR material
  61557. */
  61558. export class AnisotropyBlock extends NodeMaterialBlock {
  61559. /**
  61560. * The two properties below are set by the main PBR block prior to calling methods of this class.
  61561. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61562. * It's less burden on the user side in the editor part.
  61563. */
  61564. /** @hidden */
  61565. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61566. /** @hidden */
  61567. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61568. /**
  61569. * Create a new AnisotropyBlock
  61570. * @param name defines the block name
  61571. */
  61572. constructor(name: string);
  61573. /**
  61574. * Initialize the block and prepare the context for build
  61575. * @param state defines the state that will be used for the build
  61576. */
  61577. initialize(state: NodeMaterialBuildState): void;
  61578. /**
  61579. * Gets the current class name
  61580. * @returns the class name
  61581. */
  61582. getClassName(): string;
  61583. /**
  61584. * Gets the intensity input component
  61585. */
  61586. get intensity(): NodeMaterialConnectionPoint;
  61587. /**
  61588. * Gets the direction input component
  61589. */
  61590. get direction(): NodeMaterialConnectionPoint;
  61591. /**
  61592. * Gets the texture input component
  61593. */
  61594. get texture(): NodeMaterialConnectionPoint;
  61595. /**
  61596. * Gets the uv input component
  61597. */
  61598. get uv(): NodeMaterialConnectionPoint;
  61599. /**
  61600. * Gets the worldTangent input component
  61601. */
  61602. get worldTangent(): NodeMaterialConnectionPoint;
  61603. /**
  61604. * Gets the anisotropy object output component
  61605. */
  61606. get anisotropy(): NodeMaterialConnectionPoint;
  61607. private _generateTBNSpace;
  61608. /**
  61609. * Gets the main code of the block (fragment side)
  61610. * @param state current state of the node material building
  61611. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61612. * @returns the shader code
  61613. */
  61614. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  61615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61616. protected _buildBlock(state: NodeMaterialBuildState): this;
  61617. }
  61618. }
  61619. declare module BABYLON {
  61620. /**
  61621. * Block used to implement the clear coat module of the PBR material
  61622. */
  61623. export class ClearCoatBlock extends NodeMaterialBlock {
  61624. private _scene;
  61625. /**
  61626. * Create a new ClearCoatBlock
  61627. * @param name defines the block name
  61628. */
  61629. constructor(name: string);
  61630. /**
  61631. * Initialize the block and prepare the context for build
  61632. * @param state defines the state that will be used for the build
  61633. */
  61634. initialize(state: NodeMaterialBuildState): void;
  61635. /**
  61636. * Gets the current class name
  61637. * @returns the class name
  61638. */
  61639. getClassName(): string;
  61640. /**
  61641. * Gets the intensity input component
  61642. */
  61643. get intensity(): NodeMaterialConnectionPoint;
  61644. /**
  61645. * Gets the roughness input component
  61646. */
  61647. get roughness(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the ior input component
  61650. */
  61651. get ior(): NodeMaterialConnectionPoint;
  61652. /**
  61653. * Gets the texture input component
  61654. */
  61655. get texture(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the bump texture input component
  61658. */
  61659. get bumpTexture(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the uv input component
  61662. */
  61663. get uv(): NodeMaterialConnectionPoint;
  61664. /**
  61665. * Gets the tint color input component
  61666. */
  61667. get tintColor(): NodeMaterialConnectionPoint;
  61668. /**
  61669. * Gets the tint "at distance" input component
  61670. */
  61671. get tintAtDistance(): NodeMaterialConnectionPoint;
  61672. /**
  61673. * Gets the tint thickness input component
  61674. */
  61675. get tintThickness(): NodeMaterialConnectionPoint;
  61676. /**
  61677. * Gets the tint texture input component
  61678. */
  61679. get tintTexture(): NodeMaterialConnectionPoint;
  61680. /**
  61681. * Gets the world tangent input component
  61682. */
  61683. get worldTangent(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the clear coat object output component
  61686. */
  61687. get clearcoat(): NodeMaterialConnectionPoint;
  61688. autoConfigure(material: NodeMaterial): void;
  61689. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61691. private _generateTBNSpace;
  61692. /**
  61693. * Gets the main code of the block (fragment side)
  61694. * @param state current state of the node material building
  61695. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  61696. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61697. * @param worldPosVarName name of the variable holding the world position
  61698. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61699. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  61700. * @param worldNormalVarName name of the variable holding the world normal
  61701. * @returns the shader code
  61702. */
  61703. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  61704. protected _buildBlock(state: NodeMaterialBuildState): this;
  61705. }
  61706. }
  61707. declare module BABYLON {
  61708. /**
  61709. * Block used to implement the sub surface module of the PBR material
  61710. */
  61711. export class SubSurfaceBlock extends NodeMaterialBlock {
  61712. /**
  61713. * Create a new SubSurfaceBlock
  61714. * @param name defines the block name
  61715. */
  61716. constructor(name: string);
  61717. /**
  61718. * Stores the intensity of the different subsurface effects in the thickness texture.
  61719. * * the green channel is the translucency intensity.
  61720. * * the blue channel is the scattering intensity.
  61721. * * the alpha channel is the refraction intensity.
  61722. */
  61723. useMaskFromThicknessTexture: boolean;
  61724. /**
  61725. * Initialize the block and prepare the context for build
  61726. * @param state defines the state that will be used for the build
  61727. */
  61728. initialize(state: NodeMaterialBuildState): void;
  61729. /**
  61730. * Gets the current class name
  61731. * @returns the class name
  61732. */
  61733. getClassName(): string;
  61734. /**
  61735. * Gets the min thickness input component
  61736. */
  61737. get minThickness(): NodeMaterialConnectionPoint;
  61738. /**
  61739. * Gets the max thickness input component
  61740. */
  61741. get maxThickness(): NodeMaterialConnectionPoint;
  61742. /**
  61743. * Gets the thickness texture component
  61744. */
  61745. get thicknessTexture(): NodeMaterialConnectionPoint;
  61746. /**
  61747. * Gets the tint color input component
  61748. */
  61749. get tintColor(): NodeMaterialConnectionPoint;
  61750. /**
  61751. * Gets the translucency intensity input component
  61752. */
  61753. get translucencyIntensity(): NodeMaterialConnectionPoint;
  61754. /**
  61755. * Gets the translucency diffusion distance input component
  61756. */
  61757. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  61758. /**
  61759. * Gets the refraction object parameters
  61760. */
  61761. get refraction(): NodeMaterialConnectionPoint;
  61762. /**
  61763. * Gets the sub surface object output component
  61764. */
  61765. get subsurface(): NodeMaterialConnectionPoint;
  61766. autoConfigure(material: NodeMaterial): void;
  61767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61768. /**
  61769. * Gets the main code of the block (fragment side)
  61770. * @param state current state of the node material building
  61771. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  61772. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61773. * @param worldPosVarName name of the variable holding the world position
  61774. * @returns the shader code
  61775. */
  61776. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  61777. protected _buildBlock(state: NodeMaterialBuildState): this;
  61778. }
  61779. }
  61780. declare module BABYLON {
  61781. /**
  61782. * Block used to implement the PBR metallic/roughness model
  61783. */
  61784. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  61785. /**
  61786. * Gets or sets the light associated with this block
  61787. */
  61788. light: Nullable<Light>;
  61789. private _lightId;
  61790. private _scene;
  61791. private _environmentBRDFTexture;
  61792. private _environmentBrdfSamplerName;
  61793. private _vNormalWName;
  61794. private _invertNormalName;
  61795. /**
  61796. * Create a new ReflectionBlock
  61797. * @param name defines the block name
  61798. */
  61799. constructor(name: string);
  61800. /**
  61801. * Intensity of the direct lights e.g. the four lights available in your scene.
  61802. * This impacts both the direct diffuse and specular highlights.
  61803. */
  61804. directIntensity: number;
  61805. /**
  61806. * Intensity of the environment e.g. how much the environment will light the object
  61807. * either through harmonics for rough material or through the refelction for shiny ones.
  61808. */
  61809. environmentIntensity: number;
  61810. /**
  61811. * This is a special control allowing the reduction of the specular highlights coming from the
  61812. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  61813. */
  61814. specularIntensity: number;
  61815. /**
  61816. * Defines the falloff type used in this material.
  61817. * It by default is Physical.
  61818. */
  61819. lightFalloff: number;
  61820. /**
  61821. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  61822. */
  61823. useAlphaFromAlbedoTexture: boolean;
  61824. /**
  61825. * Specifies that alpha test should be used
  61826. */
  61827. useAlphaTest: boolean;
  61828. /**
  61829. * Defines the alpha limits in alpha test mode.
  61830. */
  61831. alphaTestCutoff: number;
  61832. /**
  61833. * Specifies that alpha blending should be used
  61834. */
  61835. useAlphaBlending: boolean;
  61836. /**
  61837. * Defines if the alpha value should be determined via the rgb values.
  61838. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  61839. */
  61840. opacityRGB: boolean;
  61841. /**
  61842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  61843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  61844. */
  61845. useRadianceOverAlpha: boolean;
  61846. /**
  61847. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  61848. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  61849. */
  61850. useSpecularOverAlpha: boolean;
  61851. /**
  61852. * Enables specular anti aliasing in the PBR shader.
  61853. * It will both interacts on the Geometry for analytical and IBL lighting.
  61854. * It also prefilter the roughness map based on the bump values.
  61855. */
  61856. enableSpecularAntiAliasing: boolean;
  61857. /**
  61858. * Defines if the material uses energy conservation.
  61859. */
  61860. useEnergyConservation: boolean;
  61861. /**
  61862. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  61863. * too much the area relying on ambient texture to define their ambient occlusion.
  61864. */
  61865. useRadianceOcclusion: boolean;
  61866. /**
  61867. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  61868. * makes the reflect vector face the model (under horizon).
  61869. */
  61870. useHorizonOcclusion: boolean;
  61871. /**
  61872. * If set to true, no lighting calculations will be applied.
  61873. */
  61874. unlit: boolean;
  61875. /**
  61876. * Force normal to face away from face.
  61877. */
  61878. forceNormalForward: boolean;
  61879. /**
  61880. * Defines the material debug mode.
  61881. * It helps seeing only some components of the material while troubleshooting.
  61882. */
  61883. debugMode: number;
  61884. /**
  61885. * Specify from where on screen the debug mode should start.
  61886. * The value goes from -1 (full screen) to 1 (not visible)
  61887. * It helps with side by side comparison against the final render
  61888. * This defaults to 0
  61889. */
  61890. debugLimit: number;
  61891. /**
  61892. * As the default viewing range might not be enough (if the ambient is really small for instance)
  61893. * You can use the factor to better multiply the final value.
  61894. */
  61895. debugFactor: number;
  61896. /**
  61897. * Initialize the block and prepare the context for build
  61898. * @param state defines the state that will be used for the build
  61899. */
  61900. initialize(state: NodeMaterialBuildState): void;
  61901. /**
  61902. * Gets the current class name
  61903. * @returns the class name
  61904. */
  61905. getClassName(): string;
  61906. /**
  61907. * Gets the world position input component
  61908. */
  61909. get worldPosition(): NodeMaterialConnectionPoint;
  61910. /**
  61911. * Gets the world normal input component
  61912. */
  61913. get worldNormal(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the perturbed normal input component
  61916. */
  61917. get perturbedNormal(): NodeMaterialConnectionPoint;
  61918. /**
  61919. * Gets the camera position input component
  61920. */
  61921. get cameraPosition(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the base color input component
  61924. */
  61925. get baseColor(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the base texture input component
  61928. */
  61929. get baseTexture(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the opacity texture input component
  61932. */
  61933. get opacityTexture(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the ambient color input component
  61936. */
  61937. get ambientColor(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the reflectivity object parameters
  61940. */
  61941. get reflectivity(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the ambient occlusion object parameters
  61944. */
  61945. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the reflection object parameters
  61948. */
  61949. get reflection(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the sheen object parameters
  61952. */
  61953. get sheen(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the clear coat object parameters
  61956. */
  61957. get clearcoat(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the sub surface object parameters
  61960. */
  61961. get subsurface(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the anisotropy object parameters
  61964. */
  61965. get anisotropy(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the ambient output component
  61968. */
  61969. get ambient(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the diffuse output component
  61972. */
  61973. get diffuse(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the specular output component
  61976. */
  61977. get specular(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the sheen output component
  61980. */
  61981. get sheenDir(): NodeMaterialConnectionPoint;
  61982. /**
  61983. * Gets the clear coat output component
  61984. */
  61985. get clearcoatDir(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the indirect diffuse output component
  61988. */
  61989. get diffuseIndirect(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the indirect specular output component
  61992. */
  61993. get specularIndirect(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the indirect sheen output component
  61996. */
  61997. get sheenIndirect(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the indirect clear coat output component
  62000. */
  62001. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  62002. /**
  62003. * Gets the refraction output component
  62004. */
  62005. get refraction(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the global lighting output component
  62008. */
  62009. get lighting(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Gets the shadow output component
  62012. */
  62013. get shadow(): NodeMaterialConnectionPoint;
  62014. /**
  62015. * Gets the alpha output component
  62016. */
  62017. get alpha(): NodeMaterialConnectionPoint;
  62018. autoConfigure(material: NodeMaterial): void;
  62019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62020. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62022. private _injectVertexCode;
  62023. /**
  62024. * Gets the code corresponding to the albedo/opacity module
  62025. * @returns the shader code
  62026. */
  62027. getAlbedoOpacityCode(): string;
  62028. protected _buildBlock(state: NodeMaterialBuildState): this;
  62029. protected _dumpPropertiesCode(): string;
  62030. serialize(): any;
  62031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62032. }
  62033. }
  62034. declare module BABYLON {
  62035. /**
  62036. * Effect Render Options
  62037. */
  62038. export interface IEffectRendererOptions {
  62039. /**
  62040. * Defines the vertices positions.
  62041. */
  62042. positions?: number[];
  62043. /**
  62044. * Defines the indices.
  62045. */
  62046. indices?: number[];
  62047. }
  62048. /**
  62049. * Helper class to render one or more effects.
  62050. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62051. */
  62052. export class EffectRenderer {
  62053. private engine;
  62054. private static _DefaultOptions;
  62055. private _vertexBuffers;
  62056. private _indexBuffer;
  62057. private _fullscreenViewport;
  62058. /**
  62059. * Creates an effect renderer
  62060. * @param engine the engine to use for rendering
  62061. * @param options defines the options of the effect renderer
  62062. */
  62063. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62064. /**
  62065. * Sets the current viewport in normalized coordinates 0-1
  62066. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62067. */
  62068. setViewport(viewport?: Viewport): void;
  62069. /**
  62070. * Binds the embedded attributes buffer to the effect.
  62071. * @param effect Defines the effect to bind the attributes for
  62072. */
  62073. bindBuffers(effect: Effect): void;
  62074. /**
  62075. * Sets the current effect wrapper to use during draw.
  62076. * The effect needs to be ready before calling this api.
  62077. * This also sets the default full screen position attribute.
  62078. * @param effectWrapper Defines the effect to draw with
  62079. */
  62080. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62081. /**
  62082. * Draws a full screen quad.
  62083. */
  62084. draw(): void;
  62085. private isRenderTargetTexture;
  62086. /**
  62087. * renders one or more effects to a specified texture
  62088. * @param effectWrapper the effect to renderer
  62089. * @param outputTexture texture to draw to, if null it will render to the screen.
  62090. */
  62091. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62092. /**
  62093. * Disposes of the effect renderer
  62094. */
  62095. dispose(): void;
  62096. }
  62097. /**
  62098. * Options to create an EffectWrapper
  62099. */
  62100. interface EffectWrapperCreationOptions {
  62101. /**
  62102. * Engine to use to create the effect
  62103. */
  62104. engine: ThinEngine;
  62105. /**
  62106. * Fragment shader for the effect
  62107. */
  62108. fragmentShader: string;
  62109. /**
  62110. * Vertex shader for the effect
  62111. */
  62112. vertexShader?: string;
  62113. /**
  62114. * Attributes to use in the shader
  62115. */
  62116. attributeNames?: Array<string>;
  62117. /**
  62118. * Uniforms to use in the shader
  62119. */
  62120. uniformNames?: Array<string>;
  62121. /**
  62122. * Texture sampler names to use in the shader
  62123. */
  62124. samplerNames?: Array<string>;
  62125. /**
  62126. * The friendly name of the effect displayed in Spector.
  62127. */
  62128. name?: string;
  62129. }
  62130. /**
  62131. * Wraps an effect to be used for rendering
  62132. */
  62133. export class EffectWrapper {
  62134. /**
  62135. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62136. */
  62137. onApplyObservable: Observable<{}>;
  62138. /**
  62139. * The underlying effect
  62140. */
  62141. effect: Effect;
  62142. /**
  62143. * Creates an effect to be renderer
  62144. * @param creationOptions options to create the effect
  62145. */
  62146. constructor(creationOptions: EffectWrapperCreationOptions);
  62147. /**
  62148. * Disposes of the effect wrapper
  62149. */
  62150. dispose(): void;
  62151. }
  62152. }
  62153. declare module BABYLON {
  62154. /**
  62155. * Helper class to push actions to a pool of workers.
  62156. */
  62157. export class WorkerPool implements IDisposable {
  62158. private _workerInfos;
  62159. private _pendingActions;
  62160. /**
  62161. * Constructor
  62162. * @param workers Array of workers to use for actions
  62163. */
  62164. constructor(workers: Array<Worker>);
  62165. /**
  62166. * Terminates all workers and clears any pending actions.
  62167. */
  62168. dispose(): void;
  62169. /**
  62170. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62171. * pended until a worker has completed its action.
  62172. * @param action The action to perform. Call onComplete when the action is complete.
  62173. */
  62174. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62175. private _execute;
  62176. }
  62177. }
  62178. declare module BABYLON {
  62179. /**
  62180. * Configuration for Draco compression
  62181. */
  62182. export interface IDracoCompressionConfiguration {
  62183. /**
  62184. * Configuration for the decoder.
  62185. */
  62186. decoder: {
  62187. /**
  62188. * The url to the WebAssembly module.
  62189. */
  62190. wasmUrl?: string;
  62191. /**
  62192. * The url to the WebAssembly binary.
  62193. */
  62194. wasmBinaryUrl?: string;
  62195. /**
  62196. * The url to the fallback JavaScript module.
  62197. */
  62198. fallbackUrl?: string;
  62199. };
  62200. }
  62201. /**
  62202. * Draco compression (https://google.github.io/draco/)
  62203. *
  62204. * This class wraps the Draco module.
  62205. *
  62206. * **Encoder**
  62207. *
  62208. * The encoder is not currently implemented.
  62209. *
  62210. * **Decoder**
  62211. *
  62212. * 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.
  62213. *
  62214. * To update the configuration, use the following code:
  62215. * ```javascript
  62216. * DracoCompression.Configuration = {
  62217. * decoder: {
  62218. * wasmUrl: "<url to the WebAssembly library>",
  62219. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62220. * fallbackUrl: "<url to the fallback JavaScript library>",
  62221. * }
  62222. * };
  62223. * ```
  62224. *
  62225. * 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.
  62226. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62227. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62228. *
  62229. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62230. * ```javascript
  62231. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62232. * ```
  62233. *
  62234. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62235. */
  62236. export class DracoCompression implements IDisposable {
  62237. private _workerPoolPromise?;
  62238. private _decoderModulePromise?;
  62239. /**
  62240. * The configuration. Defaults to the following urls:
  62241. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62242. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62243. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62244. */
  62245. static Configuration: IDracoCompressionConfiguration;
  62246. /**
  62247. * Returns true if the decoder configuration is available.
  62248. */
  62249. static get DecoderAvailable(): boolean;
  62250. /**
  62251. * Default number of workers to create when creating the draco compression object.
  62252. */
  62253. static DefaultNumWorkers: number;
  62254. private static GetDefaultNumWorkers;
  62255. private static _Default;
  62256. /**
  62257. * Default instance for the draco compression object.
  62258. */
  62259. static get Default(): DracoCompression;
  62260. /**
  62261. * Constructor
  62262. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62263. */
  62264. constructor(numWorkers?: number);
  62265. /**
  62266. * Stop all async operations and release resources.
  62267. */
  62268. dispose(): void;
  62269. /**
  62270. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62271. * @returns a promise that resolves when ready
  62272. */
  62273. whenReadyAsync(): Promise<void>;
  62274. /**
  62275. * Decode Draco compressed mesh data to vertex data.
  62276. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62277. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62278. * @returns A promise that resolves with the decoded vertex data
  62279. */
  62280. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62281. [kind: string]: number;
  62282. }): Promise<VertexData>;
  62283. }
  62284. }
  62285. declare module BABYLON {
  62286. /**
  62287. * Class for building Constructive Solid Geometry
  62288. */
  62289. export class CSG {
  62290. private polygons;
  62291. /**
  62292. * The world matrix
  62293. */
  62294. matrix: Matrix;
  62295. /**
  62296. * Stores the position
  62297. */
  62298. position: Vector3;
  62299. /**
  62300. * Stores the rotation
  62301. */
  62302. rotation: Vector3;
  62303. /**
  62304. * Stores the rotation quaternion
  62305. */
  62306. rotationQuaternion: Nullable<Quaternion>;
  62307. /**
  62308. * Stores the scaling vector
  62309. */
  62310. scaling: Vector3;
  62311. /**
  62312. * Convert the Mesh to CSG
  62313. * @param mesh The Mesh to convert to CSG
  62314. * @returns A new CSG from the Mesh
  62315. */
  62316. static FromMesh(mesh: Mesh): CSG;
  62317. /**
  62318. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62319. * @param polygons Polygons used to construct a CSG solid
  62320. */
  62321. private static FromPolygons;
  62322. /**
  62323. * Clones, or makes a deep copy, of the CSG
  62324. * @returns A new CSG
  62325. */
  62326. clone(): CSG;
  62327. /**
  62328. * Unions this CSG with another CSG
  62329. * @param csg The CSG to union against this CSG
  62330. * @returns The unioned CSG
  62331. */
  62332. union(csg: CSG): CSG;
  62333. /**
  62334. * Unions this CSG with another CSG in place
  62335. * @param csg The CSG to union against this CSG
  62336. */
  62337. unionInPlace(csg: CSG): void;
  62338. /**
  62339. * Subtracts this CSG with another CSG
  62340. * @param csg The CSG to subtract against this CSG
  62341. * @returns A new CSG
  62342. */
  62343. subtract(csg: CSG): CSG;
  62344. /**
  62345. * Subtracts this CSG with another CSG in place
  62346. * @param csg The CSG to subtact against this CSG
  62347. */
  62348. subtractInPlace(csg: CSG): void;
  62349. /**
  62350. * Intersect this CSG with another CSG
  62351. * @param csg The CSG to intersect against this CSG
  62352. * @returns A new CSG
  62353. */
  62354. intersect(csg: CSG): CSG;
  62355. /**
  62356. * Intersects this CSG with another CSG in place
  62357. * @param csg The CSG to intersect against this CSG
  62358. */
  62359. intersectInPlace(csg: CSG): void;
  62360. /**
  62361. * Return a new CSG solid with solid and empty space switched. This solid is
  62362. * not modified.
  62363. * @returns A new CSG solid with solid and empty space switched
  62364. */
  62365. inverse(): CSG;
  62366. /**
  62367. * Inverses the CSG in place
  62368. */
  62369. inverseInPlace(): void;
  62370. /**
  62371. * This is used to keep meshes transformations so they can be restored
  62372. * when we build back a Babylon Mesh
  62373. * NB : All CSG operations are performed in world coordinates
  62374. * @param csg The CSG to copy the transform attributes from
  62375. * @returns This CSG
  62376. */
  62377. copyTransformAttributes(csg: CSG): CSG;
  62378. /**
  62379. * Build Raw mesh from CSG
  62380. * Coordinates here are in world space
  62381. * @param name The name of the mesh geometry
  62382. * @param scene The Scene
  62383. * @param keepSubMeshes Specifies if the submeshes should be kept
  62384. * @returns A new Mesh
  62385. */
  62386. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62387. /**
  62388. * Build Mesh from CSG taking material and transforms into account
  62389. * @param name The name of the Mesh
  62390. * @param material The material of the Mesh
  62391. * @param scene The Scene
  62392. * @param keepSubMeshes Specifies if submeshes should be kept
  62393. * @returns The new Mesh
  62394. */
  62395. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62396. }
  62397. }
  62398. declare module BABYLON {
  62399. /**
  62400. * Class used to create a trail following a mesh
  62401. */
  62402. export class TrailMesh extends Mesh {
  62403. private _generator;
  62404. private _autoStart;
  62405. private _running;
  62406. private _diameter;
  62407. private _length;
  62408. private _sectionPolygonPointsCount;
  62409. private _sectionVectors;
  62410. private _sectionNormalVectors;
  62411. private _beforeRenderObserver;
  62412. /**
  62413. * @constructor
  62414. * @param name The value used by scene.getMeshByName() to do a lookup.
  62415. * @param generator The mesh or transform node to generate a trail.
  62416. * @param scene The scene to add this mesh to.
  62417. * @param diameter Diameter of trailing mesh. Default is 1.
  62418. * @param length Length of trailing mesh. Default is 60.
  62419. * @param autoStart Automatically start trailing mesh. Default true.
  62420. */
  62421. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62422. /**
  62423. * "TrailMesh"
  62424. * @returns "TrailMesh"
  62425. */
  62426. getClassName(): string;
  62427. private _createMesh;
  62428. /**
  62429. * Start trailing mesh.
  62430. */
  62431. start(): void;
  62432. /**
  62433. * Stop trailing mesh.
  62434. */
  62435. stop(): void;
  62436. /**
  62437. * Update trailing mesh geometry.
  62438. */
  62439. update(): void;
  62440. /**
  62441. * Returns a new TrailMesh object.
  62442. * @param name is a string, the name given to the new mesh
  62443. * @param newGenerator use new generator object for cloned trail mesh
  62444. * @returns a new mesh
  62445. */
  62446. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  62447. /**
  62448. * Serializes this trail mesh
  62449. * @param serializationObject object to write serialization to
  62450. */
  62451. serialize(serializationObject: any): void;
  62452. /**
  62453. * Parses a serialized trail mesh
  62454. * @param parsedMesh the serialized mesh
  62455. * @param scene the scene to create the trail mesh in
  62456. * @returns the created trail mesh
  62457. */
  62458. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62459. }
  62460. }
  62461. declare module BABYLON {
  62462. /**
  62463. * Class containing static functions to help procedurally build meshes
  62464. */
  62465. export class TiledBoxBuilder {
  62466. /**
  62467. * Creates a box mesh
  62468. * 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)
  62469. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62471. * * 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
  62472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62473. * @param name defines the name of the mesh
  62474. * @param options defines the options used to create the mesh
  62475. * @param scene defines the hosting scene
  62476. * @returns the box mesh
  62477. */
  62478. static CreateTiledBox(name: string, options: {
  62479. pattern?: number;
  62480. width?: number;
  62481. height?: number;
  62482. depth?: number;
  62483. tileSize?: number;
  62484. tileWidth?: number;
  62485. tileHeight?: number;
  62486. alignHorizontal?: number;
  62487. alignVertical?: number;
  62488. faceUV?: Vector4[];
  62489. faceColors?: Color4[];
  62490. sideOrientation?: number;
  62491. updatable?: boolean;
  62492. }, scene?: Nullable<Scene>): Mesh;
  62493. }
  62494. }
  62495. declare module BABYLON {
  62496. /**
  62497. * Class containing static functions to help procedurally build meshes
  62498. */
  62499. export class TorusKnotBuilder {
  62500. /**
  62501. * Creates a torus knot mesh
  62502. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62503. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62504. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62505. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62507. * * 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
  62508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62509. * @param name defines the name of the mesh
  62510. * @param options defines the options used to create the mesh
  62511. * @param scene defines the hosting scene
  62512. * @returns the torus knot mesh
  62513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62514. */
  62515. static CreateTorusKnot(name: string, options: {
  62516. radius?: number;
  62517. tube?: number;
  62518. radialSegments?: number;
  62519. tubularSegments?: number;
  62520. p?: number;
  62521. q?: number;
  62522. updatable?: boolean;
  62523. sideOrientation?: number;
  62524. frontUVs?: Vector4;
  62525. backUVs?: Vector4;
  62526. }, scene: any): Mesh;
  62527. }
  62528. }
  62529. declare module BABYLON {
  62530. /**
  62531. * Polygon
  62532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62533. */
  62534. export class Polygon {
  62535. /**
  62536. * Creates a rectangle
  62537. * @param xmin bottom X coord
  62538. * @param ymin bottom Y coord
  62539. * @param xmax top X coord
  62540. * @param ymax top Y coord
  62541. * @returns points that make the resulting rectation
  62542. */
  62543. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62544. /**
  62545. * Creates a circle
  62546. * @param radius radius of circle
  62547. * @param cx scale in x
  62548. * @param cy scale in y
  62549. * @param numberOfSides number of sides that make up the circle
  62550. * @returns points that make the resulting circle
  62551. */
  62552. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62553. /**
  62554. * Creates a polygon from input string
  62555. * @param input Input polygon data
  62556. * @returns the parsed points
  62557. */
  62558. static Parse(input: string): Vector2[];
  62559. /**
  62560. * Starts building a polygon from x and y coordinates
  62561. * @param x x coordinate
  62562. * @param y y coordinate
  62563. * @returns the started path2
  62564. */
  62565. static StartingAt(x: number, y: number): Path2;
  62566. }
  62567. /**
  62568. * Builds a polygon
  62569. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62570. */
  62571. export class PolygonMeshBuilder {
  62572. private _points;
  62573. private _outlinepoints;
  62574. private _holes;
  62575. private _name;
  62576. private _scene;
  62577. private _epoints;
  62578. private _eholes;
  62579. private _addToepoint;
  62580. /**
  62581. * Babylon reference to the earcut plugin.
  62582. */
  62583. bjsEarcut: any;
  62584. /**
  62585. * Creates a PolygonMeshBuilder
  62586. * @param name name of the builder
  62587. * @param contours Path of the polygon
  62588. * @param scene scene to add to when creating the mesh
  62589. * @param earcutInjection can be used to inject your own earcut reference
  62590. */
  62591. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62592. /**
  62593. * Adds a whole within the polygon
  62594. * @param hole Array of points defining the hole
  62595. * @returns this
  62596. */
  62597. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62598. /**
  62599. * Creates the polygon
  62600. * @param updatable If the mesh should be updatable
  62601. * @param depth The depth of the mesh created
  62602. * @returns the created mesh
  62603. */
  62604. build(updatable?: boolean, depth?: number): Mesh;
  62605. /**
  62606. * Creates the polygon
  62607. * @param depth The depth of the mesh created
  62608. * @returns the created VertexData
  62609. */
  62610. buildVertexData(depth?: number): VertexData;
  62611. /**
  62612. * Adds a side to the polygon
  62613. * @param positions points that make the polygon
  62614. * @param normals normals of the polygon
  62615. * @param uvs uvs of the polygon
  62616. * @param indices indices of the polygon
  62617. * @param bounds bounds of the polygon
  62618. * @param points points of the polygon
  62619. * @param depth depth of the polygon
  62620. * @param flip flip of the polygon
  62621. */
  62622. private addSide;
  62623. }
  62624. }
  62625. declare module BABYLON {
  62626. /**
  62627. * Class containing static functions to help procedurally build meshes
  62628. */
  62629. export class PolygonBuilder {
  62630. /**
  62631. * Creates a polygon mesh
  62632. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62633. * * 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
  62634. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62636. * * 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)
  62637. * * Remember you can only change the shape positions, not their number when updating a polygon
  62638. * @param name defines the name of the mesh
  62639. * @param options defines the options used to create the mesh
  62640. * @param scene defines the hosting scene
  62641. * @param earcutInjection can be used to inject your own earcut reference
  62642. * @returns the polygon mesh
  62643. */
  62644. static CreatePolygon(name: string, options: {
  62645. shape: Vector3[];
  62646. holes?: Vector3[][];
  62647. depth?: number;
  62648. faceUV?: Vector4[];
  62649. faceColors?: Color4[];
  62650. updatable?: boolean;
  62651. sideOrientation?: number;
  62652. frontUVs?: Vector4;
  62653. backUVs?: Vector4;
  62654. wrap?: boolean;
  62655. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62656. /**
  62657. * Creates an extruded polygon mesh, with depth in the Y direction.
  62658. * * 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)
  62659. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62660. * @param name defines the name of the mesh
  62661. * @param options defines the options used to create the mesh
  62662. * @param scene defines the hosting scene
  62663. * @param earcutInjection can be used to inject your own earcut reference
  62664. * @returns the polygon mesh
  62665. */
  62666. static ExtrudePolygon(name: string, options: {
  62667. shape: Vector3[];
  62668. holes?: Vector3[][];
  62669. depth?: number;
  62670. faceUV?: Vector4[];
  62671. faceColors?: Color4[];
  62672. updatable?: boolean;
  62673. sideOrientation?: number;
  62674. frontUVs?: Vector4;
  62675. backUVs?: Vector4;
  62676. wrap?: boolean;
  62677. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62678. }
  62679. }
  62680. declare module BABYLON {
  62681. /**
  62682. * Class containing static functions to help procedurally build meshes
  62683. */
  62684. export class LatheBuilder {
  62685. /**
  62686. * Creates lathe mesh.
  62687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62688. * * 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
  62689. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62690. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62691. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62692. * * 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
  62693. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62694. * * 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
  62695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62696. * * 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
  62697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62699. * @param name defines the name of the mesh
  62700. * @param options defines the options used to create the mesh
  62701. * @param scene defines the hosting scene
  62702. * @returns the lathe mesh
  62703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62704. */
  62705. static CreateLathe(name: string, options: {
  62706. shape: Vector3[];
  62707. radius?: number;
  62708. tessellation?: number;
  62709. clip?: number;
  62710. arc?: number;
  62711. closed?: boolean;
  62712. updatable?: boolean;
  62713. sideOrientation?: number;
  62714. frontUVs?: Vector4;
  62715. backUVs?: Vector4;
  62716. cap?: number;
  62717. invertUV?: boolean;
  62718. }, scene?: Nullable<Scene>): Mesh;
  62719. }
  62720. }
  62721. declare module BABYLON {
  62722. /**
  62723. * Class containing static functions to help procedurally build meshes
  62724. */
  62725. export class TiledPlaneBuilder {
  62726. /**
  62727. * Creates a tiled plane mesh
  62728. * * The parameter `pattern` will, depending on value, do nothing or
  62729. * * * flip (reflect about central vertical) alternate tiles across and up
  62730. * * * flip every tile on alternate rows
  62731. * * * rotate (180 degs) alternate tiles across and up
  62732. * * * rotate every tile on alternate rows
  62733. * * * flip and rotate alternate tiles across and up
  62734. * * * flip and rotate every tile on alternate rows
  62735. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62736. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62737. * * 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
  62738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62739. * * 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)
  62740. * * 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)
  62741. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62742. * @param name defines the name of the mesh
  62743. * @param options defines the options used to create the mesh
  62744. * @param scene defines the hosting scene
  62745. * @returns the box mesh
  62746. */
  62747. static CreateTiledPlane(name: string, options: {
  62748. pattern?: number;
  62749. tileSize?: number;
  62750. tileWidth?: number;
  62751. tileHeight?: number;
  62752. size?: number;
  62753. width?: number;
  62754. height?: number;
  62755. alignHorizontal?: number;
  62756. alignVertical?: number;
  62757. sideOrientation?: number;
  62758. frontUVs?: Vector4;
  62759. backUVs?: Vector4;
  62760. updatable?: boolean;
  62761. }, scene?: Nullable<Scene>): Mesh;
  62762. }
  62763. }
  62764. declare module BABYLON {
  62765. /**
  62766. * Class containing static functions to help procedurally build meshes
  62767. */
  62768. export class TubeBuilder {
  62769. /**
  62770. * Creates a tube mesh.
  62771. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62772. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62773. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62774. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62775. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62776. * * 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)
  62777. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62778. * * 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
  62779. * * 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
  62780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62781. * * 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
  62782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62784. * @param name defines the name of the mesh
  62785. * @param options defines the options used to create the mesh
  62786. * @param scene defines the hosting scene
  62787. * @returns the tube mesh
  62788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62789. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62790. */
  62791. static CreateTube(name: string, options: {
  62792. path: Vector3[];
  62793. radius?: number;
  62794. tessellation?: number;
  62795. radiusFunction?: {
  62796. (i: number, distance: number): number;
  62797. };
  62798. cap?: number;
  62799. arc?: number;
  62800. updatable?: boolean;
  62801. sideOrientation?: number;
  62802. frontUVs?: Vector4;
  62803. backUVs?: Vector4;
  62804. instance?: Mesh;
  62805. invertUV?: boolean;
  62806. }, scene?: Nullable<Scene>): Mesh;
  62807. }
  62808. }
  62809. declare module BABYLON {
  62810. /**
  62811. * Class containing static functions to help procedurally build meshes
  62812. */
  62813. export class IcoSphereBuilder {
  62814. /**
  62815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62817. * * 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`)
  62818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62819. * * 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
  62820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62821. * * 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
  62822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62823. * @param name defines the name of the mesh
  62824. * @param options defines the options used to create the mesh
  62825. * @param scene defines the hosting scene
  62826. * @returns the icosahedron mesh
  62827. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62828. */
  62829. static CreateIcoSphere(name: string, options: {
  62830. radius?: number;
  62831. radiusX?: number;
  62832. radiusY?: number;
  62833. radiusZ?: number;
  62834. flat?: boolean;
  62835. subdivisions?: number;
  62836. sideOrientation?: number;
  62837. frontUVs?: Vector4;
  62838. backUVs?: Vector4;
  62839. updatable?: boolean;
  62840. }, scene?: Nullable<Scene>): Mesh;
  62841. }
  62842. }
  62843. declare module BABYLON {
  62844. /**
  62845. * Class containing static functions to help procedurally build meshes
  62846. */
  62847. export class DecalBuilder {
  62848. /**
  62849. * Creates a decal mesh.
  62850. * 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
  62851. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62852. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62853. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62854. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62855. * @param name defines the name of the mesh
  62856. * @param sourceMesh defines the mesh where the decal must be applied
  62857. * @param options defines the options used to create the mesh
  62858. * @param scene defines the hosting scene
  62859. * @returns the decal mesh
  62860. * @see https://doc.babylonjs.com/how_to/decals
  62861. */
  62862. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62863. position?: Vector3;
  62864. normal?: Vector3;
  62865. size?: Vector3;
  62866. angle?: number;
  62867. }): Mesh;
  62868. }
  62869. }
  62870. declare module BABYLON {
  62871. /**
  62872. * Class containing static functions to help procedurally build meshes
  62873. */
  62874. export class MeshBuilder {
  62875. /**
  62876. * Creates a box mesh
  62877. * * The parameter `size` sets the size (float) of each box side (default 1)
  62878. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62879. * * 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)
  62880. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62882. * * 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
  62883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62884. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62885. * @param name defines the name of the mesh
  62886. * @param options defines the options used to create the mesh
  62887. * @param scene defines the hosting scene
  62888. * @returns the box mesh
  62889. */
  62890. static CreateBox(name: string, options: {
  62891. size?: number;
  62892. width?: number;
  62893. height?: number;
  62894. depth?: number;
  62895. faceUV?: Vector4[];
  62896. faceColors?: Color4[];
  62897. sideOrientation?: number;
  62898. frontUVs?: Vector4;
  62899. backUVs?: Vector4;
  62900. wrap?: boolean;
  62901. topBaseAt?: number;
  62902. bottomBaseAt?: number;
  62903. updatable?: boolean;
  62904. }, scene?: Nullable<Scene>): Mesh;
  62905. /**
  62906. * Creates a tiled box mesh
  62907. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62909. * @param name defines the name of the mesh
  62910. * @param options defines the options used to create the mesh
  62911. * @param scene defines the hosting scene
  62912. * @returns the tiled box mesh
  62913. */
  62914. static CreateTiledBox(name: string, options: {
  62915. pattern?: number;
  62916. size?: number;
  62917. width?: number;
  62918. height?: number;
  62919. depth: number;
  62920. tileSize?: number;
  62921. tileWidth?: number;
  62922. tileHeight?: number;
  62923. faceUV?: Vector4[];
  62924. faceColors?: Color4[];
  62925. alignHorizontal?: number;
  62926. alignVertical?: number;
  62927. sideOrientation?: number;
  62928. updatable?: boolean;
  62929. }, scene?: Nullable<Scene>): Mesh;
  62930. /**
  62931. * Creates a sphere mesh
  62932. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62933. * * 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`)
  62934. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62935. * * 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
  62936. * * 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)
  62937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62938. * * 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
  62939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62940. * @param name defines the name of the mesh
  62941. * @param options defines the options used to create the mesh
  62942. * @param scene defines the hosting scene
  62943. * @returns the sphere mesh
  62944. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62945. */
  62946. static CreateSphere(name: string, options: {
  62947. segments?: number;
  62948. diameter?: number;
  62949. diameterX?: number;
  62950. diameterY?: number;
  62951. diameterZ?: number;
  62952. arc?: number;
  62953. slice?: number;
  62954. sideOrientation?: number;
  62955. frontUVs?: Vector4;
  62956. backUVs?: Vector4;
  62957. updatable?: boolean;
  62958. }, scene?: Nullable<Scene>): Mesh;
  62959. /**
  62960. * Creates a plane polygonal mesh. By default, this is a disc
  62961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62962. * * 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
  62963. * * 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
  62964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62965. * * 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
  62966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62967. * @param name defines the name of the mesh
  62968. * @param options defines the options used to create the mesh
  62969. * @param scene defines the hosting scene
  62970. * @returns the plane polygonal mesh
  62971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62972. */
  62973. static CreateDisc(name: string, options: {
  62974. radius?: number;
  62975. tessellation?: number;
  62976. arc?: number;
  62977. updatable?: boolean;
  62978. sideOrientation?: number;
  62979. frontUVs?: Vector4;
  62980. backUVs?: Vector4;
  62981. }, scene?: Nullable<Scene>): Mesh;
  62982. /**
  62983. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62984. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62985. * * 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`)
  62986. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62987. * * 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
  62988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62989. * * 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
  62990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62991. * @param name defines the name of the mesh
  62992. * @param options defines the options used to create the mesh
  62993. * @param scene defines the hosting scene
  62994. * @returns the icosahedron mesh
  62995. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62996. */
  62997. static CreateIcoSphere(name: string, options: {
  62998. radius?: number;
  62999. radiusX?: number;
  63000. radiusY?: number;
  63001. radiusZ?: number;
  63002. flat?: boolean;
  63003. subdivisions?: number;
  63004. sideOrientation?: number;
  63005. frontUVs?: Vector4;
  63006. backUVs?: Vector4;
  63007. updatable?: boolean;
  63008. }, scene?: Nullable<Scene>): Mesh;
  63009. /**
  63010. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63011. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63012. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63013. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63014. * * 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
  63015. * * 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
  63016. * * 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
  63017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63018. * * 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
  63019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63020. * * 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
  63021. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63022. * * 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
  63023. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63025. * @param name defines the name of the mesh
  63026. * @param options defines the options used to create the mesh
  63027. * @param scene defines the hosting scene
  63028. * @returns the ribbon mesh
  63029. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63030. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63031. */
  63032. static CreateRibbon(name: string, options: {
  63033. pathArray: Vector3[][];
  63034. closeArray?: boolean;
  63035. closePath?: boolean;
  63036. offset?: number;
  63037. updatable?: boolean;
  63038. sideOrientation?: number;
  63039. frontUVs?: Vector4;
  63040. backUVs?: Vector4;
  63041. instance?: Mesh;
  63042. invertUV?: boolean;
  63043. uvs?: Vector2[];
  63044. colors?: Color4[];
  63045. }, scene?: Nullable<Scene>): Mesh;
  63046. /**
  63047. * Creates a cylinder or a cone mesh
  63048. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63049. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63050. * * 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.
  63051. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63052. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63053. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63054. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63055. * * 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).
  63056. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63057. * * 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).
  63058. * * 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
  63059. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63060. * * 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
  63061. * * 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.
  63062. * * If `enclose` is false, a ring surface is one element.
  63063. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63064. * * 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
  63065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63066. * * 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
  63067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63068. * @param name defines the name of the mesh
  63069. * @param options defines the options used to create the mesh
  63070. * @param scene defines the hosting scene
  63071. * @returns the cylinder mesh
  63072. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63073. */
  63074. static CreateCylinder(name: string, options: {
  63075. height?: number;
  63076. diameterTop?: number;
  63077. diameterBottom?: number;
  63078. diameter?: number;
  63079. tessellation?: number;
  63080. subdivisions?: number;
  63081. arc?: number;
  63082. faceColors?: Color4[];
  63083. faceUV?: Vector4[];
  63084. updatable?: boolean;
  63085. hasRings?: boolean;
  63086. enclose?: boolean;
  63087. cap?: number;
  63088. sideOrientation?: number;
  63089. frontUVs?: Vector4;
  63090. backUVs?: Vector4;
  63091. }, scene?: Nullable<Scene>): Mesh;
  63092. /**
  63093. * Creates a torus mesh
  63094. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63095. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63096. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63098. * * 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
  63099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63100. * @param name defines the name of the mesh
  63101. * @param options defines the options used to create the mesh
  63102. * @param scene defines the hosting scene
  63103. * @returns the torus mesh
  63104. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63105. */
  63106. static CreateTorus(name: string, options: {
  63107. diameter?: number;
  63108. thickness?: number;
  63109. tessellation?: number;
  63110. updatable?: boolean;
  63111. sideOrientation?: number;
  63112. frontUVs?: Vector4;
  63113. backUVs?: Vector4;
  63114. }, scene?: Nullable<Scene>): Mesh;
  63115. /**
  63116. * Creates a torus knot mesh
  63117. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63118. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63119. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63120. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63122. * * 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
  63123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63124. * @param name defines the name of the mesh
  63125. * @param options defines the options used to create the mesh
  63126. * @param scene defines the hosting scene
  63127. * @returns the torus knot mesh
  63128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63129. */
  63130. static CreateTorusKnot(name: string, options: {
  63131. radius?: number;
  63132. tube?: number;
  63133. radialSegments?: number;
  63134. tubularSegments?: number;
  63135. p?: number;
  63136. q?: number;
  63137. updatable?: boolean;
  63138. sideOrientation?: number;
  63139. frontUVs?: Vector4;
  63140. backUVs?: Vector4;
  63141. }, scene?: Nullable<Scene>): Mesh;
  63142. /**
  63143. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63144. * * 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
  63145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63146. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63147. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63148. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63149. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63150. * * 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
  63151. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63154. * @param name defines the name of the new line system
  63155. * @param options defines the options used to create the line system
  63156. * @param scene defines the hosting scene
  63157. * @returns a new line system mesh
  63158. */
  63159. static CreateLineSystem(name: string, options: {
  63160. lines: Vector3[][];
  63161. updatable?: boolean;
  63162. instance?: Nullable<LinesMesh>;
  63163. colors?: Nullable<Color4[][]>;
  63164. useVertexAlpha?: boolean;
  63165. }, scene: Nullable<Scene>): LinesMesh;
  63166. /**
  63167. * Creates a line mesh
  63168. * 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
  63169. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63170. * * The parameter `points` is an array successive Vector3
  63171. * * 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
  63172. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63173. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63174. * * When updating an instance, remember that only point positions can change, not the number of points
  63175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63177. * @param name defines the name of the new line system
  63178. * @param options defines the options used to create the line system
  63179. * @param scene defines the hosting scene
  63180. * @returns a new line mesh
  63181. */
  63182. static CreateLines(name: string, options: {
  63183. points: Vector3[];
  63184. updatable?: boolean;
  63185. instance?: Nullable<LinesMesh>;
  63186. colors?: Color4[];
  63187. useVertexAlpha?: boolean;
  63188. }, scene?: Nullable<Scene>): LinesMesh;
  63189. /**
  63190. * Creates a dashed line mesh
  63191. * * 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
  63192. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63193. * * The parameter `points` is an array successive Vector3
  63194. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63195. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63196. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63197. * * 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
  63198. * * When updating an instance, remember that only point positions can change, not the number of points
  63199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63200. * @param name defines the name of the mesh
  63201. * @param options defines the options used to create the mesh
  63202. * @param scene defines the hosting scene
  63203. * @returns the dashed line mesh
  63204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63205. */
  63206. static CreateDashedLines(name: string, options: {
  63207. points: Vector3[];
  63208. dashSize?: number;
  63209. gapSize?: number;
  63210. dashNb?: number;
  63211. updatable?: boolean;
  63212. instance?: LinesMesh;
  63213. }, scene?: Nullable<Scene>): LinesMesh;
  63214. /**
  63215. * 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.
  63216. * * 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.
  63217. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63218. * * 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.
  63219. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63220. * * 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
  63221. * * 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
  63222. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63224. * * 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
  63225. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63227. * @param name defines the name of the mesh
  63228. * @param options defines the options used to create the mesh
  63229. * @param scene defines the hosting scene
  63230. * @returns the extruded shape mesh
  63231. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63233. */
  63234. static ExtrudeShape(name: string, options: {
  63235. shape: Vector3[];
  63236. path: Vector3[];
  63237. scale?: number;
  63238. rotation?: number;
  63239. cap?: number;
  63240. updatable?: boolean;
  63241. sideOrientation?: number;
  63242. frontUVs?: Vector4;
  63243. backUVs?: Vector4;
  63244. instance?: Mesh;
  63245. invertUV?: boolean;
  63246. }, scene?: Nullable<Scene>): Mesh;
  63247. /**
  63248. * Creates an custom extruded shape mesh.
  63249. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63250. * * 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.
  63251. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63252. * * 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
  63253. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63254. * * 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
  63255. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63256. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63257. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63258. * * 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
  63259. * * 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
  63260. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63262. * * 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
  63263. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63265. * @param name defines the name of the mesh
  63266. * @param options defines the options used to create the mesh
  63267. * @param scene defines the hosting scene
  63268. * @returns the custom extruded shape mesh
  63269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63272. */
  63273. static ExtrudeShapeCustom(name: string, options: {
  63274. shape: Vector3[];
  63275. path: Vector3[];
  63276. scaleFunction?: any;
  63277. rotationFunction?: any;
  63278. ribbonCloseArray?: boolean;
  63279. ribbonClosePath?: boolean;
  63280. cap?: number;
  63281. updatable?: boolean;
  63282. sideOrientation?: number;
  63283. frontUVs?: Vector4;
  63284. backUVs?: Vector4;
  63285. instance?: Mesh;
  63286. invertUV?: boolean;
  63287. }, scene?: Nullable<Scene>): Mesh;
  63288. /**
  63289. * Creates lathe mesh.
  63290. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63291. * * 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
  63292. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63293. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63294. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63295. * * 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
  63296. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63297. * * 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
  63298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63299. * * 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
  63300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63302. * @param name defines the name of the mesh
  63303. * @param options defines the options used to create the mesh
  63304. * @param scene defines the hosting scene
  63305. * @returns the lathe mesh
  63306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63307. */
  63308. static CreateLathe(name: string, options: {
  63309. shape: Vector3[];
  63310. radius?: number;
  63311. tessellation?: number;
  63312. clip?: number;
  63313. arc?: number;
  63314. closed?: boolean;
  63315. updatable?: boolean;
  63316. sideOrientation?: number;
  63317. frontUVs?: Vector4;
  63318. backUVs?: Vector4;
  63319. cap?: number;
  63320. invertUV?: boolean;
  63321. }, scene?: Nullable<Scene>): Mesh;
  63322. /**
  63323. * Creates a tiled plane mesh
  63324. * * You can set a limited pattern arrangement with the tiles
  63325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63326. * * 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
  63327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63328. * @param name defines the name of the mesh
  63329. * @param options defines the options used to create the mesh
  63330. * @param scene defines the hosting scene
  63331. * @returns the plane mesh
  63332. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63333. */
  63334. static CreateTiledPlane(name: string, options: {
  63335. pattern?: number;
  63336. tileSize?: number;
  63337. tileWidth?: number;
  63338. tileHeight?: number;
  63339. size?: number;
  63340. width?: number;
  63341. height?: number;
  63342. alignHorizontal?: number;
  63343. alignVertical?: number;
  63344. sideOrientation?: number;
  63345. frontUVs?: Vector4;
  63346. backUVs?: Vector4;
  63347. updatable?: boolean;
  63348. }, scene?: Nullable<Scene>): Mesh;
  63349. /**
  63350. * Creates a plane mesh
  63351. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63352. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63353. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63355. * * 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
  63356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63357. * @param name defines the name of the mesh
  63358. * @param options defines the options used to create the mesh
  63359. * @param scene defines the hosting scene
  63360. * @returns the plane mesh
  63361. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63362. */
  63363. static CreatePlane(name: string, options: {
  63364. size?: number;
  63365. width?: number;
  63366. height?: number;
  63367. sideOrientation?: number;
  63368. frontUVs?: Vector4;
  63369. backUVs?: Vector4;
  63370. updatable?: boolean;
  63371. sourcePlane?: Plane;
  63372. }, scene?: Nullable<Scene>): Mesh;
  63373. /**
  63374. * Creates a ground mesh
  63375. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63376. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63378. * @param name defines the name of the mesh
  63379. * @param options defines the options used to create the mesh
  63380. * @param scene defines the hosting scene
  63381. * @returns the ground mesh
  63382. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63383. */
  63384. static CreateGround(name: string, options: {
  63385. width?: number;
  63386. height?: number;
  63387. subdivisions?: number;
  63388. subdivisionsX?: number;
  63389. subdivisionsY?: number;
  63390. updatable?: boolean;
  63391. }, scene?: Nullable<Scene>): Mesh;
  63392. /**
  63393. * Creates a tiled ground mesh
  63394. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63395. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63396. * * 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
  63397. * * 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
  63398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63399. * @param name defines the name of the mesh
  63400. * @param options defines the options used to create the mesh
  63401. * @param scene defines the hosting scene
  63402. * @returns the tiled ground mesh
  63403. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63404. */
  63405. static CreateTiledGround(name: string, options: {
  63406. xmin: number;
  63407. zmin: number;
  63408. xmax: number;
  63409. zmax: number;
  63410. subdivisions?: {
  63411. w: number;
  63412. h: number;
  63413. };
  63414. precision?: {
  63415. w: number;
  63416. h: number;
  63417. };
  63418. updatable?: boolean;
  63419. }, scene?: Nullable<Scene>): Mesh;
  63420. /**
  63421. * Creates a ground mesh from a height map
  63422. * * The parameter `url` sets the URL of the height map image resource.
  63423. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63424. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63425. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63426. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63427. * * 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.
  63428. * * 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).
  63429. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63431. * @param name defines the name of the mesh
  63432. * @param url defines the url to the height map
  63433. * @param options defines the options used to create the mesh
  63434. * @param scene defines the hosting scene
  63435. * @returns the ground mesh
  63436. * @see https://doc.babylonjs.com/babylon101/height_map
  63437. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63438. */
  63439. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63440. width?: number;
  63441. height?: number;
  63442. subdivisions?: number;
  63443. minHeight?: number;
  63444. maxHeight?: number;
  63445. colorFilter?: Color3;
  63446. alphaFilter?: number;
  63447. updatable?: boolean;
  63448. onReady?: (mesh: GroundMesh) => void;
  63449. }, scene?: Nullable<Scene>): GroundMesh;
  63450. /**
  63451. * Creates a polygon mesh
  63452. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63453. * * 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
  63454. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63456. * * 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)
  63457. * * Remember you can only change the shape positions, not their number when updating a polygon
  63458. * @param name defines the name of the mesh
  63459. * @param options defines the options used to create the mesh
  63460. * @param scene defines the hosting scene
  63461. * @param earcutInjection can be used to inject your own earcut reference
  63462. * @returns the polygon mesh
  63463. */
  63464. static CreatePolygon(name: string, options: {
  63465. shape: Vector3[];
  63466. holes?: Vector3[][];
  63467. depth?: number;
  63468. faceUV?: Vector4[];
  63469. faceColors?: Color4[];
  63470. updatable?: boolean;
  63471. sideOrientation?: number;
  63472. frontUVs?: Vector4;
  63473. backUVs?: Vector4;
  63474. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63475. /**
  63476. * Creates an extruded polygon mesh, with depth in the Y direction.
  63477. * * 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)
  63478. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63479. * @param name defines the name of the mesh
  63480. * @param options defines the options used to create the mesh
  63481. * @param scene defines the hosting scene
  63482. * @param earcutInjection can be used to inject your own earcut reference
  63483. * @returns the polygon mesh
  63484. */
  63485. static ExtrudePolygon(name: string, options: {
  63486. shape: Vector3[];
  63487. holes?: Vector3[][];
  63488. depth?: number;
  63489. faceUV?: Vector4[];
  63490. faceColors?: Color4[];
  63491. updatable?: boolean;
  63492. sideOrientation?: number;
  63493. frontUVs?: Vector4;
  63494. backUVs?: Vector4;
  63495. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63496. /**
  63497. * Creates a tube mesh.
  63498. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63499. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63500. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63501. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63502. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63503. * * 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)
  63504. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63505. * * 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
  63506. * * 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
  63507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63508. * * 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
  63509. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63511. * @param name defines the name of the mesh
  63512. * @param options defines the options used to create the mesh
  63513. * @param scene defines the hosting scene
  63514. * @returns the tube mesh
  63515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63516. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63517. */
  63518. static CreateTube(name: string, options: {
  63519. path: Vector3[];
  63520. radius?: number;
  63521. tessellation?: number;
  63522. radiusFunction?: {
  63523. (i: number, distance: number): number;
  63524. };
  63525. cap?: number;
  63526. arc?: number;
  63527. updatable?: boolean;
  63528. sideOrientation?: number;
  63529. frontUVs?: Vector4;
  63530. backUVs?: Vector4;
  63531. instance?: Mesh;
  63532. invertUV?: boolean;
  63533. }, scene?: Nullable<Scene>): Mesh;
  63534. /**
  63535. * Creates a polyhedron mesh
  63536. * * 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
  63537. * * The parameter `size` (positive float, default 1) sets the polygon size
  63538. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63539. * * 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`
  63540. * * 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
  63541. * * 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)`)
  63542. * * 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
  63543. * * 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
  63544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63545. * * 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
  63546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63547. * @param name defines the name of the mesh
  63548. * @param options defines the options used to create the mesh
  63549. * @param scene defines the hosting scene
  63550. * @returns the polyhedron mesh
  63551. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63552. */
  63553. static CreatePolyhedron(name: string, options: {
  63554. type?: number;
  63555. size?: number;
  63556. sizeX?: number;
  63557. sizeY?: number;
  63558. sizeZ?: number;
  63559. custom?: any;
  63560. faceUV?: Vector4[];
  63561. faceColors?: Color4[];
  63562. flat?: boolean;
  63563. updatable?: boolean;
  63564. sideOrientation?: number;
  63565. frontUVs?: Vector4;
  63566. backUVs?: Vector4;
  63567. }, scene?: Nullable<Scene>): Mesh;
  63568. /**
  63569. * Creates a decal mesh.
  63570. * 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
  63571. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63572. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63573. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63574. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63575. * @param name defines the name of the mesh
  63576. * @param sourceMesh defines the mesh where the decal must be applied
  63577. * @param options defines the options used to create the mesh
  63578. * @param scene defines the hosting scene
  63579. * @returns the decal mesh
  63580. * @see https://doc.babylonjs.com/how_to/decals
  63581. */
  63582. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63583. position?: Vector3;
  63584. normal?: Vector3;
  63585. size?: Vector3;
  63586. angle?: number;
  63587. }): Mesh;
  63588. }
  63589. }
  63590. declare module BABYLON {
  63591. /**
  63592. * A simplifier interface for future simplification implementations
  63593. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63594. */
  63595. export interface ISimplifier {
  63596. /**
  63597. * Simplification of a given mesh according to the given settings.
  63598. * Since this requires computation, it is assumed that the function runs async.
  63599. * @param settings The settings of the simplification, including quality and distance
  63600. * @param successCallback A callback that will be called after the mesh was simplified.
  63601. * @param errorCallback in case of an error, this callback will be called. optional.
  63602. */
  63603. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63604. }
  63605. /**
  63606. * Expected simplification settings.
  63607. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63608. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63609. */
  63610. export interface ISimplificationSettings {
  63611. /**
  63612. * Gets or sets the expected quality
  63613. */
  63614. quality: number;
  63615. /**
  63616. * Gets or sets the distance when this optimized version should be used
  63617. */
  63618. distance: number;
  63619. /**
  63620. * Gets an already optimized mesh
  63621. */
  63622. optimizeMesh?: boolean;
  63623. }
  63624. /**
  63625. * Class used to specify simplification options
  63626. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63627. */
  63628. export class SimplificationSettings implements ISimplificationSettings {
  63629. /** expected quality */
  63630. quality: number;
  63631. /** distance when this optimized version should be used */
  63632. distance: number;
  63633. /** already optimized mesh */
  63634. optimizeMesh?: boolean | undefined;
  63635. /**
  63636. * Creates a SimplificationSettings
  63637. * @param quality expected quality
  63638. * @param distance distance when this optimized version should be used
  63639. * @param optimizeMesh already optimized mesh
  63640. */
  63641. constructor(
  63642. /** expected quality */
  63643. quality: number,
  63644. /** distance when this optimized version should be used */
  63645. distance: number,
  63646. /** already optimized mesh */
  63647. optimizeMesh?: boolean | undefined);
  63648. }
  63649. /**
  63650. * Interface used to define a simplification task
  63651. */
  63652. export interface ISimplificationTask {
  63653. /**
  63654. * Array of settings
  63655. */
  63656. settings: Array<ISimplificationSettings>;
  63657. /**
  63658. * Simplification type
  63659. */
  63660. simplificationType: SimplificationType;
  63661. /**
  63662. * Mesh to simplify
  63663. */
  63664. mesh: Mesh;
  63665. /**
  63666. * Callback called on success
  63667. */
  63668. successCallback?: () => void;
  63669. /**
  63670. * Defines if parallel processing can be used
  63671. */
  63672. parallelProcessing: boolean;
  63673. }
  63674. /**
  63675. * Queue used to order the simplification tasks
  63676. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63677. */
  63678. export class SimplificationQueue {
  63679. private _simplificationArray;
  63680. /**
  63681. * Gets a boolean indicating that the process is still running
  63682. */
  63683. running: boolean;
  63684. /**
  63685. * Creates a new queue
  63686. */
  63687. constructor();
  63688. /**
  63689. * Adds a new simplification task
  63690. * @param task defines a task to add
  63691. */
  63692. addTask(task: ISimplificationTask): void;
  63693. /**
  63694. * Execute next task
  63695. */
  63696. executeNext(): void;
  63697. /**
  63698. * Execute a simplification task
  63699. * @param task defines the task to run
  63700. */
  63701. runSimplification(task: ISimplificationTask): void;
  63702. private getSimplifier;
  63703. }
  63704. /**
  63705. * The implemented types of simplification
  63706. * At the moment only Quadratic Error Decimation is implemented
  63707. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63708. */
  63709. export enum SimplificationType {
  63710. /** Quadratic error decimation */
  63711. QUADRATIC = 0
  63712. }
  63713. /**
  63714. * An implementation of the Quadratic Error simplification algorithm.
  63715. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  63716. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  63717. * @author RaananW
  63718. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63719. */
  63720. export class QuadraticErrorSimplification implements ISimplifier {
  63721. private _mesh;
  63722. private triangles;
  63723. private vertices;
  63724. private references;
  63725. private _reconstructedMesh;
  63726. /** Gets or sets the number pf sync interations */
  63727. syncIterations: number;
  63728. /** Gets or sets the aggressiveness of the simplifier */
  63729. aggressiveness: number;
  63730. /** Gets or sets the number of allowed iterations for decimation */
  63731. decimationIterations: number;
  63732. /** Gets or sets the espilon to use for bounding box computation */
  63733. boundingBoxEpsilon: number;
  63734. /**
  63735. * Creates a new QuadraticErrorSimplification
  63736. * @param _mesh defines the target mesh
  63737. */
  63738. constructor(_mesh: Mesh);
  63739. /**
  63740. * Simplification of a given mesh according to the given settings.
  63741. * Since this requires computation, it is assumed that the function runs async.
  63742. * @param settings The settings of the simplification, including quality and distance
  63743. * @param successCallback A callback that will be called after the mesh was simplified.
  63744. */
  63745. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  63746. private runDecimation;
  63747. private initWithMesh;
  63748. private init;
  63749. private reconstructMesh;
  63750. private initDecimatedMesh;
  63751. private isFlipped;
  63752. private updateTriangles;
  63753. private identifyBorder;
  63754. private updateMesh;
  63755. private vertexError;
  63756. private calculateError;
  63757. }
  63758. }
  63759. declare module BABYLON {
  63760. interface Scene {
  63761. /** @hidden (Backing field) */
  63762. _simplificationQueue: SimplificationQueue;
  63763. /**
  63764. * Gets or sets the simplification queue attached to the scene
  63765. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63766. */
  63767. simplificationQueue: SimplificationQueue;
  63768. }
  63769. interface Mesh {
  63770. /**
  63771. * Simplify the mesh according to the given array of settings.
  63772. * Function will return immediately and will simplify async
  63773. * @param settings a collection of simplification settings
  63774. * @param parallelProcessing should all levels calculate parallel or one after the other
  63775. * @param simplificationType the type of simplification to run
  63776. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63777. * @returns the current mesh
  63778. */
  63779. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63780. }
  63781. /**
  63782. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63783. * created in a scene
  63784. */
  63785. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63786. /**
  63787. * The component name helpfull to identify the component in the list of scene components.
  63788. */
  63789. readonly name: string;
  63790. /**
  63791. * The scene the component belongs to.
  63792. */
  63793. scene: Scene;
  63794. /**
  63795. * Creates a new instance of the component for the given scene
  63796. * @param scene Defines the scene to register the component in
  63797. */
  63798. constructor(scene: Scene);
  63799. /**
  63800. * Registers the component in a given scene
  63801. */
  63802. register(): void;
  63803. /**
  63804. * Rebuilds the elements related to this component in case of
  63805. * context lost for instance.
  63806. */
  63807. rebuild(): void;
  63808. /**
  63809. * Disposes the component and the associated ressources
  63810. */
  63811. dispose(): void;
  63812. private _beforeCameraUpdate;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63818. */
  63819. export interface INavigationEnginePlugin {
  63820. /**
  63821. * plugin name
  63822. */
  63823. name: string;
  63824. /**
  63825. * Creates a navigation mesh
  63826. * @param meshes array of all the geometry used to compute the navigatio mesh
  63827. * @param parameters bunch of parameters used to filter geometry
  63828. */
  63829. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63830. /**
  63831. * Create a navigation mesh debug mesh
  63832. * @param scene is where the mesh will be added
  63833. * @returns debug display mesh
  63834. */
  63835. createDebugNavMesh(scene: Scene): Mesh;
  63836. /**
  63837. * Get a navigation mesh constrained position, closest to the parameter position
  63838. * @param position world position
  63839. * @returns the closest point to position constrained by the navigation mesh
  63840. */
  63841. getClosestPoint(position: Vector3): Vector3;
  63842. /**
  63843. * Get a navigation mesh constrained position, closest to the parameter position
  63844. * @param position world position
  63845. * @param result output the closest point to position constrained by the navigation mesh
  63846. */
  63847. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63848. /**
  63849. * Get a navigation mesh constrained position, within a particular radius
  63850. * @param position world position
  63851. * @param maxRadius the maximum distance to the constrained world position
  63852. * @returns the closest point to position constrained by the navigation mesh
  63853. */
  63854. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63855. /**
  63856. * Get a navigation mesh constrained position, within a particular radius
  63857. * @param position world position
  63858. * @param maxRadius the maximum distance to the constrained world position
  63859. * @param result output the closest point to position constrained by the navigation mesh
  63860. */
  63861. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63862. /**
  63863. * Compute the final position from a segment made of destination-position
  63864. * @param position world position
  63865. * @param destination world position
  63866. * @returns the resulting point along the navmesh
  63867. */
  63868. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63869. /**
  63870. * Compute the final position from a segment made of destination-position
  63871. * @param position world position
  63872. * @param destination world position
  63873. * @param result output the resulting point along the navmesh
  63874. */
  63875. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63876. /**
  63877. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63878. * @param start world position
  63879. * @param end world position
  63880. * @returns array containing world position composing the path
  63881. */
  63882. computePath(start: Vector3, end: Vector3): Vector3[];
  63883. /**
  63884. * If this plugin is supported
  63885. * @returns true if plugin is supported
  63886. */
  63887. isSupported(): boolean;
  63888. /**
  63889. * Create a new Crowd so you can add agents
  63890. * @param maxAgents the maximum agent count in the crowd
  63891. * @param maxAgentRadius the maximum radius an agent can have
  63892. * @param scene to attach the crowd to
  63893. * @returns the crowd you can add agents to
  63894. */
  63895. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63896. /**
  63897. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63898. * The queries will try to find a solution within those bounds
  63899. * default is (1,1,1)
  63900. * @param extent x,y,z value that define the extent around the queries point of reference
  63901. */
  63902. setDefaultQueryExtent(extent: Vector3): void;
  63903. /**
  63904. * Get the Bounding box extent specified by setDefaultQueryExtent
  63905. * @returns the box extent values
  63906. */
  63907. getDefaultQueryExtent(): Vector3;
  63908. /**
  63909. * build the navmesh from a previously saved state using getNavmeshData
  63910. * @param data the Uint8Array returned by getNavmeshData
  63911. */
  63912. buildFromNavmeshData(data: Uint8Array): void;
  63913. /**
  63914. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63915. * @returns data the Uint8Array that can be saved and reused
  63916. */
  63917. getNavmeshData(): Uint8Array;
  63918. /**
  63919. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63920. * @param result output the box extent values
  63921. */
  63922. getDefaultQueryExtentToRef(result: Vector3): void;
  63923. /**
  63924. * Release all resources
  63925. */
  63926. dispose(): void;
  63927. }
  63928. /**
  63929. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63930. */
  63931. export interface ICrowd {
  63932. /**
  63933. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63934. * You can attach anything to that node. The node position is updated in the scene update tick.
  63935. * @param pos world position that will be constrained by the navigation mesh
  63936. * @param parameters agent parameters
  63937. * @param transform hooked to the agent that will be update by the scene
  63938. * @returns agent index
  63939. */
  63940. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63941. /**
  63942. * Returns the agent position in world space
  63943. * @param index agent index returned by addAgent
  63944. * @returns world space position
  63945. */
  63946. getAgentPosition(index: number): Vector3;
  63947. /**
  63948. * Gets the agent position result in world space
  63949. * @param index agent index returned by addAgent
  63950. * @param result output world space position
  63951. */
  63952. getAgentPositionToRef(index: number, result: Vector3): void;
  63953. /**
  63954. * Gets the agent velocity in world space
  63955. * @param index agent index returned by addAgent
  63956. * @returns world space velocity
  63957. */
  63958. getAgentVelocity(index: number): Vector3;
  63959. /**
  63960. * Gets the agent velocity result in world space
  63961. * @param index agent index returned by addAgent
  63962. * @param result output world space velocity
  63963. */
  63964. getAgentVelocityToRef(index: number, result: Vector3): void;
  63965. /**
  63966. * remove a particular agent previously created
  63967. * @param index agent index returned by addAgent
  63968. */
  63969. removeAgent(index: number): void;
  63970. /**
  63971. * get the list of all agents attached to this crowd
  63972. * @returns list of agent indices
  63973. */
  63974. getAgents(): number[];
  63975. /**
  63976. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63977. * @param deltaTime in seconds
  63978. */
  63979. update(deltaTime: number): void;
  63980. /**
  63981. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63982. * @param index agent index returned by addAgent
  63983. * @param destination targeted world position
  63984. */
  63985. agentGoto(index: number, destination: Vector3): void;
  63986. /**
  63987. * Teleport the agent to a new position
  63988. * @param index agent index returned by addAgent
  63989. * @param destination targeted world position
  63990. */
  63991. agentTeleport(index: number, destination: Vector3): void;
  63992. /**
  63993. * Update agent parameters
  63994. * @param index agent index returned by addAgent
  63995. * @param parameters agent parameters
  63996. */
  63997. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63998. /**
  63999. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64000. * The queries will try to find a solution within those bounds
  64001. * default is (1,1,1)
  64002. * @param extent x,y,z value that define the extent around the queries point of reference
  64003. */
  64004. setDefaultQueryExtent(extent: Vector3): void;
  64005. /**
  64006. * Get the Bounding box extent specified by setDefaultQueryExtent
  64007. * @returns the box extent values
  64008. */
  64009. getDefaultQueryExtent(): Vector3;
  64010. /**
  64011. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64012. * @param result output the box extent values
  64013. */
  64014. getDefaultQueryExtentToRef(result: Vector3): void;
  64015. /**
  64016. * Release all resources
  64017. */
  64018. dispose(): void;
  64019. }
  64020. /**
  64021. * Configures an agent
  64022. */
  64023. export interface IAgentParameters {
  64024. /**
  64025. * Agent radius. [Limit: >= 0]
  64026. */
  64027. radius: number;
  64028. /**
  64029. * Agent height. [Limit: > 0]
  64030. */
  64031. height: number;
  64032. /**
  64033. * Maximum allowed acceleration. [Limit: >= 0]
  64034. */
  64035. maxAcceleration: number;
  64036. /**
  64037. * Maximum allowed speed. [Limit: >= 0]
  64038. */
  64039. maxSpeed: number;
  64040. /**
  64041. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64042. */
  64043. collisionQueryRange: number;
  64044. /**
  64045. * The path visibility optimization range. [Limit: > 0]
  64046. */
  64047. pathOptimizationRange: number;
  64048. /**
  64049. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64050. */
  64051. separationWeight: number;
  64052. }
  64053. /**
  64054. * Configures the navigation mesh creation
  64055. */
  64056. export interface INavMeshParameters {
  64057. /**
  64058. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64059. */
  64060. cs: number;
  64061. /**
  64062. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64063. */
  64064. ch: number;
  64065. /**
  64066. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64067. */
  64068. walkableSlopeAngle: number;
  64069. /**
  64070. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64071. * be considered walkable. [Limit: >= 3] [Units: vx]
  64072. */
  64073. walkableHeight: number;
  64074. /**
  64075. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64076. */
  64077. walkableClimb: number;
  64078. /**
  64079. * The distance to erode/shrink the walkable area of the heightfield away from
  64080. * obstructions. [Limit: >=0] [Units: vx]
  64081. */
  64082. walkableRadius: number;
  64083. /**
  64084. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64085. */
  64086. maxEdgeLen: number;
  64087. /**
  64088. * The maximum distance a simplfied contour's border edges should deviate
  64089. * the original raw contour. [Limit: >=0] [Units: vx]
  64090. */
  64091. maxSimplificationError: number;
  64092. /**
  64093. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64094. */
  64095. minRegionArea: number;
  64096. /**
  64097. * Any regions with a span count smaller than this value will, if possible,
  64098. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64099. */
  64100. mergeRegionArea: number;
  64101. /**
  64102. * The maximum number of vertices allowed for polygons generated during the
  64103. * contour to polygon conversion process. [Limit: >= 3]
  64104. */
  64105. maxVertsPerPoly: number;
  64106. /**
  64107. * Sets the sampling distance to use when generating the detail mesh.
  64108. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64109. */
  64110. detailSampleDist: number;
  64111. /**
  64112. * The maximum distance the detail mesh surface should deviate from heightfield
  64113. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64114. */
  64115. detailSampleMaxError: number;
  64116. }
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * RecastJS navigation plugin
  64121. */
  64122. export class RecastJSPlugin implements INavigationEnginePlugin {
  64123. /**
  64124. * Reference to the Recast library
  64125. */
  64126. bjsRECAST: any;
  64127. /**
  64128. * plugin name
  64129. */
  64130. name: string;
  64131. /**
  64132. * the first navmesh created. We might extend this to support multiple navmeshes
  64133. */
  64134. navMesh: any;
  64135. /**
  64136. * Initializes the recastJS plugin
  64137. * @param recastInjection can be used to inject your own recast reference
  64138. */
  64139. constructor(recastInjection?: any);
  64140. /**
  64141. * Creates a navigation mesh
  64142. * @param meshes array of all the geometry used to compute the navigatio mesh
  64143. * @param parameters bunch of parameters used to filter geometry
  64144. */
  64145. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64146. /**
  64147. * Create a navigation mesh debug mesh
  64148. * @param scene is where the mesh will be added
  64149. * @returns debug display mesh
  64150. */
  64151. createDebugNavMesh(scene: Scene): Mesh;
  64152. /**
  64153. * Get a navigation mesh constrained position, closest to the parameter position
  64154. * @param position world position
  64155. * @returns the closest point to position constrained by the navigation mesh
  64156. */
  64157. getClosestPoint(position: Vector3): Vector3;
  64158. /**
  64159. * Get a navigation mesh constrained position, closest to the parameter position
  64160. * @param position world position
  64161. * @param result output the closest point to position constrained by the navigation mesh
  64162. */
  64163. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64164. /**
  64165. * Get a navigation mesh constrained position, within a particular radius
  64166. * @param position world position
  64167. * @param maxRadius the maximum distance to the constrained world position
  64168. * @returns the closest point to position constrained by the navigation mesh
  64169. */
  64170. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64171. /**
  64172. * Get a navigation mesh constrained position, within a particular radius
  64173. * @param position world position
  64174. * @param maxRadius the maximum distance to the constrained world position
  64175. * @param result output the closest point to position constrained by the navigation mesh
  64176. */
  64177. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64178. /**
  64179. * Compute the final position from a segment made of destination-position
  64180. * @param position world position
  64181. * @param destination world position
  64182. * @returns the resulting point along the navmesh
  64183. */
  64184. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64185. /**
  64186. * Compute the final position from a segment made of destination-position
  64187. * @param position world position
  64188. * @param destination world position
  64189. * @param result output the resulting point along the navmesh
  64190. */
  64191. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64192. /**
  64193. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64194. * @param start world position
  64195. * @param end world position
  64196. * @returns array containing world position composing the path
  64197. */
  64198. computePath(start: Vector3, end: Vector3): Vector3[];
  64199. /**
  64200. * Create a new Crowd so you can add agents
  64201. * @param maxAgents the maximum agent count in the crowd
  64202. * @param maxAgentRadius the maximum radius an agent can have
  64203. * @param scene to attach the crowd to
  64204. * @returns the crowd you can add agents to
  64205. */
  64206. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64207. /**
  64208. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64209. * The queries will try to find a solution within those bounds
  64210. * default is (1,1,1)
  64211. * @param extent x,y,z value that define the extent around the queries point of reference
  64212. */
  64213. setDefaultQueryExtent(extent: Vector3): void;
  64214. /**
  64215. * Get the Bounding box extent specified by setDefaultQueryExtent
  64216. * @returns the box extent values
  64217. */
  64218. getDefaultQueryExtent(): Vector3;
  64219. /**
  64220. * build the navmesh from a previously saved state using getNavmeshData
  64221. * @param data the Uint8Array returned by getNavmeshData
  64222. */
  64223. buildFromNavmeshData(data: Uint8Array): void;
  64224. /**
  64225. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64226. * @returns data the Uint8Array that can be saved and reused
  64227. */
  64228. getNavmeshData(): Uint8Array;
  64229. /**
  64230. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64231. * @param result output the box extent values
  64232. */
  64233. getDefaultQueryExtentToRef(result: Vector3): void;
  64234. /**
  64235. * Disposes
  64236. */
  64237. dispose(): void;
  64238. /**
  64239. * If this plugin is supported
  64240. * @returns true if plugin is supported
  64241. */
  64242. isSupported(): boolean;
  64243. }
  64244. /**
  64245. * Recast detour crowd implementation
  64246. */
  64247. export class RecastJSCrowd implements ICrowd {
  64248. /**
  64249. * Recast/detour plugin
  64250. */
  64251. bjsRECASTPlugin: RecastJSPlugin;
  64252. /**
  64253. * Link to the detour crowd
  64254. */
  64255. recastCrowd: any;
  64256. /**
  64257. * One transform per agent
  64258. */
  64259. transforms: TransformNode[];
  64260. /**
  64261. * All agents created
  64262. */
  64263. agents: number[];
  64264. /**
  64265. * Link to the scene is kept to unregister the crowd from the scene
  64266. */
  64267. private _scene;
  64268. /**
  64269. * Observer for crowd updates
  64270. */
  64271. private _onBeforeAnimationsObserver;
  64272. /**
  64273. * Constructor
  64274. * @param plugin recastJS plugin
  64275. * @param maxAgents the maximum agent count in the crowd
  64276. * @param maxAgentRadius the maximum radius an agent can have
  64277. * @param scene to attach the crowd to
  64278. * @returns the crowd you can add agents to
  64279. */
  64280. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64281. /**
  64282. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64283. * You can attach anything to that node. The node position is updated in the scene update tick.
  64284. * @param pos world position that will be constrained by the navigation mesh
  64285. * @param parameters agent parameters
  64286. * @param transform hooked to the agent that will be update by the scene
  64287. * @returns agent index
  64288. */
  64289. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64290. /**
  64291. * Returns the agent position in world space
  64292. * @param index agent index returned by addAgent
  64293. * @returns world space position
  64294. */
  64295. getAgentPosition(index: number): Vector3;
  64296. /**
  64297. * Returns the agent position result in world space
  64298. * @param index agent index returned by addAgent
  64299. * @param result output world space position
  64300. */
  64301. getAgentPositionToRef(index: number, result: Vector3): void;
  64302. /**
  64303. * Returns the agent velocity in world space
  64304. * @param index agent index returned by addAgent
  64305. * @returns world space velocity
  64306. */
  64307. getAgentVelocity(index: number): Vector3;
  64308. /**
  64309. * Returns the agent velocity result in world space
  64310. * @param index agent index returned by addAgent
  64311. * @param result output world space velocity
  64312. */
  64313. getAgentVelocityToRef(index: number, result: Vector3): void;
  64314. /**
  64315. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64316. * @param index agent index returned by addAgent
  64317. * @param destination targeted world position
  64318. */
  64319. agentGoto(index: number, destination: Vector3): void;
  64320. /**
  64321. * Teleport the agent to a new position
  64322. * @param index agent index returned by addAgent
  64323. * @param destination targeted world position
  64324. */
  64325. agentTeleport(index: number, destination: Vector3): void;
  64326. /**
  64327. * Update agent parameters
  64328. * @param index agent index returned by addAgent
  64329. * @param parameters agent parameters
  64330. */
  64331. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64332. /**
  64333. * remove a particular agent previously created
  64334. * @param index agent index returned by addAgent
  64335. */
  64336. removeAgent(index: number): void;
  64337. /**
  64338. * get the list of all agents attached to this crowd
  64339. * @returns list of agent indices
  64340. */
  64341. getAgents(): number[];
  64342. /**
  64343. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64344. * @param deltaTime in seconds
  64345. */
  64346. update(deltaTime: number): void;
  64347. /**
  64348. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64349. * The queries will try to find a solution within those bounds
  64350. * default is (1,1,1)
  64351. * @param extent x,y,z value that define the extent around the queries point of reference
  64352. */
  64353. setDefaultQueryExtent(extent: Vector3): void;
  64354. /**
  64355. * Get the Bounding box extent specified by setDefaultQueryExtent
  64356. * @returns the box extent values
  64357. */
  64358. getDefaultQueryExtent(): Vector3;
  64359. /**
  64360. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64361. * @param result output the box extent values
  64362. */
  64363. getDefaultQueryExtentToRef(result: Vector3): void;
  64364. /**
  64365. * Release all resources
  64366. */
  64367. dispose(): void;
  64368. }
  64369. }
  64370. declare module BABYLON {
  64371. /**
  64372. * Class used to enable access to IndexedDB
  64373. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64374. */
  64375. export class Database implements IOfflineProvider {
  64376. private _callbackManifestChecked;
  64377. private _currentSceneUrl;
  64378. private _db;
  64379. private _enableSceneOffline;
  64380. private _enableTexturesOffline;
  64381. private _manifestVersionFound;
  64382. private _mustUpdateRessources;
  64383. private _hasReachedQuota;
  64384. private _isSupported;
  64385. private _idbFactory;
  64386. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64387. private static IsUASupportingBlobStorage;
  64388. /**
  64389. * Gets a boolean indicating if Database storate is enabled (off by default)
  64390. */
  64391. static IDBStorageEnabled: boolean;
  64392. /**
  64393. * Gets a boolean indicating if scene must be saved in the database
  64394. */
  64395. get enableSceneOffline(): boolean;
  64396. /**
  64397. * Gets a boolean indicating if textures must be saved in the database
  64398. */
  64399. get enableTexturesOffline(): boolean;
  64400. /**
  64401. * Creates a new Database
  64402. * @param urlToScene defines the url to load the scene
  64403. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64404. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64405. */
  64406. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64407. private static _ParseURL;
  64408. private static _ReturnFullUrlLocation;
  64409. private _checkManifestFile;
  64410. /**
  64411. * Open the database and make it available
  64412. * @param successCallback defines the callback to call on success
  64413. * @param errorCallback defines the callback to call on error
  64414. */
  64415. open(successCallback: () => void, errorCallback: () => void): void;
  64416. /**
  64417. * Loads an image from the database
  64418. * @param url defines the url to load from
  64419. * @param image defines the target DOM image
  64420. */
  64421. loadImage(url: string, image: HTMLImageElement): void;
  64422. private _loadImageFromDBAsync;
  64423. private _saveImageIntoDBAsync;
  64424. private _checkVersionFromDB;
  64425. private _loadVersionFromDBAsync;
  64426. private _saveVersionIntoDBAsync;
  64427. /**
  64428. * Loads a file from database
  64429. * @param url defines the URL to load from
  64430. * @param sceneLoaded defines a callback to call on success
  64431. * @param progressCallBack defines a callback to call when progress changed
  64432. * @param errorCallback defines a callback to call on error
  64433. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64434. */
  64435. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64436. private _loadFileAsync;
  64437. private _saveFileAsync;
  64438. /**
  64439. * Validates if xhr data is correct
  64440. * @param xhr defines the request to validate
  64441. * @param dataType defines the expected data type
  64442. * @returns true if data is correct
  64443. */
  64444. private static _ValidateXHRData;
  64445. }
  64446. }
  64447. declare module BABYLON {
  64448. /** @hidden */
  64449. export var gpuUpdateParticlesPixelShader: {
  64450. name: string;
  64451. shader: string;
  64452. };
  64453. }
  64454. declare module BABYLON {
  64455. /** @hidden */
  64456. export var gpuUpdateParticlesVertexShader: {
  64457. name: string;
  64458. shader: string;
  64459. };
  64460. }
  64461. declare module BABYLON {
  64462. /** @hidden */
  64463. export var clipPlaneFragmentDeclaration2: {
  64464. name: string;
  64465. shader: string;
  64466. };
  64467. }
  64468. declare module BABYLON {
  64469. /** @hidden */
  64470. export var gpuRenderParticlesPixelShader: {
  64471. name: string;
  64472. shader: string;
  64473. };
  64474. }
  64475. declare module BABYLON {
  64476. /** @hidden */
  64477. export var clipPlaneVertexDeclaration2: {
  64478. name: string;
  64479. shader: string;
  64480. };
  64481. }
  64482. declare module BABYLON {
  64483. /** @hidden */
  64484. export var gpuRenderParticlesVertexShader: {
  64485. name: string;
  64486. shader: string;
  64487. };
  64488. }
  64489. declare module BABYLON {
  64490. /**
  64491. * This represents a GPU particle system in Babylon
  64492. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64493. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64494. */
  64495. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64496. /**
  64497. * The layer mask we are rendering the particles through.
  64498. */
  64499. layerMask: number;
  64500. private _capacity;
  64501. private _activeCount;
  64502. private _currentActiveCount;
  64503. private _accumulatedCount;
  64504. private _renderEffect;
  64505. private _updateEffect;
  64506. private _buffer0;
  64507. private _buffer1;
  64508. private _spriteBuffer;
  64509. private _updateVAO;
  64510. private _renderVAO;
  64511. private _targetIndex;
  64512. private _sourceBuffer;
  64513. private _targetBuffer;
  64514. private _engine;
  64515. private _currentRenderId;
  64516. private _started;
  64517. private _stopped;
  64518. private _timeDelta;
  64519. private _randomTexture;
  64520. private _randomTexture2;
  64521. private _attributesStrideSize;
  64522. private _updateEffectOptions;
  64523. private _randomTextureSize;
  64524. private _actualFrame;
  64525. private readonly _rawTextureWidth;
  64526. /**
  64527. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64528. */
  64529. static get IsSupported(): boolean;
  64530. /**
  64531. * An event triggered when the system is disposed.
  64532. */
  64533. onDisposeObservable: Observable<GPUParticleSystem>;
  64534. /**
  64535. * Gets the maximum number of particles active at the same time.
  64536. * @returns The max number of active particles.
  64537. */
  64538. getCapacity(): number;
  64539. /**
  64540. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64541. * to override the particles.
  64542. */
  64543. forceDepthWrite: boolean;
  64544. /**
  64545. * Gets or set the number of active particles
  64546. */
  64547. get activeParticleCount(): number;
  64548. set activeParticleCount(value: number);
  64549. private _preWarmDone;
  64550. /**
  64551. * Specifies if the particles are updated in emitter local space or world space.
  64552. */
  64553. isLocal: boolean;
  64554. /**
  64555. * Is this system ready to be used/rendered
  64556. * @return true if the system is ready
  64557. */
  64558. isReady(): boolean;
  64559. /**
  64560. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64561. * @returns True if it has been started, otherwise false.
  64562. */
  64563. isStarted(): boolean;
  64564. /**
  64565. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  64566. * @returns True if it has been stopped, otherwise false.
  64567. */
  64568. isStopped(): boolean;
  64569. /**
  64570. * Gets a boolean indicating that the system is stopping
  64571. * @returns true if the system is currently stopping
  64572. */
  64573. isStopping(): boolean;
  64574. /**
  64575. * Gets the number of particles active at the same time.
  64576. * @returns The number of active particles.
  64577. */
  64578. getActiveCount(): number;
  64579. /**
  64580. * Starts the particle system and begins to emit
  64581. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64582. */
  64583. start(delay?: number): void;
  64584. /**
  64585. * Stops the particle system.
  64586. */
  64587. stop(): void;
  64588. /**
  64589. * Remove all active particles
  64590. */
  64591. reset(): void;
  64592. /**
  64593. * Returns the string "GPUParticleSystem"
  64594. * @returns a string containing the class name
  64595. */
  64596. getClassName(): string;
  64597. private _colorGradientsTexture;
  64598. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64599. /**
  64600. * Adds a new color gradient
  64601. * @param gradient defines the gradient to use (between 0 and 1)
  64602. * @param color1 defines the color to affect to the specified gradient
  64603. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64604. * @returns the current particle system
  64605. */
  64606. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64607. private _refreshColorGradient;
  64608. /** Force the system to rebuild all gradients that need to be resync */
  64609. forceRefreshGradients(): void;
  64610. /**
  64611. * Remove a specific color gradient
  64612. * @param gradient defines the gradient to remove
  64613. * @returns the current particle system
  64614. */
  64615. removeColorGradient(gradient: number): GPUParticleSystem;
  64616. private _angularSpeedGradientsTexture;
  64617. private _sizeGradientsTexture;
  64618. private _velocityGradientsTexture;
  64619. private _limitVelocityGradientsTexture;
  64620. private _dragGradientsTexture;
  64621. private _addFactorGradient;
  64622. /**
  64623. * Adds a new size gradient
  64624. * @param gradient defines the gradient to use (between 0 and 1)
  64625. * @param factor defines the size factor to affect to the specified gradient
  64626. * @returns the current particle system
  64627. */
  64628. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64629. /**
  64630. * Remove a specific size gradient
  64631. * @param gradient defines the gradient to remove
  64632. * @returns the current particle system
  64633. */
  64634. removeSizeGradient(gradient: number): GPUParticleSystem;
  64635. private _refreshFactorGradient;
  64636. /**
  64637. * Adds a new angular speed gradient
  64638. * @param gradient defines the gradient to use (between 0 and 1)
  64639. * @param factor defines the angular speed to affect to the specified gradient
  64640. * @returns the current particle system
  64641. */
  64642. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64643. /**
  64644. * Remove a specific angular speed gradient
  64645. * @param gradient defines the gradient to remove
  64646. * @returns the current particle system
  64647. */
  64648. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64649. /**
  64650. * Adds a new velocity gradient
  64651. * @param gradient defines the gradient to use (between 0 and 1)
  64652. * @param factor defines the velocity to affect to the specified gradient
  64653. * @returns the current particle system
  64654. */
  64655. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64656. /**
  64657. * Remove a specific velocity gradient
  64658. * @param gradient defines the gradient to remove
  64659. * @returns the current particle system
  64660. */
  64661. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64662. /**
  64663. * Adds a new limit velocity gradient
  64664. * @param gradient defines the gradient to use (between 0 and 1)
  64665. * @param factor defines the limit velocity value to affect to the specified gradient
  64666. * @returns the current particle system
  64667. */
  64668. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64669. /**
  64670. * Remove a specific limit velocity gradient
  64671. * @param gradient defines the gradient to remove
  64672. * @returns the current particle system
  64673. */
  64674. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64675. /**
  64676. * Adds a new drag gradient
  64677. * @param gradient defines the gradient to use (between 0 and 1)
  64678. * @param factor defines the drag value to affect to the specified gradient
  64679. * @returns the current particle system
  64680. */
  64681. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64682. /**
  64683. * Remove a specific drag gradient
  64684. * @param gradient defines the gradient to remove
  64685. * @returns the current particle system
  64686. */
  64687. removeDragGradient(gradient: number): GPUParticleSystem;
  64688. /**
  64689. * Not supported by GPUParticleSystem
  64690. * @param gradient defines the gradient to use (between 0 and 1)
  64691. * @param factor defines the emit rate value to affect to the specified gradient
  64692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64693. * @returns the current particle system
  64694. */
  64695. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64696. /**
  64697. * Not supported by GPUParticleSystem
  64698. * @param gradient defines the gradient to remove
  64699. * @returns the current particle system
  64700. */
  64701. removeEmitRateGradient(gradient: number): IParticleSystem;
  64702. /**
  64703. * Not supported by GPUParticleSystem
  64704. * @param gradient defines the gradient to use (between 0 and 1)
  64705. * @param factor defines the start size value to affect to the specified gradient
  64706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64707. * @returns the current particle system
  64708. */
  64709. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64710. /**
  64711. * Not supported by GPUParticleSystem
  64712. * @param gradient defines the gradient to remove
  64713. * @returns the current particle system
  64714. */
  64715. removeStartSizeGradient(gradient: number): IParticleSystem;
  64716. /**
  64717. * Not supported by GPUParticleSystem
  64718. * @param gradient defines the gradient to use (between 0 and 1)
  64719. * @param min defines the color remap minimal range
  64720. * @param max defines the color remap maximal range
  64721. * @returns the current particle system
  64722. */
  64723. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64724. /**
  64725. * Not supported by GPUParticleSystem
  64726. * @param gradient defines the gradient to remove
  64727. * @returns the current particle system
  64728. */
  64729. removeColorRemapGradient(): IParticleSystem;
  64730. /**
  64731. * Not supported by GPUParticleSystem
  64732. * @param gradient defines the gradient to use (between 0 and 1)
  64733. * @param min defines the alpha remap minimal range
  64734. * @param max defines the alpha remap maximal range
  64735. * @returns the current particle system
  64736. */
  64737. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64738. /**
  64739. * Not supported by GPUParticleSystem
  64740. * @param gradient defines the gradient to remove
  64741. * @returns the current particle system
  64742. */
  64743. removeAlphaRemapGradient(): IParticleSystem;
  64744. /**
  64745. * Not supported by GPUParticleSystem
  64746. * @param gradient defines the gradient to use (between 0 and 1)
  64747. * @param color defines the color to affect to the specified gradient
  64748. * @returns the current particle system
  64749. */
  64750. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64751. /**
  64752. * Not supported by GPUParticleSystem
  64753. * @param gradient defines the gradient to remove
  64754. * @returns the current particle system
  64755. */
  64756. removeRampGradient(): IParticleSystem;
  64757. /**
  64758. * Not supported by GPUParticleSystem
  64759. * @returns the list of ramp gradients
  64760. */
  64761. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64762. /**
  64763. * Not supported by GPUParticleSystem
  64764. * Gets or sets a boolean indicating that ramp gradients must be used
  64765. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64766. */
  64767. get useRampGradients(): boolean;
  64768. set useRampGradients(value: boolean);
  64769. /**
  64770. * Not supported by GPUParticleSystem
  64771. * @param gradient defines the gradient to use (between 0 and 1)
  64772. * @param factor defines the life time factor to affect to the specified gradient
  64773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64774. * @returns the current particle system
  64775. */
  64776. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64777. /**
  64778. * Not supported by GPUParticleSystem
  64779. * @param gradient defines the gradient to remove
  64780. * @returns the current particle system
  64781. */
  64782. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64783. /**
  64784. * Instantiates a GPU particle system.
  64785. * 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.
  64786. * @param name The name of the particle system
  64787. * @param options The options used to create the system
  64788. * @param scene The scene the particle system belongs to
  64789. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64790. */
  64791. constructor(name: string, options: Partial<{
  64792. capacity: number;
  64793. randomTextureSize: number;
  64794. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64795. protected _reset(): void;
  64796. private _createUpdateVAO;
  64797. private _createRenderVAO;
  64798. private _initialize;
  64799. /** @hidden */
  64800. _recreateUpdateEffect(): void;
  64801. /** @hidden */
  64802. _recreateRenderEffect(): void;
  64803. /**
  64804. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64805. * @param preWarm defines if we are in the pre-warmimg phase
  64806. */
  64807. animate(preWarm?: boolean): void;
  64808. private _createFactorGradientTexture;
  64809. private _createSizeGradientTexture;
  64810. private _createAngularSpeedGradientTexture;
  64811. private _createVelocityGradientTexture;
  64812. private _createLimitVelocityGradientTexture;
  64813. private _createDragGradientTexture;
  64814. private _createColorGradientTexture;
  64815. /**
  64816. * Renders the particle system in its current state
  64817. * @param preWarm defines if the system should only update the particles but not render them
  64818. * @returns the current number of particles
  64819. */
  64820. render(preWarm?: boolean): number;
  64821. /**
  64822. * Rebuilds the particle system
  64823. */
  64824. rebuild(): void;
  64825. private _releaseBuffers;
  64826. private _releaseVAOs;
  64827. /**
  64828. * Disposes the particle system and free the associated resources
  64829. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64830. */
  64831. dispose(disposeTexture?: boolean): void;
  64832. /**
  64833. * Clones the particle system.
  64834. * @param name The name of the cloned object
  64835. * @param newEmitter The new emitter to use
  64836. * @returns the cloned particle system
  64837. */
  64838. clone(name: string, newEmitter: any): GPUParticleSystem;
  64839. /**
  64840. * Serializes the particle system to a JSON object
  64841. * @param serializeTexture defines if the texture must be serialized as well
  64842. * @returns the JSON object
  64843. */
  64844. serialize(serializeTexture?: boolean): any;
  64845. /**
  64846. * Parses a JSON object to create a GPU particle system.
  64847. * @param parsedParticleSystem The JSON object to parse
  64848. * @param scene The scene to create the particle system in
  64849. * @param rootUrl The root url to use to load external dependencies like texture
  64850. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64851. * @returns the parsed GPU particle system
  64852. */
  64853. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64854. }
  64855. }
  64856. declare module BABYLON {
  64857. /**
  64858. * Represents a set of particle systems working together to create a specific effect
  64859. */
  64860. export class ParticleSystemSet implements IDisposable {
  64861. /**
  64862. * Gets or sets base Assets URL
  64863. */
  64864. static BaseAssetsUrl: string;
  64865. private _emitterCreationOptions;
  64866. private _emitterNode;
  64867. /**
  64868. * Gets the particle system list
  64869. */
  64870. systems: IParticleSystem[];
  64871. /**
  64872. * Gets the emitter node used with this set
  64873. */
  64874. get emitterNode(): Nullable<TransformNode>;
  64875. /**
  64876. * Creates a new emitter mesh as a sphere
  64877. * @param options defines the options used to create the sphere
  64878. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64879. * @param scene defines the hosting scene
  64880. */
  64881. setEmitterAsSphere(options: {
  64882. diameter: number;
  64883. segments: number;
  64884. color: Color3;
  64885. }, renderingGroupId: number, scene: Scene): void;
  64886. /**
  64887. * Starts all particle systems of the set
  64888. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64889. */
  64890. start(emitter?: AbstractMesh): void;
  64891. /**
  64892. * Release all associated resources
  64893. */
  64894. dispose(): void;
  64895. /**
  64896. * Serialize the set into a JSON compatible object
  64897. * @param serializeTexture defines if the texture must be serialized as well
  64898. * @returns a JSON compatible representation of the set
  64899. */
  64900. serialize(serializeTexture?: boolean): any;
  64901. /**
  64902. * Parse a new ParticleSystemSet from a serialized source
  64903. * @param data defines a JSON compatible representation of the set
  64904. * @param scene defines the hosting scene
  64905. * @param gpu defines if we want GPU particles or CPU particles
  64906. * @returns a new ParticleSystemSet
  64907. */
  64908. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64909. }
  64910. }
  64911. declare module BABYLON {
  64912. /**
  64913. * This class is made for on one-liner static method to help creating particle system set.
  64914. */
  64915. export class ParticleHelper {
  64916. /**
  64917. * Gets or sets base Assets URL
  64918. */
  64919. static BaseAssetsUrl: string;
  64920. /** Define the Url to load snippets */
  64921. static SnippetUrl: string;
  64922. /**
  64923. * Create a default particle system that you can tweak
  64924. * @param emitter defines the emitter to use
  64925. * @param capacity defines the system capacity (default is 500 particles)
  64926. * @param scene defines the hosting scene
  64927. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64928. * @returns the new Particle system
  64929. */
  64930. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64931. /**
  64932. * This is the main static method (one-liner) of this helper to create different particle systems
  64933. * @param type This string represents the type to the particle system to create
  64934. * @param scene The scene where the particle system should live
  64935. * @param gpu If the system will use gpu
  64936. * @returns the ParticleSystemSet created
  64937. */
  64938. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64939. /**
  64940. * Static function used to export a particle system to a ParticleSystemSet variable.
  64941. * Please note that the emitter shape is not exported
  64942. * @param systems defines the particle systems to export
  64943. * @returns the created particle system set
  64944. */
  64945. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64946. /**
  64947. * Creates a particle system from a snippet saved in a remote file
  64948. * @param name defines the name of the particle system to create
  64949. * @param url defines the url to load from
  64950. * @param scene defines the hosting scene
  64951. * @param gpu If the system will use gpu
  64952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64953. * @returns a promise that will resolve to the new particle system
  64954. */
  64955. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  64956. /**
  64957. * Creates a particle system from a snippet saved by the particle system editor
  64958. * @param snippetId defines the snippet to load
  64959. * @param scene defines the hosting scene
  64960. * @param gpu If the system will use gpu
  64961. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64962. * @returns a promise that will resolve to the new particle system
  64963. */
  64964. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  64965. }
  64966. }
  64967. declare module BABYLON {
  64968. interface Engine {
  64969. /**
  64970. * Create an effect to use with particle systems.
  64971. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64972. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64973. * @param uniformsNames defines a list of attribute names
  64974. * @param samplers defines an array of string used to represent textures
  64975. * @param defines defines the string containing the defines to use to compile the shaders
  64976. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64977. * @param onCompiled defines a function to call when the effect creation is successful
  64978. * @param onError defines a function to call when the effect creation has failed
  64979. * @returns the new Effect
  64980. */
  64981. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64982. }
  64983. interface Mesh {
  64984. /**
  64985. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64986. * @returns an array of IParticleSystem
  64987. */
  64988. getEmittedParticleSystems(): IParticleSystem[];
  64989. /**
  64990. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64991. * @returns an array of IParticleSystem
  64992. */
  64993. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64994. }
  64995. /**
  64996. * @hidden
  64997. */
  64998. export var _IDoNeedToBeInTheBuild: number;
  64999. }
  65000. declare module BABYLON {
  65001. /** Defines the 4 color options */
  65002. export enum PointColor {
  65003. /** color value */
  65004. Color = 2,
  65005. /** uv value */
  65006. UV = 1,
  65007. /** random value */
  65008. Random = 0,
  65009. /** stated value */
  65010. Stated = 3
  65011. }
  65012. /**
  65013. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65014. * 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.
  65015. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65016. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65017. *
  65018. * Full documentation here : TO BE ENTERED
  65019. */
  65020. export class PointsCloudSystem implements IDisposable {
  65021. /**
  65022. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65023. * Example : var p = SPS.particles[i];
  65024. */
  65025. particles: CloudPoint[];
  65026. /**
  65027. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65028. */
  65029. nbParticles: number;
  65030. /**
  65031. * This a counter for your own usage. It's not set by any SPS functions.
  65032. */
  65033. counter: number;
  65034. /**
  65035. * The PCS name. This name is also given to the underlying mesh.
  65036. */
  65037. name: string;
  65038. /**
  65039. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65040. */
  65041. mesh: Mesh;
  65042. /**
  65043. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65044. * Please read :
  65045. */
  65046. vars: any;
  65047. /**
  65048. * @hidden
  65049. */
  65050. _size: number;
  65051. private _scene;
  65052. private _promises;
  65053. private _positions;
  65054. private _indices;
  65055. private _normals;
  65056. private _colors;
  65057. private _uvs;
  65058. private _indices32;
  65059. private _positions32;
  65060. private _colors32;
  65061. private _uvs32;
  65062. private _updatable;
  65063. private _isVisibilityBoxLocked;
  65064. private _alwaysVisible;
  65065. private _groups;
  65066. private _groupCounter;
  65067. private _computeParticleColor;
  65068. private _computeParticleTexture;
  65069. private _computeParticleRotation;
  65070. private _computeBoundingBox;
  65071. private _isReady;
  65072. /**
  65073. * Creates a PCS (Points Cloud System) object
  65074. * @param name (String) is the PCS name, this will be the underlying mesh name
  65075. * @param pointSize (number) is the size for each point
  65076. * @param scene (Scene) is the scene in which the PCS is added
  65077. * @param options defines the options of the PCS e.g.
  65078. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65079. */
  65080. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65081. updatable?: boolean;
  65082. });
  65083. /**
  65084. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65085. * If no points were added to the PCS, the returned mesh is just a single point.
  65086. * @returns a promise for the created mesh
  65087. */
  65088. buildMeshAsync(): Promise<Mesh>;
  65089. /**
  65090. * @hidden
  65091. */
  65092. private _buildMesh;
  65093. private _addParticle;
  65094. private _randomUnitVector;
  65095. private _getColorIndicesForCoord;
  65096. private _setPointsColorOrUV;
  65097. private _colorFromTexture;
  65098. private _calculateDensity;
  65099. /**
  65100. * Adds points to the PCS in random positions within a unit sphere
  65101. * @param nb (positive integer) the number of particles to be created from this model
  65102. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65103. * @returns the number of groups in the system
  65104. */
  65105. addPoints(nb: number, pointFunction?: any): number;
  65106. /**
  65107. * Adds points to the PCS from the surface of the model shape
  65108. * @param mesh is any Mesh object that will be used as a surface model for the points
  65109. * @param nb (positive integer) the number of particles to be created from this model
  65110. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65111. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65112. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65113. * @returns the number of groups in the system
  65114. */
  65115. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65116. /**
  65117. * Adds points to the PCS inside the model shape
  65118. * @param mesh is any Mesh object that will be used as a surface model for the points
  65119. * @param nb (positive integer) the number of particles to be created from this model
  65120. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65121. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65122. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65123. * @returns the number of groups in the system
  65124. */
  65125. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65126. /**
  65127. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65128. * This method calls `updateParticle()` for each particle of the SPS.
  65129. * For an animated SPS, it is usually called within the render loop.
  65130. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65131. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65132. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65133. * @returns the PCS.
  65134. */
  65135. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65136. /**
  65137. * Disposes the PCS.
  65138. */
  65139. dispose(): void;
  65140. /**
  65141. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65142. * doc :
  65143. * @returns the PCS.
  65144. */
  65145. refreshVisibleSize(): PointsCloudSystem;
  65146. /**
  65147. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65148. * @param size the size (float) of the visibility box
  65149. * note : this doesn't lock the PCS mesh bounding box.
  65150. * doc :
  65151. */
  65152. setVisibilityBox(size: number): void;
  65153. /**
  65154. * Gets whether the PCS is always visible or not
  65155. * doc :
  65156. */
  65157. get isAlwaysVisible(): boolean;
  65158. /**
  65159. * Sets the PCS as always visible or not
  65160. * doc :
  65161. */
  65162. set isAlwaysVisible(val: boolean);
  65163. /**
  65164. * Tells to `setParticles()` to compute the particle rotations or not
  65165. * Default value : false. The PCS is faster when it's set to false
  65166. * Note : particle rotations are only applied to parent particles
  65167. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65168. */
  65169. set computeParticleRotation(val: boolean);
  65170. /**
  65171. * Tells to `setParticles()` to compute the particle colors or not.
  65172. * Default value : true. The PCS is faster when it's set to false.
  65173. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65174. */
  65175. set computeParticleColor(val: boolean);
  65176. set computeParticleTexture(val: boolean);
  65177. /**
  65178. * Gets if `setParticles()` computes the particle colors or not.
  65179. * Default value : false. The PCS is faster when it's set to false.
  65180. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65181. */
  65182. get computeParticleColor(): boolean;
  65183. /**
  65184. * Gets if `setParticles()` computes the particle textures or not.
  65185. * Default value : false. The PCS is faster when it's set to false.
  65186. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65187. */
  65188. get computeParticleTexture(): boolean;
  65189. /**
  65190. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65191. */
  65192. set computeBoundingBox(val: boolean);
  65193. /**
  65194. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65195. */
  65196. get computeBoundingBox(): boolean;
  65197. /**
  65198. * This function does nothing. It may be overwritten to set all the particle first values.
  65199. * The PCS doesn't call this function, you may have to call it by your own.
  65200. * doc :
  65201. */
  65202. initParticles(): void;
  65203. /**
  65204. * This function does nothing. It may be overwritten to recycle a particle
  65205. * The PCS doesn't call this function, you can to call it
  65206. * doc :
  65207. * @param particle The particle to recycle
  65208. * @returns the recycled particle
  65209. */
  65210. recycleParticle(particle: CloudPoint): CloudPoint;
  65211. /**
  65212. * Updates a particle : this function should be overwritten by the user.
  65213. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65214. * doc :
  65215. * @example : just set a particle position or velocity and recycle conditions
  65216. * @param particle The particle to update
  65217. * @returns the updated particle
  65218. */
  65219. updateParticle(particle: CloudPoint): CloudPoint;
  65220. /**
  65221. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65222. * This does nothing and may be overwritten by the user.
  65223. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65224. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65225. * @param update the boolean update value actually passed to setParticles()
  65226. */
  65227. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65228. /**
  65229. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65230. * This will be passed three parameters.
  65231. * This does nothing and may be overwritten by the user.
  65232. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65234. * @param update the boolean update value actually passed to setParticles()
  65235. */
  65236. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65237. }
  65238. }
  65239. declare module BABYLON {
  65240. /**
  65241. * Represents one particle of a points cloud system.
  65242. */
  65243. export class CloudPoint {
  65244. /**
  65245. * particle global index
  65246. */
  65247. idx: number;
  65248. /**
  65249. * The color of the particle
  65250. */
  65251. color: Nullable<Color4>;
  65252. /**
  65253. * The world space position of the particle.
  65254. */
  65255. position: Vector3;
  65256. /**
  65257. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65258. */
  65259. rotation: Vector3;
  65260. /**
  65261. * The world space rotation quaternion of the particle.
  65262. */
  65263. rotationQuaternion: Nullable<Quaternion>;
  65264. /**
  65265. * The uv of the particle.
  65266. */
  65267. uv: Nullable<Vector2>;
  65268. /**
  65269. * The current speed of the particle.
  65270. */
  65271. velocity: Vector3;
  65272. /**
  65273. * The pivot point in the particle local space.
  65274. */
  65275. pivot: Vector3;
  65276. /**
  65277. * Must the particle be translated from its pivot point in its local space ?
  65278. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65279. * Default : false
  65280. */
  65281. translateFromPivot: boolean;
  65282. /**
  65283. * Index of this particle in the global "positions" array (Internal use)
  65284. * @hidden
  65285. */
  65286. _pos: number;
  65287. /**
  65288. * @hidden Index of this particle in the global "indices" array (Internal use)
  65289. */
  65290. _ind: number;
  65291. /**
  65292. * Group this particle belongs to
  65293. */
  65294. _group: PointsGroup;
  65295. /**
  65296. * Group id of this particle
  65297. */
  65298. groupId: number;
  65299. /**
  65300. * Index of the particle in its group id (Internal use)
  65301. */
  65302. idxInGroup: number;
  65303. /**
  65304. * @hidden Particle BoundingInfo object (Internal use)
  65305. */
  65306. _boundingInfo: BoundingInfo;
  65307. /**
  65308. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65309. */
  65310. _pcs: PointsCloudSystem;
  65311. /**
  65312. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65313. */
  65314. _stillInvisible: boolean;
  65315. /**
  65316. * @hidden Last computed particle rotation matrix
  65317. */
  65318. _rotationMatrix: number[];
  65319. /**
  65320. * Parent particle Id, if any.
  65321. * Default null.
  65322. */
  65323. parentId: Nullable<number>;
  65324. /**
  65325. * @hidden Internal global position in the PCS.
  65326. */
  65327. _globalPosition: Vector3;
  65328. /**
  65329. * Creates a Point Cloud object.
  65330. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65331. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65332. * @param group (PointsGroup) is the group the particle belongs to
  65333. * @param groupId (integer) is the group identifier in the PCS.
  65334. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65335. * @param pcs defines the PCS it is associated to
  65336. */
  65337. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65338. /**
  65339. * get point size
  65340. */
  65341. get size(): Vector3;
  65342. /**
  65343. * Set point size
  65344. */
  65345. set size(scale: Vector3);
  65346. /**
  65347. * Legacy support, changed quaternion to rotationQuaternion
  65348. */
  65349. get quaternion(): Nullable<Quaternion>;
  65350. /**
  65351. * Legacy support, changed quaternion to rotationQuaternion
  65352. */
  65353. set quaternion(q: Nullable<Quaternion>);
  65354. /**
  65355. * Returns a boolean. True if the particle intersects a mesh, else false
  65356. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65357. * @param target is the object (point or mesh) what the intersection is computed against
  65358. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65359. * @returns true if it intersects
  65360. */
  65361. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65362. /**
  65363. * get the rotation matrix of the particle
  65364. * @hidden
  65365. */
  65366. getRotationMatrix(m: Matrix): void;
  65367. }
  65368. /**
  65369. * Represents a group of points in a points cloud system
  65370. * * PCS internal tool, don't use it manually.
  65371. */
  65372. export class PointsGroup {
  65373. /**
  65374. * The group id
  65375. * @hidden
  65376. */
  65377. groupID: number;
  65378. /**
  65379. * image data for group (internal use)
  65380. * @hidden
  65381. */
  65382. _groupImageData: Nullable<ArrayBufferView>;
  65383. /**
  65384. * Image Width (internal use)
  65385. * @hidden
  65386. */
  65387. _groupImgWidth: number;
  65388. /**
  65389. * Image Height (internal use)
  65390. * @hidden
  65391. */
  65392. _groupImgHeight: number;
  65393. /**
  65394. * Custom position function (internal use)
  65395. * @hidden
  65396. */
  65397. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65398. /**
  65399. * density per facet for surface points
  65400. * @hidden
  65401. */
  65402. _groupDensity: number[];
  65403. /**
  65404. * Only when points are colored by texture carries pointer to texture list array
  65405. * @hidden
  65406. */
  65407. _textureNb: number;
  65408. /**
  65409. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65410. * PCS internal tool, don't use it manually.
  65411. * @hidden
  65412. */
  65413. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65414. }
  65415. }
  65416. declare module BABYLON {
  65417. interface Scene {
  65418. /** @hidden (Backing field) */
  65419. _physicsEngine: Nullable<IPhysicsEngine>;
  65420. /** @hidden */
  65421. _physicsTimeAccumulator: number;
  65422. /**
  65423. * Gets the current physics engine
  65424. * @returns a IPhysicsEngine or null if none attached
  65425. */
  65426. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65427. /**
  65428. * Enables physics to the current scene
  65429. * @param gravity defines the scene's gravity for the physics engine
  65430. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65431. * @return a boolean indicating if the physics engine was initialized
  65432. */
  65433. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65434. /**
  65435. * Disables and disposes the physics engine associated with the scene
  65436. */
  65437. disablePhysicsEngine(): void;
  65438. /**
  65439. * Gets a boolean indicating if there is an active physics engine
  65440. * @returns a boolean indicating if there is an active physics engine
  65441. */
  65442. isPhysicsEnabled(): boolean;
  65443. /**
  65444. * Deletes a physics compound impostor
  65445. * @param compound defines the compound to delete
  65446. */
  65447. deleteCompoundImpostor(compound: any): void;
  65448. /**
  65449. * An event triggered when physic simulation is about to be run
  65450. */
  65451. onBeforePhysicsObservable: Observable<Scene>;
  65452. /**
  65453. * An event triggered when physic simulation has been done
  65454. */
  65455. onAfterPhysicsObservable: Observable<Scene>;
  65456. }
  65457. interface AbstractMesh {
  65458. /** @hidden */
  65459. _physicsImpostor: Nullable<PhysicsImpostor>;
  65460. /**
  65461. * Gets or sets impostor used for physic simulation
  65462. * @see http://doc.babylonjs.com/features/physics_engine
  65463. */
  65464. physicsImpostor: Nullable<PhysicsImpostor>;
  65465. /**
  65466. * Gets the current physics impostor
  65467. * @see http://doc.babylonjs.com/features/physics_engine
  65468. * @returns a physics impostor or null
  65469. */
  65470. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65471. /** Apply a physic impulse to the mesh
  65472. * @param force defines the force to apply
  65473. * @param contactPoint defines where to apply the force
  65474. * @returns the current mesh
  65475. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65476. */
  65477. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65478. /**
  65479. * Creates a physic joint between two meshes
  65480. * @param otherMesh defines the other mesh to use
  65481. * @param pivot1 defines the pivot to use on this mesh
  65482. * @param pivot2 defines the pivot to use on the other mesh
  65483. * @param options defines additional options (can be plugin dependent)
  65484. * @returns the current mesh
  65485. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65486. */
  65487. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65488. /** @hidden */
  65489. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65490. }
  65491. /**
  65492. * Defines the physics engine scene component responsible to manage a physics engine
  65493. */
  65494. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65495. /**
  65496. * The component name helpful to identify the component in the list of scene components.
  65497. */
  65498. readonly name: string;
  65499. /**
  65500. * The scene the component belongs to.
  65501. */
  65502. scene: Scene;
  65503. /**
  65504. * Creates a new instance of the component for the given scene
  65505. * @param scene Defines the scene to register the component in
  65506. */
  65507. constructor(scene: Scene);
  65508. /**
  65509. * Registers the component in a given scene
  65510. */
  65511. register(): void;
  65512. /**
  65513. * Rebuilds the elements related to this component in case of
  65514. * context lost for instance.
  65515. */
  65516. rebuild(): void;
  65517. /**
  65518. * Disposes the component and the associated ressources
  65519. */
  65520. dispose(): void;
  65521. }
  65522. }
  65523. declare module BABYLON {
  65524. /**
  65525. * A helper for physics simulations
  65526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65527. */
  65528. export class PhysicsHelper {
  65529. private _scene;
  65530. private _physicsEngine;
  65531. /**
  65532. * Initializes the Physics helper
  65533. * @param scene Babylon.js scene
  65534. */
  65535. constructor(scene: Scene);
  65536. /**
  65537. * Applies a radial explosion impulse
  65538. * @param origin the origin of the explosion
  65539. * @param radiusOrEventOptions the radius or the options of radial explosion
  65540. * @param strength the explosion strength
  65541. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65542. * @returns A physics radial explosion event, or null
  65543. */
  65544. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65545. /**
  65546. * Applies a radial explosion force
  65547. * @param origin the origin of the explosion
  65548. * @param radiusOrEventOptions the radius or the options of radial explosion
  65549. * @param strength the explosion strength
  65550. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65551. * @returns A physics radial explosion event, or null
  65552. */
  65553. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65554. /**
  65555. * Creates a gravitational field
  65556. * @param origin the origin of the explosion
  65557. * @param radiusOrEventOptions the radius or the options of radial explosion
  65558. * @param strength the explosion strength
  65559. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65560. * @returns A physics gravitational field event, or null
  65561. */
  65562. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65563. /**
  65564. * Creates a physics updraft event
  65565. * @param origin the origin of the updraft
  65566. * @param radiusOrEventOptions the radius or the options of the updraft
  65567. * @param strength the strength of the updraft
  65568. * @param height the height of the updraft
  65569. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65570. * @returns A physics updraft event, or null
  65571. */
  65572. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65573. /**
  65574. * Creates a physics vortex event
  65575. * @param origin the of the vortex
  65576. * @param radiusOrEventOptions the radius or the options of the vortex
  65577. * @param strength the strength of the vortex
  65578. * @param height the height of the vortex
  65579. * @returns a Physics vortex event, or null
  65580. * A physics vortex event or null
  65581. */
  65582. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65583. }
  65584. /**
  65585. * Represents a physics radial explosion event
  65586. */
  65587. class PhysicsRadialExplosionEvent {
  65588. private _scene;
  65589. private _options;
  65590. private _sphere;
  65591. private _dataFetched;
  65592. /**
  65593. * Initializes a radial explosioin event
  65594. * @param _scene BabylonJS scene
  65595. * @param _options The options for the vortex event
  65596. */
  65597. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65598. /**
  65599. * Returns the data related to the radial explosion event (sphere).
  65600. * @returns The radial explosion event data
  65601. */
  65602. getData(): PhysicsRadialExplosionEventData;
  65603. /**
  65604. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65605. * @param impostor A physics imposter
  65606. * @param origin the origin of the explosion
  65607. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65608. */
  65609. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65610. /**
  65611. * Triggers affecterd impostors callbacks
  65612. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65613. */
  65614. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65615. /**
  65616. * Disposes the sphere.
  65617. * @param force Specifies if the sphere should be disposed by force
  65618. */
  65619. dispose(force?: boolean): void;
  65620. /*** Helpers ***/
  65621. private _prepareSphere;
  65622. private _intersectsWithSphere;
  65623. }
  65624. /**
  65625. * Represents a gravitational field event
  65626. */
  65627. class PhysicsGravitationalFieldEvent {
  65628. private _physicsHelper;
  65629. private _scene;
  65630. private _origin;
  65631. private _options;
  65632. private _tickCallback;
  65633. private _sphere;
  65634. private _dataFetched;
  65635. /**
  65636. * Initializes the physics gravitational field event
  65637. * @param _physicsHelper A physics helper
  65638. * @param _scene BabylonJS scene
  65639. * @param _origin The origin position of the gravitational field event
  65640. * @param _options The options for the vortex event
  65641. */
  65642. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65643. /**
  65644. * Returns the data related to the gravitational field event (sphere).
  65645. * @returns A gravitational field event
  65646. */
  65647. getData(): PhysicsGravitationalFieldEventData;
  65648. /**
  65649. * Enables the gravitational field.
  65650. */
  65651. enable(): void;
  65652. /**
  65653. * Disables the gravitational field.
  65654. */
  65655. disable(): void;
  65656. /**
  65657. * Disposes the sphere.
  65658. * @param force The force to dispose from the gravitational field event
  65659. */
  65660. dispose(force?: boolean): void;
  65661. private _tick;
  65662. }
  65663. /**
  65664. * Represents a physics updraft event
  65665. */
  65666. class PhysicsUpdraftEvent {
  65667. private _scene;
  65668. private _origin;
  65669. private _options;
  65670. private _physicsEngine;
  65671. private _originTop;
  65672. private _originDirection;
  65673. private _tickCallback;
  65674. private _cylinder;
  65675. private _cylinderPosition;
  65676. private _dataFetched;
  65677. /**
  65678. * Initializes the physics updraft event
  65679. * @param _scene BabylonJS scene
  65680. * @param _origin The origin position of the updraft
  65681. * @param _options The options for the updraft event
  65682. */
  65683. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65684. /**
  65685. * Returns the data related to the updraft event (cylinder).
  65686. * @returns A physics updraft event
  65687. */
  65688. getData(): PhysicsUpdraftEventData;
  65689. /**
  65690. * Enables the updraft.
  65691. */
  65692. enable(): void;
  65693. /**
  65694. * Disables the updraft.
  65695. */
  65696. disable(): void;
  65697. /**
  65698. * Disposes the cylinder.
  65699. * @param force Specifies if the updraft should be disposed by force
  65700. */
  65701. dispose(force?: boolean): void;
  65702. private getImpostorHitData;
  65703. private _tick;
  65704. /*** Helpers ***/
  65705. private _prepareCylinder;
  65706. private _intersectsWithCylinder;
  65707. }
  65708. /**
  65709. * Represents a physics vortex event
  65710. */
  65711. class PhysicsVortexEvent {
  65712. private _scene;
  65713. private _origin;
  65714. private _options;
  65715. private _physicsEngine;
  65716. private _originTop;
  65717. private _tickCallback;
  65718. private _cylinder;
  65719. private _cylinderPosition;
  65720. private _dataFetched;
  65721. /**
  65722. * Initializes the physics vortex event
  65723. * @param _scene The BabylonJS scene
  65724. * @param _origin The origin position of the vortex
  65725. * @param _options The options for the vortex event
  65726. */
  65727. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65728. /**
  65729. * Returns the data related to the vortex event (cylinder).
  65730. * @returns The physics vortex event data
  65731. */
  65732. getData(): PhysicsVortexEventData;
  65733. /**
  65734. * Enables the vortex.
  65735. */
  65736. enable(): void;
  65737. /**
  65738. * Disables the cortex.
  65739. */
  65740. disable(): void;
  65741. /**
  65742. * Disposes the sphere.
  65743. * @param force
  65744. */
  65745. dispose(force?: boolean): void;
  65746. private getImpostorHitData;
  65747. private _tick;
  65748. /*** Helpers ***/
  65749. private _prepareCylinder;
  65750. private _intersectsWithCylinder;
  65751. }
  65752. /**
  65753. * Options fot the radial explosion event
  65754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65755. */
  65756. export class PhysicsRadialExplosionEventOptions {
  65757. /**
  65758. * The radius of the sphere for the radial explosion.
  65759. */
  65760. radius: number;
  65761. /**
  65762. * The strenth of the explosion.
  65763. */
  65764. strength: number;
  65765. /**
  65766. * The strenght of the force in correspondence to the distance of the affected object
  65767. */
  65768. falloff: PhysicsRadialImpulseFalloff;
  65769. /**
  65770. * Sphere options for the radial explosion.
  65771. */
  65772. sphere: {
  65773. segments: number;
  65774. diameter: number;
  65775. };
  65776. /**
  65777. * Sphere options for the radial explosion.
  65778. */
  65779. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65780. }
  65781. /**
  65782. * Options fot the updraft event
  65783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65784. */
  65785. export class PhysicsUpdraftEventOptions {
  65786. /**
  65787. * The radius of the cylinder for the vortex
  65788. */
  65789. radius: number;
  65790. /**
  65791. * The strenth of the updraft.
  65792. */
  65793. strength: number;
  65794. /**
  65795. * The height of the cylinder for the updraft.
  65796. */
  65797. height: number;
  65798. /**
  65799. * The mode for the the updraft.
  65800. */
  65801. updraftMode: PhysicsUpdraftMode;
  65802. }
  65803. /**
  65804. * Options fot the vortex event
  65805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65806. */
  65807. export class PhysicsVortexEventOptions {
  65808. /**
  65809. * The radius of the cylinder for the vortex
  65810. */
  65811. radius: number;
  65812. /**
  65813. * The strenth of the vortex.
  65814. */
  65815. strength: number;
  65816. /**
  65817. * The height of the cylinder for the vortex.
  65818. */
  65819. height: number;
  65820. /**
  65821. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65822. */
  65823. centripetalForceThreshold: number;
  65824. /**
  65825. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65826. */
  65827. centripetalForceMultiplier: number;
  65828. /**
  65829. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65830. */
  65831. centrifugalForceMultiplier: number;
  65832. /**
  65833. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65834. */
  65835. updraftForceMultiplier: number;
  65836. }
  65837. /**
  65838. * The strenght of the force in correspondence to the distance of the affected object
  65839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65840. */
  65841. export enum PhysicsRadialImpulseFalloff {
  65842. /** Defines that impulse is constant in strength across it's whole radius */
  65843. Constant = 0,
  65844. /** Defines that impulse gets weaker if it's further from the origin */
  65845. Linear = 1
  65846. }
  65847. /**
  65848. * The strength of the force in correspondence to the distance of the affected object
  65849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65850. */
  65851. export enum PhysicsUpdraftMode {
  65852. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65853. Center = 0,
  65854. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65855. Perpendicular = 1
  65856. }
  65857. /**
  65858. * Interface for a physics hit data
  65859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65860. */
  65861. export interface PhysicsHitData {
  65862. /**
  65863. * The force applied at the contact point
  65864. */
  65865. force: Vector3;
  65866. /**
  65867. * The contact point
  65868. */
  65869. contactPoint: Vector3;
  65870. /**
  65871. * The distance from the origin to the contact point
  65872. */
  65873. distanceFromOrigin: number;
  65874. }
  65875. /**
  65876. * Interface for radial explosion event data
  65877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65878. */
  65879. export interface PhysicsRadialExplosionEventData {
  65880. /**
  65881. * A sphere used for the radial explosion event
  65882. */
  65883. sphere: Mesh;
  65884. }
  65885. /**
  65886. * Interface for gravitational field event data
  65887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65888. */
  65889. export interface PhysicsGravitationalFieldEventData {
  65890. /**
  65891. * A sphere mesh used for the gravitational field event
  65892. */
  65893. sphere: Mesh;
  65894. }
  65895. /**
  65896. * Interface for updraft event data
  65897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65898. */
  65899. export interface PhysicsUpdraftEventData {
  65900. /**
  65901. * A cylinder used for the updraft event
  65902. */
  65903. cylinder: Mesh;
  65904. }
  65905. /**
  65906. * Interface for vortex event data
  65907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65908. */
  65909. export interface PhysicsVortexEventData {
  65910. /**
  65911. * A cylinder used for the vortex event
  65912. */
  65913. cylinder: Mesh;
  65914. }
  65915. /**
  65916. * Interface for an affected physics impostor
  65917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65918. */
  65919. export interface PhysicsAffectedImpostorWithData {
  65920. /**
  65921. * The impostor affected by the effect
  65922. */
  65923. impostor: PhysicsImpostor;
  65924. /**
  65925. * The data about the hit/horce from the explosion
  65926. */
  65927. hitData: PhysicsHitData;
  65928. }
  65929. }
  65930. declare module BABYLON {
  65931. /** @hidden */
  65932. export var blackAndWhitePixelShader: {
  65933. name: string;
  65934. shader: string;
  65935. };
  65936. }
  65937. declare module BABYLON {
  65938. /**
  65939. * Post process used to render in black and white
  65940. */
  65941. export class BlackAndWhitePostProcess extends PostProcess {
  65942. /**
  65943. * Linear about to convert he result to black and white (default: 1)
  65944. */
  65945. degree: number;
  65946. /**
  65947. * Creates a black and white post process
  65948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65949. * @param name The name of the effect.
  65950. * @param options The required width/height ratio to downsize to before computing the render pass.
  65951. * @param camera The camera to apply the render pass to.
  65952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65953. * @param engine The engine which the post process will be applied. (default: current engine)
  65954. * @param reusable If the post process can be reused on the same frame. (default: false)
  65955. */
  65956. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /**
  65961. * This represents a set of one or more post processes in Babylon.
  65962. * A post process can be used to apply a shader to a texture after it is rendered.
  65963. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65964. */
  65965. export class PostProcessRenderEffect {
  65966. private _postProcesses;
  65967. private _getPostProcesses;
  65968. private _singleInstance;
  65969. private _cameras;
  65970. private _indicesForCamera;
  65971. /**
  65972. * Name of the effect
  65973. * @hidden
  65974. */
  65975. _name: string;
  65976. /**
  65977. * Instantiates a post process render effect.
  65978. * A post process can be used to apply a shader to a texture after it is rendered.
  65979. * @param engine The engine the effect is tied to
  65980. * @param name The name of the effect
  65981. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65982. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65983. */
  65984. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65985. /**
  65986. * Checks if all the post processes in the effect are supported.
  65987. */
  65988. get isSupported(): boolean;
  65989. /**
  65990. * Updates the current state of the effect
  65991. * @hidden
  65992. */
  65993. _update(): void;
  65994. /**
  65995. * Attaches the effect on cameras
  65996. * @param cameras The camera to attach to.
  65997. * @hidden
  65998. */
  65999. _attachCameras(cameras: Camera): void;
  66000. /**
  66001. * Attaches the effect on cameras
  66002. * @param cameras The camera to attach to.
  66003. * @hidden
  66004. */
  66005. _attachCameras(cameras: Camera[]): void;
  66006. /**
  66007. * Detaches the effect on cameras
  66008. * @param cameras The camera to detatch from.
  66009. * @hidden
  66010. */
  66011. _detachCameras(cameras: Camera): void;
  66012. /**
  66013. * Detatches the effect on cameras
  66014. * @param cameras The camera to detatch from.
  66015. * @hidden
  66016. */
  66017. _detachCameras(cameras: Camera[]): void;
  66018. /**
  66019. * Enables the effect on given cameras
  66020. * @param cameras The camera to enable.
  66021. * @hidden
  66022. */
  66023. _enable(cameras: Camera): void;
  66024. /**
  66025. * Enables the effect on given cameras
  66026. * @param cameras The camera to enable.
  66027. * @hidden
  66028. */
  66029. _enable(cameras: Nullable<Camera[]>): void;
  66030. /**
  66031. * Disables the effect on the given cameras
  66032. * @param cameras The camera to disable.
  66033. * @hidden
  66034. */
  66035. _disable(cameras: Camera): void;
  66036. /**
  66037. * Disables the effect on the given cameras
  66038. * @param cameras The camera to disable.
  66039. * @hidden
  66040. */
  66041. _disable(cameras: Nullable<Camera[]>): void;
  66042. /**
  66043. * Gets a list of the post processes contained in the effect.
  66044. * @param camera The camera to get the post processes on.
  66045. * @returns The list of the post processes in the effect.
  66046. */
  66047. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66048. }
  66049. }
  66050. declare module BABYLON {
  66051. /** @hidden */
  66052. export var extractHighlightsPixelShader: {
  66053. name: string;
  66054. shader: string;
  66055. };
  66056. }
  66057. declare module BABYLON {
  66058. /**
  66059. * 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.
  66060. */
  66061. export class ExtractHighlightsPostProcess extends PostProcess {
  66062. /**
  66063. * The luminance threshold, pixels below this value will be set to black.
  66064. */
  66065. threshold: number;
  66066. /** @hidden */
  66067. _exposure: number;
  66068. /**
  66069. * Post process which has the input texture to be used when performing highlight extraction
  66070. * @hidden
  66071. */
  66072. _inputPostProcess: Nullable<PostProcess>;
  66073. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66074. }
  66075. }
  66076. declare module BABYLON {
  66077. /** @hidden */
  66078. export var bloomMergePixelShader: {
  66079. name: string;
  66080. shader: string;
  66081. };
  66082. }
  66083. declare module BABYLON {
  66084. /**
  66085. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66086. */
  66087. export class BloomMergePostProcess extends PostProcess {
  66088. /** Weight of the bloom to be added to the original input. */
  66089. weight: number;
  66090. /**
  66091. * Creates a new instance of @see BloomMergePostProcess
  66092. * @param name The name of the effect.
  66093. * @param originalFromInput Post process which's input will be used for the merge.
  66094. * @param blurred Blurred highlights post process which's output will be used.
  66095. * @param weight Weight of the bloom to be added to the original input.
  66096. * @param options The required width/height ratio to downsize to before computing the render pass.
  66097. * @param camera The camera to apply the render pass to.
  66098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66099. * @param engine The engine which the post process will be applied. (default: current engine)
  66100. * @param reusable If the post process can be reused on the same frame. (default: false)
  66101. * @param textureType Type of textures used when performing the post process. (default: 0)
  66102. * @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)
  66103. */
  66104. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66105. /** Weight of the bloom to be added to the original input. */
  66106. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66107. }
  66108. }
  66109. declare module BABYLON {
  66110. /**
  66111. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66112. */
  66113. export class BloomEffect extends PostProcessRenderEffect {
  66114. private bloomScale;
  66115. /**
  66116. * @hidden Internal
  66117. */
  66118. _effects: Array<PostProcess>;
  66119. /**
  66120. * @hidden Internal
  66121. */
  66122. _downscale: ExtractHighlightsPostProcess;
  66123. private _blurX;
  66124. private _blurY;
  66125. private _merge;
  66126. /**
  66127. * The luminance threshold to find bright areas of the image to bloom.
  66128. */
  66129. get threshold(): number;
  66130. set threshold(value: number);
  66131. /**
  66132. * The strength of the bloom.
  66133. */
  66134. get weight(): number;
  66135. set weight(value: number);
  66136. /**
  66137. * Specifies the size of the bloom blur kernel, relative to the final output size
  66138. */
  66139. get kernel(): number;
  66140. set kernel(value: number);
  66141. /**
  66142. * Creates a new instance of @see BloomEffect
  66143. * @param scene The scene the effect belongs to.
  66144. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66145. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66146. * @param bloomWeight The the strength of bloom.
  66147. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66148. * @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)
  66149. */
  66150. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66151. /**
  66152. * Disposes each of the internal effects for a given camera.
  66153. * @param camera The camera to dispose the effect on.
  66154. */
  66155. disposeEffects(camera: Camera): void;
  66156. /**
  66157. * @hidden Internal
  66158. */
  66159. _updateEffects(): void;
  66160. /**
  66161. * Internal
  66162. * @returns if all the contained post processes are ready.
  66163. * @hidden
  66164. */
  66165. _isReady(): boolean;
  66166. }
  66167. }
  66168. declare module BABYLON {
  66169. /** @hidden */
  66170. export var chromaticAberrationPixelShader: {
  66171. name: string;
  66172. shader: string;
  66173. };
  66174. }
  66175. declare module BABYLON {
  66176. /**
  66177. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66178. */
  66179. export class ChromaticAberrationPostProcess extends PostProcess {
  66180. /**
  66181. * The amount of seperation of rgb channels (default: 30)
  66182. */
  66183. aberrationAmount: number;
  66184. /**
  66185. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66186. */
  66187. radialIntensity: number;
  66188. /**
  66189. * 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))
  66190. */
  66191. direction: Vector2;
  66192. /**
  66193. * 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))
  66194. */
  66195. centerPosition: Vector2;
  66196. /**
  66197. * Creates a new instance ChromaticAberrationPostProcess
  66198. * @param name The name of the effect.
  66199. * @param screenWidth The width of the screen to apply the effect on.
  66200. * @param screenHeight The height of the screen to apply the effect on.
  66201. * @param options The required width/height ratio to downsize to before computing the render pass.
  66202. * @param camera The camera to apply the render pass to.
  66203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66204. * @param engine The engine which the post process will be applied. (default: current engine)
  66205. * @param reusable If the post process can be reused on the same frame. (default: false)
  66206. * @param textureType Type of textures used when performing the post process. (default: 0)
  66207. * @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)
  66208. */
  66209. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66210. }
  66211. }
  66212. declare module BABYLON {
  66213. /** @hidden */
  66214. export var circleOfConfusionPixelShader: {
  66215. name: string;
  66216. shader: string;
  66217. };
  66218. }
  66219. declare module BABYLON {
  66220. /**
  66221. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66222. */
  66223. export class CircleOfConfusionPostProcess extends PostProcess {
  66224. /**
  66225. * 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.
  66226. */
  66227. lensSize: number;
  66228. /**
  66229. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66230. */
  66231. fStop: number;
  66232. /**
  66233. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66234. */
  66235. focusDistance: number;
  66236. /**
  66237. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66238. */
  66239. focalLength: number;
  66240. private _depthTexture;
  66241. /**
  66242. * Creates a new instance CircleOfConfusionPostProcess
  66243. * @param name The name of the effect.
  66244. * @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.
  66245. * @param options The required width/height ratio to downsize to before computing the render pass.
  66246. * @param camera The camera to apply the render pass to.
  66247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66248. * @param engine The engine which the post process will be applied. (default: current engine)
  66249. * @param reusable If the post process can be reused on the same frame. (default: false)
  66250. * @param textureType Type of textures used when performing the post process. (default: 0)
  66251. * @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)
  66252. */
  66253. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66254. /**
  66255. * 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.
  66256. */
  66257. set depthTexture(value: RenderTargetTexture);
  66258. }
  66259. }
  66260. declare module BABYLON {
  66261. /** @hidden */
  66262. export var colorCorrectionPixelShader: {
  66263. name: string;
  66264. shader: string;
  66265. };
  66266. }
  66267. declare module BABYLON {
  66268. /**
  66269. *
  66270. * This post-process allows the modification of rendered colors by using
  66271. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66272. *
  66273. * The object needs to be provided an url to a texture containing the color
  66274. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66275. * Use an image editing software to tweak the LUT to match your needs.
  66276. *
  66277. * For an example of a color LUT, see here:
  66278. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66279. * For explanations on color grading, see here:
  66280. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66281. *
  66282. */
  66283. export class ColorCorrectionPostProcess extends PostProcess {
  66284. private _colorTableTexture;
  66285. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66286. }
  66287. }
  66288. declare module BABYLON {
  66289. /** @hidden */
  66290. export var convolutionPixelShader: {
  66291. name: string;
  66292. shader: string;
  66293. };
  66294. }
  66295. declare module BABYLON {
  66296. /**
  66297. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66298. * input texture to perform effects such as edge detection or sharpening
  66299. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66300. */
  66301. export class ConvolutionPostProcess extends PostProcess {
  66302. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66303. kernel: number[];
  66304. /**
  66305. * Creates a new instance ConvolutionPostProcess
  66306. * @param name The name of the effect.
  66307. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66308. * @param options The required width/height ratio to downsize to before computing the render pass.
  66309. * @param camera The camera to apply the render pass to.
  66310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66311. * @param engine The engine which the post process will be applied. (default: current engine)
  66312. * @param reusable If the post process can be reused on the same frame. (default: false)
  66313. * @param textureType Type of textures used when performing the post process. (default: 0)
  66314. */
  66315. constructor(name: string,
  66316. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66317. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66318. /**
  66319. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66320. */
  66321. static EdgeDetect0Kernel: number[];
  66322. /**
  66323. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66324. */
  66325. static EdgeDetect1Kernel: number[];
  66326. /**
  66327. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66328. */
  66329. static EdgeDetect2Kernel: number[];
  66330. /**
  66331. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66332. */
  66333. static SharpenKernel: number[];
  66334. /**
  66335. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66336. */
  66337. static EmbossKernel: number[];
  66338. /**
  66339. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66340. */
  66341. static GaussianKernel: number[];
  66342. }
  66343. }
  66344. declare module BABYLON {
  66345. /**
  66346. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66347. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66348. * based on samples that have a large difference in distance than the center pixel.
  66349. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66350. */
  66351. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66352. direction: Vector2;
  66353. /**
  66354. * Creates a new instance CircleOfConfusionPostProcess
  66355. * @param name The name of the effect.
  66356. * @param scene The scene the effect belongs to.
  66357. * @param direction The direction the blur should be applied.
  66358. * @param kernel The size of the kernel used to blur.
  66359. * @param options The required width/height ratio to downsize to before computing the render pass.
  66360. * @param camera The camera to apply the render pass to.
  66361. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66362. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66364. * @param engine The engine which the post process will be applied. (default: current engine)
  66365. * @param reusable If the post process can be reused on the same frame. (default: false)
  66366. * @param textureType Type of textures used when performing the post process. (default: 0)
  66367. * @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)
  66368. */
  66369. 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);
  66370. }
  66371. }
  66372. declare module BABYLON {
  66373. /** @hidden */
  66374. export var depthOfFieldMergePixelShader: {
  66375. name: string;
  66376. shader: string;
  66377. };
  66378. }
  66379. declare module BABYLON {
  66380. /**
  66381. * Options to be set when merging outputs from the default pipeline.
  66382. */
  66383. export class DepthOfFieldMergePostProcessOptions {
  66384. /**
  66385. * The original image to merge on top of
  66386. */
  66387. originalFromInput: PostProcess;
  66388. /**
  66389. * Parameters to perform the merge of the depth of field effect
  66390. */
  66391. depthOfField?: {
  66392. circleOfConfusion: PostProcess;
  66393. blurSteps: Array<PostProcess>;
  66394. };
  66395. /**
  66396. * Parameters to perform the merge of bloom effect
  66397. */
  66398. bloom?: {
  66399. blurred: PostProcess;
  66400. weight: number;
  66401. };
  66402. }
  66403. /**
  66404. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66405. */
  66406. export class DepthOfFieldMergePostProcess extends PostProcess {
  66407. private blurSteps;
  66408. /**
  66409. * Creates a new instance of DepthOfFieldMergePostProcess
  66410. * @param name The name of the effect.
  66411. * @param originalFromInput Post process which's input will be used for the merge.
  66412. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66413. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66414. * @param options The required width/height ratio to downsize to before computing the render pass.
  66415. * @param camera The camera to apply the render pass to.
  66416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66417. * @param engine The engine which the post process will be applied. (default: current engine)
  66418. * @param reusable If the post process can be reused on the same frame. (default: false)
  66419. * @param textureType Type of textures used when performing the post process. (default: 0)
  66420. * @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)
  66421. */
  66422. 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);
  66423. /**
  66424. * Updates the effect with the current post process compile time values and recompiles the shader.
  66425. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66426. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66427. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66428. * @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
  66429. * @param onCompiled Called when the shader has been compiled.
  66430. * @param onError Called if there is an error when compiling a shader.
  66431. */
  66432. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66433. }
  66434. }
  66435. declare module BABYLON {
  66436. /**
  66437. * Specifies the level of max blur that should be applied when using the depth of field effect
  66438. */
  66439. export enum DepthOfFieldEffectBlurLevel {
  66440. /**
  66441. * Subtle blur
  66442. */
  66443. Low = 0,
  66444. /**
  66445. * Medium blur
  66446. */
  66447. Medium = 1,
  66448. /**
  66449. * Large blur
  66450. */
  66451. High = 2
  66452. }
  66453. /**
  66454. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66455. */
  66456. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66457. private _circleOfConfusion;
  66458. /**
  66459. * @hidden Internal, blurs from high to low
  66460. */
  66461. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66462. private _depthOfFieldBlurY;
  66463. private _dofMerge;
  66464. /**
  66465. * @hidden Internal post processes in depth of field effect
  66466. */
  66467. _effects: Array<PostProcess>;
  66468. /**
  66469. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66470. */
  66471. set focalLength(value: number);
  66472. get focalLength(): number;
  66473. /**
  66474. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66475. */
  66476. set fStop(value: number);
  66477. get fStop(): number;
  66478. /**
  66479. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66480. */
  66481. set focusDistance(value: number);
  66482. get focusDistance(): number;
  66483. /**
  66484. * 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.
  66485. */
  66486. set lensSize(value: number);
  66487. get lensSize(): number;
  66488. /**
  66489. * Creates a new instance DepthOfFieldEffect
  66490. * @param scene The scene the effect belongs to.
  66491. * @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.
  66492. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66493. * @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)
  66494. */
  66495. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66496. /**
  66497. * Get the current class name of the current effet
  66498. * @returns "DepthOfFieldEffect"
  66499. */
  66500. getClassName(): string;
  66501. /**
  66502. * 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.
  66503. */
  66504. set depthTexture(value: RenderTargetTexture);
  66505. /**
  66506. * Disposes each of the internal effects for a given camera.
  66507. * @param camera The camera to dispose the effect on.
  66508. */
  66509. disposeEffects(camera: Camera): void;
  66510. /**
  66511. * @hidden Internal
  66512. */
  66513. _updateEffects(): void;
  66514. /**
  66515. * Internal
  66516. * @returns if all the contained post processes are ready.
  66517. * @hidden
  66518. */
  66519. _isReady(): boolean;
  66520. }
  66521. }
  66522. declare module BABYLON {
  66523. /** @hidden */
  66524. export var displayPassPixelShader: {
  66525. name: string;
  66526. shader: string;
  66527. };
  66528. }
  66529. declare module BABYLON {
  66530. /**
  66531. * DisplayPassPostProcess which produces an output the same as it's input
  66532. */
  66533. export class DisplayPassPostProcess extends PostProcess {
  66534. /**
  66535. * Creates the DisplayPassPostProcess
  66536. * @param name The name of the effect.
  66537. * @param options The required width/height ratio to downsize to before computing the render pass.
  66538. * @param camera The camera to apply the render pass to.
  66539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66540. * @param engine The engine which the post process will be applied. (default: current engine)
  66541. * @param reusable If the post process can be reused on the same frame. (default: false)
  66542. */
  66543. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66544. }
  66545. }
  66546. declare module BABYLON {
  66547. /** @hidden */
  66548. export var filterPixelShader: {
  66549. name: string;
  66550. shader: string;
  66551. };
  66552. }
  66553. declare module BABYLON {
  66554. /**
  66555. * Applies a kernel filter to the image
  66556. */
  66557. export class FilterPostProcess extends PostProcess {
  66558. /** The matrix to be applied to the image */
  66559. kernelMatrix: Matrix;
  66560. /**
  66561. *
  66562. * @param name The name of the effect.
  66563. * @param kernelMatrix The matrix to be applied to the image
  66564. * @param options The required width/height ratio to downsize to before computing the render pass.
  66565. * @param camera The camera to apply the render pass to.
  66566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66567. * @param engine The engine which the post process will be applied. (default: current engine)
  66568. * @param reusable If the post process can be reused on the same frame. (default: false)
  66569. */
  66570. constructor(name: string,
  66571. /** The matrix to be applied to the image */
  66572. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66573. }
  66574. }
  66575. declare module BABYLON {
  66576. /** @hidden */
  66577. export var fxaaPixelShader: {
  66578. name: string;
  66579. shader: string;
  66580. };
  66581. }
  66582. declare module BABYLON {
  66583. /** @hidden */
  66584. export var fxaaVertexShader: {
  66585. name: string;
  66586. shader: string;
  66587. };
  66588. }
  66589. declare module BABYLON {
  66590. /**
  66591. * Fxaa post process
  66592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66593. */
  66594. export class FxaaPostProcess extends PostProcess {
  66595. /** @hidden */
  66596. texelWidth: number;
  66597. /** @hidden */
  66598. texelHeight: number;
  66599. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66600. private _getDefines;
  66601. }
  66602. }
  66603. declare module BABYLON {
  66604. /** @hidden */
  66605. export var grainPixelShader: {
  66606. name: string;
  66607. shader: string;
  66608. };
  66609. }
  66610. declare module BABYLON {
  66611. /**
  66612. * The GrainPostProcess adds noise to the image at mid luminance levels
  66613. */
  66614. export class GrainPostProcess extends PostProcess {
  66615. /**
  66616. * The intensity of the grain added (default: 30)
  66617. */
  66618. intensity: number;
  66619. /**
  66620. * If the grain should be randomized on every frame
  66621. */
  66622. animated: boolean;
  66623. /**
  66624. * Creates a new instance of @see GrainPostProcess
  66625. * @param name The name of the effect.
  66626. * @param options The required width/height ratio to downsize to before computing the render pass.
  66627. * @param camera The camera to apply the render pass to.
  66628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66629. * @param engine The engine which the post process will be applied. (default: current engine)
  66630. * @param reusable If the post process can be reused on the same frame. (default: false)
  66631. * @param textureType Type of textures used when performing the post process. (default: 0)
  66632. * @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)
  66633. */
  66634. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66635. }
  66636. }
  66637. declare module BABYLON {
  66638. /** @hidden */
  66639. export var highlightsPixelShader: {
  66640. name: string;
  66641. shader: string;
  66642. };
  66643. }
  66644. declare module BABYLON {
  66645. /**
  66646. * Extracts highlights from the image
  66647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66648. */
  66649. export class HighlightsPostProcess extends PostProcess {
  66650. /**
  66651. * Extracts highlights from the image
  66652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66653. * @param name The name of the effect.
  66654. * @param options The required width/height ratio to downsize to before computing the render pass.
  66655. * @param camera The camera to apply the render pass to.
  66656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66657. * @param engine The engine which the post process will be applied. (default: current engine)
  66658. * @param reusable If the post process can be reused on the same frame. (default: false)
  66659. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66660. */
  66661. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66662. }
  66663. }
  66664. declare module BABYLON {
  66665. /** @hidden */
  66666. export var mrtFragmentDeclaration: {
  66667. name: string;
  66668. shader: string;
  66669. };
  66670. }
  66671. declare module BABYLON {
  66672. /** @hidden */
  66673. export var geometryPixelShader: {
  66674. name: string;
  66675. shader: string;
  66676. };
  66677. }
  66678. declare module BABYLON {
  66679. /** @hidden */
  66680. export var geometryVertexShader: {
  66681. name: string;
  66682. shader: string;
  66683. };
  66684. }
  66685. declare module BABYLON {
  66686. /** @hidden */
  66687. interface ISavedTransformationMatrix {
  66688. world: Matrix;
  66689. viewProjection: Matrix;
  66690. }
  66691. /**
  66692. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66693. */
  66694. export class GeometryBufferRenderer {
  66695. /**
  66696. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66697. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66698. */
  66699. static readonly POSITION_TEXTURE_TYPE: number;
  66700. /**
  66701. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66702. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66703. */
  66704. static readonly VELOCITY_TEXTURE_TYPE: number;
  66705. /**
  66706. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  66707. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  66708. */
  66709. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  66710. /**
  66711. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66712. * in order to compute objects velocities when enableVelocity is set to "true"
  66713. * @hidden
  66714. */
  66715. _previousTransformationMatrices: {
  66716. [index: number]: ISavedTransformationMatrix;
  66717. };
  66718. /**
  66719. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66720. * in order to compute objects velocities when enableVelocity is set to "true"
  66721. * @hidden
  66722. */
  66723. _previousBonesTransformationMatrices: {
  66724. [index: number]: Float32Array;
  66725. };
  66726. /**
  66727. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66728. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66729. */
  66730. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66731. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  66732. renderTransparentMeshes: boolean;
  66733. private _scene;
  66734. private _multiRenderTarget;
  66735. private _ratio;
  66736. private _enablePosition;
  66737. private _enableVelocity;
  66738. private _enableReflectivity;
  66739. private _positionIndex;
  66740. private _velocityIndex;
  66741. private _reflectivityIndex;
  66742. protected _effect: Effect;
  66743. protected _cachedDefines: string;
  66744. /**
  66745. * Set the render list (meshes to be rendered) used in the G buffer.
  66746. */
  66747. set renderList(meshes: Mesh[]);
  66748. /**
  66749. * Gets wether or not G buffer are supported by the running hardware.
  66750. * This requires draw buffer supports
  66751. */
  66752. get isSupported(): boolean;
  66753. /**
  66754. * Returns the index of the given texture type in the G-Buffer textures array
  66755. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66756. * @returns the index of the given texture type in the G-Buffer textures array
  66757. */
  66758. getTextureIndex(textureType: number): number;
  66759. /**
  66760. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66761. */
  66762. get enablePosition(): boolean;
  66763. /**
  66764. * Sets whether or not objects positions are enabled for the G buffer.
  66765. */
  66766. set enablePosition(enable: boolean);
  66767. /**
  66768. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66769. */
  66770. get enableVelocity(): boolean;
  66771. /**
  66772. * Sets wether or not objects velocities are enabled for the G buffer.
  66773. */
  66774. set enableVelocity(enable: boolean);
  66775. /**
  66776. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  66777. */
  66778. get enableReflectivity(): boolean;
  66779. /**
  66780. * Sets wether or not objects roughness are enabled for the G buffer.
  66781. */
  66782. set enableReflectivity(enable: boolean);
  66783. /**
  66784. * Gets the scene associated with the buffer.
  66785. */
  66786. get scene(): Scene;
  66787. /**
  66788. * Gets the ratio used by the buffer during its creation.
  66789. * How big is the buffer related to the main canvas.
  66790. */
  66791. get ratio(): number;
  66792. /** @hidden */
  66793. static _SceneComponentInitialization: (scene: Scene) => void;
  66794. /**
  66795. * Creates a new G Buffer for the scene
  66796. * @param scene The scene the buffer belongs to
  66797. * @param ratio How big is the buffer related to the main canvas.
  66798. */
  66799. constructor(scene: Scene, ratio?: number);
  66800. /**
  66801. * Checks wether everything is ready to render a submesh to the G buffer.
  66802. * @param subMesh the submesh to check readiness for
  66803. * @param useInstances is the mesh drawn using instance or not
  66804. * @returns true if ready otherwise false
  66805. */
  66806. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66807. /**
  66808. * Gets the current underlying G Buffer.
  66809. * @returns the buffer
  66810. */
  66811. getGBuffer(): MultiRenderTarget;
  66812. /**
  66813. * Gets the number of samples used to render the buffer (anti aliasing).
  66814. */
  66815. get samples(): number;
  66816. /**
  66817. * Sets the number of samples used to render the buffer (anti aliasing).
  66818. */
  66819. set samples(value: number);
  66820. /**
  66821. * Disposes the renderer and frees up associated resources.
  66822. */
  66823. dispose(): void;
  66824. protected _createRenderTargets(): void;
  66825. private _copyBonesTransformationMatrices;
  66826. }
  66827. }
  66828. declare module BABYLON {
  66829. interface Scene {
  66830. /** @hidden (Backing field) */
  66831. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66832. /**
  66833. * Gets or Sets the current geometry buffer associated to the scene.
  66834. */
  66835. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66836. /**
  66837. * Enables a GeometryBufferRender and associates it with the scene
  66838. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66839. * @returns the GeometryBufferRenderer
  66840. */
  66841. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66842. /**
  66843. * Disables the GeometryBufferRender associated with the scene
  66844. */
  66845. disableGeometryBufferRenderer(): void;
  66846. }
  66847. /**
  66848. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66849. * in several rendering techniques.
  66850. */
  66851. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66852. /**
  66853. * The component name helpful to identify the component in the list of scene components.
  66854. */
  66855. readonly name: string;
  66856. /**
  66857. * The scene the component belongs to.
  66858. */
  66859. scene: Scene;
  66860. /**
  66861. * Creates a new instance of the component for the given scene
  66862. * @param scene Defines the scene to register the component in
  66863. */
  66864. constructor(scene: Scene);
  66865. /**
  66866. * Registers the component in a given scene
  66867. */
  66868. register(): void;
  66869. /**
  66870. * Rebuilds the elements related to this component in case of
  66871. * context lost for instance.
  66872. */
  66873. rebuild(): void;
  66874. /**
  66875. * Disposes the component and the associated ressources
  66876. */
  66877. dispose(): void;
  66878. private _gatherRenderTargets;
  66879. }
  66880. }
  66881. declare module BABYLON {
  66882. /** @hidden */
  66883. export var motionBlurPixelShader: {
  66884. name: string;
  66885. shader: string;
  66886. };
  66887. }
  66888. declare module BABYLON {
  66889. /**
  66890. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66891. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66892. * As an example, all you have to do is to create the post-process:
  66893. * var mb = new BABYLON.MotionBlurPostProcess(
  66894. * 'mb', // The name of the effect.
  66895. * scene, // The scene containing the objects to blur according to their velocity.
  66896. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66897. * camera // The camera to apply the render pass to.
  66898. * );
  66899. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66900. */
  66901. export class MotionBlurPostProcess extends PostProcess {
  66902. /**
  66903. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66904. */
  66905. motionStrength: number;
  66906. /**
  66907. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66908. */
  66909. get motionBlurSamples(): number;
  66910. /**
  66911. * Sets the number of iterations to be used for motion blur quality
  66912. */
  66913. set motionBlurSamples(samples: number);
  66914. private _motionBlurSamples;
  66915. private _geometryBufferRenderer;
  66916. /**
  66917. * Creates a new instance MotionBlurPostProcess
  66918. * @param name The name of the effect.
  66919. * @param scene The scene containing the objects to blur according to their velocity.
  66920. * @param options The required width/height ratio to downsize to before computing the render pass.
  66921. * @param camera The camera to apply the render pass to.
  66922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66923. * @param engine The engine which the post process will be applied. (default: current engine)
  66924. * @param reusable If the post process can be reused on the same frame. (default: false)
  66925. * @param textureType Type of textures used when performing the post process. (default: 0)
  66926. * @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)
  66927. */
  66928. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66929. /**
  66930. * Excludes the given skinned mesh from computing bones velocities.
  66931. * 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.
  66932. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66933. */
  66934. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66935. /**
  66936. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66937. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66938. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66939. */
  66940. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66941. /**
  66942. * Disposes the post process.
  66943. * @param camera The camera to dispose the post process on.
  66944. */
  66945. dispose(camera?: Camera): void;
  66946. }
  66947. }
  66948. declare module BABYLON {
  66949. /** @hidden */
  66950. export var refractionPixelShader: {
  66951. name: string;
  66952. shader: string;
  66953. };
  66954. }
  66955. declare module BABYLON {
  66956. /**
  66957. * Post process which applies a refractin texture
  66958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66959. */
  66960. export class RefractionPostProcess extends PostProcess {
  66961. /** the base color of the refraction (used to taint the rendering) */
  66962. color: Color3;
  66963. /** simulated refraction depth */
  66964. depth: number;
  66965. /** the coefficient of the base color (0 to remove base color tainting) */
  66966. colorLevel: number;
  66967. private _refTexture;
  66968. private _ownRefractionTexture;
  66969. /**
  66970. * Gets or sets the refraction texture
  66971. * Please note that you are responsible for disposing the texture if you set it manually
  66972. */
  66973. get refractionTexture(): Texture;
  66974. set refractionTexture(value: Texture);
  66975. /**
  66976. * Initializes the RefractionPostProcess
  66977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66978. * @param name The name of the effect.
  66979. * @param refractionTextureUrl Url of the refraction texture to use
  66980. * @param color the base color of the refraction (used to taint the rendering)
  66981. * @param depth simulated refraction depth
  66982. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66983. * @param camera The camera to apply the render pass to.
  66984. * @param options The required width/height ratio to downsize to before computing the render pass.
  66985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66986. * @param engine The engine which the post process will be applied. (default: current engine)
  66987. * @param reusable If the post process can be reused on the same frame. (default: false)
  66988. */
  66989. constructor(name: string, refractionTextureUrl: string,
  66990. /** the base color of the refraction (used to taint the rendering) */
  66991. color: Color3,
  66992. /** simulated refraction depth */
  66993. depth: number,
  66994. /** the coefficient of the base color (0 to remove base color tainting) */
  66995. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66996. /**
  66997. * Disposes of the post process
  66998. * @param camera Camera to dispose post process on
  66999. */
  67000. dispose(camera: Camera): void;
  67001. }
  67002. }
  67003. declare module BABYLON {
  67004. /** @hidden */
  67005. export var sharpenPixelShader: {
  67006. name: string;
  67007. shader: string;
  67008. };
  67009. }
  67010. declare module BABYLON {
  67011. /**
  67012. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67013. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67014. */
  67015. export class SharpenPostProcess extends PostProcess {
  67016. /**
  67017. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67018. */
  67019. colorAmount: number;
  67020. /**
  67021. * How much sharpness should be applied (default: 0.3)
  67022. */
  67023. edgeAmount: number;
  67024. /**
  67025. * Creates a new instance ConvolutionPostProcess
  67026. * @param name The name of the effect.
  67027. * @param options The required width/height ratio to downsize to before computing the render pass.
  67028. * @param camera The camera to apply the render pass to.
  67029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67030. * @param engine The engine which the post process will be applied. (default: current engine)
  67031. * @param reusable If the post process can be reused on the same frame. (default: false)
  67032. * @param textureType Type of textures used when performing the post process. (default: 0)
  67033. * @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)
  67034. */
  67035. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67036. }
  67037. }
  67038. declare module BABYLON {
  67039. /**
  67040. * PostProcessRenderPipeline
  67041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67042. */
  67043. export class PostProcessRenderPipeline {
  67044. private engine;
  67045. private _renderEffects;
  67046. private _renderEffectsForIsolatedPass;
  67047. /**
  67048. * List of inspectable custom properties (used by the Inspector)
  67049. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67050. */
  67051. inspectableCustomProperties: IInspectable[];
  67052. /**
  67053. * @hidden
  67054. */
  67055. protected _cameras: Camera[];
  67056. /** @hidden */
  67057. _name: string;
  67058. /**
  67059. * Gets pipeline name
  67060. */
  67061. get name(): string;
  67062. /** Gets the list of attached cameras */
  67063. get cameras(): Camera[];
  67064. /**
  67065. * Initializes a PostProcessRenderPipeline
  67066. * @param engine engine to add the pipeline to
  67067. * @param name name of the pipeline
  67068. */
  67069. constructor(engine: Engine, name: string);
  67070. /**
  67071. * Gets the class name
  67072. * @returns "PostProcessRenderPipeline"
  67073. */
  67074. getClassName(): string;
  67075. /**
  67076. * If all the render effects in the pipeline are supported
  67077. */
  67078. get isSupported(): boolean;
  67079. /**
  67080. * Adds an effect to the pipeline
  67081. * @param renderEffect the effect to add
  67082. */
  67083. addEffect(renderEffect: PostProcessRenderEffect): void;
  67084. /** @hidden */
  67085. _rebuild(): void;
  67086. /** @hidden */
  67087. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67088. /** @hidden */
  67089. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67090. /** @hidden */
  67091. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67092. /** @hidden */
  67093. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67094. /** @hidden */
  67095. _attachCameras(cameras: Camera, unique: boolean): void;
  67096. /** @hidden */
  67097. _attachCameras(cameras: Camera[], unique: boolean): void;
  67098. /** @hidden */
  67099. _detachCameras(cameras: Camera): void;
  67100. /** @hidden */
  67101. _detachCameras(cameras: Nullable<Camera[]>): void;
  67102. /** @hidden */
  67103. _update(): void;
  67104. /** @hidden */
  67105. _reset(): void;
  67106. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67107. /**
  67108. * Disposes of the pipeline
  67109. */
  67110. dispose(): void;
  67111. }
  67112. }
  67113. declare module BABYLON {
  67114. /**
  67115. * PostProcessRenderPipelineManager class
  67116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67117. */
  67118. export class PostProcessRenderPipelineManager {
  67119. private _renderPipelines;
  67120. /**
  67121. * Initializes a PostProcessRenderPipelineManager
  67122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67123. */
  67124. constructor();
  67125. /**
  67126. * Gets the list of supported render pipelines
  67127. */
  67128. get supportedPipelines(): PostProcessRenderPipeline[];
  67129. /**
  67130. * Adds a pipeline to the manager
  67131. * @param renderPipeline The pipeline to add
  67132. */
  67133. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67134. /**
  67135. * Attaches a camera to the pipeline
  67136. * @param renderPipelineName The name of the pipeline to attach to
  67137. * @param cameras the camera to attach
  67138. * @param unique if the camera can be attached multiple times to the pipeline
  67139. */
  67140. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67141. /**
  67142. * Detaches a camera from the pipeline
  67143. * @param renderPipelineName The name of the pipeline to detach from
  67144. * @param cameras the camera to detach
  67145. */
  67146. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67147. /**
  67148. * Enables an effect by name on a pipeline
  67149. * @param renderPipelineName the name of the pipeline to enable the effect in
  67150. * @param renderEffectName the name of the effect to enable
  67151. * @param cameras the cameras that the effect should be enabled on
  67152. */
  67153. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67154. /**
  67155. * Disables an effect by name on a pipeline
  67156. * @param renderPipelineName the name of the pipeline to disable the effect in
  67157. * @param renderEffectName the name of the effect to disable
  67158. * @param cameras the cameras that the effect should be disabled on
  67159. */
  67160. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67161. /**
  67162. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67163. */
  67164. update(): void;
  67165. /** @hidden */
  67166. _rebuild(): void;
  67167. /**
  67168. * Disposes of the manager and pipelines
  67169. */
  67170. dispose(): void;
  67171. }
  67172. }
  67173. declare module BABYLON {
  67174. interface Scene {
  67175. /** @hidden (Backing field) */
  67176. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67177. /**
  67178. * Gets the postprocess render pipeline manager
  67179. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67180. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67181. */
  67182. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67183. }
  67184. /**
  67185. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67186. */
  67187. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67188. /**
  67189. * The component name helpfull to identify the component in the list of scene components.
  67190. */
  67191. readonly name: string;
  67192. /**
  67193. * The scene the component belongs to.
  67194. */
  67195. scene: Scene;
  67196. /**
  67197. * Creates a new instance of the component for the given scene
  67198. * @param scene Defines the scene to register the component in
  67199. */
  67200. constructor(scene: Scene);
  67201. /**
  67202. * Registers the component in a given scene
  67203. */
  67204. register(): void;
  67205. /**
  67206. * Rebuilds the elements related to this component in case of
  67207. * context lost for instance.
  67208. */
  67209. rebuild(): void;
  67210. /**
  67211. * Disposes the component and the associated ressources
  67212. */
  67213. dispose(): void;
  67214. private _gatherRenderTargets;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67220. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67221. */
  67222. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67223. private _scene;
  67224. private _camerasToBeAttached;
  67225. /**
  67226. * ID of the sharpen post process,
  67227. */
  67228. private readonly SharpenPostProcessId;
  67229. /**
  67230. * @ignore
  67231. * ID of the image processing post process;
  67232. */
  67233. readonly ImageProcessingPostProcessId: string;
  67234. /**
  67235. * @ignore
  67236. * ID of the Fast Approximate Anti-Aliasing post process;
  67237. */
  67238. readonly FxaaPostProcessId: string;
  67239. /**
  67240. * ID of the chromatic aberration post process,
  67241. */
  67242. private readonly ChromaticAberrationPostProcessId;
  67243. /**
  67244. * ID of the grain post process
  67245. */
  67246. private readonly GrainPostProcessId;
  67247. /**
  67248. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67249. */
  67250. sharpen: SharpenPostProcess;
  67251. private _sharpenEffect;
  67252. private bloom;
  67253. /**
  67254. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67255. */
  67256. depthOfField: DepthOfFieldEffect;
  67257. /**
  67258. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67259. */
  67260. fxaa: FxaaPostProcess;
  67261. /**
  67262. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67263. */
  67264. imageProcessing: ImageProcessingPostProcess;
  67265. /**
  67266. * Chromatic aberration post process which will shift rgb colors in the image
  67267. */
  67268. chromaticAberration: ChromaticAberrationPostProcess;
  67269. private _chromaticAberrationEffect;
  67270. /**
  67271. * Grain post process which add noise to the image
  67272. */
  67273. grain: GrainPostProcess;
  67274. private _grainEffect;
  67275. /**
  67276. * Glow post process which adds a glow to emissive areas of the image
  67277. */
  67278. private _glowLayer;
  67279. /**
  67280. * Animations which can be used to tweak settings over a period of time
  67281. */
  67282. animations: Animation[];
  67283. private _imageProcessingConfigurationObserver;
  67284. private _sharpenEnabled;
  67285. private _bloomEnabled;
  67286. private _depthOfFieldEnabled;
  67287. private _depthOfFieldBlurLevel;
  67288. private _fxaaEnabled;
  67289. private _imageProcessingEnabled;
  67290. private _defaultPipelineTextureType;
  67291. private _bloomScale;
  67292. private _chromaticAberrationEnabled;
  67293. private _grainEnabled;
  67294. private _buildAllowed;
  67295. /**
  67296. * Gets active scene
  67297. */
  67298. get scene(): Scene;
  67299. /**
  67300. * Enable or disable the sharpen process from the pipeline
  67301. */
  67302. set sharpenEnabled(enabled: boolean);
  67303. get sharpenEnabled(): boolean;
  67304. private _resizeObserver;
  67305. private _hardwareScaleLevel;
  67306. private _bloomKernel;
  67307. /**
  67308. * Specifies the size of the bloom blur kernel, relative to the final output size
  67309. */
  67310. get bloomKernel(): number;
  67311. set bloomKernel(value: number);
  67312. /**
  67313. * Specifies the weight of the bloom in the final rendering
  67314. */
  67315. private _bloomWeight;
  67316. /**
  67317. * Specifies the luma threshold for the area that will be blurred by the bloom
  67318. */
  67319. private _bloomThreshold;
  67320. private _hdr;
  67321. /**
  67322. * The strength of the bloom.
  67323. */
  67324. set bloomWeight(value: number);
  67325. get bloomWeight(): number;
  67326. /**
  67327. * The strength of the bloom.
  67328. */
  67329. set bloomThreshold(value: number);
  67330. get bloomThreshold(): number;
  67331. /**
  67332. * The scale of the bloom, lower value will provide better performance.
  67333. */
  67334. set bloomScale(value: number);
  67335. get bloomScale(): number;
  67336. /**
  67337. * Enable or disable the bloom from the pipeline
  67338. */
  67339. set bloomEnabled(enabled: boolean);
  67340. get bloomEnabled(): boolean;
  67341. private _rebuildBloom;
  67342. /**
  67343. * If the depth of field is enabled.
  67344. */
  67345. get depthOfFieldEnabled(): boolean;
  67346. set depthOfFieldEnabled(enabled: boolean);
  67347. /**
  67348. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67349. */
  67350. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67351. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67352. /**
  67353. * If the anti aliasing is enabled.
  67354. */
  67355. set fxaaEnabled(enabled: boolean);
  67356. get fxaaEnabled(): boolean;
  67357. private _samples;
  67358. /**
  67359. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67360. */
  67361. set samples(sampleCount: number);
  67362. get samples(): number;
  67363. /**
  67364. * If image processing is enabled.
  67365. */
  67366. set imageProcessingEnabled(enabled: boolean);
  67367. get imageProcessingEnabled(): boolean;
  67368. /**
  67369. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67370. */
  67371. set glowLayerEnabled(enabled: boolean);
  67372. get glowLayerEnabled(): boolean;
  67373. /**
  67374. * Gets the glow layer (or null if not defined)
  67375. */
  67376. get glowLayer(): Nullable<GlowLayer>;
  67377. /**
  67378. * Enable or disable the chromaticAberration process from the pipeline
  67379. */
  67380. set chromaticAberrationEnabled(enabled: boolean);
  67381. get chromaticAberrationEnabled(): boolean;
  67382. /**
  67383. * Enable or disable the grain process from the pipeline
  67384. */
  67385. set grainEnabled(enabled: boolean);
  67386. get grainEnabled(): boolean;
  67387. /**
  67388. * @constructor
  67389. * @param name - The rendering pipeline name (default: "")
  67390. * @param hdr - If high dynamic range textures should be used (default: true)
  67391. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67392. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67393. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67394. */
  67395. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67396. /**
  67397. * Get the class name
  67398. * @returns "DefaultRenderingPipeline"
  67399. */
  67400. getClassName(): string;
  67401. /**
  67402. * Force the compilation of the entire pipeline.
  67403. */
  67404. prepare(): void;
  67405. private _hasCleared;
  67406. private _prevPostProcess;
  67407. private _prevPrevPostProcess;
  67408. private _setAutoClearAndTextureSharing;
  67409. private _depthOfFieldSceneObserver;
  67410. private _buildPipeline;
  67411. private _disposePostProcesses;
  67412. /**
  67413. * Adds a camera to the pipeline
  67414. * @param camera the camera to be added
  67415. */
  67416. addCamera(camera: Camera): void;
  67417. /**
  67418. * Removes a camera from the pipeline
  67419. * @param camera the camera to remove
  67420. */
  67421. removeCamera(camera: Camera): void;
  67422. /**
  67423. * Dispose of the pipeline and stop all post processes
  67424. */
  67425. dispose(): void;
  67426. /**
  67427. * Serialize the rendering pipeline (Used when exporting)
  67428. * @returns the serialized object
  67429. */
  67430. serialize(): any;
  67431. /**
  67432. * Parse the serialized pipeline
  67433. * @param source Source pipeline.
  67434. * @param scene The scene to load the pipeline to.
  67435. * @param rootUrl The URL of the serialized pipeline.
  67436. * @returns An instantiated pipeline from the serialized object.
  67437. */
  67438. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67439. }
  67440. }
  67441. declare module BABYLON {
  67442. /** @hidden */
  67443. export var lensHighlightsPixelShader: {
  67444. name: string;
  67445. shader: string;
  67446. };
  67447. }
  67448. declare module BABYLON {
  67449. /** @hidden */
  67450. export var depthOfFieldPixelShader: {
  67451. name: string;
  67452. shader: string;
  67453. };
  67454. }
  67455. declare module BABYLON {
  67456. /**
  67457. * BABYLON.JS Chromatic Aberration GLSL Shader
  67458. * Author: Olivier Guyot
  67459. * Separates very slightly R, G and B colors on the edges of the screen
  67460. * Inspired by Francois Tarlier & Martins Upitis
  67461. */
  67462. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67463. /**
  67464. * @ignore
  67465. * The chromatic aberration PostProcess id in the pipeline
  67466. */
  67467. LensChromaticAberrationEffect: string;
  67468. /**
  67469. * @ignore
  67470. * The highlights enhancing PostProcess id in the pipeline
  67471. */
  67472. HighlightsEnhancingEffect: string;
  67473. /**
  67474. * @ignore
  67475. * The depth-of-field PostProcess id in the pipeline
  67476. */
  67477. LensDepthOfFieldEffect: string;
  67478. private _scene;
  67479. private _depthTexture;
  67480. private _grainTexture;
  67481. private _chromaticAberrationPostProcess;
  67482. private _highlightsPostProcess;
  67483. private _depthOfFieldPostProcess;
  67484. private _edgeBlur;
  67485. private _grainAmount;
  67486. private _chromaticAberration;
  67487. private _distortion;
  67488. private _highlightsGain;
  67489. private _highlightsThreshold;
  67490. private _dofDistance;
  67491. private _dofAperture;
  67492. private _dofDarken;
  67493. private _dofPentagon;
  67494. private _blurNoise;
  67495. /**
  67496. * @constructor
  67497. *
  67498. * Effect parameters are as follow:
  67499. * {
  67500. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67501. * edge_blur: number; // from 0 to x (1 for realism)
  67502. * distortion: number; // from 0 to x (1 for realism)
  67503. * grain_amount: number; // from 0 to 1
  67504. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67505. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67506. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67507. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67508. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67509. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67510. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67511. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67512. * }
  67513. * Note: if an effect parameter is unset, effect is disabled
  67514. *
  67515. * @param name The rendering pipeline name
  67516. * @param parameters - An object containing all parameters (see above)
  67517. * @param scene The scene linked to this pipeline
  67518. * @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)
  67519. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67520. */
  67521. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67522. /**
  67523. * Get the class name
  67524. * @returns "LensRenderingPipeline"
  67525. */
  67526. getClassName(): string;
  67527. /**
  67528. * Gets associated scene
  67529. */
  67530. get scene(): Scene;
  67531. /**
  67532. * Gets or sets the edge blur
  67533. */
  67534. get edgeBlur(): number;
  67535. set edgeBlur(value: number);
  67536. /**
  67537. * Gets or sets the grain amount
  67538. */
  67539. get grainAmount(): number;
  67540. set grainAmount(value: number);
  67541. /**
  67542. * Gets or sets the chromatic aberration amount
  67543. */
  67544. get chromaticAberration(): number;
  67545. set chromaticAberration(value: number);
  67546. /**
  67547. * Gets or sets the depth of field aperture
  67548. */
  67549. get dofAperture(): number;
  67550. set dofAperture(value: number);
  67551. /**
  67552. * Gets or sets the edge distortion
  67553. */
  67554. get edgeDistortion(): number;
  67555. set edgeDistortion(value: number);
  67556. /**
  67557. * Gets or sets the depth of field distortion
  67558. */
  67559. get dofDistortion(): number;
  67560. set dofDistortion(value: number);
  67561. /**
  67562. * Gets or sets the darken out of focus amount
  67563. */
  67564. get darkenOutOfFocus(): number;
  67565. set darkenOutOfFocus(value: number);
  67566. /**
  67567. * Gets or sets a boolean indicating if blur noise is enabled
  67568. */
  67569. get blurNoise(): boolean;
  67570. set blurNoise(value: boolean);
  67571. /**
  67572. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67573. */
  67574. get pentagonBokeh(): boolean;
  67575. set pentagonBokeh(value: boolean);
  67576. /**
  67577. * Gets or sets the highlight grain amount
  67578. */
  67579. get highlightsGain(): number;
  67580. set highlightsGain(value: number);
  67581. /**
  67582. * Gets or sets the highlight threshold
  67583. */
  67584. get highlightsThreshold(): number;
  67585. set highlightsThreshold(value: number);
  67586. /**
  67587. * Sets the amount of blur at the edges
  67588. * @param amount blur amount
  67589. */
  67590. setEdgeBlur(amount: number): void;
  67591. /**
  67592. * Sets edge blur to 0
  67593. */
  67594. disableEdgeBlur(): void;
  67595. /**
  67596. * Sets the amout of grain
  67597. * @param amount Amount of grain
  67598. */
  67599. setGrainAmount(amount: number): void;
  67600. /**
  67601. * Set grain amount to 0
  67602. */
  67603. disableGrain(): void;
  67604. /**
  67605. * Sets the chromatic aberration amount
  67606. * @param amount amount of chromatic aberration
  67607. */
  67608. setChromaticAberration(amount: number): void;
  67609. /**
  67610. * Sets chromatic aberration amount to 0
  67611. */
  67612. disableChromaticAberration(): void;
  67613. /**
  67614. * Sets the EdgeDistortion amount
  67615. * @param amount amount of EdgeDistortion
  67616. */
  67617. setEdgeDistortion(amount: number): void;
  67618. /**
  67619. * Sets edge distortion to 0
  67620. */
  67621. disableEdgeDistortion(): void;
  67622. /**
  67623. * Sets the FocusDistance amount
  67624. * @param amount amount of FocusDistance
  67625. */
  67626. setFocusDistance(amount: number): void;
  67627. /**
  67628. * Disables depth of field
  67629. */
  67630. disableDepthOfField(): void;
  67631. /**
  67632. * Sets the Aperture amount
  67633. * @param amount amount of Aperture
  67634. */
  67635. setAperture(amount: number): void;
  67636. /**
  67637. * Sets the DarkenOutOfFocus amount
  67638. * @param amount amount of DarkenOutOfFocus
  67639. */
  67640. setDarkenOutOfFocus(amount: number): void;
  67641. private _pentagonBokehIsEnabled;
  67642. /**
  67643. * Creates a pentagon bokeh effect
  67644. */
  67645. enablePentagonBokeh(): void;
  67646. /**
  67647. * Disables the pentagon bokeh effect
  67648. */
  67649. disablePentagonBokeh(): void;
  67650. /**
  67651. * Enables noise blur
  67652. */
  67653. enableNoiseBlur(): void;
  67654. /**
  67655. * Disables noise blur
  67656. */
  67657. disableNoiseBlur(): void;
  67658. /**
  67659. * Sets the HighlightsGain amount
  67660. * @param amount amount of HighlightsGain
  67661. */
  67662. setHighlightsGain(amount: number): void;
  67663. /**
  67664. * Sets the HighlightsThreshold amount
  67665. * @param amount amount of HighlightsThreshold
  67666. */
  67667. setHighlightsThreshold(amount: number): void;
  67668. /**
  67669. * Disables highlights
  67670. */
  67671. disableHighlights(): void;
  67672. /**
  67673. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67674. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67675. */
  67676. dispose(disableDepthRender?: boolean): void;
  67677. private _createChromaticAberrationPostProcess;
  67678. private _createHighlightsPostProcess;
  67679. private _createDepthOfFieldPostProcess;
  67680. private _createGrainTexture;
  67681. }
  67682. }
  67683. declare module BABYLON {
  67684. /** @hidden */
  67685. export var ssao2PixelShader: {
  67686. name: string;
  67687. shader: string;
  67688. };
  67689. }
  67690. declare module BABYLON {
  67691. /** @hidden */
  67692. export var ssaoCombinePixelShader: {
  67693. name: string;
  67694. shader: string;
  67695. };
  67696. }
  67697. declare module BABYLON {
  67698. /**
  67699. * Render pipeline to produce ssao effect
  67700. */
  67701. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67702. /**
  67703. * @ignore
  67704. * The PassPostProcess id in the pipeline that contains the original scene color
  67705. */
  67706. SSAOOriginalSceneColorEffect: string;
  67707. /**
  67708. * @ignore
  67709. * The SSAO PostProcess id in the pipeline
  67710. */
  67711. SSAORenderEffect: string;
  67712. /**
  67713. * @ignore
  67714. * The horizontal blur PostProcess id in the pipeline
  67715. */
  67716. SSAOBlurHRenderEffect: string;
  67717. /**
  67718. * @ignore
  67719. * The vertical blur PostProcess id in the pipeline
  67720. */
  67721. SSAOBlurVRenderEffect: string;
  67722. /**
  67723. * @ignore
  67724. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67725. */
  67726. SSAOCombineRenderEffect: string;
  67727. /**
  67728. * The output strength of the SSAO post-process. Default value is 1.0.
  67729. */
  67730. totalStrength: number;
  67731. /**
  67732. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67733. */
  67734. maxZ: number;
  67735. /**
  67736. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67737. */
  67738. minZAspect: number;
  67739. private _samples;
  67740. /**
  67741. * Number of samples used for the SSAO calculations. Default value is 8
  67742. */
  67743. set samples(n: number);
  67744. get samples(): number;
  67745. private _textureSamples;
  67746. /**
  67747. * Number of samples to use for antialiasing
  67748. */
  67749. set textureSamples(n: number);
  67750. get textureSamples(): number;
  67751. /**
  67752. * Ratio object used for SSAO ratio and blur ratio
  67753. */
  67754. private _ratio;
  67755. /**
  67756. * Dynamically generated sphere sampler.
  67757. */
  67758. private _sampleSphere;
  67759. /**
  67760. * Blur filter offsets
  67761. */
  67762. private _samplerOffsets;
  67763. private _expensiveBlur;
  67764. /**
  67765. * If bilateral blur should be used
  67766. */
  67767. set expensiveBlur(b: boolean);
  67768. get expensiveBlur(): boolean;
  67769. /**
  67770. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67771. */
  67772. radius: number;
  67773. /**
  67774. * The base color of the SSAO post-process
  67775. * The final result is "base + ssao" between [0, 1]
  67776. */
  67777. base: number;
  67778. /**
  67779. * Support test.
  67780. */
  67781. static get IsSupported(): boolean;
  67782. private _scene;
  67783. private _depthTexture;
  67784. private _normalTexture;
  67785. private _randomTexture;
  67786. private _originalColorPostProcess;
  67787. private _ssaoPostProcess;
  67788. private _blurHPostProcess;
  67789. private _blurVPostProcess;
  67790. private _ssaoCombinePostProcess;
  67791. /**
  67792. * Gets active scene
  67793. */
  67794. get scene(): Scene;
  67795. /**
  67796. * @constructor
  67797. * @param name The rendering pipeline name
  67798. * @param scene The scene linked to this pipeline
  67799. * @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 }
  67800. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67801. */
  67802. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67803. /**
  67804. * Get the class name
  67805. * @returns "SSAO2RenderingPipeline"
  67806. */
  67807. getClassName(): string;
  67808. /**
  67809. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67810. */
  67811. dispose(disableGeometryBufferRenderer?: boolean): void;
  67812. private _createBlurPostProcess;
  67813. /** @hidden */
  67814. _rebuild(): void;
  67815. private _bits;
  67816. private _radicalInverse_VdC;
  67817. private _hammersley;
  67818. private _hemisphereSample_uniform;
  67819. private _generateHemisphere;
  67820. private _createSSAOPostProcess;
  67821. private _createSSAOCombinePostProcess;
  67822. private _createRandomTexture;
  67823. /**
  67824. * Serialize the rendering pipeline (Used when exporting)
  67825. * @returns the serialized object
  67826. */
  67827. serialize(): any;
  67828. /**
  67829. * Parse the serialized pipeline
  67830. * @param source Source pipeline.
  67831. * @param scene The scene to load the pipeline to.
  67832. * @param rootUrl The URL of the serialized pipeline.
  67833. * @returns An instantiated pipeline from the serialized object.
  67834. */
  67835. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /** @hidden */
  67840. export var ssaoPixelShader: {
  67841. name: string;
  67842. shader: string;
  67843. };
  67844. }
  67845. declare module BABYLON {
  67846. /**
  67847. * Render pipeline to produce ssao effect
  67848. */
  67849. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67850. /**
  67851. * @ignore
  67852. * The PassPostProcess id in the pipeline that contains the original scene color
  67853. */
  67854. SSAOOriginalSceneColorEffect: string;
  67855. /**
  67856. * @ignore
  67857. * The SSAO PostProcess id in the pipeline
  67858. */
  67859. SSAORenderEffect: string;
  67860. /**
  67861. * @ignore
  67862. * The horizontal blur PostProcess id in the pipeline
  67863. */
  67864. SSAOBlurHRenderEffect: string;
  67865. /**
  67866. * @ignore
  67867. * The vertical blur PostProcess id in the pipeline
  67868. */
  67869. SSAOBlurVRenderEffect: string;
  67870. /**
  67871. * @ignore
  67872. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67873. */
  67874. SSAOCombineRenderEffect: string;
  67875. /**
  67876. * The output strength of the SSAO post-process. Default value is 1.0.
  67877. */
  67878. totalStrength: number;
  67879. /**
  67880. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67881. */
  67882. radius: number;
  67883. /**
  67884. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67885. * Must not be equal to fallOff and superior to fallOff.
  67886. * Default value is 0.0075
  67887. */
  67888. area: number;
  67889. /**
  67890. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67891. * Must not be equal to area and inferior to area.
  67892. * Default value is 0.000001
  67893. */
  67894. fallOff: number;
  67895. /**
  67896. * The base color of the SSAO post-process
  67897. * The final result is "base + ssao" between [0, 1]
  67898. */
  67899. base: number;
  67900. private _scene;
  67901. private _depthTexture;
  67902. private _randomTexture;
  67903. private _originalColorPostProcess;
  67904. private _ssaoPostProcess;
  67905. private _blurHPostProcess;
  67906. private _blurVPostProcess;
  67907. private _ssaoCombinePostProcess;
  67908. private _firstUpdate;
  67909. /**
  67910. * Gets active scene
  67911. */
  67912. get scene(): Scene;
  67913. /**
  67914. * @constructor
  67915. * @param name - The rendering pipeline name
  67916. * @param scene - The scene linked to this pipeline
  67917. * @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 }
  67918. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67919. */
  67920. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67921. /**
  67922. * Get the class name
  67923. * @returns "SSAORenderingPipeline"
  67924. */
  67925. getClassName(): string;
  67926. /**
  67927. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67928. */
  67929. dispose(disableDepthRender?: boolean): void;
  67930. private _createBlurPostProcess;
  67931. /** @hidden */
  67932. _rebuild(): void;
  67933. private _createSSAOPostProcess;
  67934. private _createSSAOCombinePostProcess;
  67935. private _createRandomTexture;
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export var screenSpaceReflectionPixelShader: {
  67941. name: string;
  67942. shader: string;
  67943. };
  67944. }
  67945. declare module BABYLON {
  67946. /**
  67947. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  67948. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  67949. */
  67950. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  67951. /**
  67952. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  67953. */
  67954. threshold: number;
  67955. /**
  67956. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  67957. */
  67958. strength: number;
  67959. /**
  67960. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  67961. */
  67962. reflectionSpecularFalloffExponent: number;
  67963. /**
  67964. * 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]
  67965. */
  67966. step: number;
  67967. /**
  67968. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  67969. */
  67970. roughnessFactor: number;
  67971. private _geometryBufferRenderer;
  67972. private _enableSmoothReflections;
  67973. private _reflectionSamples;
  67974. private _smoothSteps;
  67975. /**
  67976. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  67977. * @param name The name of the effect.
  67978. * @param scene The scene containing the objects to calculate reflections.
  67979. * @param options The required width/height ratio to downsize to before computing the render pass.
  67980. * @param camera The camera to apply the render pass to.
  67981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67982. * @param engine The engine which the post process will be applied. (default: current engine)
  67983. * @param reusable If the post process can be reused on the same frame. (default: false)
  67984. * @param textureType Type of textures used when performing the post process. (default: 0)
  67985. * @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)
  67986. */
  67987. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67988. /**
  67989. * Gets wether or not smoothing reflections is enabled.
  67990. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  67991. */
  67992. get enableSmoothReflections(): boolean;
  67993. /**
  67994. * Sets wether or not smoothing reflections is enabled.
  67995. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  67996. */
  67997. set enableSmoothReflections(enabled: boolean);
  67998. /**
  67999. * Gets the number of samples taken while computing reflections. More samples count is high,
  68000. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68001. */
  68002. get reflectionSamples(): number;
  68003. /**
  68004. * Sets the number of samples taken while computing reflections. More samples count is high,
  68005. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68006. */
  68007. set reflectionSamples(samples: number);
  68008. /**
  68009. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68010. * more the post-process will require GPU power and can generate a drop in FPS.
  68011. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68012. */
  68013. get smoothSteps(): number;
  68014. set smoothSteps(steps: number);
  68015. private _updateEffectDefines;
  68016. }
  68017. }
  68018. declare module BABYLON {
  68019. /** @hidden */
  68020. export var standardPixelShader: {
  68021. name: string;
  68022. shader: string;
  68023. };
  68024. }
  68025. declare module BABYLON {
  68026. /**
  68027. * Standard rendering pipeline
  68028. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68029. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68030. */
  68031. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68032. /**
  68033. * Public members
  68034. */
  68035. /**
  68036. * Post-process which contains the original scene color before the pipeline applies all the effects
  68037. */
  68038. originalPostProcess: Nullable<PostProcess>;
  68039. /**
  68040. * Post-process used to down scale an image x4
  68041. */
  68042. downSampleX4PostProcess: Nullable<PostProcess>;
  68043. /**
  68044. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68045. */
  68046. brightPassPostProcess: Nullable<PostProcess>;
  68047. /**
  68048. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68049. */
  68050. blurHPostProcesses: PostProcess[];
  68051. /**
  68052. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68053. */
  68054. blurVPostProcesses: PostProcess[];
  68055. /**
  68056. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68057. */
  68058. textureAdderPostProcess: Nullable<PostProcess>;
  68059. /**
  68060. * Post-process used to create volumetric lighting effect
  68061. */
  68062. volumetricLightPostProcess: Nullable<PostProcess>;
  68063. /**
  68064. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68065. */
  68066. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68067. /**
  68068. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68069. */
  68070. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68071. /**
  68072. * Post-process used to merge the volumetric light effect and the real scene color
  68073. */
  68074. volumetricLightMergePostProces: Nullable<PostProcess>;
  68075. /**
  68076. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68077. */
  68078. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68079. /**
  68080. * Base post-process used to calculate the average luminance of the final image for HDR
  68081. */
  68082. luminancePostProcess: Nullable<PostProcess>;
  68083. /**
  68084. * Post-processes used to create down sample post-processes in order to get
  68085. * the average luminance of the final image for HDR
  68086. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68087. */
  68088. luminanceDownSamplePostProcesses: PostProcess[];
  68089. /**
  68090. * Post-process used to create a HDR effect (light adaptation)
  68091. */
  68092. hdrPostProcess: Nullable<PostProcess>;
  68093. /**
  68094. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68095. */
  68096. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68097. /**
  68098. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68099. */
  68100. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68101. /**
  68102. * Post-process used to merge the final HDR post-process and the real scene color
  68103. */
  68104. hdrFinalPostProcess: Nullable<PostProcess>;
  68105. /**
  68106. * Post-process used to create a lens flare effect
  68107. */
  68108. lensFlarePostProcess: Nullable<PostProcess>;
  68109. /**
  68110. * Post-process that merges the result of the lens flare post-process and the real scene color
  68111. */
  68112. lensFlareComposePostProcess: Nullable<PostProcess>;
  68113. /**
  68114. * Post-process used to create a motion blur effect
  68115. */
  68116. motionBlurPostProcess: Nullable<PostProcess>;
  68117. /**
  68118. * Post-process used to create a depth of field effect
  68119. */
  68120. depthOfFieldPostProcess: Nullable<PostProcess>;
  68121. /**
  68122. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68123. */
  68124. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68125. /**
  68126. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  68127. */
  68128. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  68129. /**
  68130. * Represents the brightness threshold in order to configure the illuminated surfaces
  68131. */
  68132. brightThreshold: number;
  68133. /**
  68134. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68135. */
  68136. blurWidth: number;
  68137. /**
  68138. * Sets if the blur for highlighted surfaces must be only horizontal
  68139. */
  68140. horizontalBlur: boolean;
  68141. /**
  68142. * Gets the overall exposure used by the pipeline
  68143. */
  68144. get exposure(): number;
  68145. /**
  68146. * Sets the overall exposure used by the pipeline
  68147. */
  68148. set exposure(value: number);
  68149. /**
  68150. * Texture used typically to simulate "dirty" on camera lens
  68151. */
  68152. lensTexture: Nullable<Texture>;
  68153. /**
  68154. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68155. */
  68156. volumetricLightCoefficient: number;
  68157. /**
  68158. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68159. */
  68160. volumetricLightPower: number;
  68161. /**
  68162. * Used the set the blur intensity to smooth the volumetric lights
  68163. */
  68164. volumetricLightBlurScale: number;
  68165. /**
  68166. * Light (spot or directional) used to generate the volumetric lights rays
  68167. * The source light must have a shadow generate so the pipeline can get its
  68168. * depth map
  68169. */
  68170. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68171. /**
  68172. * For eye adaptation, represents the minimum luminance the eye can see
  68173. */
  68174. hdrMinimumLuminance: number;
  68175. /**
  68176. * For eye adaptation, represents the decrease luminance speed
  68177. */
  68178. hdrDecreaseRate: number;
  68179. /**
  68180. * For eye adaptation, represents the increase luminance speed
  68181. */
  68182. hdrIncreaseRate: number;
  68183. /**
  68184. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68185. */
  68186. get hdrAutoExposure(): boolean;
  68187. /**
  68188. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68189. */
  68190. set hdrAutoExposure(value: boolean);
  68191. /**
  68192. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68193. */
  68194. lensColorTexture: Nullable<Texture>;
  68195. /**
  68196. * The overall strengh for the lens flare effect
  68197. */
  68198. lensFlareStrength: number;
  68199. /**
  68200. * Dispersion coefficient for lens flare ghosts
  68201. */
  68202. lensFlareGhostDispersal: number;
  68203. /**
  68204. * Main lens flare halo width
  68205. */
  68206. lensFlareHaloWidth: number;
  68207. /**
  68208. * Based on the lens distortion effect, defines how much the lens flare result
  68209. * is distorted
  68210. */
  68211. lensFlareDistortionStrength: number;
  68212. /**
  68213. * Configures the blur intensity used for for lens flare (halo)
  68214. */
  68215. lensFlareBlurWidth: number;
  68216. /**
  68217. * Lens star texture must be used to simulate rays on the flares and is available
  68218. * in the documentation
  68219. */
  68220. lensStarTexture: Nullable<Texture>;
  68221. /**
  68222. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68223. * flare effect by taking account of the dirt texture
  68224. */
  68225. lensFlareDirtTexture: Nullable<Texture>;
  68226. /**
  68227. * Represents the focal length for the depth of field effect
  68228. */
  68229. depthOfFieldDistance: number;
  68230. /**
  68231. * Represents the blur intensity for the blurred part of the depth of field effect
  68232. */
  68233. depthOfFieldBlurWidth: number;
  68234. /**
  68235. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68236. */
  68237. get motionStrength(): number;
  68238. /**
  68239. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68240. */
  68241. set motionStrength(strength: number);
  68242. /**
  68243. * Gets wether or not the motion blur post-process is object based or screen based.
  68244. */
  68245. get objectBasedMotionBlur(): boolean;
  68246. /**
  68247. * Sets wether or not the motion blur post-process should be object based or screen based
  68248. */
  68249. set objectBasedMotionBlur(value: boolean);
  68250. /**
  68251. * List of animations for the pipeline (IAnimatable implementation)
  68252. */
  68253. animations: Animation[];
  68254. /**
  68255. * Private members
  68256. */
  68257. private _scene;
  68258. private _currentDepthOfFieldSource;
  68259. private _basePostProcess;
  68260. private _fixedExposure;
  68261. private _currentExposure;
  68262. private _hdrAutoExposure;
  68263. private _hdrCurrentLuminance;
  68264. private _motionStrength;
  68265. private _isObjectBasedMotionBlur;
  68266. private _floatTextureType;
  68267. private _camerasToBeAttached;
  68268. private _ratio;
  68269. private _bloomEnabled;
  68270. private _depthOfFieldEnabled;
  68271. private _vlsEnabled;
  68272. private _lensFlareEnabled;
  68273. private _hdrEnabled;
  68274. private _motionBlurEnabled;
  68275. private _fxaaEnabled;
  68276. private _screenSpaceReflectionsEnabled;
  68277. private _motionBlurSamples;
  68278. private _volumetricLightStepsCount;
  68279. private _samples;
  68280. /**
  68281. * @ignore
  68282. * Specifies if the bloom pipeline is enabled
  68283. */
  68284. get BloomEnabled(): boolean;
  68285. set BloomEnabled(enabled: boolean);
  68286. /**
  68287. * @ignore
  68288. * Specifies if the depth of field pipeline is enabed
  68289. */
  68290. get DepthOfFieldEnabled(): boolean;
  68291. set DepthOfFieldEnabled(enabled: boolean);
  68292. /**
  68293. * @ignore
  68294. * Specifies if the lens flare pipeline is enabed
  68295. */
  68296. get LensFlareEnabled(): boolean;
  68297. set LensFlareEnabled(enabled: boolean);
  68298. /**
  68299. * @ignore
  68300. * Specifies if the HDR pipeline is enabled
  68301. */
  68302. get HDREnabled(): boolean;
  68303. set HDREnabled(enabled: boolean);
  68304. /**
  68305. * @ignore
  68306. * Specifies if the volumetric lights scattering effect is enabled
  68307. */
  68308. get VLSEnabled(): boolean;
  68309. set VLSEnabled(enabled: boolean);
  68310. /**
  68311. * @ignore
  68312. * Specifies if the motion blur effect is enabled
  68313. */
  68314. get MotionBlurEnabled(): boolean;
  68315. set MotionBlurEnabled(enabled: boolean);
  68316. /**
  68317. * Specifies if anti-aliasing is enabled
  68318. */
  68319. get fxaaEnabled(): boolean;
  68320. set fxaaEnabled(enabled: boolean);
  68321. /**
  68322. * Specifies if screen space reflections are enabled.
  68323. */
  68324. get screenSpaceReflectionsEnabled(): boolean;
  68325. set screenSpaceReflectionsEnabled(enabled: boolean);
  68326. /**
  68327. * Specifies the number of steps used to calculate the volumetric lights
  68328. * Typically in interval [50, 200]
  68329. */
  68330. get volumetricLightStepsCount(): number;
  68331. set volumetricLightStepsCount(count: number);
  68332. /**
  68333. * Specifies the number of samples used for the motion blur effect
  68334. * Typically in interval [16, 64]
  68335. */
  68336. get motionBlurSamples(): number;
  68337. set motionBlurSamples(samples: number);
  68338. /**
  68339. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68340. */
  68341. get samples(): number;
  68342. set samples(sampleCount: number);
  68343. /**
  68344. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68345. * @constructor
  68346. * @param name The rendering pipeline name
  68347. * @param scene The scene linked to this pipeline
  68348. * @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)
  68349. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68350. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68351. */
  68352. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68353. private _buildPipeline;
  68354. private _createDownSampleX4PostProcess;
  68355. private _createBrightPassPostProcess;
  68356. private _createBlurPostProcesses;
  68357. private _createTextureAdderPostProcess;
  68358. private _createVolumetricLightPostProcess;
  68359. private _createLuminancePostProcesses;
  68360. private _createHdrPostProcess;
  68361. private _createLensFlarePostProcess;
  68362. private _createDepthOfFieldPostProcess;
  68363. private _createMotionBlurPostProcess;
  68364. private _getDepthTexture;
  68365. private _disposePostProcesses;
  68366. /**
  68367. * Dispose of the pipeline and stop all post processes
  68368. */
  68369. dispose(): void;
  68370. /**
  68371. * Serialize the rendering pipeline (Used when exporting)
  68372. * @returns the serialized object
  68373. */
  68374. serialize(): any;
  68375. /**
  68376. * Parse the serialized pipeline
  68377. * @param source Source pipeline.
  68378. * @param scene The scene to load the pipeline to.
  68379. * @param rootUrl The URL of the serialized pipeline.
  68380. * @returns An instantiated pipeline from the serialized object.
  68381. */
  68382. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68383. /**
  68384. * Luminance steps
  68385. */
  68386. static LuminanceSteps: number;
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /** @hidden */
  68391. export var stereoscopicInterlacePixelShader: {
  68392. name: string;
  68393. shader: string;
  68394. };
  68395. }
  68396. declare module BABYLON {
  68397. /**
  68398. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  68399. */
  68400. export class StereoscopicInterlacePostProcessI extends PostProcess {
  68401. private _stepSize;
  68402. private _passedProcess;
  68403. /**
  68404. * Initializes a StereoscopicInterlacePostProcessI
  68405. * @param name The name of the effect.
  68406. * @param rigCameras The rig cameras to be appled to the post process
  68407. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  68408. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  68409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68410. * @param engine The engine which the post process will be applied. (default: current engine)
  68411. * @param reusable If the post process can be reused on the same frame. (default: false)
  68412. */
  68413. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68414. }
  68415. /**
  68416. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  68417. */
  68418. export class StereoscopicInterlacePostProcess extends PostProcess {
  68419. private _stepSize;
  68420. private _passedProcess;
  68421. /**
  68422. * Initializes a StereoscopicInterlacePostProcess
  68423. * @param name The name of the effect.
  68424. * @param rigCameras The rig cameras to be appled to the post process
  68425. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  68426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68427. * @param engine The engine which the post process will be applied. (default: current engine)
  68428. * @param reusable If the post process can be reused on the same frame. (default: false)
  68429. */
  68430. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68431. }
  68432. }
  68433. declare module BABYLON {
  68434. /** @hidden */
  68435. export var tonemapPixelShader: {
  68436. name: string;
  68437. shader: string;
  68438. };
  68439. }
  68440. declare module BABYLON {
  68441. /** Defines operator used for tonemapping */
  68442. export enum TonemappingOperator {
  68443. /** Hable */
  68444. Hable = 0,
  68445. /** Reinhard */
  68446. Reinhard = 1,
  68447. /** HejiDawson */
  68448. HejiDawson = 2,
  68449. /** Photographic */
  68450. Photographic = 3
  68451. }
  68452. /**
  68453. * Defines a post process to apply tone mapping
  68454. */
  68455. export class TonemapPostProcess extends PostProcess {
  68456. private _operator;
  68457. /** Defines the required exposure adjustement */
  68458. exposureAdjustment: number;
  68459. /**
  68460. * Creates a new TonemapPostProcess
  68461. * @param name defines the name of the postprocess
  68462. * @param _operator defines the operator to use
  68463. * @param exposureAdjustment defines the required exposure adjustement
  68464. * @param camera defines the camera to use (can be null)
  68465. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68466. * @param engine defines the hosting engine (can be ignore if camera is set)
  68467. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68468. */
  68469. constructor(name: string, _operator: TonemappingOperator,
  68470. /** Defines the required exposure adjustement */
  68471. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68472. }
  68473. }
  68474. declare module BABYLON {
  68475. /** @hidden */
  68476. export var volumetricLightScatteringPixelShader: {
  68477. name: string;
  68478. shader: string;
  68479. };
  68480. }
  68481. declare module BABYLON {
  68482. /** @hidden */
  68483. export var volumetricLightScatteringPassVertexShader: {
  68484. name: string;
  68485. shader: string;
  68486. };
  68487. }
  68488. declare module BABYLON {
  68489. /** @hidden */
  68490. export var volumetricLightScatteringPassPixelShader: {
  68491. name: string;
  68492. shader: string;
  68493. };
  68494. }
  68495. declare module BABYLON {
  68496. /**
  68497. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68498. */
  68499. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68500. private _volumetricLightScatteringPass;
  68501. private _volumetricLightScatteringRTT;
  68502. private _viewPort;
  68503. private _screenCoordinates;
  68504. private _cachedDefines;
  68505. /**
  68506. * If not undefined, the mesh position is computed from the attached node position
  68507. */
  68508. attachedNode: {
  68509. position: Vector3;
  68510. };
  68511. /**
  68512. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68513. */
  68514. customMeshPosition: Vector3;
  68515. /**
  68516. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68517. */
  68518. useCustomMeshPosition: boolean;
  68519. /**
  68520. * If the post-process should inverse the light scattering direction
  68521. */
  68522. invert: boolean;
  68523. /**
  68524. * The internal mesh used by the post-process
  68525. */
  68526. mesh: Mesh;
  68527. /**
  68528. * @hidden
  68529. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68530. */
  68531. get useDiffuseColor(): boolean;
  68532. set useDiffuseColor(useDiffuseColor: boolean);
  68533. /**
  68534. * Array containing the excluded meshes not rendered in the internal pass
  68535. */
  68536. excludedMeshes: AbstractMesh[];
  68537. /**
  68538. * Controls the overall intensity of the post-process
  68539. */
  68540. exposure: number;
  68541. /**
  68542. * Dissipates each sample's contribution in range [0, 1]
  68543. */
  68544. decay: number;
  68545. /**
  68546. * Controls the overall intensity of each sample
  68547. */
  68548. weight: number;
  68549. /**
  68550. * Controls the density of each sample
  68551. */
  68552. density: number;
  68553. /**
  68554. * @constructor
  68555. * @param name The post-process name
  68556. * @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)
  68557. * @param camera The camera that the post-process will be attached to
  68558. * @param mesh The mesh used to create the light scattering
  68559. * @param samples The post-process quality, default 100
  68560. * @param samplingModeThe post-process filtering mode
  68561. * @param engine The babylon engine
  68562. * @param reusable If the post-process is reusable
  68563. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68564. */
  68565. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68566. /**
  68567. * Returns the string "VolumetricLightScatteringPostProcess"
  68568. * @returns "VolumetricLightScatteringPostProcess"
  68569. */
  68570. getClassName(): string;
  68571. private _isReady;
  68572. /**
  68573. * Sets the new light position for light scattering effect
  68574. * @param position The new custom light position
  68575. */
  68576. setCustomMeshPosition(position: Vector3): void;
  68577. /**
  68578. * Returns the light position for light scattering effect
  68579. * @return Vector3 The custom light position
  68580. */
  68581. getCustomMeshPosition(): Vector3;
  68582. /**
  68583. * Disposes the internal assets and detaches the post-process from the camera
  68584. */
  68585. dispose(camera: Camera): void;
  68586. /**
  68587. * Returns the render target texture used by the post-process
  68588. * @return the render target texture used by the post-process
  68589. */
  68590. getPass(): RenderTargetTexture;
  68591. private _meshExcluded;
  68592. private _createPass;
  68593. private _updateMeshScreenCoordinates;
  68594. /**
  68595. * Creates a default mesh for the Volumeric Light Scattering post-process
  68596. * @param name The mesh name
  68597. * @param scene The scene where to create the mesh
  68598. * @return the default mesh
  68599. */
  68600. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68601. }
  68602. }
  68603. declare module BABYLON {
  68604. interface Scene {
  68605. /** @hidden (Backing field) */
  68606. _boundingBoxRenderer: BoundingBoxRenderer;
  68607. /** @hidden (Backing field) */
  68608. _forceShowBoundingBoxes: boolean;
  68609. /**
  68610. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68611. */
  68612. forceShowBoundingBoxes: boolean;
  68613. /**
  68614. * Gets the bounding box renderer associated with the scene
  68615. * @returns a BoundingBoxRenderer
  68616. */
  68617. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68618. }
  68619. interface AbstractMesh {
  68620. /** @hidden (Backing field) */
  68621. _showBoundingBox: boolean;
  68622. /**
  68623. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68624. */
  68625. showBoundingBox: boolean;
  68626. }
  68627. /**
  68628. * Component responsible of rendering the bounding box of the meshes in a scene.
  68629. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68630. */
  68631. export class BoundingBoxRenderer implements ISceneComponent {
  68632. /**
  68633. * The component name helpfull to identify the component in the list of scene components.
  68634. */
  68635. readonly name: string;
  68636. /**
  68637. * The scene the component belongs to.
  68638. */
  68639. scene: Scene;
  68640. /**
  68641. * Color of the bounding box lines placed in front of an object
  68642. */
  68643. frontColor: Color3;
  68644. /**
  68645. * Color of the bounding box lines placed behind an object
  68646. */
  68647. backColor: Color3;
  68648. /**
  68649. * Defines if the renderer should show the back lines or not
  68650. */
  68651. showBackLines: boolean;
  68652. /**
  68653. * @hidden
  68654. */
  68655. renderList: SmartArray<BoundingBox>;
  68656. private _colorShader;
  68657. private _vertexBuffers;
  68658. private _indexBuffer;
  68659. private _fillIndexBuffer;
  68660. private _fillIndexData;
  68661. /**
  68662. * Instantiates a new bounding box renderer in a scene.
  68663. * @param scene the scene the renderer renders in
  68664. */
  68665. constructor(scene: Scene);
  68666. /**
  68667. * Registers the component in a given scene
  68668. */
  68669. register(): void;
  68670. private _evaluateSubMesh;
  68671. private _activeMesh;
  68672. private _prepareRessources;
  68673. private _createIndexBuffer;
  68674. /**
  68675. * Rebuilds the elements related to this component in case of
  68676. * context lost for instance.
  68677. */
  68678. rebuild(): void;
  68679. /**
  68680. * @hidden
  68681. */
  68682. reset(): void;
  68683. /**
  68684. * Render the bounding boxes of a specific rendering group
  68685. * @param renderingGroupId defines the rendering group to render
  68686. */
  68687. render(renderingGroupId: number): void;
  68688. /**
  68689. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68690. * @param mesh Define the mesh to render the occlusion bounding box for
  68691. */
  68692. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68693. /**
  68694. * Dispose and release the resources attached to this renderer.
  68695. */
  68696. dispose(): void;
  68697. }
  68698. }
  68699. declare module BABYLON {
  68700. interface Scene {
  68701. /** @hidden (Backing field) */
  68702. _depthRenderer: {
  68703. [id: string]: DepthRenderer;
  68704. };
  68705. /**
  68706. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68707. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68708. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68709. * @returns the created depth renderer
  68710. */
  68711. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68712. /**
  68713. * Disables a depth renderer for a given camera
  68714. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68715. */
  68716. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68717. }
  68718. /**
  68719. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68720. * in several rendering techniques.
  68721. */
  68722. export class DepthRendererSceneComponent implements ISceneComponent {
  68723. /**
  68724. * The component name helpfull to identify the component in the list of scene components.
  68725. */
  68726. readonly name: string;
  68727. /**
  68728. * The scene the component belongs to.
  68729. */
  68730. scene: Scene;
  68731. /**
  68732. * Creates a new instance of the component for the given scene
  68733. * @param scene Defines the scene to register the component in
  68734. */
  68735. constructor(scene: Scene);
  68736. /**
  68737. * Registers the component in a given scene
  68738. */
  68739. register(): void;
  68740. /**
  68741. * Rebuilds the elements related to this component in case of
  68742. * context lost for instance.
  68743. */
  68744. rebuild(): void;
  68745. /**
  68746. * Disposes the component and the associated ressources
  68747. */
  68748. dispose(): void;
  68749. private _gatherRenderTargets;
  68750. private _gatherActiveCameraRenderTargets;
  68751. }
  68752. }
  68753. declare module BABYLON {
  68754. /** @hidden */
  68755. export var outlinePixelShader: {
  68756. name: string;
  68757. shader: string;
  68758. };
  68759. }
  68760. declare module BABYLON {
  68761. /** @hidden */
  68762. export var outlineVertexShader: {
  68763. name: string;
  68764. shader: string;
  68765. };
  68766. }
  68767. declare module BABYLON {
  68768. interface Scene {
  68769. /** @hidden */
  68770. _outlineRenderer: OutlineRenderer;
  68771. /**
  68772. * Gets the outline renderer associated with the scene
  68773. * @returns a OutlineRenderer
  68774. */
  68775. getOutlineRenderer(): OutlineRenderer;
  68776. }
  68777. interface AbstractMesh {
  68778. /** @hidden (Backing field) */
  68779. _renderOutline: boolean;
  68780. /**
  68781. * Gets or sets a boolean indicating if the outline must be rendered as well
  68782. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68783. */
  68784. renderOutline: boolean;
  68785. /** @hidden (Backing field) */
  68786. _renderOverlay: boolean;
  68787. /**
  68788. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68789. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68790. */
  68791. renderOverlay: boolean;
  68792. }
  68793. /**
  68794. * This class is responsible to draw bothe outline/overlay of meshes.
  68795. * It should not be used directly but through the available method on mesh.
  68796. */
  68797. export class OutlineRenderer implements ISceneComponent {
  68798. /**
  68799. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68800. */
  68801. private static _StencilReference;
  68802. /**
  68803. * The name of the component. Each component must have a unique name.
  68804. */
  68805. name: string;
  68806. /**
  68807. * The scene the component belongs to.
  68808. */
  68809. scene: Scene;
  68810. /**
  68811. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68812. */
  68813. zOffset: number;
  68814. private _engine;
  68815. private _effect;
  68816. private _cachedDefines;
  68817. private _savedDepthWrite;
  68818. /**
  68819. * Instantiates a new outline renderer. (There could be only one per scene).
  68820. * @param scene Defines the scene it belongs to
  68821. */
  68822. constructor(scene: Scene);
  68823. /**
  68824. * Register the component to one instance of a scene.
  68825. */
  68826. register(): void;
  68827. /**
  68828. * Rebuilds the elements related to this component in case of
  68829. * context lost for instance.
  68830. */
  68831. rebuild(): void;
  68832. /**
  68833. * Disposes the component and the associated ressources.
  68834. */
  68835. dispose(): void;
  68836. /**
  68837. * Renders the outline in the canvas.
  68838. * @param subMesh Defines the sumesh to render
  68839. * @param batch Defines the batch of meshes in case of instances
  68840. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68841. */
  68842. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68843. /**
  68844. * Returns whether or not the outline renderer is ready for a given submesh.
  68845. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68846. * @param subMesh Defines the submesh to check readyness for
  68847. * @param useInstances Defines wheter wee are trying to render instances or not
  68848. * @returns true if ready otherwise false
  68849. */
  68850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68851. private _beforeRenderingMesh;
  68852. private _afterRenderingMesh;
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /**
  68857. * Defines the basic options interface of a Sprite Frame Source Size.
  68858. */
  68859. export interface ISpriteJSONSpriteSourceSize {
  68860. /**
  68861. * number of the original width of the Frame
  68862. */
  68863. w: number;
  68864. /**
  68865. * number of the original height of the Frame
  68866. */
  68867. h: number;
  68868. }
  68869. /**
  68870. * Defines the basic options interface of a Sprite Frame Data.
  68871. */
  68872. export interface ISpriteJSONSpriteFrameData {
  68873. /**
  68874. * number of the x offset of the Frame
  68875. */
  68876. x: number;
  68877. /**
  68878. * number of the y offset of the Frame
  68879. */
  68880. y: number;
  68881. /**
  68882. * number of the width of the Frame
  68883. */
  68884. w: number;
  68885. /**
  68886. * number of the height of the Frame
  68887. */
  68888. h: number;
  68889. }
  68890. /**
  68891. * Defines the basic options interface of a JSON Sprite.
  68892. */
  68893. export interface ISpriteJSONSprite {
  68894. /**
  68895. * string name of the Frame
  68896. */
  68897. filename: string;
  68898. /**
  68899. * ISpriteJSONSpriteFrame basic object of the frame data
  68900. */
  68901. frame: ISpriteJSONSpriteFrameData;
  68902. /**
  68903. * boolean to flag is the frame was rotated.
  68904. */
  68905. rotated: boolean;
  68906. /**
  68907. * boolean to flag is the frame was trimmed.
  68908. */
  68909. trimmed: boolean;
  68910. /**
  68911. * ISpriteJSONSpriteFrame basic object of the source data
  68912. */
  68913. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68914. /**
  68915. * ISpriteJSONSpriteFrame basic object of the source data
  68916. */
  68917. sourceSize: ISpriteJSONSpriteSourceSize;
  68918. }
  68919. /**
  68920. * Defines the basic options interface of a JSON atlas.
  68921. */
  68922. export interface ISpriteJSONAtlas {
  68923. /**
  68924. * Array of objects that contain the frame data.
  68925. */
  68926. frames: Array<ISpriteJSONSprite>;
  68927. /**
  68928. * object basic object containing the sprite meta data.
  68929. */
  68930. meta?: object;
  68931. }
  68932. }
  68933. declare module BABYLON {
  68934. /** @hidden */
  68935. export var spriteMapPixelShader: {
  68936. name: string;
  68937. shader: string;
  68938. };
  68939. }
  68940. declare module BABYLON {
  68941. /** @hidden */
  68942. export var spriteMapVertexShader: {
  68943. name: string;
  68944. shader: string;
  68945. };
  68946. }
  68947. declare module BABYLON {
  68948. /**
  68949. * Defines the basic options interface of a SpriteMap
  68950. */
  68951. export interface ISpriteMapOptions {
  68952. /**
  68953. * Vector2 of the number of cells in the grid.
  68954. */
  68955. stageSize?: Vector2;
  68956. /**
  68957. * Vector2 of the size of the output plane in World Units.
  68958. */
  68959. outputSize?: Vector2;
  68960. /**
  68961. * Vector3 of the position of the output plane in World Units.
  68962. */
  68963. outputPosition?: Vector3;
  68964. /**
  68965. * Vector3 of the rotation of the output plane.
  68966. */
  68967. outputRotation?: Vector3;
  68968. /**
  68969. * number of layers that the system will reserve in resources.
  68970. */
  68971. layerCount?: number;
  68972. /**
  68973. * number of max animation frames a single cell will reserve in resources.
  68974. */
  68975. maxAnimationFrames?: number;
  68976. /**
  68977. * number cell index of the base tile when the system compiles.
  68978. */
  68979. baseTile?: number;
  68980. /**
  68981. * boolean flip the sprite after its been repositioned by the framing data.
  68982. */
  68983. flipU?: boolean;
  68984. /**
  68985. * Vector3 scalar of the global RGB values of the SpriteMap.
  68986. */
  68987. colorMultiply?: Vector3;
  68988. }
  68989. /**
  68990. * Defines the IDisposable interface in order to be cleanable from resources.
  68991. */
  68992. export interface ISpriteMap extends IDisposable {
  68993. /**
  68994. * String name of the SpriteMap.
  68995. */
  68996. name: string;
  68997. /**
  68998. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68999. */
  69000. atlasJSON: ISpriteJSONAtlas;
  69001. /**
  69002. * Texture of the SpriteMap.
  69003. */
  69004. spriteSheet: Texture;
  69005. /**
  69006. * The parameters to initialize the SpriteMap with.
  69007. */
  69008. options: ISpriteMapOptions;
  69009. }
  69010. /**
  69011. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69012. */
  69013. export class SpriteMap implements ISpriteMap {
  69014. /** The Name of the spriteMap */
  69015. name: string;
  69016. /** The JSON file with the frame and meta data */
  69017. atlasJSON: ISpriteJSONAtlas;
  69018. /** The systems Sprite Sheet Texture */
  69019. spriteSheet: Texture;
  69020. /** Arguments passed with the Constructor */
  69021. options: ISpriteMapOptions;
  69022. /** Public Sprite Storage array, parsed from atlasJSON */
  69023. sprites: Array<ISpriteJSONSprite>;
  69024. /** Returns the Number of Sprites in the System */
  69025. get spriteCount(): number;
  69026. /** Returns the Position of Output Plane*/
  69027. get position(): Vector3;
  69028. /** Returns the Position of Output Plane*/
  69029. set position(v: Vector3);
  69030. /** Returns the Rotation of Output Plane*/
  69031. get rotation(): Vector3;
  69032. /** Returns the Rotation of Output Plane*/
  69033. set rotation(v: Vector3);
  69034. /** Sets the AnimationMap*/
  69035. get animationMap(): RawTexture;
  69036. /** Sets the AnimationMap*/
  69037. set animationMap(v: RawTexture);
  69038. /** Scene that the SpriteMap was created in */
  69039. private _scene;
  69040. /** Texture Buffer of Float32 that holds tile frame data*/
  69041. private _frameMap;
  69042. /** Texture Buffers of Float32 that holds tileMap data*/
  69043. private _tileMaps;
  69044. /** Texture Buffer of Float32 that holds Animation Data*/
  69045. private _animationMap;
  69046. /** Custom ShaderMaterial Central to the System*/
  69047. private _material;
  69048. /** Custom ShaderMaterial Central to the System*/
  69049. private _output;
  69050. /** Systems Time Ticker*/
  69051. private _time;
  69052. /**
  69053. * Creates a new SpriteMap
  69054. * @param name defines the SpriteMaps Name
  69055. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69056. * @param spriteSheet is the Texture that the Sprites are on.
  69057. * @param options a basic deployment configuration
  69058. * @param scene The Scene that the map is deployed on
  69059. */
  69060. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69061. /**
  69062. * Returns tileID location
  69063. * @returns Vector2 the cell position ID
  69064. */
  69065. getTileID(): Vector2;
  69066. /**
  69067. * Gets the UV location of the mouse over the SpriteMap.
  69068. * @returns Vector2 the UV position of the mouse interaction
  69069. */
  69070. getMousePosition(): Vector2;
  69071. /**
  69072. * Creates the "frame" texture Buffer
  69073. * -------------------------------------
  69074. * Structure of frames
  69075. * "filename": "Falling-Water-2.png",
  69076. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69077. * "rotated": true,
  69078. * "trimmed": true,
  69079. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69080. * "sourceSize": {"w":32,"h":32}
  69081. * @returns RawTexture of the frameMap
  69082. */
  69083. private _createFrameBuffer;
  69084. /**
  69085. * Creates the tileMap texture Buffer
  69086. * @param buffer normally and array of numbers, or a false to generate from scratch
  69087. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69088. * @returns RawTexture of the tileMap
  69089. */
  69090. private _createTileBuffer;
  69091. /**
  69092. * Modifies the data of the tileMaps
  69093. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69094. * @param pos is the iVector2 Coordinates of the Tile
  69095. * @param tile The SpriteIndex of the new Tile
  69096. */
  69097. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69098. /**
  69099. * Creates the animationMap texture Buffer
  69100. * @param buffer normally and array of numbers, or a false to generate from scratch
  69101. * @returns RawTexture of the animationMap
  69102. */
  69103. private _createTileAnimationBuffer;
  69104. /**
  69105. * Modifies the data of the animationMap
  69106. * @param cellID is the Index of the Sprite
  69107. * @param _frame is the target Animation frame
  69108. * @param toCell is the Target Index of the next frame of the animation
  69109. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69110. * @param speed is a global scalar of the time variable on the map.
  69111. */
  69112. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69113. /**
  69114. * Exports the .tilemaps file
  69115. */
  69116. saveTileMaps(): void;
  69117. /**
  69118. * Imports the .tilemaps file
  69119. * @param url of the .tilemaps file
  69120. */
  69121. loadTileMaps(url: string): void;
  69122. /**
  69123. * Release associated resources
  69124. */
  69125. dispose(): void;
  69126. }
  69127. }
  69128. declare module BABYLON {
  69129. /**
  69130. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69131. * @see http://doc.babylonjs.com/babylon101/sprites
  69132. */
  69133. export class SpritePackedManager extends SpriteManager {
  69134. /** defines the packed manager's name */
  69135. name: string;
  69136. /**
  69137. * Creates a new sprite manager from a packed sprite sheet
  69138. * @param name defines the manager's name
  69139. * @param imgUrl defines the sprite sheet url
  69140. * @param capacity defines the maximum allowed number of sprites
  69141. * @param scene defines the hosting scene
  69142. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69143. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69144. * @param samplingMode defines the smapling mode to use with spritesheet
  69145. * @param fromPacked set to true; do not alter
  69146. */
  69147. constructor(
  69148. /** defines the packed manager's name */
  69149. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69150. }
  69151. }
  69152. declare module BABYLON {
  69153. /**
  69154. * Defines the list of states available for a task inside a AssetsManager
  69155. */
  69156. export enum AssetTaskState {
  69157. /**
  69158. * Initialization
  69159. */
  69160. INIT = 0,
  69161. /**
  69162. * Running
  69163. */
  69164. RUNNING = 1,
  69165. /**
  69166. * Done
  69167. */
  69168. DONE = 2,
  69169. /**
  69170. * Error
  69171. */
  69172. ERROR = 3
  69173. }
  69174. /**
  69175. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69176. */
  69177. export abstract class AbstractAssetTask {
  69178. /**
  69179. * Task name
  69180. */ name: string;
  69181. /**
  69182. * Callback called when the task is successful
  69183. */
  69184. onSuccess: (task: any) => void;
  69185. /**
  69186. * Callback called when the task is not successful
  69187. */
  69188. onError: (task: any, message?: string, exception?: any) => void;
  69189. /**
  69190. * Creates a new AssetsManager
  69191. * @param name defines the name of the task
  69192. */
  69193. constructor(
  69194. /**
  69195. * Task name
  69196. */ name: string);
  69197. private _isCompleted;
  69198. private _taskState;
  69199. private _errorObject;
  69200. /**
  69201. * Get if the task is completed
  69202. */
  69203. get isCompleted(): boolean;
  69204. /**
  69205. * Gets the current state of the task
  69206. */
  69207. get taskState(): AssetTaskState;
  69208. /**
  69209. * Gets the current error object (if task is in error)
  69210. */
  69211. get errorObject(): {
  69212. message?: string;
  69213. exception?: any;
  69214. };
  69215. /**
  69216. * Internal only
  69217. * @hidden
  69218. */
  69219. _setErrorObject(message?: string, exception?: any): void;
  69220. /**
  69221. * Execute the current task
  69222. * @param scene defines the scene where you want your assets to be loaded
  69223. * @param onSuccess is a callback called when the task is successfully executed
  69224. * @param onError is a callback called if an error occurs
  69225. */
  69226. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69227. /**
  69228. * Execute the current task
  69229. * @param scene defines the scene where you want your assets to be loaded
  69230. * @param onSuccess is a callback called when the task is successfully executed
  69231. * @param onError is a callback called if an error occurs
  69232. */
  69233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69234. /**
  69235. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69236. * This can be used with failed tasks that have the reason for failure fixed.
  69237. */
  69238. reset(): void;
  69239. private onErrorCallback;
  69240. private onDoneCallback;
  69241. }
  69242. /**
  69243. * Define the interface used by progress events raised during assets loading
  69244. */
  69245. export interface IAssetsProgressEvent {
  69246. /**
  69247. * Defines the number of remaining tasks to process
  69248. */
  69249. remainingCount: number;
  69250. /**
  69251. * Defines the total number of tasks
  69252. */
  69253. totalCount: number;
  69254. /**
  69255. * Defines the task that was just processed
  69256. */
  69257. task: AbstractAssetTask;
  69258. }
  69259. /**
  69260. * Class used to share progress information about assets loading
  69261. */
  69262. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69263. /**
  69264. * Defines the number of remaining tasks to process
  69265. */
  69266. remainingCount: number;
  69267. /**
  69268. * Defines the total number of tasks
  69269. */
  69270. totalCount: number;
  69271. /**
  69272. * Defines the task that was just processed
  69273. */
  69274. task: AbstractAssetTask;
  69275. /**
  69276. * Creates a AssetsProgressEvent
  69277. * @param remainingCount defines the number of remaining tasks to process
  69278. * @param totalCount defines the total number of tasks
  69279. * @param task defines the task that was just processed
  69280. */
  69281. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69282. }
  69283. /**
  69284. * Define a task used by AssetsManager to load meshes
  69285. */
  69286. export class MeshAssetTask extends AbstractAssetTask {
  69287. /**
  69288. * Defines the name of the task
  69289. */
  69290. name: string;
  69291. /**
  69292. * Defines the list of mesh's names you want to load
  69293. */
  69294. meshesNames: any;
  69295. /**
  69296. * Defines the root url to use as a base to load your meshes and associated resources
  69297. */
  69298. rootUrl: string;
  69299. /**
  69300. * Defines the filename or File of the scene to load from
  69301. */
  69302. sceneFilename: string | File;
  69303. /**
  69304. * Gets the list of loaded meshes
  69305. */
  69306. loadedMeshes: Array<AbstractMesh>;
  69307. /**
  69308. * Gets the list of loaded particle systems
  69309. */
  69310. loadedParticleSystems: Array<IParticleSystem>;
  69311. /**
  69312. * Gets the list of loaded skeletons
  69313. */
  69314. loadedSkeletons: Array<Skeleton>;
  69315. /**
  69316. * Gets the list of loaded animation groups
  69317. */
  69318. loadedAnimationGroups: Array<AnimationGroup>;
  69319. /**
  69320. * Callback called when the task is successful
  69321. */
  69322. onSuccess: (task: MeshAssetTask) => void;
  69323. /**
  69324. * Callback called when the task is successful
  69325. */
  69326. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69327. /**
  69328. * Creates a new MeshAssetTask
  69329. * @param name defines the name of the task
  69330. * @param meshesNames defines the list of mesh's names you want to load
  69331. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69332. * @param sceneFilename defines the filename or File of the scene to load from
  69333. */
  69334. constructor(
  69335. /**
  69336. * Defines the name of the task
  69337. */
  69338. name: string,
  69339. /**
  69340. * Defines the list of mesh's names you want to load
  69341. */
  69342. meshesNames: any,
  69343. /**
  69344. * Defines the root url to use as a base to load your meshes and associated resources
  69345. */
  69346. rootUrl: string,
  69347. /**
  69348. * Defines the filename or File of the scene to load from
  69349. */
  69350. sceneFilename: string | File);
  69351. /**
  69352. * Execute the current task
  69353. * @param scene defines the scene where you want your assets to be loaded
  69354. * @param onSuccess is a callback called when the task is successfully executed
  69355. * @param onError is a callback called if an error occurs
  69356. */
  69357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69358. }
  69359. /**
  69360. * Define a task used by AssetsManager to load text content
  69361. */
  69362. export class TextFileAssetTask extends AbstractAssetTask {
  69363. /**
  69364. * Defines the name of the task
  69365. */
  69366. name: string;
  69367. /**
  69368. * Defines the location of the file to load
  69369. */
  69370. url: string;
  69371. /**
  69372. * Gets the loaded text string
  69373. */
  69374. text: string;
  69375. /**
  69376. * Callback called when the task is successful
  69377. */
  69378. onSuccess: (task: TextFileAssetTask) => void;
  69379. /**
  69380. * Callback called when the task is successful
  69381. */
  69382. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69383. /**
  69384. * Creates a new TextFileAssetTask object
  69385. * @param name defines the name of the task
  69386. * @param url defines the location of the file to load
  69387. */
  69388. constructor(
  69389. /**
  69390. * Defines the name of the task
  69391. */
  69392. name: string,
  69393. /**
  69394. * Defines the location of the file to load
  69395. */
  69396. url: string);
  69397. /**
  69398. * Execute the current task
  69399. * @param scene defines the scene where you want your assets to be loaded
  69400. * @param onSuccess is a callback called when the task is successfully executed
  69401. * @param onError is a callback called if an error occurs
  69402. */
  69403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69404. }
  69405. /**
  69406. * Define a task used by AssetsManager to load binary data
  69407. */
  69408. export class BinaryFileAssetTask extends AbstractAssetTask {
  69409. /**
  69410. * Defines the name of the task
  69411. */
  69412. name: string;
  69413. /**
  69414. * Defines the location of the file to load
  69415. */
  69416. url: string;
  69417. /**
  69418. * Gets the lodaded data (as an array buffer)
  69419. */
  69420. data: ArrayBuffer;
  69421. /**
  69422. * Callback called when the task is successful
  69423. */
  69424. onSuccess: (task: BinaryFileAssetTask) => void;
  69425. /**
  69426. * Callback called when the task is successful
  69427. */
  69428. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69429. /**
  69430. * Creates a new BinaryFileAssetTask object
  69431. * @param name defines the name of the new task
  69432. * @param url defines the location of the file to load
  69433. */
  69434. constructor(
  69435. /**
  69436. * Defines the name of the task
  69437. */
  69438. name: string,
  69439. /**
  69440. * Defines the location of the file to load
  69441. */
  69442. url: string);
  69443. /**
  69444. * Execute the current task
  69445. * @param scene defines the scene where you want your assets to be loaded
  69446. * @param onSuccess is a callback called when the task is successfully executed
  69447. * @param onError is a callback called if an error occurs
  69448. */
  69449. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69450. }
  69451. /**
  69452. * Define a task used by AssetsManager to load images
  69453. */
  69454. export class ImageAssetTask extends AbstractAssetTask {
  69455. /**
  69456. * Defines the name of the task
  69457. */
  69458. name: string;
  69459. /**
  69460. * Defines the location of the image to load
  69461. */
  69462. url: string;
  69463. /**
  69464. * Gets the loaded images
  69465. */
  69466. image: HTMLImageElement;
  69467. /**
  69468. * Callback called when the task is successful
  69469. */
  69470. onSuccess: (task: ImageAssetTask) => void;
  69471. /**
  69472. * Callback called when the task is successful
  69473. */
  69474. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69475. /**
  69476. * Creates a new ImageAssetTask
  69477. * @param name defines the name of the task
  69478. * @param url defines the location of the image to load
  69479. */
  69480. constructor(
  69481. /**
  69482. * Defines the name of the task
  69483. */
  69484. name: string,
  69485. /**
  69486. * Defines the location of the image to load
  69487. */
  69488. url: string);
  69489. /**
  69490. * Execute the current task
  69491. * @param scene defines the scene where you want your assets to be loaded
  69492. * @param onSuccess is a callback called when the task is successfully executed
  69493. * @param onError is a callback called if an error occurs
  69494. */
  69495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69496. }
  69497. /**
  69498. * Defines the interface used by texture loading tasks
  69499. */
  69500. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69501. /**
  69502. * Gets the loaded texture
  69503. */
  69504. texture: TEX;
  69505. }
  69506. /**
  69507. * Define a task used by AssetsManager to load 2D textures
  69508. */
  69509. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69510. /**
  69511. * Defines the name of the task
  69512. */
  69513. name: string;
  69514. /**
  69515. * Defines the location of the file to load
  69516. */
  69517. url: string;
  69518. /**
  69519. * Defines if mipmap should not be generated (default is false)
  69520. */
  69521. noMipmap?: boolean | undefined;
  69522. /**
  69523. * Defines if texture must be inverted on Y axis (default is true)
  69524. */
  69525. invertY: boolean;
  69526. /**
  69527. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69528. */
  69529. samplingMode: number;
  69530. /**
  69531. * Gets the loaded texture
  69532. */
  69533. texture: Texture;
  69534. /**
  69535. * Callback called when the task is successful
  69536. */
  69537. onSuccess: (task: TextureAssetTask) => void;
  69538. /**
  69539. * Callback called when the task is successful
  69540. */
  69541. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69542. /**
  69543. * Creates a new TextureAssetTask object
  69544. * @param name defines the name of the task
  69545. * @param url defines the location of the file to load
  69546. * @param noMipmap defines if mipmap should not be generated (default is false)
  69547. * @param invertY defines if texture must be inverted on Y axis (default is true)
  69548. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69549. */
  69550. constructor(
  69551. /**
  69552. * Defines the name of the task
  69553. */
  69554. name: string,
  69555. /**
  69556. * Defines the location of the file to load
  69557. */
  69558. url: string,
  69559. /**
  69560. * Defines if mipmap should not be generated (default is false)
  69561. */
  69562. noMipmap?: boolean | undefined,
  69563. /**
  69564. * Defines if texture must be inverted on Y axis (default is true)
  69565. */
  69566. invertY?: boolean,
  69567. /**
  69568. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69569. */
  69570. samplingMode?: number);
  69571. /**
  69572. * Execute the current task
  69573. * @param scene defines the scene where you want your assets to be loaded
  69574. * @param onSuccess is a callback called when the task is successfully executed
  69575. * @param onError is a callback called if an error occurs
  69576. */
  69577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69578. }
  69579. /**
  69580. * Define a task used by AssetsManager to load cube textures
  69581. */
  69582. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69583. /**
  69584. * Defines the name of the task
  69585. */
  69586. name: string;
  69587. /**
  69588. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69589. */
  69590. url: string;
  69591. /**
  69592. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69593. */
  69594. extensions?: string[] | undefined;
  69595. /**
  69596. * Defines if mipmaps should not be generated (default is false)
  69597. */
  69598. noMipmap?: boolean | undefined;
  69599. /**
  69600. * Defines the explicit list of files (undefined by default)
  69601. */
  69602. files?: string[] | undefined;
  69603. /**
  69604. * Gets the loaded texture
  69605. */
  69606. texture: CubeTexture;
  69607. /**
  69608. * Callback called when the task is successful
  69609. */
  69610. onSuccess: (task: CubeTextureAssetTask) => void;
  69611. /**
  69612. * Callback called when the task is successful
  69613. */
  69614. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69615. /**
  69616. * Creates a new CubeTextureAssetTask
  69617. * @param name defines the name of the task
  69618. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69619. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69620. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69621. * @param files defines the explicit list of files (undefined by default)
  69622. */
  69623. constructor(
  69624. /**
  69625. * Defines the name of the task
  69626. */
  69627. name: string,
  69628. /**
  69629. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69630. */
  69631. url: string,
  69632. /**
  69633. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69634. */
  69635. extensions?: string[] | undefined,
  69636. /**
  69637. * Defines if mipmaps should not be generated (default is false)
  69638. */
  69639. noMipmap?: boolean | undefined,
  69640. /**
  69641. * Defines the explicit list of files (undefined by default)
  69642. */
  69643. files?: string[] | undefined);
  69644. /**
  69645. * Execute the current task
  69646. * @param scene defines the scene where you want your assets to be loaded
  69647. * @param onSuccess is a callback called when the task is successfully executed
  69648. * @param onError is a callback called if an error occurs
  69649. */
  69650. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69651. }
  69652. /**
  69653. * Define a task used by AssetsManager to load HDR cube textures
  69654. */
  69655. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69656. /**
  69657. * Defines the name of the task
  69658. */
  69659. name: string;
  69660. /**
  69661. * Defines the location of the file to load
  69662. */
  69663. url: string;
  69664. /**
  69665. * Defines the desired size (the more it increases the longer the generation will be)
  69666. */
  69667. size: number;
  69668. /**
  69669. * Defines if mipmaps should not be generated (default is false)
  69670. */
  69671. noMipmap: boolean;
  69672. /**
  69673. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69674. */
  69675. generateHarmonics: boolean;
  69676. /**
  69677. * 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)
  69678. */
  69679. gammaSpace: boolean;
  69680. /**
  69681. * Internal Use Only
  69682. */
  69683. reserved: boolean;
  69684. /**
  69685. * Gets the loaded texture
  69686. */
  69687. texture: HDRCubeTexture;
  69688. /**
  69689. * Callback called when the task is successful
  69690. */
  69691. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69692. /**
  69693. * Callback called when the task is successful
  69694. */
  69695. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69696. /**
  69697. * Creates a new HDRCubeTextureAssetTask object
  69698. * @param name defines the name of the task
  69699. * @param url defines the location of the file to load
  69700. * @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.
  69701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69702. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69703. * @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)
  69704. * @param reserved Internal use only
  69705. */
  69706. constructor(
  69707. /**
  69708. * Defines the name of the task
  69709. */
  69710. name: string,
  69711. /**
  69712. * Defines the location of the file to load
  69713. */
  69714. url: string,
  69715. /**
  69716. * Defines the desired size (the more it increases the longer the generation will be)
  69717. */
  69718. size: number,
  69719. /**
  69720. * Defines if mipmaps should not be generated (default is false)
  69721. */
  69722. noMipmap?: boolean,
  69723. /**
  69724. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69725. */
  69726. generateHarmonics?: boolean,
  69727. /**
  69728. * 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)
  69729. */
  69730. gammaSpace?: boolean,
  69731. /**
  69732. * Internal Use Only
  69733. */
  69734. reserved?: boolean);
  69735. /**
  69736. * Execute the current task
  69737. * @param scene defines the scene where you want your assets to be loaded
  69738. * @param onSuccess is a callback called when the task is successfully executed
  69739. * @param onError is a callback called if an error occurs
  69740. */
  69741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69742. }
  69743. /**
  69744. * Define a task used by AssetsManager to load Equirectangular cube textures
  69745. */
  69746. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69747. /**
  69748. * Defines the name of the task
  69749. */
  69750. name: string;
  69751. /**
  69752. * Defines the location of the file to load
  69753. */
  69754. url: string;
  69755. /**
  69756. * Defines the desired size (the more it increases the longer the generation will be)
  69757. */
  69758. size: number;
  69759. /**
  69760. * Defines if mipmaps should not be generated (default is false)
  69761. */
  69762. noMipmap: boolean;
  69763. /**
  69764. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69765. * but the standard material would require them in Gamma space) (default is true)
  69766. */
  69767. gammaSpace: boolean;
  69768. /**
  69769. * Gets the loaded texture
  69770. */
  69771. texture: EquiRectangularCubeTexture;
  69772. /**
  69773. * Callback called when the task is successful
  69774. */
  69775. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69776. /**
  69777. * Callback called when the task is successful
  69778. */
  69779. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69780. /**
  69781. * Creates a new EquiRectangularCubeTextureAssetTask object
  69782. * @param name defines the name of the task
  69783. * @param url defines the location of the file to load
  69784. * @param size defines the desired size (the more it increases the longer the generation will be)
  69785. * If the size is omitted this implies you are using a preprocessed cubemap.
  69786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69787. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69788. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69789. * (default is true)
  69790. */
  69791. constructor(
  69792. /**
  69793. * Defines the name of the task
  69794. */
  69795. name: string,
  69796. /**
  69797. * Defines the location of the file to load
  69798. */
  69799. url: string,
  69800. /**
  69801. * Defines the desired size (the more it increases the longer the generation will be)
  69802. */
  69803. size: number,
  69804. /**
  69805. * Defines if mipmaps should not be generated (default is false)
  69806. */
  69807. noMipmap?: boolean,
  69808. /**
  69809. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69810. * but the standard material would require them in Gamma space) (default is true)
  69811. */
  69812. gammaSpace?: boolean);
  69813. /**
  69814. * Execute the current task
  69815. * @param scene defines the scene where you want your assets to be loaded
  69816. * @param onSuccess is a callback called when the task is successfully executed
  69817. * @param onError is a callback called if an error occurs
  69818. */
  69819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69820. }
  69821. /**
  69822. * This class can be used to easily import assets into a scene
  69823. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69824. */
  69825. export class AssetsManager {
  69826. private _scene;
  69827. private _isLoading;
  69828. protected _tasks: AbstractAssetTask[];
  69829. protected _waitingTasksCount: number;
  69830. protected _totalTasksCount: number;
  69831. /**
  69832. * Callback called when all tasks are processed
  69833. */
  69834. onFinish: (tasks: AbstractAssetTask[]) => void;
  69835. /**
  69836. * Callback called when a task is successful
  69837. */
  69838. onTaskSuccess: (task: AbstractAssetTask) => void;
  69839. /**
  69840. * Callback called when a task had an error
  69841. */
  69842. onTaskError: (task: AbstractAssetTask) => void;
  69843. /**
  69844. * Callback called when a task is done (whatever the result is)
  69845. */
  69846. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69847. /**
  69848. * Observable called when all tasks are processed
  69849. */
  69850. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69851. /**
  69852. * Observable called when a task had an error
  69853. */
  69854. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69855. /**
  69856. * Observable called when all tasks were executed
  69857. */
  69858. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69859. /**
  69860. * Observable called when a task is done (whatever the result is)
  69861. */
  69862. onProgressObservable: Observable<IAssetsProgressEvent>;
  69863. /**
  69864. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69866. */
  69867. useDefaultLoadingScreen: boolean;
  69868. /**
  69869. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69870. * when all assets have been downloaded.
  69871. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69872. */
  69873. autoHideLoadingUI: boolean;
  69874. /**
  69875. * Creates a new AssetsManager
  69876. * @param scene defines the scene to work on
  69877. */
  69878. constructor(scene: Scene);
  69879. /**
  69880. * Add a MeshAssetTask to the list of active tasks
  69881. * @param taskName defines the name of the new task
  69882. * @param meshesNames defines the name of meshes to load
  69883. * @param rootUrl defines the root url to use to locate files
  69884. * @param sceneFilename defines the filename of the scene file
  69885. * @returns a new MeshAssetTask object
  69886. */
  69887. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69888. /**
  69889. * Add a TextFileAssetTask to the list of active tasks
  69890. * @param taskName defines the name of the new task
  69891. * @param url defines the url of the file to load
  69892. * @returns a new TextFileAssetTask object
  69893. */
  69894. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69895. /**
  69896. * Add a BinaryFileAssetTask to the list of active tasks
  69897. * @param taskName defines the name of the new task
  69898. * @param url defines the url of the file to load
  69899. * @returns a new BinaryFileAssetTask object
  69900. */
  69901. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69902. /**
  69903. * Add a ImageAssetTask to the list of active tasks
  69904. * @param taskName defines the name of the new task
  69905. * @param url defines the url of the file to load
  69906. * @returns a new ImageAssetTask object
  69907. */
  69908. addImageTask(taskName: string, url: string): ImageAssetTask;
  69909. /**
  69910. * Add a TextureAssetTask to the list of active tasks
  69911. * @param taskName defines the name of the new task
  69912. * @param url defines the url of the file to load
  69913. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69914. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69915. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69916. * @returns a new TextureAssetTask object
  69917. */
  69918. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69919. /**
  69920. * Add a CubeTextureAssetTask to the list of active tasks
  69921. * @param taskName defines the name of the new task
  69922. * @param url defines the url of the file to load
  69923. * @param extensions defines the extension to use to load the cube map (can be null)
  69924. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69925. * @param files defines the list of files to load (can be null)
  69926. * @returns a new CubeTextureAssetTask object
  69927. */
  69928. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69929. /**
  69930. *
  69931. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69932. * @param taskName defines the name of the new task
  69933. * @param url defines the url of the file to load
  69934. * @param size defines the size you want for the cubemap (can be null)
  69935. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69936. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69937. * @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)
  69938. * @param reserved Internal use only
  69939. * @returns a new HDRCubeTextureAssetTask object
  69940. */
  69941. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69942. /**
  69943. *
  69944. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69945. * @param taskName defines the name of the new task
  69946. * @param url defines the url of the file to load
  69947. * @param size defines the size you want for the cubemap (can be null)
  69948. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69949. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69950. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69951. * @returns a new EquiRectangularCubeTextureAssetTask object
  69952. */
  69953. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69954. /**
  69955. * Remove a task from the assets manager.
  69956. * @param task the task to remove
  69957. */
  69958. removeTask(task: AbstractAssetTask): void;
  69959. private _decreaseWaitingTasksCount;
  69960. private _runTask;
  69961. /**
  69962. * Reset the AssetsManager and remove all tasks
  69963. * @return the current instance of the AssetsManager
  69964. */
  69965. reset(): AssetsManager;
  69966. /**
  69967. * Start the loading process
  69968. * @return the current instance of the AssetsManager
  69969. */
  69970. load(): AssetsManager;
  69971. /**
  69972. * Start the loading process as an async operation
  69973. * @return a promise returning the list of failed tasks
  69974. */
  69975. loadAsync(): Promise<void>;
  69976. }
  69977. }
  69978. declare module BABYLON {
  69979. /**
  69980. * Wrapper class for promise with external resolve and reject.
  69981. */
  69982. export class Deferred<T> {
  69983. /**
  69984. * The promise associated with this deferred object.
  69985. */
  69986. readonly promise: Promise<T>;
  69987. private _resolve;
  69988. private _reject;
  69989. /**
  69990. * The resolve method of the promise associated with this deferred object.
  69991. */
  69992. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69993. /**
  69994. * The reject method of the promise associated with this deferred object.
  69995. */
  69996. get reject(): (reason?: any) => void;
  69997. /**
  69998. * Constructor for this deferred object.
  69999. */
  70000. constructor();
  70001. }
  70002. }
  70003. declare module BABYLON {
  70004. /**
  70005. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70006. */
  70007. export class MeshExploder {
  70008. private _centerMesh;
  70009. private _meshes;
  70010. private _meshesOrigins;
  70011. private _toCenterVectors;
  70012. private _scaledDirection;
  70013. private _newPosition;
  70014. private _centerPosition;
  70015. /**
  70016. * Explodes meshes from a center mesh.
  70017. * @param meshes The meshes to explode.
  70018. * @param centerMesh The mesh to be center of explosion.
  70019. */
  70020. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70021. private _setCenterMesh;
  70022. /**
  70023. * Get class name
  70024. * @returns "MeshExploder"
  70025. */
  70026. getClassName(): string;
  70027. /**
  70028. * "Exploded meshes"
  70029. * @returns Array of meshes with the centerMesh at index 0.
  70030. */
  70031. getMeshes(): Array<Mesh>;
  70032. /**
  70033. * Explodes meshes giving a specific direction
  70034. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70035. */
  70036. explode(direction?: number): void;
  70037. }
  70038. }
  70039. declare module BABYLON {
  70040. /**
  70041. * Class used to help managing file picking and drag'n'drop
  70042. */
  70043. export class FilesInput {
  70044. /**
  70045. * List of files ready to be loaded
  70046. */
  70047. static get FilesToLoad(): {
  70048. [key: string]: File;
  70049. };
  70050. /**
  70051. * Callback called when a file is processed
  70052. */
  70053. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70054. private _engine;
  70055. private _currentScene;
  70056. private _sceneLoadedCallback;
  70057. private _progressCallback;
  70058. private _additionalRenderLoopLogicCallback;
  70059. private _textureLoadingCallback;
  70060. private _startingProcessingFilesCallback;
  70061. private _onReloadCallback;
  70062. private _errorCallback;
  70063. private _elementToMonitor;
  70064. private _sceneFileToLoad;
  70065. private _filesToLoad;
  70066. /**
  70067. * Creates a new FilesInput
  70068. * @param engine defines the rendering engine
  70069. * @param scene defines the hosting scene
  70070. * @param sceneLoadedCallback callback called when scene is loaded
  70071. * @param progressCallback callback called to track progress
  70072. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70073. * @param textureLoadingCallback callback called when a texture is loading
  70074. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70075. * @param onReloadCallback callback called when a reload is requested
  70076. * @param errorCallback callback call if an error occurs
  70077. */
  70078. 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);
  70079. private _dragEnterHandler;
  70080. private _dragOverHandler;
  70081. private _dropHandler;
  70082. /**
  70083. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70084. * @param elementToMonitor defines the DOM element to track
  70085. */
  70086. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70087. /**
  70088. * Release all associated resources
  70089. */
  70090. dispose(): void;
  70091. private renderFunction;
  70092. private drag;
  70093. private drop;
  70094. private _traverseFolder;
  70095. private _processFiles;
  70096. /**
  70097. * Load files from a drop event
  70098. * @param event defines the drop event to use as source
  70099. */
  70100. loadFiles(event: any): void;
  70101. private _processReload;
  70102. /**
  70103. * Reload the current scene from the loaded files
  70104. */
  70105. reload(): void;
  70106. }
  70107. }
  70108. declare module BABYLON {
  70109. /**
  70110. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70112. */
  70113. export class SceneOptimization {
  70114. /**
  70115. * Defines the priority of this optimization (0 by default which means first in the list)
  70116. */
  70117. priority: number;
  70118. /**
  70119. * Gets a string describing the action executed by the current optimization
  70120. * @returns description string
  70121. */
  70122. getDescription(): string;
  70123. /**
  70124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70125. * @param scene defines the current scene where to apply this optimization
  70126. * @param optimizer defines the current optimizer
  70127. * @returns true if everything that can be done was applied
  70128. */
  70129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70130. /**
  70131. * Creates the SceneOptimization object
  70132. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70133. * @param desc defines the description associated with the optimization
  70134. */
  70135. constructor(
  70136. /**
  70137. * Defines the priority of this optimization (0 by default which means first in the list)
  70138. */
  70139. priority?: number);
  70140. }
  70141. /**
  70142. * Defines an optimization used to reduce the size of render target textures
  70143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70144. */
  70145. export class TextureOptimization extends SceneOptimization {
  70146. /**
  70147. * Defines the priority of this optimization (0 by default which means first in the list)
  70148. */
  70149. priority: number;
  70150. /**
  70151. * 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
  70152. */
  70153. maximumSize: number;
  70154. /**
  70155. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70156. */
  70157. step: number;
  70158. /**
  70159. * Gets a string describing the action executed by the current optimization
  70160. * @returns description string
  70161. */
  70162. getDescription(): string;
  70163. /**
  70164. * Creates the TextureOptimization object
  70165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70166. * @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
  70167. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70168. */
  70169. constructor(
  70170. /**
  70171. * Defines the priority of this optimization (0 by default which means first in the list)
  70172. */
  70173. priority?: number,
  70174. /**
  70175. * 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
  70176. */
  70177. maximumSize?: number,
  70178. /**
  70179. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70180. */
  70181. step?: number);
  70182. /**
  70183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70184. * @param scene defines the current scene where to apply this optimization
  70185. * @param optimizer defines the current optimizer
  70186. * @returns true if everything that can be done was applied
  70187. */
  70188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70189. }
  70190. /**
  70191. * Defines an optimization used to increase or decrease the rendering resolution
  70192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70193. */
  70194. export class HardwareScalingOptimization extends SceneOptimization {
  70195. /**
  70196. * Defines the priority of this optimization (0 by default which means first in the list)
  70197. */
  70198. priority: number;
  70199. /**
  70200. * Defines the maximum scale to use (2 by default)
  70201. */
  70202. maximumScale: number;
  70203. /**
  70204. * Defines the step to use between two passes (0.5 by default)
  70205. */
  70206. step: number;
  70207. private _currentScale;
  70208. private _directionOffset;
  70209. /**
  70210. * Gets a string describing the action executed by the current optimization
  70211. * @return description string
  70212. */
  70213. getDescription(): string;
  70214. /**
  70215. * Creates the HardwareScalingOptimization object
  70216. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70217. * @param maximumScale defines the maximum scale to use (2 by default)
  70218. * @param step defines the step to use between two passes (0.5 by default)
  70219. */
  70220. constructor(
  70221. /**
  70222. * Defines the priority of this optimization (0 by default which means first in the list)
  70223. */
  70224. priority?: number,
  70225. /**
  70226. * Defines the maximum scale to use (2 by default)
  70227. */
  70228. maximumScale?: number,
  70229. /**
  70230. * Defines the step to use between two passes (0.5 by default)
  70231. */
  70232. step?: number);
  70233. /**
  70234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70235. * @param scene defines the current scene where to apply this optimization
  70236. * @param optimizer defines the current optimizer
  70237. * @returns true if everything that can be done was applied
  70238. */
  70239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70240. }
  70241. /**
  70242. * Defines an optimization used to remove shadows
  70243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70244. */
  70245. export class ShadowsOptimization extends SceneOptimization {
  70246. /**
  70247. * Gets a string describing the action executed by the current optimization
  70248. * @return description string
  70249. */
  70250. getDescription(): string;
  70251. /**
  70252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70253. * @param scene defines the current scene where to apply this optimization
  70254. * @param optimizer defines the current optimizer
  70255. * @returns true if everything that can be done was applied
  70256. */
  70257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70258. }
  70259. /**
  70260. * Defines an optimization used to turn post-processes off
  70261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70262. */
  70263. export class PostProcessesOptimization extends SceneOptimization {
  70264. /**
  70265. * Gets a string describing the action executed by the current optimization
  70266. * @return description string
  70267. */
  70268. getDescription(): string;
  70269. /**
  70270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70271. * @param scene defines the current scene where to apply this optimization
  70272. * @param optimizer defines the current optimizer
  70273. * @returns true if everything that can be done was applied
  70274. */
  70275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70276. }
  70277. /**
  70278. * Defines an optimization used to turn lens flares off
  70279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70280. */
  70281. export class LensFlaresOptimization extends SceneOptimization {
  70282. /**
  70283. * Gets a string describing the action executed by the current optimization
  70284. * @return description string
  70285. */
  70286. getDescription(): string;
  70287. /**
  70288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70289. * @param scene defines the current scene where to apply this optimization
  70290. * @param optimizer defines the current optimizer
  70291. * @returns true if everything that can be done was applied
  70292. */
  70293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70294. }
  70295. /**
  70296. * Defines an optimization based on user defined callback.
  70297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70298. */
  70299. export class CustomOptimization extends SceneOptimization {
  70300. /**
  70301. * Callback called to apply the custom optimization.
  70302. */
  70303. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70304. /**
  70305. * Callback called to get custom description
  70306. */
  70307. onGetDescription: () => string;
  70308. /**
  70309. * Gets a string describing the action executed by the current optimization
  70310. * @returns description string
  70311. */
  70312. getDescription(): string;
  70313. /**
  70314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70315. * @param scene defines the current scene where to apply this optimization
  70316. * @param optimizer defines the current optimizer
  70317. * @returns true if everything that can be done was applied
  70318. */
  70319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70320. }
  70321. /**
  70322. * Defines an optimization used to turn particles off
  70323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70324. */
  70325. export class ParticlesOptimization extends SceneOptimization {
  70326. /**
  70327. * Gets a string describing the action executed by the current optimization
  70328. * @return description string
  70329. */
  70330. getDescription(): string;
  70331. /**
  70332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70333. * @param scene defines the current scene where to apply this optimization
  70334. * @param optimizer defines the current optimizer
  70335. * @returns true if everything that can be done was applied
  70336. */
  70337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70338. }
  70339. /**
  70340. * Defines an optimization used to turn render targets off
  70341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70342. */
  70343. export class RenderTargetsOptimization extends SceneOptimization {
  70344. /**
  70345. * Gets a string describing the action executed by the current optimization
  70346. * @return description string
  70347. */
  70348. getDescription(): string;
  70349. /**
  70350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70351. * @param scene defines the current scene where to apply this optimization
  70352. * @param optimizer defines the current optimizer
  70353. * @returns true if everything that can be done was applied
  70354. */
  70355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70356. }
  70357. /**
  70358. * Defines an optimization used to merge meshes with compatible materials
  70359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70360. */
  70361. export class MergeMeshesOptimization extends SceneOptimization {
  70362. private static _UpdateSelectionTree;
  70363. /**
  70364. * Gets or sets a boolean which defines if optimization octree has to be updated
  70365. */
  70366. static get UpdateSelectionTree(): boolean;
  70367. /**
  70368. * Gets or sets a boolean which defines if optimization octree has to be updated
  70369. */
  70370. static set UpdateSelectionTree(value: boolean);
  70371. /**
  70372. * Gets a string describing the action executed by the current optimization
  70373. * @return description string
  70374. */
  70375. getDescription(): string;
  70376. private _canBeMerged;
  70377. /**
  70378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70379. * @param scene defines the current scene where to apply this optimization
  70380. * @param optimizer defines the current optimizer
  70381. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70382. * @returns true if everything that can be done was applied
  70383. */
  70384. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70385. }
  70386. /**
  70387. * Defines a list of options used by SceneOptimizer
  70388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70389. */
  70390. export class SceneOptimizerOptions {
  70391. /**
  70392. * Defines the target frame rate to reach (60 by default)
  70393. */
  70394. targetFrameRate: number;
  70395. /**
  70396. * Defines the interval between two checkes (2000ms by default)
  70397. */
  70398. trackerDuration: number;
  70399. /**
  70400. * Gets the list of optimizations to apply
  70401. */
  70402. optimizations: SceneOptimization[];
  70403. /**
  70404. * Creates a new list of options used by SceneOptimizer
  70405. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70406. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70407. */
  70408. constructor(
  70409. /**
  70410. * Defines the target frame rate to reach (60 by default)
  70411. */
  70412. targetFrameRate?: number,
  70413. /**
  70414. * Defines the interval between two checkes (2000ms by default)
  70415. */
  70416. trackerDuration?: number);
  70417. /**
  70418. * Add a new optimization
  70419. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70420. * @returns the current SceneOptimizerOptions
  70421. */
  70422. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70423. /**
  70424. * Add a new custom optimization
  70425. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70426. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70427. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70428. * @returns the current SceneOptimizerOptions
  70429. */
  70430. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70431. /**
  70432. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70433. * @param targetFrameRate defines the target frame rate (60 by default)
  70434. * @returns a SceneOptimizerOptions object
  70435. */
  70436. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70437. /**
  70438. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70439. * @param targetFrameRate defines the target frame rate (60 by default)
  70440. * @returns a SceneOptimizerOptions object
  70441. */
  70442. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70443. /**
  70444. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70445. * @param targetFrameRate defines the target frame rate (60 by default)
  70446. * @returns a SceneOptimizerOptions object
  70447. */
  70448. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70449. }
  70450. /**
  70451. * Class used to run optimizations in order to reach a target frame rate
  70452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70453. */
  70454. export class SceneOptimizer implements IDisposable {
  70455. private _isRunning;
  70456. private _options;
  70457. private _scene;
  70458. private _currentPriorityLevel;
  70459. private _targetFrameRate;
  70460. private _trackerDuration;
  70461. private _currentFrameRate;
  70462. private _sceneDisposeObserver;
  70463. private _improvementMode;
  70464. /**
  70465. * Defines an observable called when the optimizer reaches the target frame rate
  70466. */
  70467. onSuccessObservable: Observable<SceneOptimizer>;
  70468. /**
  70469. * Defines an observable called when the optimizer enables an optimization
  70470. */
  70471. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70472. /**
  70473. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70474. */
  70475. onFailureObservable: Observable<SceneOptimizer>;
  70476. /**
  70477. * Gets a boolean indicating if the optimizer is in improvement mode
  70478. */
  70479. get isInImprovementMode(): boolean;
  70480. /**
  70481. * Gets the current priority level (0 at start)
  70482. */
  70483. get currentPriorityLevel(): number;
  70484. /**
  70485. * Gets the current frame rate checked by the SceneOptimizer
  70486. */
  70487. get currentFrameRate(): number;
  70488. /**
  70489. * Gets or sets the current target frame rate (60 by default)
  70490. */
  70491. get targetFrameRate(): number;
  70492. /**
  70493. * Gets or sets the current target frame rate (60 by default)
  70494. */
  70495. set targetFrameRate(value: number);
  70496. /**
  70497. * Gets or sets the current interval between two checks (every 2000ms by default)
  70498. */
  70499. get trackerDuration(): number;
  70500. /**
  70501. * Gets or sets the current interval between two checks (every 2000ms by default)
  70502. */
  70503. set trackerDuration(value: number);
  70504. /**
  70505. * Gets the list of active optimizations
  70506. */
  70507. get optimizations(): SceneOptimization[];
  70508. /**
  70509. * Creates a new SceneOptimizer
  70510. * @param scene defines the scene to work on
  70511. * @param options defines the options to use with the SceneOptimizer
  70512. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70513. * @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)
  70514. */
  70515. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70516. /**
  70517. * Stops the current optimizer
  70518. */
  70519. stop(): void;
  70520. /**
  70521. * Reset the optimizer to initial step (current priority level = 0)
  70522. */
  70523. reset(): void;
  70524. /**
  70525. * Start the optimizer. By default it will try to reach a specific framerate
  70526. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70527. */
  70528. start(): void;
  70529. private _checkCurrentState;
  70530. /**
  70531. * Release all resources
  70532. */
  70533. dispose(): void;
  70534. /**
  70535. * Helper function to create a SceneOptimizer with one single line of code
  70536. * @param scene defines the scene to work on
  70537. * @param options defines the options to use with the SceneOptimizer
  70538. * @param onSuccess defines a callback to call on success
  70539. * @param onFailure defines a callback to call on failure
  70540. * @returns the new SceneOptimizer object
  70541. */
  70542. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70543. }
  70544. }
  70545. declare module BABYLON {
  70546. /**
  70547. * Class used to serialize a scene into a string
  70548. */
  70549. export class SceneSerializer {
  70550. /**
  70551. * Clear cache used by a previous serialization
  70552. */
  70553. static ClearCache(): void;
  70554. /**
  70555. * Serialize a scene into a JSON compatible object
  70556. * @param scene defines the scene to serialize
  70557. * @returns a JSON compatible object
  70558. */
  70559. static Serialize(scene: Scene): any;
  70560. /**
  70561. * Serialize a mesh into a JSON compatible object
  70562. * @param toSerialize defines the mesh to serialize
  70563. * @param withParents defines if parents must be serialized as well
  70564. * @param withChildren defines if children must be serialized as well
  70565. * @returns a JSON compatible object
  70566. */
  70567. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70568. }
  70569. }
  70570. declare module BABYLON {
  70571. /**
  70572. * Class used to host texture specific utilities
  70573. */
  70574. export class TextureTools {
  70575. /**
  70576. * Uses the GPU to create a copy texture rescaled at a given size
  70577. * @param texture Texture to copy from
  70578. * @param width defines the desired width
  70579. * @param height defines the desired height
  70580. * @param useBilinearMode defines if bilinear mode has to be used
  70581. * @return the generated texture
  70582. */
  70583. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70584. }
  70585. }
  70586. declare module BABYLON {
  70587. /**
  70588. * This represents the different options available for the video capture.
  70589. */
  70590. export interface VideoRecorderOptions {
  70591. /** Defines the mime type of the video. */
  70592. mimeType: string;
  70593. /** Defines the FPS the video should be recorded at. */
  70594. fps: number;
  70595. /** Defines the chunk size for the recording data. */
  70596. recordChunckSize: number;
  70597. /** The audio tracks to attach to the recording. */
  70598. audioTracks?: MediaStreamTrack[];
  70599. }
  70600. /**
  70601. * This can help with recording videos from BabylonJS.
  70602. * This is based on the available WebRTC functionalities of the browser.
  70603. *
  70604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70605. */
  70606. export class VideoRecorder {
  70607. private static readonly _defaultOptions;
  70608. /**
  70609. * Returns whether or not the VideoRecorder is available in your browser.
  70610. * @param engine Defines the Babylon Engine.
  70611. * @returns true if supported otherwise false.
  70612. */
  70613. static IsSupported(engine: Engine): boolean;
  70614. private readonly _options;
  70615. private _canvas;
  70616. private _mediaRecorder;
  70617. private _recordedChunks;
  70618. private _fileName;
  70619. private _resolve;
  70620. private _reject;
  70621. /**
  70622. * True when a recording is already in progress.
  70623. */
  70624. get isRecording(): boolean;
  70625. /**
  70626. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70627. * @param engine Defines the BabylonJS Engine you wish to record.
  70628. * @param options Defines options that can be used to customize the capture.
  70629. */
  70630. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70631. /**
  70632. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70633. */
  70634. stopRecording(): void;
  70635. /**
  70636. * Starts recording the canvas for a max duration specified in parameters.
  70637. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70638. * If null no automatic download will start and you can rely on the promise to get the data back.
  70639. * @param maxDuration Defines the maximum recording time in seconds.
  70640. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70641. * @return A promise callback at the end of the recording with the video data in Blob.
  70642. */
  70643. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70644. /**
  70645. * Releases internal resources used during the recording.
  70646. */
  70647. dispose(): void;
  70648. private _handleDataAvailable;
  70649. private _handleError;
  70650. private _handleStop;
  70651. }
  70652. }
  70653. declare module BABYLON {
  70654. /**
  70655. * Class containing a set of static utilities functions for screenshots
  70656. */
  70657. export class ScreenshotTools {
  70658. /**
  70659. * Captures a screenshot of the current rendering
  70660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70661. * @param engine defines the rendering engine
  70662. * @param camera defines the source camera
  70663. * @param size This parameter can be set to a single number or to an object with the
  70664. * following (optional) properties: precision, width, height. If a single number is passed,
  70665. * it will be used for both width and height. If an object is passed, the screenshot size
  70666. * will be derived from the parameters. The precision property is a multiplier allowing
  70667. * rendering at a higher or lower resolution
  70668. * @param successCallback defines the callback receives a single parameter which contains the
  70669. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70670. * src parameter of an <img> to display it
  70671. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70672. * Check your browser for supported MIME types
  70673. */
  70674. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70675. /**
  70676. * Captures a screenshot of the current rendering
  70677. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70678. * @param engine defines the rendering engine
  70679. * @param camera defines the source camera
  70680. * @param size This parameter can be set to a single number or to an object with the
  70681. * following (optional) properties: precision, width, height. If a single number is passed,
  70682. * it will be used for both width and height. If an object is passed, the screenshot size
  70683. * will be derived from the parameters. The precision property is a multiplier allowing
  70684. * rendering at a higher or lower resolution
  70685. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70686. * Check your browser for supported MIME types
  70687. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70688. * to the src parameter of an <img> to display it
  70689. */
  70690. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70691. /**
  70692. * Generates an image screenshot from the specified camera.
  70693. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70694. * @param engine The engine to use for rendering
  70695. * @param camera The camera to use for rendering
  70696. * @param size This parameter can be set to a single number or to an object with the
  70697. * following (optional) properties: precision, width, height. If a single number is passed,
  70698. * it will be used for both width and height. If an object is passed, the screenshot size
  70699. * will be derived from the parameters. The precision property is a multiplier allowing
  70700. * rendering at a higher or lower resolution
  70701. * @param successCallback The callback receives a single parameter which contains the
  70702. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70703. * src parameter of an <img> to display it
  70704. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70705. * Check your browser for supported MIME types
  70706. * @param samples Texture samples (default: 1)
  70707. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70708. * @param fileName A name for for the downloaded file.
  70709. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70710. */
  70711. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  70712. /**
  70713. * Generates an image screenshot from the specified camera.
  70714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70715. * @param engine The engine to use for rendering
  70716. * @param camera The camera to use for rendering
  70717. * @param size This parameter can be set to a single number or to an object with the
  70718. * following (optional) properties: precision, width, height. If a single number is passed,
  70719. * it will be used for both width and height. If an object is passed, the screenshot size
  70720. * will be derived from the parameters. The precision property is a multiplier allowing
  70721. * rendering at a higher or lower resolution
  70722. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70723. * Check your browser for supported MIME types
  70724. * @param samples Texture samples (default: 1)
  70725. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70726. * @param fileName A name for for the downloaded file.
  70727. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70728. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70729. * to the src parameter of an <img> to display it
  70730. */
  70731. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  70732. /**
  70733. * Gets height and width for screenshot size
  70734. * @private
  70735. */
  70736. private static _getScreenshotSize;
  70737. }
  70738. }
  70739. declare module BABYLON {
  70740. /**
  70741. * Interface for a data buffer
  70742. */
  70743. export interface IDataBuffer {
  70744. /**
  70745. * Reads bytes from the data buffer.
  70746. * @param byteOffset The byte offset to read
  70747. * @param byteLength The byte length to read
  70748. * @returns A promise that resolves when the bytes are read
  70749. */
  70750. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70751. /**
  70752. * The byte length of the buffer.
  70753. */
  70754. readonly byteLength: number;
  70755. }
  70756. /**
  70757. * Utility class for reading from a data buffer
  70758. */
  70759. export class DataReader {
  70760. /**
  70761. * The data buffer associated with this data reader.
  70762. */
  70763. readonly buffer: IDataBuffer;
  70764. /**
  70765. * The current byte offset from the beginning of the data buffer.
  70766. */
  70767. byteOffset: number;
  70768. private _dataView;
  70769. private _dataByteOffset;
  70770. /**
  70771. * Constructor
  70772. * @param buffer The buffer to read
  70773. */
  70774. constructor(buffer: IDataBuffer);
  70775. /**
  70776. * Loads the given byte length.
  70777. * @param byteLength The byte length to load
  70778. * @returns A promise that resolves when the load is complete
  70779. */
  70780. loadAsync(byteLength: number): Promise<void>;
  70781. /**
  70782. * Read a unsigned 32-bit integer from the currently loaded data range.
  70783. * @returns The 32-bit integer read
  70784. */
  70785. readUint32(): number;
  70786. /**
  70787. * Read a byte array from the currently loaded data range.
  70788. * @param byteLength The byte length to read
  70789. * @returns The byte array read
  70790. */
  70791. readUint8Array(byteLength: number): Uint8Array;
  70792. /**
  70793. * Read a string from the currently loaded data range.
  70794. * @param byteLength The byte length to read
  70795. * @returns The string read
  70796. */
  70797. readString(byteLength: number): string;
  70798. /**
  70799. * Skips the given byte length the currently loaded data range.
  70800. * @param byteLength The byte length to skip
  70801. */
  70802. skipBytes(byteLength: number): void;
  70803. }
  70804. }
  70805. declare module BABYLON {
  70806. /**
  70807. * Class for storing data to local storage if available or in-memory storage otherwise
  70808. */
  70809. export class DataStorage {
  70810. private static _Storage;
  70811. private static _GetStorage;
  70812. /**
  70813. * Reads a string from the data storage
  70814. * @param key The key to read
  70815. * @param defaultValue The value if the key doesn't exist
  70816. * @returns The string value
  70817. */
  70818. static ReadString(key: string, defaultValue: string): string;
  70819. /**
  70820. * Writes a string to the data storage
  70821. * @param key The key to write
  70822. * @param value The value to write
  70823. */
  70824. static WriteString(key: string, value: string): void;
  70825. /**
  70826. * Reads a boolean from the data storage
  70827. * @param key The key to read
  70828. * @param defaultValue The value if the key doesn't exist
  70829. * @returns The boolean value
  70830. */
  70831. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  70832. /**
  70833. * Writes a boolean to the data storage
  70834. * @param key The key to write
  70835. * @param value The value to write
  70836. */
  70837. static WriteBoolean(key: string, value: boolean): void;
  70838. /**
  70839. * Reads a number from the data storage
  70840. * @param key The key to read
  70841. * @param defaultValue The value if the key doesn't exist
  70842. * @returns The number value
  70843. */
  70844. static ReadNumber(key: string, defaultValue: number): number;
  70845. /**
  70846. * Writes a number to the data storage
  70847. * @param key The key to write
  70848. * @param value The value to write
  70849. */
  70850. static WriteNumber(key: string, value: number): void;
  70851. }
  70852. }
  70853. declare module BABYLON {
  70854. /**
  70855. * Options used for hit testing
  70856. */
  70857. export interface IWebXRLegacyHitTestOptions {
  70858. /**
  70859. * Only test when user interacted with the scene. Default - hit test every frame
  70860. */
  70861. testOnPointerDownOnly?: boolean;
  70862. /**
  70863. * The node to use to transform the local results to world coordinates
  70864. */
  70865. worldParentNode?: TransformNode;
  70866. }
  70867. /**
  70868. * Interface defining the babylon result of raycasting/hit-test
  70869. */
  70870. export interface IWebXRLegacyHitResult {
  70871. /**
  70872. * Transformation matrix that can be applied to a node that will put it in the hit point location
  70873. */
  70874. transformationMatrix: Matrix;
  70875. /**
  70876. * The native hit test result
  70877. */
  70878. xrHitResult: XRHitResult | XRHitTestResult;
  70879. }
  70880. /**
  70881. * The currently-working hit-test module.
  70882. * Hit test (or Ray-casting) is used to interact with the real world.
  70883. * For further information read here - https://github.com/immersive-web/hit-test
  70884. */
  70885. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  70886. /**
  70887. * options to use when constructing this feature
  70888. */
  70889. readonly options: IWebXRLegacyHitTestOptions;
  70890. private _direction;
  70891. private _mat;
  70892. private _onSelectEnabled;
  70893. private _origin;
  70894. /**
  70895. * The module's name
  70896. */
  70897. static readonly Name: string;
  70898. /**
  70899. * The (Babylon) version of this module.
  70900. * This is an integer representing the implementation version.
  70901. * This number does not correspond to the WebXR specs version
  70902. */
  70903. static readonly Version: number;
  70904. /**
  70905. * Populated with the last native XR Hit Results
  70906. */
  70907. lastNativeXRHitResults: XRHitResult[];
  70908. /**
  70909. * Triggered when new babylon (transformed) hit test results are available
  70910. */
  70911. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  70912. /**
  70913. * Creates a new instance of the (legacy version) hit test feature
  70914. * @param _xrSessionManager an instance of WebXRSessionManager
  70915. * @param options options to use when constructing this feature
  70916. */
  70917. constructor(_xrSessionManager: WebXRSessionManager,
  70918. /**
  70919. * options to use when constructing this feature
  70920. */
  70921. options?: IWebXRLegacyHitTestOptions);
  70922. /**
  70923. * execute a hit test with an XR Ray
  70924. *
  70925. * @param xrSession a native xrSession that will execute this hit test
  70926. * @param xrRay the ray (position and direction) to use for ray-casting
  70927. * @param referenceSpace native XR reference space to use for the hit-test
  70928. * @param filter filter function that will filter the results
  70929. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  70930. */
  70931. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  70932. /**
  70933. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  70934. * @param event the (select) event to use to select with
  70935. * @param referenceSpace the reference space to use for this hit test
  70936. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  70937. */
  70938. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70939. /**
  70940. * attach this feature
  70941. * Will usually be called by the features manager
  70942. *
  70943. * @returns true if successful.
  70944. */
  70945. attach(): boolean;
  70946. /**
  70947. * detach this feature.
  70948. * Will usually be called by the features manager
  70949. *
  70950. * @returns true if successful.
  70951. */
  70952. detach(): boolean;
  70953. /**
  70954. * Dispose this feature and all of the resources attached
  70955. */
  70956. dispose(): void;
  70957. protected _onXRFrame(frame: XRFrame): void;
  70958. private _onHitTestResults;
  70959. private _onSelect;
  70960. }
  70961. }
  70962. declare module BABYLON {
  70963. /**
  70964. * Options used in the plane detector module
  70965. */
  70966. export interface IWebXRPlaneDetectorOptions {
  70967. /**
  70968. * The node to use to transform the local results to world coordinates
  70969. */
  70970. worldParentNode?: TransformNode;
  70971. }
  70972. /**
  70973. * A babylon interface for a WebXR plane.
  70974. * A Plane is actually a polygon, built from N points in space
  70975. *
  70976. * Supported in chrome 79, not supported in canary 81 ATM
  70977. */
  70978. export interface IWebXRPlane {
  70979. /**
  70980. * a babylon-assigned ID for this polygon
  70981. */
  70982. id: number;
  70983. /**
  70984. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  70985. */
  70986. polygonDefinition: Array<Vector3>;
  70987. /**
  70988. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  70989. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  70990. */
  70991. transformationMatrix: Matrix;
  70992. /**
  70993. * the native xr-plane object
  70994. */
  70995. xrPlane: XRPlane;
  70996. }
  70997. /**
  70998. * The plane detector is used to detect planes in the real world when in AR
  70999. * For more information see https://github.com/immersive-web/real-world-geometry/
  71000. */
  71001. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  71002. private _options;
  71003. private _detectedPlanes;
  71004. private _enabled;
  71005. private _lastFrameDetected;
  71006. /**
  71007. * The module's name
  71008. */
  71009. static readonly Name: string;
  71010. /**
  71011. * The (Babylon) version of this module.
  71012. * This is an integer representing the implementation version.
  71013. * This number does not correspond to the WebXR specs version
  71014. */
  71015. static readonly Version: number;
  71016. /**
  71017. * Observers registered here will be executed when a new plane was added to the session
  71018. */
  71019. onPlaneAddedObservable: Observable<IWebXRPlane>;
  71020. /**
  71021. * Observers registered here will be executed when a plane is no longer detected in the session
  71022. */
  71023. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  71024. /**
  71025. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  71026. * This can execute N times every frame
  71027. */
  71028. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  71029. /**
  71030. * construct a new Plane Detector
  71031. * @param _xrSessionManager an instance of xr Session manager
  71032. * @param _options configuration to use when constructing this feature
  71033. */
  71034. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  71035. /**
  71036. * Dispose this feature and all of the resources attached
  71037. */
  71038. dispose(): void;
  71039. protected _onXRFrame(frame: XRFrame): void;
  71040. private _init;
  71041. private _updatePlaneWithXRPlane;
  71042. /**
  71043. * avoiding using Array.find for global support.
  71044. * @param xrPlane the plane to find in the array
  71045. */
  71046. private findIndexInPlaneArray;
  71047. }
  71048. }
  71049. declare module BABYLON {
  71050. /**
  71051. * Configuration options of the anchor system
  71052. */
  71053. export interface IWebXRAnchorSystemOptions {
  71054. /**
  71055. * Should a new anchor be added every time a select event is triggered
  71056. */
  71057. addAnchorOnSelect?: boolean;
  71058. /**
  71059. * should the anchor system use plane detection.
  71060. * If set to true, the plane-detection feature should be set using setPlaneDetector
  71061. */
  71062. usePlaneDetection?: boolean;
  71063. /**
  71064. * a node that will be used to convert local to world coordinates
  71065. */
  71066. worldParentNode?: TransformNode;
  71067. }
  71068. /**
  71069. * A babylon container for an XR Anchor
  71070. */
  71071. export interface IWebXRAnchor {
  71072. /**
  71073. * A babylon-assigned ID for this anchor
  71074. */
  71075. id: number;
  71076. /**
  71077. * Transformation matrix to apply to an object attached to this anchor
  71078. */
  71079. transformationMatrix: Matrix;
  71080. /**
  71081. * The native anchor object
  71082. */
  71083. xrAnchor: XRAnchor;
  71084. }
  71085. /**
  71086. * An implementation of the anchor system of WebXR.
  71087. * Note that the current documented implementation is not available in any browser. Future implementations
  71088. * will use the frame to create an anchor and not the session or a detected plane
  71089. * For further information see https://github.com/immersive-web/anchors/
  71090. */
  71091. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  71092. private _options;
  71093. private _enabled;
  71094. private _hitTestModule;
  71095. private _lastFrameDetected;
  71096. private _onSelect;
  71097. private _planeDetector;
  71098. private _trackedAnchors;
  71099. /**
  71100. * The module's name
  71101. */
  71102. static readonly Name: string;
  71103. /**
  71104. * The (Babylon) version of this module.
  71105. * This is an integer representing the implementation version.
  71106. * This number does not correspond to the WebXR specs version
  71107. */
  71108. static readonly Version: number;
  71109. /**
  71110. * Observers registered here will be executed when a new anchor was added to the session
  71111. */
  71112. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  71113. /**
  71114. * Observers registered here will be executed when an anchor was removed from the session
  71115. */
  71116. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  71117. /**
  71118. * Observers registered here will be executed when an existing anchor updates
  71119. * This can execute N times every frame
  71120. */
  71121. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  71122. /**
  71123. * constructs a new anchor system
  71124. * @param _xrSessionManager an instance of WebXRSessionManager
  71125. * @param _options configuration object for this feature
  71126. */
  71127. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  71128. /**
  71129. * Add anchor at a specific XR point.
  71130. *
  71131. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  71132. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  71133. * @returns a promise the fulfills when the anchor was created
  71134. */
  71135. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  71136. /**
  71137. * attach this feature
  71138. * Will usually be called by the features manager
  71139. *
  71140. * @returns true if successful.
  71141. */
  71142. attach(): boolean;
  71143. /**
  71144. * detach this feature.
  71145. * Will usually be called by the features manager
  71146. *
  71147. * @returns true if successful.
  71148. */
  71149. detach(): boolean;
  71150. /**
  71151. * Dispose this feature and all of the resources attached
  71152. */
  71153. dispose(): void;
  71154. /**
  71155. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  71156. * @param hitTestModule the hit-test module to use.
  71157. */
  71158. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  71159. /**
  71160. * set the plane detector to use in order to create anchors from frames
  71161. * @param planeDetector the plane-detector module to use
  71162. * @param enable enable plane-anchors. default is true
  71163. */
  71164. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  71165. protected _onXRFrame(frame: XRFrame): void;
  71166. /**
  71167. * avoiding using Array.find for global support.
  71168. * @param xrAnchor the plane to find in the array
  71169. */
  71170. private _findIndexInAnchorArray;
  71171. private _updateAnchorWithXRFrame;
  71172. }
  71173. }
  71174. declare module BABYLON {
  71175. /**
  71176. * Options interface for the background remover plugin
  71177. */
  71178. export interface IWebXRBackgroundRemoverOptions {
  71179. /**
  71180. * Further background meshes to disable when entering AR
  71181. */
  71182. backgroundMeshes?: AbstractMesh[];
  71183. /**
  71184. * flags to configure the removal of the environment helper.
  71185. * If not set, the entire background will be removed. If set, flags should be set as well.
  71186. */
  71187. environmentHelperRemovalFlags?: {
  71188. /**
  71189. * Should the skybox be removed (default false)
  71190. */
  71191. skyBox?: boolean;
  71192. /**
  71193. * Should the ground be removed (default false)
  71194. */
  71195. ground?: boolean;
  71196. };
  71197. /**
  71198. * don't disable the environment helper
  71199. */
  71200. ignoreEnvironmentHelper?: boolean;
  71201. }
  71202. /**
  71203. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  71204. */
  71205. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  71206. /**
  71207. * read-only options to be used in this module
  71208. */
  71209. readonly options: IWebXRBackgroundRemoverOptions;
  71210. /**
  71211. * The module's name
  71212. */
  71213. static readonly Name: string;
  71214. /**
  71215. * The (Babylon) version of this module.
  71216. * This is an integer representing the implementation version.
  71217. * This number does not correspond to the WebXR specs version
  71218. */
  71219. static readonly Version: number;
  71220. /**
  71221. * registered observers will be triggered when the background state changes
  71222. */
  71223. onBackgroundStateChangedObservable: Observable<boolean>;
  71224. /**
  71225. * constructs a new background remover module
  71226. * @param _xrSessionManager the session manager for this module
  71227. * @param options read-only options to be used in this module
  71228. */
  71229. constructor(_xrSessionManager: WebXRSessionManager,
  71230. /**
  71231. * read-only options to be used in this module
  71232. */
  71233. options?: IWebXRBackgroundRemoverOptions);
  71234. /**
  71235. * attach this feature
  71236. * Will usually be called by the features manager
  71237. *
  71238. * @returns true if successful.
  71239. */
  71240. attach(): boolean;
  71241. /**
  71242. * detach this feature.
  71243. * Will usually be called by the features manager
  71244. *
  71245. * @returns true if successful.
  71246. */
  71247. detach(): boolean;
  71248. /**
  71249. * Dispose this feature and all of the resources attached
  71250. */
  71251. dispose(): void;
  71252. protected _onXRFrame(_xrFrame: XRFrame): void;
  71253. private _setBackgroundState;
  71254. }
  71255. }
  71256. declare module BABYLON {
  71257. /**
  71258. * Options for the controller physics feature
  71259. */
  71260. export class IWebXRControllerPhysicsOptions {
  71261. /**
  71262. * Should the headset get its own impostor
  71263. */
  71264. enableHeadsetImpostor?: boolean;
  71265. /**
  71266. * Optional parameters for the headset impostor
  71267. */
  71268. headsetImpostorParams?: {
  71269. /**
  71270. * The type of impostor to create. Default is sphere
  71271. */
  71272. impostorType: number;
  71273. /**
  71274. * the size of the impostor. Defaults to 10cm
  71275. */
  71276. impostorSize?: number | {
  71277. width: number;
  71278. height: number;
  71279. depth: number;
  71280. };
  71281. /**
  71282. * Friction definitions
  71283. */
  71284. friction?: number;
  71285. /**
  71286. * Restitution
  71287. */
  71288. restitution?: number;
  71289. };
  71290. /**
  71291. * The physics properties of the future impostors
  71292. */
  71293. physicsProperties?: {
  71294. /**
  71295. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  71296. * Note that this requires a physics engine that supports mesh impostors!
  71297. */
  71298. useControllerMesh?: boolean;
  71299. /**
  71300. * The type of impostor to create. Default is sphere
  71301. */
  71302. impostorType?: number;
  71303. /**
  71304. * the size of the impostor. Defaults to 10cm
  71305. */
  71306. impostorSize?: number | {
  71307. width: number;
  71308. height: number;
  71309. depth: number;
  71310. };
  71311. /**
  71312. * Friction definitions
  71313. */
  71314. friction?: number;
  71315. /**
  71316. * Restitution
  71317. */
  71318. restitution?: number;
  71319. };
  71320. /**
  71321. * the xr input to use with this pointer selection
  71322. */
  71323. xrInput: WebXRInput;
  71324. }
  71325. /**
  71326. * Add physics impostor to your webxr controllers,
  71327. * including naive calculation of their linear and angular velocity
  71328. */
  71329. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  71330. private readonly _options;
  71331. private _attachController;
  71332. private _controllers;
  71333. private _debugMode;
  71334. private _delta;
  71335. private _headsetImpostor?;
  71336. private _headsetMesh?;
  71337. private _lastTimestamp;
  71338. private _tmpQuaternion;
  71339. private _tmpVector;
  71340. /**
  71341. * The module's name
  71342. */
  71343. static readonly Name: string;
  71344. /**
  71345. * The (Babylon) version of this module.
  71346. * This is an integer representing the implementation version.
  71347. * This number does not correspond to the webxr specs version
  71348. */
  71349. static readonly Version: number;
  71350. /**
  71351. * Construct a new Controller Physics Feature
  71352. * @param _xrSessionManager the corresponding xr session manager
  71353. * @param _options options to create this feature with
  71354. */
  71355. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  71356. /**
  71357. * @hidden
  71358. * enable debugging - will show console outputs and the impostor mesh
  71359. */
  71360. _enablePhysicsDebug(): void;
  71361. /**
  71362. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  71363. * @param xrController the controller to add
  71364. */
  71365. addController(xrController: WebXRInputSource): void;
  71366. /**
  71367. * attach this feature
  71368. * Will usually be called by the features manager
  71369. *
  71370. * @returns true if successful.
  71371. */
  71372. attach(): boolean;
  71373. /**
  71374. * detach this feature.
  71375. * Will usually be called by the features manager
  71376. *
  71377. * @returns true if successful.
  71378. */
  71379. detach(): boolean;
  71380. /**
  71381. * Get the headset impostor, if enabled
  71382. * @returns the impostor
  71383. */
  71384. getHeadsetImpostor(): PhysicsImpostor | undefined;
  71385. /**
  71386. * Get the physics impostor of a specific controller.
  71387. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  71388. * @param controller the controller or the controller id of which to get the impostor
  71389. * @returns the impostor or null
  71390. */
  71391. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  71392. /**
  71393. * Update the physics properties provided in the constructor
  71394. * @param newProperties the new properties object
  71395. */
  71396. setPhysicsProperties(newProperties: {
  71397. impostorType?: number;
  71398. impostorSize?: number | {
  71399. width: number;
  71400. height: number;
  71401. depth: number;
  71402. };
  71403. friction?: number;
  71404. restitution?: number;
  71405. }): void;
  71406. protected _onXRFrame(_xrFrame: any): void;
  71407. private _detachController;
  71408. }
  71409. }
  71410. declare module BABYLON {
  71411. /**
  71412. * Options used for hit testing (version 2)
  71413. */
  71414. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  71415. /**
  71416. * Do not create a permanent hit test. Will usually be used when only
  71417. * transient inputs are needed.
  71418. */
  71419. disablePermanentHitTest?: boolean;
  71420. /**
  71421. * Enable transient (for example touch-based) hit test inspections
  71422. */
  71423. enableTransientHitTest?: boolean;
  71424. /**
  71425. * Offset ray for the permanent hit test
  71426. */
  71427. offsetRay?: Vector3;
  71428. /**
  71429. * Offset ray for the transient hit test
  71430. */
  71431. transientOffsetRay?: Vector3;
  71432. /**
  71433. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  71434. */
  71435. useReferenceSpace?: boolean;
  71436. }
  71437. /**
  71438. * Interface defining the babylon result of hit-test
  71439. */
  71440. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  71441. /**
  71442. * The input source that generated this hit test (if transient)
  71443. */
  71444. inputSource?: XRInputSource;
  71445. /**
  71446. * Is this a transient hit test
  71447. */
  71448. isTransient?: boolean;
  71449. /**
  71450. * Position of the hit test result
  71451. */
  71452. position: Vector3;
  71453. /**
  71454. * Rotation of the hit test result
  71455. */
  71456. rotationQuaternion: Quaternion;
  71457. }
  71458. /**
  71459. * The currently-working hit-test module.
  71460. * Hit test (or Ray-casting) is used to interact with the real world.
  71461. * For further information read here - https://github.com/immersive-web/hit-test
  71462. *
  71463. * Tested on chrome (mobile) 80.
  71464. */
  71465. export class WebXRHitTest extends WebXRAbstractFeature {
  71466. /**
  71467. * options to use when constructing this feature
  71468. */
  71469. readonly options: IWebXRHitTestOptions;
  71470. private _tmpMat;
  71471. private _tmpPos;
  71472. private _tmpQuat;
  71473. private _transientXrHitTestSource;
  71474. private _xrHitTestSource;
  71475. private initHitTestSource;
  71476. /**
  71477. * The module's name
  71478. */
  71479. static readonly Name: string;
  71480. /**
  71481. * The (Babylon) version of this module.
  71482. * This is an integer representing the implementation version.
  71483. * This number does not correspond to the WebXR specs version
  71484. */
  71485. static readonly Version: number;
  71486. /**
  71487. * When set to true, each hit test will have its own position/rotation objects
  71488. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  71489. * the developers will clone them or copy them as they see fit.
  71490. */
  71491. autoCloneTransformation: boolean;
  71492. /**
  71493. * Populated with the last native XR Hit Results
  71494. */
  71495. lastNativeXRHitResults: XRHitResult[];
  71496. /**
  71497. * Triggered when new babylon (transformed) hit test results are available
  71498. */
  71499. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  71500. /**
  71501. * Use this to temporarily pause hit test checks.
  71502. */
  71503. paused: boolean;
  71504. /**
  71505. * Creates a new instance of the hit test feature
  71506. * @param _xrSessionManager an instance of WebXRSessionManager
  71507. * @param options options to use when constructing this feature
  71508. */
  71509. constructor(_xrSessionManager: WebXRSessionManager,
  71510. /**
  71511. * options to use when constructing this feature
  71512. */
  71513. options?: IWebXRHitTestOptions);
  71514. /**
  71515. * attach this feature
  71516. * Will usually be called by the features manager
  71517. *
  71518. * @returns true if successful.
  71519. */
  71520. attach(): boolean;
  71521. /**
  71522. * detach this feature.
  71523. * Will usually be called by the features manager
  71524. *
  71525. * @returns true if successful.
  71526. */
  71527. detach(): boolean;
  71528. /**
  71529. * Dispose this feature and all of the resources attached
  71530. */
  71531. dispose(): void;
  71532. protected _onXRFrame(frame: XRFrame): void;
  71533. private _processWebXRHitTestResult;
  71534. }
  71535. }
  71536. declare module BABYLON {
  71537. /**
  71538. * The motion controller class for all microsoft mixed reality controllers
  71539. */
  71540. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  71541. protected readonly _mapping: {
  71542. defaultButton: {
  71543. valueNodeName: string;
  71544. unpressedNodeName: string;
  71545. pressedNodeName: string;
  71546. };
  71547. defaultAxis: {
  71548. valueNodeName: string;
  71549. minNodeName: string;
  71550. maxNodeName: string;
  71551. };
  71552. buttons: {
  71553. "xr-standard-trigger": {
  71554. rootNodeName: string;
  71555. componentProperty: string;
  71556. states: string[];
  71557. };
  71558. "xr-standard-squeeze": {
  71559. rootNodeName: string;
  71560. componentProperty: string;
  71561. states: string[];
  71562. };
  71563. "xr-standard-touchpad": {
  71564. rootNodeName: string;
  71565. labelAnchorNodeName: string;
  71566. touchPointNodeName: string;
  71567. };
  71568. "xr-standard-thumbstick": {
  71569. rootNodeName: string;
  71570. componentProperty: string;
  71571. states: string[];
  71572. };
  71573. };
  71574. axes: {
  71575. "xr-standard-touchpad": {
  71576. "x-axis": {
  71577. rootNodeName: string;
  71578. };
  71579. "y-axis": {
  71580. rootNodeName: string;
  71581. };
  71582. };
  71583. "xr-standard-thumbstick": {
  71584. "x-axis": {
  71585. rootNodeName: string;
  71586. };
  71587. "y-axis": {
  71588. rootNodeName: string;
  71589. };
  71590. };
  71591. };
  71592. };
  71593. /**
  71594. * The base url used to load the left and right controller models
  71595. */
  71596. static MODEL_BASE_URL: string;
  71597. /**
  71598. * The name of the left controller model file
  71599. */
  71600. static MODEL_LEFT_FILENAME: string;
  71601. /**
  71602. * The name of the right controller model file
  71603. */
  71604. static MODEL_RIGHT_FILENAME: string;
  71605. profileId: string;
  71606. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71607. protected _getFilenameAndPath(): {
  71608. filename: string;
  71609. path: string;
  71610. };
  71611. protected _getModelLoadingConstraints(): boolean;
  71612. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71613. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71614. protected _updateModel(): void;
  71615. }
  71616. }
  71617. declare module BABYLON {
  71618. /**
  71619. * The motion controller class for oculus touch (quest, rift).
  71620. * This class supports legacy mapping as well the standard xr mapping
  71621. */
  71622. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  71623. private _forceLegacyControllers;
  71624. private _modelRootNode;
  71625. /**
  71626. * The base url used to load the left and right controller models
  71627. */
  71628. static MODEL_BASE_URL: string;
  71629. /**
  71630. * The name of the left controller model file
  71631. */
  71632. static MODEL_LEFT_FILENAME: string;
  71633. /**
  71634. * The name of the right controller model file
  71635. */
  71636. static MODEL_RIGHT_FILENAME: string;
  71637. /**
  71638. * Base Url for the Quest controller model.
  71639. */
  71640. static QUEST_MODEL_BASE_URL: string;
  71641. profileId: string;
  71642. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  71643. protected _getFilenameAndPath(): {
  71644. filename: string;
  71645. path: string;
  71646. };
  71647. protected _getModelLoadingConstraints(): boolean;
  71648. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71649. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71650. protected _updateModel(): void;
  71651. /**
  71652. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  71653. * between the touch and touch 2.
  71654. */
  71655. private _isQuest;
  71656. }
  71657. }
  71658. declare module BABYLON {
  71659. /**
  71660. * The motion controller class for the standard HTC-Vive controllers
  71661. */
  71662. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  71663. private _modelRootNode;
  71664. /**
  71665. * The base url used to load the left and right controller models
  71666. */
  71667. static MODEL_BASE_URL: string;
  71668. /**
  71669. * File name for the controller model.
  71670. */
  71671. static MODEL_FILENAME: string;
  71672. profileId: string;
  71673. /**
  71674. * Create a new Vive motion controller object
  71675. * @param scene the scene to use to create this controller
  71676. * @param gamepadObject the corresponding gamepad object
  71677. * @param handedness the handedness of the controller
  71678. */
  71679. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71680. protected _getFilenameAndPath(): {
  71681. filename: string;
  71682. path: string;
  71683. };
  71684. protected _getModelLoadingConstraints(): boolean;
  71685. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71686. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71687. protected _updateModel(): void;
  71688. }
  71689. }
  71690. declare module BABYLON {
  71691. /**
  71692. * A cursor which tracks a point on a path
  71693. */
  71694. export class PathCursor {
  71695. private path;
  71696. /**
  71697. * Stores path cursor callbacks for when an onchange event is triggered
  71698. */
  71699. private _onchange;
  71700. /**
  71701. * The value of the path cursor
  71702. */
  71703. value: number;
  71704. /**
  71705. * The animation array of the path cursor
  71706. */
  71707. animations: Animation[];
  71708. /**
  71709. * Initializes the path cursor
  71710. * @param path The path to track
  71711. */
  71712. constructor(path: Path2);
  71713. /**
  71714. * Gets the cursor point on the path
  71715. * @returns A point on the path cursor at the cursor location
  71716. */
  71717. getPoint(): Vector3;
  71718. /**
  71719. * Moves the cursor ahead by the step amount
  71720. * @param step The amount to move the cursor forward
  71721. * @returns This path cursor
  71722. */
  71723. moveAhead(step?: number): PathCursor;
  71724. /**
  71725. * Moves the cursor behind by the step amount
  71726. * @param step The amount to move the cursor back
  71727. * @returns This path cursor
  71728. */
  71729. moveBack(step?: number): PathCursor;
  71730. /**
  71731. * Moves the cursor by the step amount
  71732. * If the step amount is greater than one, an exception is thrown
  71733. * @param step The amount to move the cursor
  71734. * @returns This path cursor
  71735. */
  71736. move(step: number): PathCursor;
  71737. /**
  71738. * Ensures that the value is limited between zero and one
  71739. * @returns This path cursor
  71740. */
  71741. private ensureLimits;
  71742. /**
  71743. * Runs onchange callbacks on change (used by the animation engine)
  71744. * @returns This path cursor
  71745. */
  71746. private raiseOnChange;
  71747. /**
  71748. * Executes a function on change
  71749. * @param f A path cursor onchange callback
  71750. * @returns This path cursor
  71751. */
  71752. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71753. }
  71754. }
  71755. declare module BABYLON {
  71756. /** @hidden */
  71757. export var blurPixelShader: {
  71758. name: string;
  71759. shader: string;
  71760. };
  71761. }
  71762. declare module BABYLON {
  71763. /** @hidden */
  71764. export var pointCloudVertexDeclaration: {
  71765. name: string;
  71766. shader: string;
  71767. };
  71768. }
  71769. // Mixins
  71770. interface Window {
  71771. mozIndexedDB: IDBFactory;
  71772. webkitIndexedDB: IDBFactory;
  71773. msIndexedDB: IDBFactory;
  71774. webkitURL: typeof URL;
  71775. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  71776. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  71777. WebGLRenderingContext: WebGLRenderingContext;
  71778. MSGesture: MSGesture;
  71779. CANNON: any;
  71780. AudioContext: AudioContext;
  71781. webkitAudioContext: AudioContext;
  71782. PointerEvent: any;
  71783. Math: Math;
  71784. Uint8Array: Uint8ArrayConstructor;
  71785. Float32Array: Float32ArrayConstructor;
  71786. mozURL: typeof URL;
  71787. msURL: typeof URL;
  71788. VRFrameData: any; // WebVR, from specs 1.1
  71789. DracoDecoderModule: any;
  71790. setImmediate(handler: (...args: any[]) => void): number;
  71791. }
  71792. interface HTMLCanvasElement {
  71793. requestPointerLock(): void;
  71794. msRequestPointerLock?(): void;
  71795. mozRequestPointerLock?(): void;
  71796. webkitRequestPointerLock?(): void;
  71797. /** Track wether a record is in progress */
  71798. isRecording: boolean;
  71799. /** Capture Stream method defined by some browsers */
  71800. captureStream(fps?: number): MediaStream;
  71801. }
  71802. interface CanvasRenderingContext2D {
  71803. msImageSmoothingEnabled: boolean;
  71804. }
  71805. interface MouseEvent {
  71806. mozMovementX: number;
  71807. mozMovementY: number;
  71808. webkitMovementX: number;
  71809. webkitMovementY: number;
  71810. msMovementX: number;
  71811. msMovementY: number;
  71812. }
  71813. interface Navigator {
  71814. mozGetVRDevices: (any: any) => any;
  71815. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71816. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71817. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71818. webkitGetGamepads(): Gamepad[];
  71819. msGetGamepads(): Gamepad[];
  71820. webkitGamepads(): Gamepad[];
  71821. }
  71822. interface HTMLVideoElement {
  71823. mozSrcObject: any;
  71824. }
  71825. interface Math {
  71826. fround(x: number): number;
  71827. imul(a: number, b: number): number;
  71828. }
  71829. interface WebGLRenderingContext {
  71830. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  71831. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  71832. vertexAttribDivisor(index: number, divisor: number): void;
  71833. createVertexArray(): any;
  71834. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  71835. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  71836. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  71837. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  71838. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  71839. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  71840. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  71841. // Queries
  71842. createQuery(): WebGLQuery;
  71843. deleteQuery(query: WebGLQuery): void;
  71844. beginQuery(target: number, query: WebGLQuery): void;
  71845. endQuery(target: number): void;
  71846. getQueryParameter(query: WebGLQuery, pname: number): any;
  71847. getQuery(target: number, pname: number): any;
  71848. MAX_SAMPLES: number;
  71849. RGBA8: number;
  71850. READ_FRAMEBUFFER: number;
  71851. DRAW_FRAMEBUFFER: number;
  71852. UNIFORM_BUFFER: number;
  71853. HALF_FLOAT_OES: number;
  71854. RGBA16F: number;
  71855. RGBA32F: number;
  71856. R32F: number;
  71857. RG32F: number;
  71858. RGB32F: number;
  71859. R16F: number;
  71860. RG16F: number;
  71861. RGB16F: number;
  71862. RED: number;
  71863. RG: number;
  71864. R8: number;
  71865. RG8: number;
  71866. UNSIGNED_INT_24_8: number;
  71867. DEPTH24_STENCIL8: number;
  71868. MIN: number;
  71869. MAX: number;
  71870. /* Multiple Render Targets */
  71871. drawBuffers(buffers: number[]): void;
  71872. readBuffer(src: number): void;
  71873. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  71874. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  71875. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  71876. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  71877. // Occlusion Query
  71878. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  71879. ANY_SAMPLES_PASSED: number;
  71880. QUERY_RESULT_AVAILABLE: number;
  71881. QUERY_RESULT: number;
  71882. }
  71883. interface WebGLProgram {
  71884. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  71885. }
  71886. interface EXT_disjoint_timer_query {
  71887. QUERY_COUNTER_BITS_EXT: number;
  71888. TIME_ELAPSED_EXT: number;
  71889. TIMESTAMP_EXT: number;
  71890. GPU_DISJOINT_EXT: number;
  71891. QUERY_RESULT_EXT: number;
  71892. QUERY_RESULT_AVAILABLE_EXT: number;
  71893. queryCounterEXT(query: WebGLQuery, target: number): void;
  71894. createQueryEXT(): WebGLQuery;
  71895. beginQueryEXT(target: number, query: WebGLQuery): void;
  71896. endQueryEXT(target: number): void;
  71897. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  71898. deleteQueryEXT(query: WebGLQuery): void;
  71899. }
  71900. interface WebGLUniformLocation {
  71901. _currentState: any;
  71902. }
  71903. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  71904. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  71905. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  71906. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  71907. interface WebGLRenderingContext {
  71908. readonly RASTERIZER_DISCARD: number;
  71909. readonly DEPTH_COMPONENT24: number;
  71910. readonly TEXTURE_3D: number;
  71911. readonly TEXTURE_2D_ARRAY: number;
  71912. readonly TEXTURE_COMPARE_FUNC: number;
  71913. readonly TEXTURE_COMPARE_MODE: number;
  71914. readonly COMPARE_REF_TO_TEXTURE: number;
  71915. readonly TEXTURE_WRAP_R: number;
  71916. readonly HALF_FLOAT: number;
  71917. readonly RGB8: number;
  71918. readonly RED_INTEGER: number;
  71919. readonly RG_INTEGER: number;
  71920. readonly RGB_INTEGER: number;
  71921. readonly RGBA_INTEGER: number;
  71922. readonly R8_SNORM: number;
  71923. readonly RG8_SNORM: number;
  71924. readonly RGB8_SNORM: number;
  71925. readonly RGBA8_SNORM: number;
  71926. readonly R8I: number;
  71927. readonly RG8I: number;
  71928. readonly RGB8I: number;
  71929. readonly RGBA8I: number;
  71930. readonly R8UI: number;
  71931. readonly RG8UI: number;
  71932. readonly RGB8UI: number;
  71933. readonly RGBA8UI: number;
  71934. readonly R16I: number;
  71935. readonly RG16I: number;
  71936. readonly RGB16I: number;
  71937. readonly RGBA16I: number;
  71938. readonly R16UI: number;
  71939. readonly RG16UI: number;
  71940. readonly RGB16UI: number;
  71941. readonly RGBA16UI: number;
  71942. readonly R32I: number;
  71943. readonly RG32I: number;
  71944. readonly RGB32I: number;
  71945. readonly RGBA32I: number;
  71946. readonly R32UI: number;
  71947. readonly RG32UI: number;
  71948. readonly RGB32UI: number;
  71949. readonly RGBA32UI: number;
  71950. readonly RGB10_A2UI: number;
  71951. readonly R11F_G11F_B10F: number;
  71952. readonly RGB9_E5: number;
  71953. readonly RGB10_A2: number;
  71954. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  71955. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  71956. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  71957. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71958. readonly DEPTH_COMPONENT32F: number;
  71959. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  71960. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  71961. 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;
  71962. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  71963. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  71964. readonly TRANSFORM_FEEDBACK: number;
  71965. readonly INTERLEAVED_ATTRIBS: number;
  71966. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  71967. createTransformFeedback(): WebGLTransformFeedback;
  71968. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  71969. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  71970. beginTransformFeedback(primitiveMode: number): void;
  71971. endTransformFeedback(): void;
  71972. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  71973. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  71974. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  71975. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  71976. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  71977. }
  71978. interface ImageBitmap {
  71979. readonly width: number;
  71980. readonly height: number;
  71981. close(): void;
  71982. }
  71983. interface WebGLQuery extends WebGLObject {
  71984. }
  71985. declare var WebGLQuery: {
  71986. prototype: WebGLQuery;
  71987. new(): WebGLQuery;
  71988. };
  71989. interface WebGLSampler extends WebGLObject {
  71990. }
  71991. declare var WebGLSampler: {
  71992. prototype: WebGLSampler;
  71993. new(): WebGLSampler;
  71994. };
  71995. interface WebGLSync extends WebGLObject {
  71996. }
  71997. declare var WebGLSync: {
  71998. prototype: WebGLSync;
  71999. new(): WebGLSync;
  72000. };
  72001. interface WebGLTransformFeedback extends WebGLObject {
  72002. }
  72003. declare var WebGLTransformFeedback: {
  72004. prototype: WebGLTransformFeedback;
  72005. new(): WebGLTransformFeedback;
  72006. };
  72007. interface WebGLVertexArrayObject extends WebGLObject {
  72008. }
  72009. declare var WebGLVertexArrayObject: {
  72010. prototype: WebGLVertexArrayObject;
  72011. new(): WebGLVertexArrayObject;
  72012. };
  72013. // Type definitions for WebVR API
  72014. // Project: https://w3c.github.io/webvr/
  72015. // Definitions by: six a <https://github.com/lostfictions>
  72016. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72017. interface VRDisplay extends EventTarget {
  72018. /**
  72019. * Dictionary of capabilities describing the VRDisplay.
  72020. */
  72021. readonly capabilities: VRDisplayCapabilities;
  72022. /**
  72023. * z-depth defining the far plane of the eye view frustum
  72024. * enables mapping of values in the render target depth
  72025. * attachment to scene coordinates. Initially set to 10000.0.
  72026. */
  72027. depthFar: number;
  72028. /**
  72029. * z-depth defining the near plane of the eye view frustum
  72030. * enables mapping of values in the render target depth
  72031. * attachment to scene coordinates. Initially set to 0.01.
  72032. */
  72033. depthNear: number;
  72034. /**
  72035. * An identifier for this distinct VRDisplay. Used as an
  72036. * association point in the Gamepad API.
  72037. */
  72038. readonly displayId: number;
  72039. /**
  72040. * A display name, a user-readable name identifying it.
  72041. */
  72042. readonly displayName: string;
  72043. readonly isConnected: boolean;
  72044. readonly isPresenting: boolean;
  72045. /**
  72046. * If this VRDisplay supports room-scale experiences, the optional
  72047. * stage attribute contains details on the room-scale parameters.
  72048. */
  72049. readonly stageParameters: VRStageParameters | null;
  72050. /**
  72051. * Passing the value returned by `requestAnimationFrame` to
  72052. * `cancelAnimationFrame` will unregister the callback.
  72053. * @param handle Define the hanle of the request to cancel
  72054. */
  72055. cancelAnimationFrame(handle: number): void;
  72056. /**
  72057. * Stops presenting to the VRDisplay.
  72058. * @returns a promise to know when it stopped
  72059. */
  72060. exitPresent(): Promise<void>;
  72061. /**
  72062. * Return the current VREyeParameters for the given eye.
  72063. * @param whichEye Define the eye we want the parameter for
  72064. * @returns the eye parameters
  72065. */
  72066. getEyeParameters(whichEye: string): VREyeParameters;
  72067. /**
  72068. * Populates the passed VRFrameData with the information required to render
  72069. * the current frame.
  72070. * @param frameData Define the data structure to populate
  72071. * @returns true if ok otherwise false
  72072. */
  72073. getFrameData(frameData: VRFrameData): boolean;
  72074. /**
  72075. * Get the layers currently being presented.
  72076. * @returns the list of VR layers
  72077. */
  72078. getLayers(): VRLayer[];
  72079. /**
  72080. * Return a VRPose containing the future predicted pose of the VRDisplay
  72081. * when the current frame will be presented. The value returned will not
  72082. * change until JavaScript has returned control to the browser.
  72083. *
  72084. * The VRPose will contain the position, orientation, velocity,
  72085. * and acceleration of each of these properties.
  72086. * @returns the pose object
  72087. */
  72088. getPose(): VRPose;
  72089. /**
  72090. * Return the current instantaneous pose of the VRDisplay, with no
  72091. * prediction applied.
  72092. * @returns the current instantaneous pose
  72093. */
  72094. getImmediatePose(): VRPose;
  72095. /**
  72096. * The callback passed to `requestAnimationFrame` will be called
  72097. * any time a new frame should be rendered. When the VRDisplay is
  72098. * presenting the callback will be called at the native refresh
  72099. * rate of the HMD. When not presenting this function acts
  72100. * identically to how window.requestAnimationFrame acts. Content should
  72101. * make no assumptions of frame rate or vsync behavior as the HMD runs
  72102. * asynchronously from other displays and at differing refresh rates.
  72103. * @param callback Define the eaction to run next frame
  72104. * @returns the request handle it
  72105. */
  72106. requestAnimationFrame(callback: FrameRequestCallback): number;
  72107. /**
  72108. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  72109. * Repeat calls while already presenting will update the VRLayers being displayed.
  72110. * @param layers Define the list of layer to present
  72111. * @returns a promise to know when the request has been fulfilled
  72112. */
  72113. requestPresent(layers: VRLayer[]): Promise<void>;
  72114. /**
  72115. * Reset the pose for this display, treating its current position and
  72116. * orientation as the "origin/zero" values. VRPose.position,
  72117. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  72118. * updated when calling resetPose(). This should be called in only
  72119. * sitting-space experiences.
  72120. */
  72121. resetPose(): void;
  72122. /**
  72123. * The VRLayer provided to the VRDisplay will be captured and presented
  72124. * in the HMD. Calling this function has the same effect on the source
  72125. * canvas as any other operation that uses its source image, and canvases
  72126. * created without preserveDrawingBuffer set to true will be cleared.
  72127. * @param pose Define the pose to submit
  72128. */
  72129. submitFrame(pose?: VRPose): void;
  72130. }
  72131. declare var VRDisplay: {
  72132. prototype: VRDisplay;
  72133. new(): VRDisplay;
  72134. };
  72135. interface VRLayer {
  72136. leftBounds?: number[] | Float32Array | null;
  72137. rightBounds?: number[] | Float32Array | null;
  72138. source?: HTMLCanvasElement | null;
  72139. }
  72140. interface VRDisplayCapabilities {
  72141. readonly canPresent: boolean;
  72142. readonly hasExternalDisplay: boolean;
  72143. readonly hasOrientation: boolean;
  72144. readonly hasPosition: boolean;
  72145. readonly maxLayers: number;
  72146. }
  72147. interface VREyeParameters {
  72148. /** @deprecated */
  72149. readonly fieldOfView: VRFieldOfView;
  72150. readonly offset: Float32Array;
  72151. readonly renderHeight: number;
  72152. readonly renderWidth: number;
  72153. }
  72154. interface VRFieldOfView {
  72155. readonly downDegrees: number;
  72156. readonly leftDegrees: number;
  72157. readonly rightDegrees: number;
  72158. readonly upDegrees: number;
  72159. }
  72160. interface VRFrameData {
  72161. readonly leftProjectionMatrix: Float32Array;
  72162. readonly leftViewMatrix: Float32Array;
  72163. readonly pose: VRPose;
  72164. readonly rightProjectionMatrix: Float32Array;
  72165. readonly rightViewMatrix: Float32Array;
  72166. readonly timestamp: number;
  72167. }
  72168. interface VRPose {
  72169. readonly angularAcceleration: Float32Array | null;
  72170. readonly angularVelocity: Float32Array | null;
  72171. readonly linearAcceleration: Float32Array | null;
  72172. readonly linearVelocity: Float32Array | null;
  72173. readonly orientation: Float32Array | null;
  72174. readonly position: Float32Array | null;
  72175. readonly timestamp: number;
  72176. }
  72177. interface VRStageParameters {
  72178. sittingToStandingTransform?: Float32Array;
  72179. sizeX?: number;
  72180. sizeY?: number;
  72181. }
  72182. interface Navigator {
  72183. getVRDisplays(): Promise<VRDisplay[]>;
  72184. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  72185. }
  72186. interface Window {
  72187. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  72188. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  72189. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  72190. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72191. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72192. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  72193. }
  72194. interface Gamepad {
  72195. readonly displayId: number;
  72196. }
  72197. type XRSessionMode =
  72198. | "inline"
  72199. | "immersive-vr"
  72200. | "immersive-ar";
  72201. type XRReferenceSpaceType =
  72202. | "viewer"
  72203. | "local"
  72204. | "local-floor"
  72205. | "bounded-floor"
  72206. | "unbounded";
  72207. type XREnvironmentBlendMode =
  72208. | "opaque"
  72209. | "additive"
  72210. | "alpha-blend";
  72211. type XRVisibilityState =
  72212. | "visible"
  72213. | "visible-blurred"
  72214. | "hidden";
  72215. type XRHandedness =
  72216. | "none"
  72217. | "left"
  72218. | "right";
  72219. type XRTargetRayMode =
  72220. | "gaze"
  72221. | "tracked-pointer"
  72222. | "screen";
  72223. type XREye =
  72224. | "none"
  72225. | "left"
  72226. | "right";
  72227. type XREventType =
  72228. | "devicechange"
  72229. | "visibilitychange"
  72230. | "end"
  72231. | "inputsourceschange"
  72232. | "select"
  72233. | "selectstart"
  72234. | "selectend"
  72235. | "squeeze"
  72236. | "squeezestart"
  72237. | "squeezeend"
  72238. | "reset";
  72239. interface XRSpace extends EventTarget {
  72240. }
  72241. interface XRRenderState {
  72242. depthNear?: number;
  72243. depthFar?: number;
  72244. inlineVerticalFieldOfView?: number;
  72245. baseLayer?: XRWebGLLayer;
  72246. }
  72247. interface XRInputSource {
  72248. handedness: XRHandedness;
  72249. targetRayMode: XRTargetRayMode;
  72250. targetRaySpace: XRSpace;
  72251. gripSpace: XRSpace | undefined;
  72252. gamepad: Gamepad | undefined;
  72253. profiles: Array<string>;
  72254. }
  72255. interface XRSessionInit {
  72256. optionalFeatures?: XRReferenceSpaceType[];
  72257. requiredFeatures?: XRReferenceSpaceType[];
  72258. }
  72259. interface XRSession extends XRAnchorCreator {
  72260. addEventListener: Function;
  72261. removeEventListener: Function;
  72262. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  72263. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  72264. requestAnimationFrame: Function;
  72265. end(): Promise<void>;
  72266. renderState: XRRenderState;
  72267. inputSources: Array<XRInputSource>;
  72268. // hit test
  72269. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  72270. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  72271. // legacy AR hit test
  72272. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72273. // legacy plane detection
  72274. updateWorldTrackingState(options: {
  72275. planeDetectionState?: { enabled: boolean; }
  72276. }): void;
  72277. }
  72278. interface XRReferenceSpace extends XRSpace {
  72279. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  72280. onreset: any;
  72281. }
  72282. type XRPlaneSet = Set<XRPlane>;
  72283. type XRAnchorSet = Set<XRAnchor>;
  72284. interface XRFrame {
  72285. session: XRSession;
  72286. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  72287. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  72288. // AR
  72289. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  72290. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  72291. // Anchors
  72292. trackedAnchors?: XRAnchorSet;
  72293. // Planes
  72294. worldInformation: {
  72295. detectedPlanes?: XRPlaneSet;
  72296. };
  72297. }
  72298. interface XRViewerPose extends XRPose {
  72299. views: Array<XRView>;
  72300. }
  72301. interface XRPose {
  72302. transform: XRRigidTransform;
  72303. emulatedPosition: boolean;
  72304. }
  72305. interface XRWebGLLayerOptions {
  72306. antialias?: boolean;
  72307. depth?: boolean;
  72308. stencil?: boolean;
  72309. alpha?: boolean;
  72310. multiview?: boolean;
  72311. framebufferScaleFactor?: number;
  72312. }
  72313. declare var XRWebGLLayer: {
  72314. prototype: XRWebGLLayer;
  72315. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  72316. };
  72317. interface XRWebGLLayer {
  72318. framebuffer: WebGLFramebuffer;
  72319. framebufferWidth: number;
  72320. framebufferHeight: number;
  72321. getViewport: Function;
  72322. }
  72323. declare class XRRigidTransform {
  72324. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  72325. position: DOMPointReadOnly;
  72326. orientation: DOMPointReadOnly;
  72327. matrix: Float32Array;
  72328. inverse: XRRigidTransform;
  72329. }
  72330. interface XRView {
  72331. eye: XREye;
  72332. projectionMatrix: Float32Array;
  72333. transform: XRRigidTransform;
  72334. }
  72335. interface XRInputSourceChangeEvent {
  72336. session: XRSession;
  72337. removed: Array<XRInputSource>;
  72338. added: Array<XRInputSource>;
  72339. }
  72340. interface XRInputSourceEvent extends Event {
  72341. readonly frame: XRFrame;
  72342. readonly inputSource: XRInputSource;
  72343. }
  72344. // Experimental(er) features
  72345. declare class XRRay {
  72346. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  72347. origin: DOMPointReadOnly;
  72348. direction: DOMPointReadOnly;
  72349. matrix: Float32Array;
  72350. }
  72351. declare enum XRHitTestTrackableType {
  72352. "point",
  72353. "plane"
  72354. }
  72355. interface XRHitResult {
  72356. hitMatrix: Float32Array;
  72357. }
  72358. interface XRTransientInputHitTestResult {
  72359. readonly inputSource: XRInputSource;
  72360. readonly results: Array<XRHitTestResult>;
  72361. }
  72362. interface XRHitTestResult {
  72363. getPose(baseSpace: XRSpace): XRPose | undefined;
  72364. }
  72365. interface XRHitTestSource {
  72366. cancel(): void;
  72367. }
  72368. interface XRTransientInputHitTestSource {
  72369. cancel(): void;
  72370. }
  72371. interface XRHitTestOptionsInit {
  72372. space: XRSpace;
  72373. entityTypes?: Array<XRHitTestTrackableType>;
  72374. offsetRay?: XRRay;
  72375. }
  72376. interface XRTransientInputHitTestOptionsInit {
  72377. profile: string;
  72378. entityTypes?: Array<XRHitTestTrackableType>;
  72379. offsetRay?: XRRay;
  72380. }
  72381. interface XRAnchor {
  72382. // remove?
  72383. id?: string;
  72384. anchorSpace: XRSpace;
  72385. lastChangedTime: number;
  72386. detach(): void;
  72387. }
  72388. interface XRPlane extends XRAnchorCreator {
  72389. orientation: "Horizontal" | "Vertical";
  72390. planeSpace: XRSpace;
  72391. polygon: Array<DOMPointReadOnly>;
  72392. lastChangedTime: number;
  72393. }
  72394. interface XRAnchorCreator {
  72395. // AR Anchors
  72396. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  72397. }
  72398. /**
  72399. * @ignore
  72400. */
  72401. declare module BABYLON.GLTF2.Exporter {
  72402. }
  72403. /**
  72404. * @ignore
  72405. */
  72406. declare module BABYLON.GLTF1 {
  72407. }
  72408. declare module BABYLON.GUI {
  72409. /**
  72410. * Class used to specific a value and its associated unit
  72411. */
  72412. export class ValueAndUnit {
  72413. /** defines the unit to store */
  72414. unit: number;
  72415. /** defines a boolean indicating if the value can be negative */
  72416. negativeValueAllowed: boolean;
  72417. private _value;
  72418. private _originalUnit;
  72419. /**
  72420. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  72421. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72422. */
  72423. ignoreAdaptiveScaling: boolean;
  72424. /**
  72425. * Creates a new ValueAndUnit
  72426. * @param value defines the value to store
  72427. * @param unit defines the unit to store
  72428. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  72429. */
  72430. constructor(value: number,
  72431. /** defines the unit to store */
  72432. unit?: number,
  72433. /** defines a boolean indicating if the value can be negative */
  72434. negativeValueAllowed?: boolean);
  72435. /** Gets a boolean indicating if the value is a percentage */
  72436. get isPercentage(): boolean;
  72437. /** Gets a boolean indicating if the value is store as pixel */
  72438. get isPixel(): boolean;
  72439. /** Gets direct internal value */
  72440. get internalValue(): number;
  72441. /**
  72442. * Gets value as pixel
  72443. * @param host defines the root host
  72444. * @param refValue defines the reference value for percentages
  72445. * @returns the value as pixel
  72446. */
  72447. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  72448. /**
  72449. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  72450. * @param value defines the value to store
  72451. * @param unit defines the unit to store
  72452. * @returns the current ValueAndUnit
  72453. */
  72454. updateInPlace(value: number, unit?: number): ValueAndUnit;
  72455. /**
  72456. * Gets the value accordingly to its unit
  72457. * @param host defines the root host
  72458. * @returns the value
  72459. */
  72460. getValue(host: AdvancedDynamicTexture): number;
  72461. /**
  72462. * Gets a string representation of the value
  72463. * @param host defines the root host
  72464. * @param decimals defines an optional number of decimals to display
  72465. * @returns a string
  72466. */
  72467. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  72468. /**
  72469. * Store a value parsed from a string
  72470. * @param source defines the source string
  72471. * @returns true if the value was successfully parsed
  72472. */
  72473. fromString(source: string | number): boolean;
  72474. private static _Regex;
  72475. private static _UNITMODE_PERCENTAGE;
  72476. private static _UNITMODE_PIXEL;
  72477. /** UNITMODE_PERCENTAGE */
  72478. static get UNITMODE_PERCENTAGE(): number;
  72479. /** UNITMODE_PIXEL */
  72480. static get UNITMODE_PIXEL(): number;
  72481. }
  72482. }
  72483. declare module BABYLON.GUI {
  72484. /**
  72485. * Define a style used by control to automatically setup properties based on a template.
  72486. * Only support font related properties so far
  72487. */
  72488. export class Style implements BABYLON.IDisposable {
  72489. private _fontFamily;
  72490. private _fontStyle;
  72491. private _fontWeight;
  72492. /** @hidden */
  72493. _host: AdvancedDynamicTexture;
  72494. /** @hidden */
  72495. _fontSize: ValueAndUnit;
  72496. /**
  72497. * BABYLON.Observable raised when the style values are changed
  72498. */
  72499. onChangedObservable: BABYLON.Observable<Style>;
  72500. /**
  72501. * Creates a new style object
  72502. * @param host defines the AdvancedDynamicTexture which hosts this style
  72503. */
  72504. constructor(host: AdvancedDynamicTexture);
  72505. /**
  72506. * Gets or sets the font size
  72507. */
  72508. get fontSize(): string | number;
  72509. set fontSize(value: string | number);
  72510. /**
  72511. * Gets or sets the font family
  72512. */
  72513. get fontFamily(): string;
  72514. set fontFamily(value: string);
  72515. /**
  72516. * Gets or sets the font style
  72517. */
  72518. get fontStyle(): string;
  72519. set fontStyle(value: string);
  72520. /** Gets or sets font weight */
  72521. get fontWeight(): string;
  72522. set fontWeight(value: string);
  72523. /** Dispose all associated resources */
  72524. dispose(): void;
  72525. }
  72526. }
  72527. declare module BABYLON.GUI {
  72528. /**
  72529. * Class used to transport BABYLON.Vector2 information for pointer events
  72530. */
  72531. export class Vector2WithInfo extends BABYLON.Vector2 {
  72532. /** defines the current mouse button index */
  72533. buttonIndex: number;
  72534. /**
  72535. * Creates a new Vector2WithInfo
  72536. * @param source defines the vector2 data to transport
  72537. * @param buttonIndex defines the current mouse button index
  72538. */
  72539. constructor(source: BABYLON.Vector2,
  72540. /** defines the current mouse button index */
  72541. buttonIndex?: number);
  72542. }
  72543. /** Class used to provide 2D matrix features */
  72544. export class Matrix2D {
  72545. /** Gets the internal array of 6 floats used to store matrix data */
  72546. m: Float32Array;
  72547. /**
  72548. * Creates a new matrix
  72549. * @param m00 defines value for (0, 0)
  72550. * @param m01 defines value for (0, 1)
  72551. * @param m10 defines value for (1, 0)
  72552. * @param m11 defines value for (1, 1)
  72553. * @param m20 defines value for (2, 0)
  72554. * @param m21 defines value for (2, 1)
  72555. */
  72556. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  72557. /**
  72558. * Fills the matrix from direct values
  72559. * @param m00 defines value for (0, 0)
  72560. * @param m01 defines value for (0, 1)
  72561. * @param m10 defines value for (1, 0)
  72562. * @param m11 defines value for (1, 1)
  72563. * @param m20 defines value for (2, 0)
  72564. * @param m21 defines value for (2, 1)
  72565. * @returns the current modified matrix
  72566. */
  72567. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  72568. /**
  72569. * Gets matrix determinant
  72570. * @returns the determinant
  72571. */
  72572. determinant(): number;
  72573. /**
  72574. * Inverses the matrix and stores it in a target matrix
  72575. * @param result defines the target matrix
  72576. * @returns the current matrix
  72577. */
  72578. invertToRef(result: Matrix2D): Matrix2D;
  72579. /**
  72580. * Multiplies the current matrix with another one
  72581. * @param other defines the second operand
  72582. * @param result defines the target matrix
  72583. * @returns the current matrix
  72584. */
  72585. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  72586. /**
  72587. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  72588. * @param x defines the x coordinate to transform
  72589. * @param y defines the x coordinate to transform
  72590. * @param result defines the target vector2
  72591. * @returns the current matrix
  72592. */
  72593. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  72594. /**
  72595. * Creates an identity matrix
  72596. * @returns a new matrix
  72597. */
  72598. static Identity(): Matrix2D;
  72599. /**
  72600. * Creates a translation matrix and stores it in a target matrix
  72601. * @param x defines the x coordinate of the translation
  72602. * @param y defines the y coordinate of the translation
  72603. * @param result defines the target matrix
  72604. */
  72605. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  72606. /**
  72607. * Creates a scaling matrix and stores it in a target matrix
  72608. * @param x defines the x coordinate of the scaling
  72609. * @param y defines the y coordinate of the scaling
  72610. * @param result defines the target matrix
  72611. */
  72612. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  72613. /**
  72614. * Creates a rotation matrix and stores it in a target matrix
  72615. * @param angle defines the rotation angle
  72616. * @param result defines the target matrix
  72617. */
  72618. static RotationToRef(angle: number, result: Matrix2D): void;
  72619. private static _TempPreTranslationMatrix;
  72620. private static _TempPostTranslationMatrix;
  72621. private static _TempRotationMatrix;
  72622. private static _TempScalingMatrix;
  72623. private static _TempCompose0;
  72624. private static _TempCompose1;
  72625. private static _TempCompose2;
  72626. /**
  72627. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  72628. * @param tx defines the x coordinate of the translation
  72629. * @param ty defines the y coordinate of the translation
  72630. * @param angle defines the rotation angle
  72631. * @param scaleX defines the x coordinate of the scaling
  72632. * @param scaleY defines the y coordinate of the scaling
  72633. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  72634. * @param result defines the target matrix
  72635. */
  72636. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  72637. }
  72638. }
  72639. declare module BABYLON.GUI {
  72640. /**
  72641. * Class used to store 2D control sizes
  72642. */
  72643. export class Measure {
  72644. /** defines left coordinate */
  72645. left: number;
  72646. /** defines top coordinate */
  72647. top: number;
  72648. /** defines width dimension */
  72649. width: number;
  72650. /** defines height dimension */
  72651. height: number;
  72652. /**
  72653. * Creates a new measure
  72654. * @param left defines left coordinate
  72655. * @param top defines top coordinate
  72656. * @param width defines width dimension
  72657. * @param height defines height dimension
  72658. */
  72659. constructor(
  72660. /** defines left coordinate */
  72661. left: number,
  72662. /** defines top coordinate */
  72663. top: number,
  72664. /** defines width dimension */
  72665. width: number,
  72666. /** defines height dimension */
  72667. height: number);
  72668. /**
  72669. * Copy from another measure
  72670. * @param other defines the other measure to copy from
  72671. */
  72672. copyFrom(other: Measure): void;
  72673. /**
  72674. * Copy from a group of 4 floats
  72675. * @param left defines left coordinate
  72676. * @param top defines top coordinate
  72677. * @param width defines width dimension
  72678. * @param height defines height dimension
  72679. */
  72680. copyFromFloats(left: number, top: number, width: number, height: number): void;
  72681. /**
  72682. * Computes the axis aligned bounding box measure for two given measures
  72683. * @param a Input measure
  72684. * @param b Input measure
  72685. * @param result the resulting bounding measure
  72686. */
  72687. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  72688. /**
  72689. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  72690. * @param transform the matrix to transform the measure before computing the AABB
  72691. * @param result the resulting AABB
  72692. */
  72693. transformToRef(transform: Matrix2D, result: Measure): void;
  72694. /**
  72695. * Check equality between this measure and another one
  72696. * @param other defines the other measures
  72697. * @returns true if both measures are equals
  72698. */
  72699. isEqualsTo(other: Measure): boolean;
  72700. /**
  72701. * Creates an empty measure
  72702. * @returns a new measure
  72703. */
  72704. static Empty(): Measure;
  72705. }
  72706. }
  72707. declare module BABYLON.GUI {
  72708. /**
  72709. * Interface used to define a control that can receive focus
  72710. */
  72711. export interface IFocusableControl {
  72712. /**
  72713. * Function called when the control receives the focus
  72714. */
  72715. onFocus(): void;
  72716. /**
  72717. * Function called when the control loses the focus
  72718. */
  72719. onBlur(): void;
  72720. /**
  72721. * Function called to let the control handle keyboard events
  72722. * @param evt defines the current keyboard event
  72723. */
  72724. processKeyboard(evt: KeyboardEvent): void;
  72725. /**
  72726. * Function called to get the list of controls that should not steal the focus from this control
  72727. * @returns an array of controls
  72728. */
  72729. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72730. }
  72731. /**
  72732. * Class used to create texture to support 2D GUI elements
  72733. * @see http://doc.babylonjs.com/how_to/gui
  72734. */
  72735. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  72736. private _isDirty;
  72737. private _renderObserver;
  72738. private _resizeObserver;
  72739. private _preKeyboardObserver;
  72740. private _pointerMoveObserver;
  72741. private _pointerObserver;
  72742. private _canvasPointerOutObserver;
  72743. private _background;
  72744. /** @hidden */
  72745. _rootContainer: Container;
  72746. /** @hidden */
  72747. _lastPickedControl: Control;
  72748. /** @hidden */
  72749. _lastControlOver: {
  72750. [pointerId: number]: Control;
  72751. };
  72752. /** @hidden */
  72753. _lastControlDown: {
  72754. [pointerId: number]: Control;
  72755. };
  72756. /** @hidden */
  72757. _capturingControl: {
  72758. [pointerId: number]: Control;
  72759. };
  72760. /** @hidden */
  72761. _shouldBlockPointer: boolean;
  72762. /** @hidden */
  72763. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  72764. /** @hidden */
  72765. _linkedControls: Control[];
  72766. private _isFullscreen;
  72767. private _fullscreenViewport;
  72768. private _idealWidth;
  72769. private _idealHeight;
  72770. private _useSmallestIdeal;
  72771. private _renderAtIdealSize;
  72772. private _focusedControl;
  72773. private _blockNextFocusCheck;
  72774. private _renderScale;
  72775. private _rootElement;
  72776. private _cursorChanged;
  72777. private _defaultMousePointerId;
  72778. /** @hidden */
  72779. _numLayoutCalls: number;
  72780. /** Gets the number of layout calls made the last time the ADT has been rendered */
  72781. get numLayoutCalls(): number;
  72782. /** @hidden */
  72783. _numRenderCalls: number;
  72784. /** Gets the number of render calls made the last time the ADT has been rendered */
  72785. get numRenderCalls(): number;
  72786. /**
  72787. * Define type to string to ensure compatibility across browsers
  72788. * Safari doesn't support DataTransfer constructor
  72789. */
  72790. private _clipboardData;
  72791. /**
  72792. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  72793. */
  72794. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  72795. /**
  72796. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  72797. */
  72798. onControlPickedObservable: BABYLON.Observable<Control>;
  72799. /**
  72800. * BABYLON.Observable event triggered before layout is evaluated
  72801. */
  72802. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72803. /**
  72804. * BABYLON.Observable event triggered after the layout was evaluated
  72805. */
  72806. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72807. /**
  72808. * BABYLON.Observable event triggered before the texture is rendered
  72809. */
  72810. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72811. /**
  72812. * BABYLON.Observable event triggered after the texture was rendered
  72813. */
  72814. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72815. /**
  72816. * Gets or sets a boolean defining if alpha is stored as premultiplied
  72817. */
  72818. premulAlpha: boolean;
  72819. /**
  72820. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  72821. * Useful when you want more antialiasing
  72822. */
  72823. get renderScale(): number;
  72824. set renderScale(value: number);
  72825. /** Gets or sets the background color */
  72826. get background(): string;
  72827. set background(value: string);
  72828. /**
  72829. * Gets or sets the ideal width used to design controls.
  72830. * The GUI will then rescale everything accordingly
  72831. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72832. */
  72833. get idealWidth(): number;
  72834. set idealWidth(value: number);
  72835. /**
  72836. * Gets or sets the ideal height used to design controls.
  72837. * The GUI will then rescale everything accordingly
  72838. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72839. */
  72840. get idealHeight(): number;
  72841. set idealHeight(value: number);
  72842. /**
  72843. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  72844. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72845. */
  72846. get useSmallestIdeal(): boolean;
  72847. set useSmallestIdeal(value: boolean);
  72848. /**
  72849. * Gets or sets a boolean indicating if adaptive scaling must be used
  72850. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72851. */
  72852. get renderAtIdealSize(): boolean;
  72853. set renderAtIdealSize(value: boolean);
  72854. /**
  72855. * Gets the ratio used when in "ideal mode"
  72856. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72857. * */
  72858. get idealRatio(): number;
  72859. /**
  72860. * Gets the underlying layer used to render the texture when in fullscreen mode
  72861. */
  72862. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  72863. /**
  72864. * Gets the root container control
  72865. */
  72866. get rootContainer(): Container;
  72867. /**
  72868. * Returns an array containing the root container.
  72869. * This is mostly used to let the Inspector introspects the ADT
  72870. * @returns an array containing the rootContainer
  72871. */
  72872. getChildren(): Array<Container>;
  72873. /**
  72874. * Will return all controls that are inside this texture
  72875. * @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
  72876. * @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
  72877. * @return all child controls
  72878. */
  72879. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72880. /**
  72881. * Gets or sets the current focused control
  72882. */
  72883. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  72884. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  72885. /**
  72886. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  72887. */
  72888. get isForeground(): boolean;
  72889. set isForeground(value: boolean);
  72890. /**
  72891. * Gets or set information about clipboardData
  72892. */
  72893. get clipboardData(): string;
  72894. set clipboardData(value: string);
  72895. /**
  72896. * Creates a new AdvancedDynamicTexture
  72897. * @param name defines the name of the texture
  72898. * @param width defines the width of the texture
  72899. * @param height defines the height of the texture
  72900. * @param scene defines the hosting scene
  72901. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  72902. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72903. */
  72904. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  72905. /**
  72906. * Get the current class name of the texture useful for serialization or dynamic coding.
  72907. * @returns "AdvancedDynamicTexture"
  72908. */
  72909. getClassName(): string;
  72910. /**
  72911. * Function used to execute a function on all controls
  72912. * @param func defines the function to execute
  72913. * @param container defines the container where controls belong. If null the root container will be used
  72914. */
  72915. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  72916. private _useInvalidateRectOptimization;
  72917. /**
  72918. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  72919. */
  72920. get useInvalidateRectOptimization(): boolean;
  72921. set useInvalidateRectOptimization(value: boolean);
  72922. private _invalidatedRectangle;
  72923. /**
  72924. * Invalidates a rectangle area on the gui texture
  72925. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  72926. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  72927. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  72928. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  72929. */
  72930. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  72931. /**
  72932. * Marks the texture as dirty forcing a complete update
  72933. */
  72934. markAsDirty(): void;
  72935. /**
  72936. * Helper function used to create a new style
  72937. * @returns a new style
  72938. * @see http://doc.babylonjs.com/how_to/gui#styles
  72939. */
  72940. createStyle(): Style;
  72941. /**
  72942. * Adds a new control to the root container
  72943. * @param control defines the control to add
  72944. * @returns the current texture
  72945. */
  72946. addControl(control: Control): AdvancedDynamicTexture;
  72947. /**
  72948. * Removes a control from the root container
  72949. * @param control defines the control to remove
  72950. * @returns the current texture
  72951. */
  72952. removeControl(control: Control): AdvancedDynamicTexture;
  72953. /**
  72954. * Release all resources
  72955. */
  72956. dispose(): void;
  72957. private _onResize;
  72958. /** @hidden */
  72959. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  72960. /**
  72961. * Get screen coordinates for a vector3
  72962. * @param position defines the position to project
  72963. * @param worldMatrix defines the world matrix to use
  72964. * @returns the projected position
  72965. */
  72966. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  72967. private _checkUpdate;
  72968. private _clearMeasure;
  72969. private _render;
  72970. /** @hidden */
  72971. _changeCursor(cursor: string): void;
  72972. /** @hidden */
  72973. _registerLastControlDown(control: Control, pointerId: number): void;
  72974. private _doPicking;
  72975. /** @hidden */
  72976. _cleanControlAfterRemovalFromList(list: {
  72977. [pointerId: number]: Control;
  72978. }, control: Control): void;
  72979. /** @hidden */
  72980. _cleanControlAfterRemoval(control: Control): void;
  72981. /** Attach to all scene events required to support pointer events */
  72982. attach(): void;
  72983. /** @hidden */
  72984. private onClipboardCopy;
  72985. /** @hidden */
  72986. private onClipboardCut;
  72987. /** @hidden */
  72988. private onClipboardPaste;
  72989. /**
  72990. * Register the clipboard Events onto the canvas
  72991. */
  72992. registerClipboardEvents(): void;
  72993. /**
  72994. * Unregister the clipboard Events from the canvas
  72995. */
  72996. unRegisterClipboardEvents(): void;
  72997. /**
  72998. * Connect the texture to a hosting mesh to enable interactions
  72999. * @param mesh defines the mesh to attach to
  73000. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  73001. */
  73002. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  73003. /**
  73004. * Move the focus to a specific control
  73005. * @param control defines the control which will receive the focus
  73006. */
  73007. moveFocusToControl(control: IFocusableControl): void;
  73008. private _manageFocus;
  73009. private _attachToOnPointerOut;
  73010. /**
  73011. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  73012. * @param mesh defines the mesh which will receive the texture
  73013. * @param width defines the texture width (1024 by default)
  73014. * @param height defines the texture height (1024 by default)
  73015. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  73016. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  73017. * @returns a new AdvancedDynamicTexture
  73018. */
  73019. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  73020. /**
  73021. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  73022. * In this mode the texture will rely on a layer for its rendering.
  73023. * This allows it to be treated like any other layer.
  73024. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  73025. * LayerMask is set through advancedTexture.layer.layerMask
  73026. * @param name defines name for the texture
  73027. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  73028. * @param scene defines the hsoting scene
  73029. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  73030. * @returns a new AdvancedDynamicTexture
  73031. */
  73032. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  73033. }
  73034. }
  73035. declare module BABYLON.GUI {
  73036. /**
  73037. * Root class used for all 2D controls
  73038. * @see http://doc.babylonjs.com/how_to/gui#controls
  73039. */
  73040. export class Control {
  73041. /** defines the name of the control */
  73042. name?: string | undefined;
  73043. /**
  73044. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  73045. */
  73046. static AllowAlphaInheritance: boolean;
  73047. private _alpha;
  73048. private _alphaSet;
  73049. private _zIndex;
  73050. /** @hidden */
  73051. _host: AdvancedDynamicTexture;
  73052. /** Gets or sets the control parent */
  73053. parent: BABYLON.Nullable<Container>;
  73054. /** @hidden */
  73055. _currentMeasure: Measure;
  73056. private _fontFamily;
  73057. private _fontStyle;
  73058. private _fontWeight;
  73059. private _fontSize;
  73060. private _font;
  73061. /** @hidden */
  73062. _width: ValueAndUnit;
  73063. /** @hidden */
  73064. _height: ValueAndUnit;
  73065. /** @hidden */
  73066. protected _fontOffset: {
  73067. ascent: number;
  73068. height: number;
  73069. descent: number;
  73070. };
  73071. private _color;
  73072. private _style;
  73073. private _styleObserver;
  73074. /** @hidden */
  73075. protected _horizontalAlignment: number;
  73076. /** @hidden */
  73077. protected _verticalAlignment: number;
  73078. /** @hidden */
  73079. protected _isDirty: boolean;
  73080. /** @hidden */
  73081. protected _wasDirty: boolean;
  73082. /** @hidden */
  73083. _tempParentMeasure: Measure;
  73084. /** @hidden */
  73085. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  73086. /** @hidden */
  73087. protected _cachedParentMeasure: Measure;
  73088. private _paddingLeft;
  73089. private _paddingRight;
  73090. private _paddingTop;
  73091. private _paddingBottom;
  73092. /** @hidden */
  73093. _left: ValueAndUnit;
  73094. /** @hidden */
  73095. _top: ValueAndUnit;
  73096. private _scaleX;
  73097. private _scaleY;
  73098. private _rotation;
  73099. private _transformCenterX;
  73100. private _transformCenterY;
  73101. /** @hidden */
  73102. _transformMatrix: Matrix2D;
  73103. /** @hidden */
  73104. protected _invertTransformMatrix: Matrix2D;
  73105. /** @hidden */
  73106. protected _transformedPosition: BABYLON.Vector2;
  73107. private _isMatrixDirty;
  73108. private _cachedOffsetX;
  73109. private _cachedOffsetY;
  73110. private _isVisible;
  73111. private _isHighlighted;
  73112. /** @hidden */
  73113. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  73114. private _fontSet;
  73115. private _dummyVector2;
  73116. private _downCount;
  73117. private _enterCount;
  73118. private _doNotRender;
  73119. private _downPointerIds;
  73120. protected _isEnabled: boolean;
  73121. protected _disabledColor: string;
  73122. protected _disabledColorItem: string;
  73123. /** @hidden */
  73124. protected _rebuildLayout: boolean;
  73125. /** @hidden */
  73126. _customData: any;
  73127. /** @hidden */
  73128. _isClipped: boolean;
  73129. /** @hidden */
  73130. _automaticSize: boolean;
  73131. /** @hidden */
  73132. _tag: any;
  73133. /**
  73134. * 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
  73135. */
  73136. uniqueId: number;
  73137. /**
  73138. * Gets or sets an object used to store user defined information for the node
  73139. */
  73140. metadata: any;
  73141. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  73142. isHitTestVisible: boolean;
  73143. /** Gets or sets a boolean indicating if the control can block pointer events */
  73144. isPointerBlocker: boolean;
  73145. /** Gets or sets a boolean indicating if the control can be focusable */
  73146. isFocusInvisible: boolean;
  73147. /**
  73148. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  73149. * 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
  73150. */
  73151. clipChildren: boolean;
  73152. /**
  73153. * Gets or sets a boolean indicating that control content must be clipped
  73154. * 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
  73155. */
  73156. clipContent: boolean;
  73157. /**
  73158. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  73159. */
  73160. useBitmapCache: boolean;
  73161. private _cacheData;
  73162. private _shadowOffsetX;
  73163. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  73164. get shadowOffsetX(): number;
  73165. set shadowOffsetX(value: number);
  73166. private _shadowOffsetY;
  73167. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  73168. get shadowOffsetY(): number;
  73169. set shadowOffsetY(value: number);
  73170. private _shadowBlur;
  73171. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  73172. get shadowBlur(): number;
  73173. set shadowBlur(value: number);
  73174. private _shadowColor;
  73175. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  73176. get shadowColor(): string;
  73177. set shadowColor(value: string);
  73178. /** Gets or sets the cursor to use when the control is hovered */
  73179. hoverCursor: string;
  73180. /** @hidden */
  73181. protected _linkOffsetX: ValueAndUnit;
  73182. /** @hidden */
  73183. protected _linkOffsetY: ValueAndUnit;
  73184. /** Gets the control type name */
  73185. get typeName(): string;
  73186. /**
  73187. * Get the current class name of the control.
  73188. * @returns current class name
  73189. */
  73190. getClassName(): string;
  73191. /**
  73192. * An event triggered when pointer wheel is scrolled
  73193. */
  73194. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  73195. /**
  73196. * An event triggered when the pointer move over the control.
  73197. */
  73198. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  73199. /**
  73200. * An event triggered when the pointer move out of the control.
  73201. */
  73202. onPointerOutObservable: BABYLON.Observable<Control>;
  73203. /**
  73204. * An event triggered when the pointer taps the control
  73205. */
  73206. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  73207. /**
  73208. * An event triggered when pointer up
  73209. */
  73210. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  73211. /**
  73212. * An event triggered when a control is clicked on
  73213. */
  73214. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  73215. /**
  73216. * An event triggered when pointer enters the control
  73217. */
  73218. onPointerEnterObservable: BABYLON.Observable<Control>;
  73219. /**
  73220. * An event triggered when the control is marked as dirty
  73221. */
  73222. onDirtyObservable: BABYLON.Observable<Control>;
  73223. /**
  73224. * An event triggered before drawing the control
  73225. */
  73226. onBeforeDrawObservable: BABYLON.Observable<Control>;
  73227. /**
  73228. * An event triggered after the control was drawn
  73229. */
  73230. onAfterDrawObservable: BABYLON.Observable<Control>;
  73231. /**
  73232. * An event triggered when the control has been disposed
  73233. */
  73234. onDisposeObservable: BABYLON.Observable<Control>;
  73235. /**
  73236. * Get the hosting AdvancedDynamicTexture
  73237. */
  73238. get host(): AdvancedDynamicTexture;
  73239. /** Gets or set information about font offsets (used to render and align text) */
  73240. get fontOffset(): {
  73241. ascent: number;
  73242. height: number;
  73243. descent: number;
  73244. };
  73245. set fontOffset(offset: {
  73246. ascent: number;
  73247. height: number;
  73248. descent: number;
  73249. });
  73250. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  73251. get alpha(): number;
  73252. set alpha(value: number);
  73253. /**
  73254. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  73255. */
  73256. get isHighlighted(): boolean;
  73257. set isHighlighted(value: boolean);
  73258. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  73259. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73260. */
  73261. get scaleX(): number;
  73262. set scaleX(value: number);
  73263. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  73264. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73265. */
  73266. get scaleY(): number;
  73267. set scaleY(value: number);
  73268. /** Gets or sets the rotation angle (0 by default)
  73269. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73270. */
  73271. get rotation(): number;
  73272. set rotation(value: number);
  73273. /** Gets or sets the transformation center on Y axis (0 by default)
  73274. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73275. */
  73276. get transformCenterY(): number;
  73277. set transformCenterY(value: number);
  73278. /** Gets or sets the transformation center on X axis (0 by default)
  73279. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73280. */
  73281. get transformCenterX(): number;
  73282. set transformCenterX(value: number);
  73283. /**
  73284. * Gets or sets the horizontal alignment
  73285. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73286. */
  73287. get horizontalAlignment(): number;
  73288. set horizontalAlignment(value: number);
  73289. /**
  73290. * Gets or sets the vertical alignment
  73291. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73292. */
  73293. get verticalAlignment(): number;
  73294. set verticalAlignment(value: number);
  73295. /**
  73296. * Gets or sets control width
  73297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73298. */
  73299. get width(): string | number;
  73300. set width(value: string | number);
  73301. /**
  73302. * Gets or sets the control width in pixel
  73303. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73304. */
  73305. get widthInPixels(): number;
  73306. set widthInPixels(value: number);
  73307. /**
  73308. * Gets or sets control height
  73309. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73310. */
  73311. get height(): string | number;
  73312. set height(value: string | number);
  73313. /**
  73314. * Gets or sets control height in pixel
  73315. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73316. */
  73317. get heightInPixels(): number;
  73318. set heightInPixels(value: number);
  73319. /** Gets or set font family */
  73320. get fontFamily(): string;
  73321. set fontFamily(value: string);
  73322. /** Gets or sets font style */
  73323. get fontStyle(): string;
  73324. set fontStyle(value: string);
  73325. /** Gets or sets font weight */
  73326. get fontWeight(): string;
  73327. set fontWeight(value: string);
  73328. /**
  73329. * Gets or sets style
  73330. * @see http://doc.babylonjs.com/how_to/gui#styles
  73331. */
  73332. get style(): BABYLON.Nullable<Style>;
  73333. set style(value: BABYLON.Nullable<Style>);
  73334. /** @hidden */
  73335. get _isFontSizeInPercentage(): boolean;
  73336. /** Gets or sets font size in pixels */
  73337. get fontSizeInPixels(): number;
  73338. set fontSizeInPixels(value: number);
  73339. /** Gets or sets font size */
  73340. get fontSize(): string | number;
  73341. set fontSize(value: string | number);
  73342. /** Gets or sets foreground color */
  73343. get color(): string;
  73344. set color(value: string);
  73345. /** Gets or sets z index which is used to reorder controls on the z axis */
  73346. get zIndex(): number;
  73347. set zIndex(value: number);
  73348. /** Gets or sets a boolean indicating if the control can be rendered */
  73349. get notRenderable(): boolean;
  73350. set notRenderable(value: boolean);
  73351. /** Gets or sets a boolean indicating if the control is visible */
  73352. get isVisible(): boolean;
  73353. set isVisible(value: boolean);
  73354. /** Gets a boolean indicating that the control needs to update its rendering */
  73355. get isDirty(): boolean;
  73356. /**
  73357. * Gets the current linked mesh (or null if none)
  73358. */
  73359. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73360. /**
  73361. * Gets or sets a value indicating the padding to use on the left of the control
  73362. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73363. */
  73364. get paddingLeft(): string | number;
  73365. set paddingLeft(value: string | number);
  73366. /**
  73367. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  73368. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73369. */
  73370. get paddingLeftInPixels(): number;
  73371. set paddingLeftInPixels(value: number);
  73372. /**
  73373. * Gets or sets a value indicating the padding to use on the right of the control
  73374. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73375. */
  73376. get paddingRight(): string | number;
  73377. set paddingRight(value: string | number);
  73378. /**
  73379. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  73380. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73381. */
  73382. get paddingRightInPixels(): number;
  73383. set paddingRightInPixels(value: number);
  73384. /**
  73385. * Gets or sets a value indicating the padding to use on the top of the control
  73386. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73387. */
  73388. get paddingTop(): string | number;
  73389. set paddingTop(value: string | number);
  73390. /**
  73391. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  73392. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73393. */
  73394. get paddingTopInPixels(): number;
  73395. set paddingTopInPixels(value: number);
  73396. /**
  73397. * Gets or sets a value indicating the padding to use on the bottom of the control
  73398. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73399. */
  73400. get paddingBottom(): string | number;
  73401. set paddingBottom(value: string | number);
  73402. /**
  73403. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  73404. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73405. */
  73406. get paddingBottomInPixels(): number;
  73407. set paddingBottomInPixels(value: number);
  73408. /**
  73409. * Gets or sets a value indicating the left coordinate of the control
  73410. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73411. */
  73412. get left(): string | number;
  73413. set left(value: string | number);
  73414. /**
  73415. * Gets or sets a value indicating the left coordinate in pixels of the control
  73416. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73417. */
  73418. get leftInPixels(): number;
  73419. set leftInPixels(value: number);
  73420. /**
  73421. * Gets or sets a value indicating the top coordinate of the control
  73422. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73423. */
  73424. get top(): string | number;
  73425. set top(value: string | number);
  73426. /**
  73427. * Gets or sets a value indicating the top coordinate in pixels of the control
  73428. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73429. */
  73430. get topInPixels(): number;
  73431. set topInPixels(value: number);
  73432. /**
  73433. * Gets or sets a value indicating the offset on X axis to the linked mesh
  73434. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73435. */
  73436. get linkOffsetX(): string | number;
  73437. set linkOffsetX(value: string | number);
  73438. /**
  73439. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  73440. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73441. */
  73442. get linkOffsetXInPixels(): number;
  73443. set linkOffsetXInPixels(value: number);
  73444. /**
  73445. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  73446. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73447. */
  73448. get linkOffsetY(): string | number;
  73449. set linkOffsetY(value: string | number);
  73450. /**
  73451. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  73452. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73453. */
  73454. get linkOffsetYInPixels(): number;
  73455. set linkOffsetYInPixels(value: number);
  73456. /** Gets the center coordinate on X axis */
  73457. get centerX(): number;
  73458. /** Gets the center coordinate on Y axis */
  73459. get centerY(): number;
  73460. /** Gets or sets if control is Enabled*/
  73461. get isEnabled(): boolean;
  73462. set isEnabled(value: boolean);
  73463. /** Gets or sets background color of control if it's disabled*/
  73464. get disabledColor(): string;
  73465. set disabledColor(value: string);
  73466. /** Gets or sets front color of control if it's disabled*/
  73467. get disabledColorItem(): string;
  73468. set disabledColorItem(value: string);
  73469. /**
  73470. * Creates a new control
  73471. * @param name defines the name of the control
  73472. */
  73473. constructor(
  73474. /** defines the name of the control */
  73475. name?: string | undefined);
  73476. /** @hidden */
  73477. protected _getTypeName(): string;
  73478. /**
  73479. * Gets the first ascendant in the hierarchy of the given type
  73480. * @param className defines the required type
  73481. * @returns the ascendant or null if not found
  73482. */
  73483. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  73484. /** @hidden */
  73485. _resetFontCache(): void;
  73486. /**
  73487. * Determines if a container is an ascendant of the current control
  73488. * @param container defines the container to look for
  73489. * @returns true if the container is one of the ascendant of the control
  73490. */
  73491. isAscendant(container: Control): boolean;
  73492. /**
  73493. * Gets coordinates in local control space
  73494. * @param globalCoordinates defines the coordinates to transform
  73495. * @returns the new coordinates in local space
  73496. */
  73497. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73498. /**
  73499. * Gets coordinates in local control space
  73500. * @param globalCoordinates defines the coordinates to transform
  73501. * @param result defines the target vector2 where to store the result
  73502. * @returns the current control
  73503. */
  73504. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  73505. /**
  73506. * Gets coordinates in parent local control space
  73507. * @param globalCoordinates defines the coordinates to transform
  73508. * @returns the new coordinates in parent local space
  73509. */
  73510. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73511. /**
  73512. * Move the current control to a vector3 position projected onto the screen.
  73513. * @param position defines the target position
  73514. * @param scene defines the hosting scene
  73515. */
  73516. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  73517. /**
  73518. * Will store all controls that have this control as ascendant in a given array
  73519. * @param results defines the array where to store the descendants
  73520. * @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
  73521. * @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
  73522. */
  73523. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73524. /**
  73525. * Will return all controls that have this control as ascendant
  73526. * @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
  73527. * @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
  73528. * @return all child controls
  73529. */
  73530. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73531. /**
  73532. * Link current control with a target mesh
  73533. * @param mesh defines the mesh to link with
  73534. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73535. */
  73536. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  73537. /** @hidden */
  73538. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  73539. /** @hidden */
  73540. _offsetLeft(offset: number): void;
  73541. /** @hidden */
  73542. _offsetTop(offset: number): void;
  73543. /** @hidden */
  73544. _markMatrixAsDirty(): void;
  73545. /** @hidden */
  73546. _flagDescendantsAsMatrixDirty(): void;
  73547. /** @hidden */
  73548. _intersectsRect(rect: Measure): boolean;
  73549. /** @hidden */
  73550. protected invalidateRect(): void;
  73551. /** @hidden */
  73552. _markAsDirty(force?: boolean): void;
  73553. /** @hidden */
  73554. _markAllAsDirty(): void;
  73555. /** @hidden */
  73556. _link(host: AdvancedDynamicTexture): void;
  73557. /** @hidden */
  73558. protected _transform(context?: CanvasRenderingContext2D): void;
  73559. /** @hidden */
  73560. _renderHighlight(context: CanvasRenderingContext2D): void;
  73561. /** @hidden */
  73562. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73563. /** @hidden */
  73564. protected _applyStates(context: CanvasRenderingContext2D): void;
  73565. /** @hidden */
  73566. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73567. /** @hidden */
  73568. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73569. protected _evaluateClippingState(parentMeasure: Measure): void;
  73570. /** @hidden */
  73571. _measure(): void;
  73572. /** @hidden */
  73573. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73574. /** @hidden */
  73575. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73576. /** @hidden */
  73577. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73578. /** @hidden */
  73579. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73580. private static _ClipMeasure;
  73581. private _tmpMeasureA;
  73582. private _clip;
  73583. /** @hidden */
  73584. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  73585. /** @hidden */
  73586. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73587. /**
  73588. * Tests if a given coordinates belong to the current control
  73589. * @param x defines x coordinate to test
  73590. * @param y defines y coordinate to test
  73591. * @returns true if the coordinates are inside the control
  73592. */
  73593. contains(x: number, y: number): boolean;
  73594. /** @hidden */
  73595. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73596. /** @hidden */
  73597. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73598. /** @hidden */
  73599. _onPointerEnter(target: Control): boolean;
  73600. /** @hidden */
  73601. _onPointerOut(target: Control, force?: boolean): void;
  73602. /** @hidden */
  73603. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73604. /** @hidden */
  73605. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73606. /** @hidden */
  73607. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73608. /** @hidden */
  73609. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  73610. /** @hidden */
  73611. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73612. private _prepareFont;
  73613. /** Releases associated resources */
  73614. dispose(): void;
  73615. private static _HORIZONTAL_ALIGNMENT_LEFT;
  73616. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  73617. private static _HORIZONTAL_ALIGNMENT_CENTER;
  73618. private static _VERTICAL_ALIGNMENT_TOP;
  73619. private static _VERTICAL_ALIGNMENT_BOTTOM;
  73620. private static _VERTICAL_ALIGNMENT_CENTER;
  73621. /** HORIZONTAL_ALIGNMENT_LEFT */
  73622. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  73623. /** HORIZONTAL_ALIGNMENT_RIGHT */
  73624. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  73625. /** HORIZONTAL_ALIGNMENT_CENTER */
  73626. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  73627. /** VERTICAL_ALIGNMENT_TOP */
  73628. static get VERTICAL_ALIGNMENT_TOP(): number;
  73629. /** VERTICAL_ALIGNMENT_BOTTOM */
  73630. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  73631. /** VERTICAL_ALIGNMENT_CENTER */
  73632. static get VERTICAL_ALIGNMENT_CENTER(): number;
  73633. private static _FontHeightSizes;
  73634. /** @hidden */
  73635. static _GetFontOffset(font: string): {
  73636. ascent: number;
  73637. height: number;
  73638. descent: number;
  73639. };
  73640. /**
  73641. * Creates a stack panel that can be used to render headers
  73642. * @param control defines the control to associate with the header
  73643. * @param text defines the text of the header
  73644. * @param size defines the size of the header
  73645. * @param options defines options used to configure the header
  73646. * @returns a new StackPanel
  73647. * @ignore
  73648. * @hidden
  73649. */
  73650. static AddHeader: (control: Control, text: string, size: string | number, options: {
  73651. isHorizontal: boolean;
  73652. controlFirst: boolean;
  73653. }) => any;
  73654. /** @hidden */
  73655. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  73656. }
  73657. }
  73658. declare module BABYLON.GUI {
  73659. /**
  73660. * Root class for 2D containers
  73661. * @see http://doc.babylonjs.com/how_to/gui#containers
  73662. */
  73663. export class Container extends Control {
  73664. name?: string | undefined;
  73665. /** @hidden */
  73666. _children: Control[];
  73667. /** @hidden */
  73668. protected _measureForChildren: Measure;
  73669. /** @hidden */
  73670. protected _background: string;
  73671. /** @hidden */
  73672. protected _adaptWidthToChildren: boolean;
  73673. /** @hidden */
  73674. protected _adaptHeightToChildren: boolean;
  73675. /**
  73676. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  73677. */
  73678. logLayoutCycleErrors: boolean;
  73679. /**
  73680. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  73681. */
  73682. maxLayoutCycle: number;
  73683. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  73684. get adaptHeightToChildren(): boolean;
  73685. set adaptHeightToChildren(value: boolean);
  73686. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  73687. get adaptWidthToChildren(): boolean;
  73688. set adaptWidthToChildren(value: boolean);
  73689. /** Gets or sets background color */
  73690. get background(): string;
  73691. set background(value: string);
  73692. /** Gets the list of children */
  73693. get children(): Control[];
  73694. /**
  73695. * Creates a new Container
  73696. * @param name defines the name of the container
  73697. */
  73698. constructor(name?: string | undefined);
  73699. protected _getTypeName(): string;
  73700. _flagDescendantsAsMatrixDirty(): void;
  73701. /**
  73702. * Gets a child using its name
  73703. * @param name defines the child name to look for
  73704. * @returns the child control if found
  73705. */
  73706. getChildByName(name: string): BABYLON.Nullable<Control>;
  73707. /**
  73708. * Gets a child using its type and its name
  73709. * @param name defines the child name to look for
  73710. * @param type defines the child type to look for
  73711. * @returns the child control if found
  73712. */
  73713. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  73714. /**
  73715. * Search for a specific control in children
  73716. * @param control defines the control to look for
  73717. * @returns true if the control is in child list
  73718. */
  73719. containsControl(control: Control): boolean;
  73720. /**
  73721. * Adds a new control to the current container
  73722. * @param control defines the control to add
  73723. * @returns the current container
  73724. */
  73725. addControl(control: BABYLON.Nullable<Control>): Container;
  73726. /**
  73727. * Removes all controls from the current container
  73728. * @returns the current container
  73729. */
  73730. clearControls(): Container;
  73731. /**
  73732. * Removes a control from the current container
  73733. * @param control defines the control to remove
  73734. * @returns the current container
  73735. */
  73736. removeControl(control: Control): Container;
  73737. /** @hidden */
  73738. _reOrderControl(control: Control): void;
  73739. /** @hidden */
  73740. _offsetLeft(offset: number): void;
  73741. /** @hidden */
  73742. _offsetTop(offset: number): void;
  73743. /** @hidden */
  73744. _markAllAsDirty(): void;
  73745. /** @hidden */
  73746. protected _localDraw(context: CanvasRenderingContext2D): void;
  73747. /** @hidden */
  73748. _link(host: AdvancedDynamicTexture): void;
  73749. /** @hidden */
  73750. protected _beforeLayout(): void;
  73751. /** @hidden */
  73752. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73753. /** @hidden */
  73754. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73755. protected _postMeasure(): void;
  73756. /** @hidden */
  73757. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73758. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73759. /** @hidden */
  73760. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73761. /** @hidden */
  73762. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73763. /** Releases associated resources */
  73764. dispose(): void;
  73765. }
  73766. }
  73767. declare module BABYLON.GUI {
  73768. /** Class used to create rectangle container */
  73769. export class Rectangle extends Container {
  73770. name?: string | undefined;
  73771. private _thickness;
  73772. private _cornerRadius;
  73773. /** Gets or sets border thickness */
  73774. get thickness(): number;
  73775. set thickness(value: number);
  73776. /** Gets or sets the corner radius angle */
  73777. get cornerRadius(): number;
  73778. set cornerRadius(value: number);
  73779. /**
  73780. * Creates a new Rectangle
  73781. * @param name defines the control name
  73782. */
  73783. constructor(name?: string | undefined);
  73784. protected _getTypeName(): string;
  73785. protected _localDraw(context: CanvasRenderingContext2D): void;
  73786. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73787. private _drawRoundedRect;
  73788. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73789. }
  73790. }
  73791. declare module BABYLON.GUI {
  73792. /**
  73793. * Enum that determines the text-wrapping mode to use.
  73794. */
  73795. export enum TextWrapping {
  73796. /**
  73797. * Clip the text when it's larger than Control.width; this is the default mode.
  73798. */
  73799. Clip = 0,
  73800. /**
  73801. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  73802. */
  73803. WordWrap = 1,
  73804. /**
  73805. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  73806. */
  73807. Ellipsis = 2
  73808. }
  73809. /**
  73810. * Class used to create text block control
  73811. */
  73812. export class TextBlock extends Control {
  73813. /**
  73814. * Defines the name of the control
  73815. */
  73816. name?: string | undefined;
  73817. private _text;
  73818. private _textWrapping;
  73819. private _textHorizontalAlignment;
  73820. private _textVerticalAlignment;
  73821. private _lines;
  73822. private _resizeToFit;
  73823. private _lineSpacing;
  73824. private _outlineWidth;
  73825. private _outlineColor;
  73826. /**
  73827. * An event triggered after the text is changed
  73828. */
  73829. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  73830. /**
  73831. * An event triggered after the text was broken up into lines
  73832. */
  73833. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  73834. /**
  73835. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  73836. */
  73837. get lines(): any[];
  73838. /**
  73839. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  73840. */
  73841. get resizeToFit(): boolean;
  73842. /**
  73843. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  73844. */
  73845. set resizeToFit(value: boolean);
  73846. /**
  73847. * Gets or sets a boolean indicating if text must be wrapped
  73848. */
  73849. get textWrapping(): TextWrapping | boolean;
  73850. /**
  73851. * Gets or sets a boolean indicating if text must be wrapped
  73852. */
  73853. set textWrapping(value: TextWrapping | boolean);
  73854. /**
  73855. * Gets or sets text to display
  73856. */
  73857. get text(): string;
  73858. /**
  73859. * Gets or sets text to display
  73860. */
  73861. set text(value: string);
  73862. /**
  73863. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  73864. */
  73865. get textHorizontalAlignment(): number;
  73866. /**
  73867. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  73868. */
  73869. set textHorizontalAlignment(value: number);
  73870. /**
  73871. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  73872. */
  73873. get textVerticalAlignment(): number;
  73874. /**
  73875. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  73876. */
  73877. set textVerticalAlignment(value: number);
  73878. /**
  73879. * Gets or sets line spacing value
  73880. */
  73881. set lineSpacing(value: string | number);
  73882. /**
  73883. * Gets or sets line spacing value
  73884. */
  73885. get lineSpacing(): string | number;
  73886. /**
  73887. * Gets or sets outlineWidth of the text to display
  73888. */
  73889. get outlineWidth(): number;
  73890. /**
  73891. * Gets or sets outlineWidth of the text to display
  73892. */
  73893. set outlineWidth(value: number);
  73894. /**
  73895. * Gets or sets outlineColor of the text to display
  73896. */
  73897. get outlineColor(): string;
  73898. /**
  73899. * Gets or sets outlineColor of the text to display
  73900. */
  73901. set outlineColor(value: string);
  73902. /**
  73903. * Creates a new TextBlock object
  73904. * @param name defines the name of the control
  73905. * @param text defines the text to display (emptry string by default)
  73906. */
  73907. constructor(
  73908. /**
  73909. * Defines the name of the control
  73910. */
  73911. name?: string | undefined, text?: string);
  73912. protected _getTypeName(): string;
  73913. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73914. private _drawText;
  73915. /** @hidden */
  73916. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73917. protected _applyStates(context: CanvasRenderingContext2D): void;
  73918. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  73919. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  73920. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  73921. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  73922. protected _renderLines(context: CanvasRenderingContext2D): void;
  73923. /**
  73924. * Given a width constraint applied on the text block, find the expected height
  73925. * @returns expected height
  73926. */
  73927. computeExpectedHeight(): number;
  73928. dispose(): void;
  73929. }
  73930. }
  73931. declare module BABYLON.GUI {
  73932. /**
  73933. * Class used to create 2D images
  73934. */
  73935. export class Image extends Control {
  73936. name?: string | undefined;
  73937. private _workingCanvas;
  73938. private _domImage;
  73939. private _imageWidth;
  73940. private _imageHeight;
  73941. private _loaded;
  73942. private _stretch;
  73943. private _source;
  73944. private _autoScale;
  73945. private _sourceLeft;
  73946. private _sourceTop;
  73947. private _sourceWidth;
  73948. private _sourceHeight;
  73949. private _svgAttributesComputationCompleted;
  73950. private _isSVG;
  73951. private _cellWidth;
  73952. private _cellHeight;
  73953. private _cellId;
  73954. private _populateNinePatchSlicesFromImage;
  73955. private _sliceLeft;
  73956. private _sliceRight;
  73957. private _sliceTop;
  73958. private _sliceBottom;
  73959. private _detectPointerOnOpaqueOnly;
  73960. /**
  73961. * BABYLON.Observable notified when the content is loaded
  73962. */
  73963. onImageLoadedObservable: BABYLON.Observable<Image>;
  73964. /**
  73965. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  73966. */
  73967. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  73968. /**
  73969. * Gets a boolean indicating that the content is loaded
  73970. */
  73971. get isLoaded(): boolean;
  73972. /**
  73973. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  73974. */
  73975. get populateNinePatchSlicesFromImage(): boolean;
  73976. set populateNinePatchSlicesFromImage(value: boolean);
  73977. /**
  73978. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  73979. * Beware using this as this will comsume more memory as the image has to be stored twice
  73980. */
  73981. get detectPointerOnOpaqueOnly(): boolean;
  73982. set detectPointerOnOpaqueOnly(value: boolean);
  73983. /**
  73984. * Gets or sets the left value for slicing (9-patch)
  73985. */
  73986. get sliceLeft(): number;
  73987. set sliceLeft(value: number);
  73988. /**
  73989. * Gets or sets the right value for slicing (9-patch)
  73990. */
  73991. get sliceRight(): number;
  73992. set sliceRight(value: number);
  73993. /**
  73994. * Gets or sets the top value for slicing (9-patch)
  73995. */
  73996. get sliceTop(): number;
  73997. set sliceTop(value: number);
  73998. /**
  73999. * Gets or sets the bottom value for slicing (9-patch)
  74000. */
  74001. get sliceBottom(): number;
  74002. set sliceBottom(value: number);
  74003. /**
  74004. * Gets or sets the left coordinate in the source image
  74005. */
  74006. get sourceLeft(): number;
  74007. set sourceLeft(value: number);
  74008. /**
  74009. * Gets or sets the top coordinate in the source image
  74010. */
  74011. get sourceTop(): number;
  74012. set sourceTop(value: number);
  74013. /**
  74014. * Gets or sets the width to capture in the source image
  74015. */
  74016. get sourceWidth(): number;
  74017. set sourceWidth(value: number);
  74018. /**
  74019. * Gets or sets the height to capture in the source image
  74020. */
  74021. get sourceHeight(): number;
  74022. set sourceHeight(value: number);
  74023. /** Indicates if the format of the image is SVG */
  74024. get isSVG(): boolean;
  74025. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  74026. get svgAttributesComputationCompleted(): boolean;
  74027. /**
  74028. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  74029. * @see http://doc.babylonjs.com/how_to/gui#image
  74030. */
  74031. get autoScale(): boolean;
  74032. set autoScale(value: boolean);
  74033. /** Gets or sets the streching mode used by the image */
  74034. get stretch(): number;
  74035. set stretch(value: number);
  74036. /** @hidden */
  74037. _rotate90(n: number, preserveProperties?: boolean): Image;
  74038. private _handleRotationForSVGImage;
  74039. private _rotate90SourceProperties;
  74040. /**
  74041. * Gets or sets the internal DOM image used to render the control
  74042. */
  74043. set domImage(value: HTMLImageElement);
  74044. get domImage(): HTMLImageElement;
  74045. private _onImageLoaded;
  74046. private _extractNinePatchSliceDataFromImage;
  74047. /**
  74048. * Gets or sets image source url
  74049. */
  74050. set source(value: BABYLON.Nullable<string>);
  74051. /**
  74052. * Checks for svg document with icon id present
  74053. */
  74054. private _svgCheck;
  74055. /**
  74056. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  74057. * given external svg file and icon id
  74058. */
  74059. private _getSVGAttribs;
  74060. /**
  74061. * Gets or sets the cell width to use when animation sheet is enabled
  74062. * @see http://doc.babylonjs.com/how_to/gui#image
  74063. */
  74064. get cellWidth(): number;
  74065. set cellWidth(value: number);
  74066. /**
  74067. * Gets or sets the cell height to use when animation sheet is enabled
  74068. * @see http://doc.babylonjs.com/how_to/gui#image
  74069. */
  74070. get cellHeight(): number;
  74071. set cellHeight(value: number);
  74072. /**
  74073. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  74074. * @see http://doc.babylonjs.com/how_to/gui#image
  74075. */
  74076. get cellId(): number;
  74077. set cellId(value: number);
  74078. /**
  74079. * Creates a new Image
  74080. * @param name defines the control name
  74081. * @param url defines the image url
  74082. */
  74083. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  74084. /**
  74085. * Tests if a given coordinates belong to the current control
  74086. * @param x defines x coordinate to test
  74087. * @param y defines y coordinate to test
  74088. * @returns true if the coordinates are inside the control
  74089. */
  74090. contains(x: number, y: number): boolean;
  74091. protected _getTypeName(): string;
  74092. /** Force the control to synchronize with its content */
  74093. synchronizeSizeWithContent(): void;
  74094. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74095. private _prepareWorkingCanvasForOpaqueDetection;
  74096. private _drawImage;
  74097. _draw(context: CanvasRenderingContext2D): void;
  74098. private _renderCornerPatch;
  74099. private _renderNinePatch;
  74100. dispose(): void;
  74101. /** STRETCH_NONE */
  74102. static readonly STRETCH_NONE: number;
  74103. /** STRETCH_FILL */
  74104. static readonly STRETCH_FILL: number;
  74105. /** STRETCH_UNIFORM */
  74106. static readonly STRETCH_UNIFORM: number;
  74107. /** STRETCH_EXTEND */
  74108. static readonly STRETCH_EXTEND: number;
  74109. /** NINE_PATCH */
  74110. static readonly STRETCH_NINE_PATCH: number;
  74111. }
  74112. }
  74113. declare module BABYLON.GUI {
  74114. /**
  74115. * Class used to create 2D buttons
  74116. */
  74117. export class Button extends Rectangle {
  74118. name?: string | undefined;
  74119. /**
  74120. * Function called to generate a pointer enter animation
  74121. */
  74122. pointerEnterAnimation: () => void;
  74123. /**
  74124. * Function called to generate a pointer out animation
  74125. */
  74126. pointerOutAnimation: () => void;
  74127. /**
  74128. * Function called to generate a pointer down animation
  74129. */
  74130. pointerDownAnimation: () => void;
  74131. /**
  74132. * Function called to generate a pointer up animation
  74133. */
  74134. pointerUpAnimation: () => void;
  74135. /**
  74136. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  74137. */
  74138. delegatePickingToChildren: boolean;
  74139. private _image;
  74140. /**
  74141. * Returns the image part of the button (if any)
  74142. */
  74143. get image(): BABYLON.Nullable<Image>;
  74144. private _textBlock;
  74145. /**
  74146. * Returns the image part of the button (if any)
  74147. */
  74148. get textBlock(): BABYLON.Nullable<TextBlock>;
  74149. /**
  74150. * Creates a new Button
  74151. * @param name defines the name of the button
  74152. */
  74153. constructor(name?: string | undefined);
  74154. protected _getTypeName(): string;
  74155. /** @hidden */
  74156. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74157. /** @hidden */
  74158. _onPointerEnter(target: Control): boolean;
  74159. /** @hidden */
  74160. _onPointerOut(target: Control, force?: boolean): void;
  74161. /** @hidden */
  74162. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74163. /** @hidden */
  74164. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74165. /**
  74166. * Creates a new button made with an image and a text
  74167. * @param name defines the name of the button
  74168. * @param text defines the text of the button
  74169. * @param imageUrl defines the url of the image
  74170. * @returns a new Button
  74171. */
  74172. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  74173. /**
  74174. * Creates a new button made with an image
  74175. * @param name defines the name of the button
  74176. * @param imageUrl defines the url of the image
  74177. * @returns a new Button
  74178. */
  74179. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  74180. /**
  74181. * Creates a new button made with a text
  74182. * @param name defines the name of the button
  74183. * @param text defines the text of the button
  74184. * @returns a new Button
  74185. */
  74186. static CreateSimpleButton(name: string, text: string): Button;
  74187. /**
  74188. * Creates a new button made with an image and a centered text
  74189. * @param name defines the name of the button
  74190. * @param text defines the text of the button
  74191. * @param imageUrl defines the url of the image
  74192. * @returns a new Button
  74193. */
  74194. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  74195. }
  74196. }
  74197. declare module BABYLON.GUI {
  74198. /**
  74199. * Class used to create a 2D stack panel container
  74200. */
  74201. export class StackPanel extends Container {
  74202. name?: string | undefined;
  74203. private _isVertical;
  74204. private _manualWidth;
  74205. private _manualHeight;
  74206. private _doNotTrackManualChanges;
  74207. /**
  74208. * Gets or sets a boolean indicating that layou warnings should be ignored
  74209. */
  74210. ignoreLayoutWarnings: boolean;
  74211. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  74212. get isVertical(): boolean;
  74213. set isVertical(value: boolean);
  74214. /**
  74215. * Gets or sets panel width.
  74216. * This value should not be set when in horizontal mode as it will be computed automatically
  74217. */
  74218. set width(value: string | number);
  74219. get width(): string | number;
  74220. /**
  74221. * Gets or sets panel height.
  74222. * This value should not be set when in vertical mode as it will be computed automatically
  74223. */
  74224. set height(value: string | number);
  74225. get height(): string | number;
  74226. /**
  74227. * Creates a new StackPanel
  74228. * @param name defines control name
  74229. */
  74230. constructor(name?: string | undefined);
  74231. protected _getTypeName(): string;
  74232. /** @hidden */
  74233. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74234. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74235. protected _postMeasure(): void;
  74236. }
  74237. }
  74238. declare module BABYLON.GUI {
  74239. /**
  74240. * Class used to represent a 2D checkbox
  74241. */
  74242. export class Checkbox extends Control {
  74243. name?: string | undefined;
  74244. private _isChecked;
  74245. private _background;
  74246. private _checkSizeRatio;
  74247. private _thickness;
  74248. /** Gets or sets border thickness */
  74249. get thickness(): number;
  74250. set thickness(value: number);
  74251. /**
  74252. * BABYLON.Observable raised when isChecked property changes
  74253. */
  74254. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74255. /** Gets or sets a value indicating the ratio between overall size and check size */
  74256. get checkSizeRatio(): number;
  74257. set checkSizeRatio(value: number);
  74258. /** Gets or sets background color */
  74259. get background(): string;
  74260. set background(value: string);
  74261. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74262. get isChecked(): boolean;
  74263. set isChecked(value: boolean);
  74264. /**
  74265. * Creates a new CheckBox
  74266. * @param name defines the control name
  74267. */
  74268. constructor(name?: string | undefined);
  74269. protected _getTypeName(): string;
  74270. /** @hidden */
  74271. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74272. /** @hidden */
  74273. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74274. /**
  74275. * Utility function to easily create a checkbox with a header
  74276. * @param title defines the label to use for the header
  74277. * @param onValueChanged defines the callback to call when value changes
  74278. * @returns a StackPanel containing the checkbox and a textBlock
  74279. */
  74280. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  74281. }
  74282. }
  74283. declare module BABYLON.GUI {
  74284. /**
  74285. * Class used to store key control properties
  74286. */
  74287. export class KeyPropertySet {
  74288. /** Width */
  74289. width?: string;
  74290. /** Height */
  74291. height?: string;
  74292. /** Left padding */
  74293. paddingLeft?: string;
  74294. /** Right padding */
  74295. paddingRight?: string;
  74296. /** Top padding */
  74297. paddingTop?: string;
  74298. /** Bottom padding */
  74299. paddingBottom?: string;
  74300. /** Foreground color */
  74301. color?: string;
  74302. /** Background color */
  74303. background?: string;
  74304. }
  74305. /**
  74306. * Class used to create virtual keyboard
  74307. */
  74308. export class VirtualKeyboard extends StackPanel {
  74309. /** BABYLON.Observable raised when a key is pressed */
  74310. onKeyPressObservable: BABYLON.Observable<string>;
  74311. /** Gets or sets default key button width */
  74312. defaultButtonWidth: string;
  74313. /** Gets or sets default key button height */
  74314. defaultButtonHeight: string;
  74315. /** Gets or sets default key button left padding */
  74316. defaultButtonPaddingLeft: string;
  74317. /** Gets or sets default key button right padding */
  74318. defaultButtonPaddingRight: string;
  74319. /** Gets or sets default key button top padding */
  74320. defaultButtonPaddingTop: string;
  74321. /** Gets or sets default key button bottom padding */
  74322. defaultButtonPaddingBottom: string;
  74323. /** Gets or sets default key button foreground color */
  74324. defaultButtonColor: string;
  74325. /** Gets or sets default key button background color */
  74326. defaultButtonBackground: string;
  74327. /** Gets or sets shift button foreground color */
  74328. shiftButtonColor: string;
  74329. /** Gets or sets shift button thickness*/
  74330. selectedShiftThickness: number;
  74331. /** Gets shift key state */
  74332. shiftState: number;
  74333. protected _getTypeName(): string;
  74334. private _createKey;
  74335. /**
  74336. * Adds a new row of keys
  74337. * @param keys defines the list of keys to add
  74338. * @param propertySets defines the associated property sets
  74339. */
  74340. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  74341. /**
  74342. * Set the shift key to a specific state
  74343. * @param shiftState defines the new shift state
  74344. */
  74345. applyShiftState(shiftState: number): void;
  74346. private _currentlyConnectedInputText;
  74347. private _connectedInputTexts;
  74348. private _onKeyPressObserver;
  74349. /** Gets the input text control currently attached to the keyboard */
  74350. get connectedInputText(): BABYLON.Nullable<InputText>;
  74351. /**
  74352. * Connects the keyboard with an input text control
  74353. *
  74354. * @param input defines the target control
  74355. */
  74356. connect(input: InputText): void;
  74357. /**
  74358. * Disconnects the keyboard from connected InputText controls
  74359. *
  74360. * @param input optionally defines a target control, otherwise all are disconnected
  74361. */
  74362. disconnect(input?: InputText): void;
  74363. private _removeConnectedInputObservables;
  74364. /**
  74365. * Release all resources
  74366. */
  74367. dispose(): void;
  74368. /**
  74369. * Creates a new keyboard using a default layout
  74370. *
  74371. * @param name defines control name
  74372. * @returns a new VirtualKeyboard
  74373. */
  74374. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  74375. }
  74376. }
  74377. declare module BABYLON.GUI {
  74378. /**
  74379. * Class used to create input text control
  74380. */
  74381. export class InputText extends Control implements IFocusableControl {
  74382. name?: string | undefined;
  74383. private _text;
  74384. private _placeholderText;
  74385. private _background;
  74386. private _focusedBackground;
  74387. private _focusedColor;
  74388. private _placeholderColor;
  74389. private _thickness;
  74390. private _margin;
  74391. private _autoStretchWidth;
  74392. private _maxWidth;
  74393. private _isFocused;
  74394. private _blinkTimeout;
  74395. private _blinkIsEven;
  74396. private _cursorOffset;
  74397. private _scrollLeft;
  74398. private _textWidth;
  74399. private _clickedCoordinate;
  74400. private _deadKey;
  74401. private _addKey;
  74402. private _currentKey;
  74403. private _isTextHighlightOn;
  74404. private _textHighlightColor;
  74405. private _highligherOpacity;
  74406. private _highlightedText;
  74407. private _startHighlightIndex;
  74408. private _endHighlightIndex;
  74409. private _cursorIndex;
  74410. private _onFocusSelectAll;
  74411. private _isPointerDown;
  74412. private _onClipboardObserver;
  74413. private _onPointerDblTapObserver;
  74414. /** @hidden */
  74415. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  74416. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  74417. promptMessage: string;
  74418. /** Force disable prompt on mobile device */
  74419. disableMobilePrompt: boolean;
  74420. /** BABYLON.Observable raised when the text changes */
  74421. onTextChangedObservable: BABYLON.Observable<InputText>;
  74422. /** BABYLON.Observable raised just before an entered character is to be added */
  74423. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  74424. /** BABYLON.Observable raised when the control gets the focus */
  74425. onFocusObservable: BABYLON.Observable<InputText>;
  74426. /** BABYLON.Observable raised when the control loses the focus */
  74427. onBlurObservable: BABYLON.Observable<InputText>;
  74428. /**Observable raised when the text is highlighted */
  74429. onTextHighlightObservable: BABYLON.Observable<InputText>;
  74430. /**Observable raised when copy event is triggered */
  74431. onTextCopyObservable: BABYLON.Observable<InputText>;
  74432. /** BABYLON.Observable raised when cut event is triggered */
  74433. onTextCutObservable: BABYLON.Observable<InputText>;
  74434. /** BABYLON.Observable raised when paste event is triggered */
  74435. onTextPasteObservable: BABYLON.Observable<InputText>;
  74436. /** BABYLON.Observable raised when a key event was processed */
  74437. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  74438. /** Gets or sets the maximum width allowed by the control */
  74439. get maxWidth(): string | number;
  74440. /** Gets the maximum width allowed by the control in pixels */
  74441. get maxWidthInPixels(): number;
  74442. set maxWidth(value: string | number);
  74443. /** Gets or sets the text highlighter transparency; default: 0.4 */
  74444. get highligherOpacity(): number;
  74445. set highligherOpacity(value: number);
  74446. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  74447. get onFocusSelectAll(): boolean;
  74448. set onFocusSelectAll(value: boolean);
  74449. /** Gets or sets the text hightlight color */
  74450. get textHighlightColor(): string;
  74451. set textHighlightColor(value: string);
  74452. /** Gets or sets control margin */
  74453. get margin(): string;
  74454. /** Gets control margin in pixels */
  74455. get marginInPixels(): number;
  74456. set margin(value: string);
  74457. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  74458. get autoStretchWidth(): boolean;
  74459. set autoStretchWidth(value: boolean);
  74460. /** Gets or sets border thickness */
  74461. get thickness(): number;
  74462. set thickness(value: number);
  74463. /** Gets or sets the background color when focused */
  74464. get focusedBackground(): string;
  74465. set focusedBackground(value: string);
  74466. /** Gets or sets the background color when focused */
  74467. get focusedColor(): string;
  74468. set focusedColor(value: string);
  74469. /** Gets or sets the background color */
  74470. get background(): string;
  74471. set background(value: string);
  74472. /** Gets or sets the placeholder color */
  74473. get placeholderColor(): string;
  74474. set placeholderColor(value: string);
  74475. /** Gets or sets the text displayed when the control is empty */
  74476. get placeholderText(): string;
  74477. set placeholderText(value: string);
  74478. /** Gets or sets the dead key flag */
  74479. get deadKey(): boolean;
  74480. set deadKey(flag: boolean);
  74481. /** Gets or sets the highlight text */
  74482. get highlightedText(): string;
  74483. set highlightedText(text: string);
  74484. /** Gets or sets if the current key should be added */
  74485. get addKey(): boolean;
  74486. set addKey(flag: boolean);
  74487. /** Gets or sets the value of the current key being entered */
  74488. get currentKey(): string;
  74489. set currentKey(key: string);
  74490. /** Gets or sets the text displayed in the control */
  74491. get text(): string;
  74492. set text(value: string);
  74493. /** Gets or sets control width */
  74494. get width(): string | number;
  74495. set width(value: string | number);
  74496. /**
  74497. * Creates a new InputText
  74498. * @param name defines the control name
  74499. * @param text defines the text of the control
  74500. */
  74501. constructor(name?: string | undefined, text?: string);
  74502. /** @hidden */
  74503. onBlur(): void;
  74504. /** @hidden */
  74505. onFocus(): void;
  74506. protected _getTypeName(): string;
  74507. /**
  74508. * Function called to get the list of controls that should not steal the focus from this control
  74509. * @returns an array of controls
  74510. */
  74511. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74512. /** @hidden */
  74513. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  74514. /** @hidden */
  74515. private _updateValueFromCursorIndex;
  74516. /** @hidden */
  74517. private _processDblClick;
  74518. /** @hidden */
  74519. private _selectAllText;
  74520. /**
  74521. * Handles the keyboard event
  74522. * @param evt Defines the KeyboardEvent
  74523. */
  74524. processKeyboard(evt: KeyboardEvent): void;
  74525. /** @hidden */
  74526. private _onCopyText;
  74527. /** @hidden */
  74528. private _onCutText;
  74529. /** @hidden */
  74530. private _onPasteText;
  74531. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74532. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74533. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74534. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74535. protected _beforeRenderText(text: string): string;
  74536. dispose(): void;
  74537. }
  74538. }
  74539. declare module BABYLON.GUI {
  74540. /**
  74541. * Class used to create a 2D grid container
  74542. */
  74543. export class Grid extends Container {
  74544. name?: string | undefined;
  74545. private _rowDefinitions;
  74546. private _columnDefinitions;
  74547. private _cells;
  74548. private _childControls;
  74549. /**
  74550. * Gets the number of columns
  74551. */
  74552. get columnCount(): number;
  74553. /**
  74554. * Gets the number of rows
  74555. */
  74556. get rowCount(): number;
  74557. /** Gets the list of children */
  74558. get children(): Control[];
  74559. /** Gets the list of cells (e.g. the containers) */
  74560. get cells(): {
  74561. [key: string]: Container;
  74562. };
  74563. /**
  74564. * Gets the definition of a specific row
  74565. * @param index defines the index of the row
  74566. * @returns the row definition
  74567. */
  74568. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74569. /**
  74570. * Gets the definition of a specific column
  74571. * @param index defines the index of the column
  74572. * @returns the column definition
  74573. */
  74574. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74575. /**
  74576. * Adds a new row to the grid
  74577. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74578. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  74579. * @returns the current grid
  74580. */
  74581. addRowDefinition(height: number, isPixel?: boolean): Grid;
  74582. /**
  74583. * Adds a new column to the grid
  74584. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74585. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74586. * @returns the current grid
  74587. */
  74588. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  74589. /**
  74590. * Update a row definition
  74591. * @param index defines the index of the row to update
  74592. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74593. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  74594. * @returns the current grid
  74595. */
  74596. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  74597. /**
  74598. * Update a column definition
  74599. * @param index defines the index of the column to update
  74600. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74601. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74602. * @returns the current grid
  74603. */
  74604. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  74605. /**
  74606. * Gets the list of children stored in a specific cell
  74607. * @param row defines the row to check
  74608. * @param column defines the column to check
  74609. * @returns the list of controls
  74610. */
  74611. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  74612. /**
  74613. * Gets a string representing the child cell info (row x column)
  74614. * @param child defines the control to get info from
  74615. * @returns a string containing the child cell info (row x column)
  74616. */
  74617. getChildCellInfo(child: Control): string;
  74618. private _removeCell;
  74619. private _offsetCell;
  74620. /**
  74621. * Remove a column definition at specified index
  74622. * @param index defines the index of the column to remove
  74623. * @returns the current grid
  74624. */
  74625. removeColumnDefinition(index: number): Grid;
  74626. /**
  74627. * Remove a row definition at specified index
  74628. * @param index defines the index of the row to remove
  74629. * @returns the current grid
  74630. */
  74631. removeRowDefinition(index: number): Grid;
  74632. /**
  74633. * Adds a new control to the current grid
  74634. * @param control defines the control to add
  74635. * @param row defines the row where to add the control (0 by default)
  74636. * @param column defines the column where to add the control (0 by default)
  74637. * @returns the current grid
  74638. */
  74639. addControl(control: Control, row?: number, column?: number): Grid;
  74640. /**
  74641. * Removes a control from the current container
  74642. * @param control defines the control to remove
  74643. * @returns the current container
  74644. */
  74645. removeControl(control: Control): Container;
  74646. /**
  74647. * Creates a new Grid
  74648. * @param name defines control name
  74649. */
  74650. constructor(name?: string | undefined);
  74651. protected _getTypeName(): string;
  74652. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  74653. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74654. _flagDescendantsAsMatrixDirty(): void;
  74655. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74656. /** Releases associated resources */
  74657. dispose(): void;
  74658. }
  74659. }
  74660. declare module BABYLON.GUI {
  74661. /** Class used to create color pickers */
  74662. export class ColorPicker extends Control {
  74663. name?: string | undefined;
  74664. private static _Epsilon;
  74665. private _colorWheelCanvas;
  74666. private _value;
  74667. private _tmpColor;
  74668. private _pointerStartedOnSquare;
  74669. private _pointerStartedOnWheel;
  74670. private _squareLeft;
  74671. private _squareTop;
  74672. private _squareSize;
  74673. private _h;
  74674. private _s;
  74675. private _v;
  74676. private _lastPointerDownID;
  74677. /**
  74678. * BABYLON.Observable raised when the value changes
  74679. */
  74680. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  74681. /** Gets or sets the color of the color picker */
  74682. get value(): BABYLON.Color3;
  74683. set value(value: BABYLON.Color3);
  74684. /**
  74685. * Gets or sets control width
  74686. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74687. */
  74688. get width(): string | number;
  74689. set width(value: string | number);
  74690. /**
  74691. * Gets or sets control height
  74692. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74693. */
  74694. get height(): string | number;
  74695. /** Gets or sets control height */
  74696. set height(value: string | number);
  74697. /** Gets or sets control size */
  74698. get size(): string | number;
  74699. set size(value: string | number);
  74700. /**
  74701. * Creates a new ColorPicker
  74702. * @param name defines the control name
  74703. */
  74704. constructor(name?: string | undefined);
  74705. protected _getTypeName(): string;
  74706. /** @hidden */
  74707. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74708. private _updateSquareProps;
  74709. private _drawGradientSquare;
  74710. private _drawCircle;
  74711. private _createColorWheelCanvas;
  74712. /** @hidden */
  74713. _draw(context: CanvasRenderingContext2D): void;
  74714. private _pointerIsDown;
  74715. private _updateValueFromPointer;
  74716. private _isPointOnSquare;
  74717. private _isPointOnWheel;
  74718. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74719. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74720. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74721. /**
  74722. * This function expands the color picker by creating a color picker dialog with manual
  74723. * color value input and the ability to save colors into an array to be used later in
  74724. * subsequent launches of the dialogue.
  74725. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  74726. * @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.
  74727. * @returns picked color as a hex string and the saved colors array as hex strings.
  74728. */
  74729. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  74730. pickerWidth?: string;
  74731. pickerHeight?: string;
  74732. headerHeight?: string;
  74733. lastColor?: string;
  74734. swatchLimit?: number;
  74735. numSwatchesPerLine?: number;
  74736. savedColors?: Array<string>;
  74737. }): Promise<{
  74738. savedColors?: string[];
  74739. pickedColor: string;
  74740. }>;
  74741. }
  74742. }
  74743. declare module BABYLON.GUI {
  74744. /** Class used to create 2D ellipse containers */
  74745. export class Ellipse extends Container {
  74746. name?: string | undefined;
  74747. private _thickness;
  74748. /** Gets or sets border thickness */
  74749. get thickness(): number;
  74750. set thickness(value: number);
  74751. /**
  74752. * Creates a new Ellipse
  74753. * @param name defines the control name
  74754. */
  74755. constructor(name?: string | undefined);
  74756. protected _getTypeName(): string;
  74757. protected _localDraw(context: CanvasRenderingContext2D): void;
  74758. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74759. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74760. }
  74761. }
  74762. declare module BABYLON.GUI {
  74763. /**
  74764. * Class used to create a password control
  74765. */
  74766. export class InputPassword extends InputText {
  74767. protected _beforeRenderText(text: string): string;
  74768. }
  74769. }
  74770. declare module BABYLON.GUI {
  74771. /** Class used to render 2D lines */
  74772. export class Line extends Control {
  74773. name?: string | undefined;
  74774. private _lineWidth;
  74775. private _x1;
  74776. private _y1;
  74777. private _x2;
  74778. private _y2;
  74779. private _dash;
  74780. private _connectedControl;
  74781. private _connectedControlDirtyObserver;
  74782. /** Gets or sets the dash pattern */
  74783. get dash(): Array<number>;
  74784. set dash(value: Array<number>);
  74785. /** Gets or sets the control connected with the line end */
  74786. get connectedControl(): Control;
  74787. set connectedControl(value: Control);
  74788. /** Gets or sets start coordinates on X axis */
  74789. get x1(): string | number;
  74790. set x1(value: string | number);
  74791. /** Gets or sets start coordinates on Y axis */
  74792. get y1(): string | number;
  74793. set y1(value: string | number);
  74794. /** Gets or sets end coordinates on X axis */
  74795. get x2(): string | number;
  74796. set x2(value: string | number);
  74797. /** Gets or sets end coordinates on Y axis */
  74798. get y2(): string | number;
  74799. set y2(value: string | number);
  74800. /** Gets or sets line width */
  74801. get lineWidth(): number;
  74802. set lineWidth(value: number);
  74803. /** Gets or sets horizontal alignment */
  74804. set horizontalAlignment(value: number);
  74805. /** Gets or sets vertical alignment */
  74806. set verticalAlignment(value: number);
  74807. private get _effectiveX2();
  74808. private get _effectiveY2();
  74809. /**
  74810. * Creates a new Line
  74811. * @param name defines the control name
  74812. */
  74813. constructor(name?: string | undefined);
  74814. protected _getTypeName(): string;
  74815. _draw(context: CanvasRenderingContext2D): void;
  74816. _measure(): void;
  74817. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74818. /**
  74819. * Move one end of the line given 3D cartesian coordinates.
  74820. * @param position Targeted world position
  74821. * @param scene BABYLON.Scene
  74822. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  74823. */
  74824. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  74825. /**
  74826. * Move one end of the line to a position in screen absolute space.
  74827. * @param projectedPosition Position in screen absolute space (X, Y)
  74828. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  74829. */
  74830. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  74831. }
  74832. }
  74833. declare module BABYLON.GUI {
  74834. /**
  74835. * Class used to store a point for a MultiLine object.
  74836. * The point can be pure 2D coordinates, a mesh or a control
  74837. */
  74838. export class MultiLinePoint {
  74839. private _multiLine;
  74840. private _x;
  74841. private _y;
  74842. private _control;
  74843. private _mesh;
  74844. private _controlObserver;
  74845. private _meshObserver;
  74846. /** @hidden */
  74847. _point: BABYLON.Vector2;
  74848. /**
  74849. * Creates a new MultiLinePoint
  74850. * @param multiLine defines the source MultiLine object
  74851. */
  74852. constructor(multiLine: MultiLine);
  74853. /** Gets or sets x coordinate */
  74854. get x(): string | number;
  74855. set x(value: string | number);
  74856. /** Gets or sets y coordinate */
  74857. get y(): string | number;
  74858. set y(value: string | number);
  74859. /** Gets or sets the control associated with this point */
  74860. get control(): BABYLON.Nullable<Control>;
  74861. set control(value: BABYLON.Nullable<Control>);
  74862. /** Gets or sets the mesh associated with this point */
  74863. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74864. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  74865. /** Resets links */
  74866. resetLinks(): void;
  74867. /**
  74868. * Gets a translation vector
  74869. * @returns the translation vector
  74870. */
  74871. translate(): BABYLON.Vector2;
  74872. private _translatePoint;
  74873. /** Release associated resources */
  74874. dispose(): void;
  74875. }
  74876. }
  74877. declare module BABYLON.GUI {
  74878. /**
  74879. * Class used to create multi line control
  74880. */
  74881. export class MultiLine extends Control {
  74882. name?: string | undefined;
  74883. private _lineWidth;
  74884. private _dash;
  74885. private _points;
  74886. private _minX;
  74887. private _minY;
  74888. private _maxX;
  74889. private _maxY;
  74890. /**
  74891. * Creates a new MultiLine
  74892. * @param name defines the control name
  74893. */
  74894. constructor(name?: string | undefined);
  74895. /** Gets or sets dash pattern */
  74896. get dash(): Array<number>;
  74897. set dash(value: Array<number>);
  74898. /**
  74899. * Gets point stored at specified index
  74900. * @param index defines the index to look for
  74901. * @returns the requested point if found
  74902. */
  74903. getAt(index: number): MultiLinePoint;
  74904. /** Function called when a point is updated */
  74905. onPointUpdate: () => void;
  74906. /**
  74907. * Adds new points to the point collection
  74908. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  74909. * @returns the list of created MultiLinePoint
  74910. */
  74911. add(...items: (AbstractMesh | Control | {
  74912. x: string | number;
  74913. y: string | number;
  74914. })[]): MultiLinePoint[];
  74915. /**
  74916. * Adds a new point to the point collection
  74917. * @param item defines the item (mesh, control or 2d coordiantes) to add
  74918. * @returns the created MultiLinePoint
  74919. */
  74920. push(item?: (AbstractMesh | Control | {
  74921. x: string | number;
  74922. y: string | number;
  74923. })): MultiLinePoint;
  74924. /**
  74925. * Remove a specific value or point from the active point collection
  74926. * @param value defines the value or point to remove
  74927. */
  74928. remove(value: number | MultiLinePoint): void;
  74929. /**
  74930. * Resets this object to initial state (no point)
  74931. */
  74932. reset(): void;
  74933. /**
  74934. * Resets all links
  74935. */
  74936. resetLinks(): void;
  74937. /** Gets or sets line width */
  74938. get lineWidth(): number;
  74939. set lineWidth(value: number);
  74940. set horizontalAlignment(value: number);
  74941. set verticalAlignment(value: number);
  74942. protected _getTypeName(): string;
  74943. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74944. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74945. _measure(): void;
  74946. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74947. dispose(): void;
  74948. }
  74949. }
  74950. declare module BABYLON.GUI {
  74951. /**
  74952. * Class used to create radio button controls
  74953. */
  74954. export class RadioButton extends Control {
  74955. name?: string | undefined;
  74956. private _isChecked;
  74957. private _background;
  74958. private _checkSizeRatio;
  74959. private _thickness;
  74960. /** Gets or sets border thickness */
  74961. get thickness(): number;
  74962. set thickness(value: number);
  74963. /** Gets or sets group name */
  74964. group: string;
  74965. /** BABYLON.Observable raised when isChecked is changed */
  74966. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74967. /** Gets or sets a value indicating the ratio between overall size and check size */
  74968. get checkSizeRatio(): number;
  74969. set checkSizeRatio(value: number);
  74970. /** Gets or sets background color */
  74971. get background(): string;
  74972. set background(value: string);
  74973. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74974. get isChecked(): boolean;
  74975. set isChecked(value: boolean);
  74976. /**
  74977. * Creates a new RadioButton
  74978. * @param name defines the control name
  74979. */
  74980. constructor(name?: string | undefined);
  74981. protected _getTypeName(): string;
  74982. _draw(context: CanvasRenderingContext2D): void;
  74983. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74984. /**
  74985. * Utility function to easily create a radio button with a header
  74986. * @param title defines the label to use for the header
  74987. * @param group defines the group to use for the radio button
  74988. * @param isChecked defines the initial state of the radio button
  74989. * @param onValueChanged defines the callback to call when value changes
  74990. * @returns a StackPanel containing the radio button and a textBlock
  74991. */
  74992. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  74993. }
  74994. }
  74995. declare module BABYLON.GUI {
  74996. /**
  74997. * Class used to create slider controls
  74998. */
  74999. export class BaseSlider extends Control {
  75000. name?: string | undefined;
  75001. protected _thumbWidth: ValueAndUnit;
  75002. private _minimum;
  75003. private _maximum;
  75004. private _value;
  75005. private _isVertical;
  75006. protected _barOffset: ValueAndUnit;
  75007. private _isThumbClamped;
  75008. protected _displayThumb: boolean;
  75009. private _step;
  75010. private _lastPointerDownID;
  75011. protected _effectiveBarOffset: number;
  75012. protected _renderLeft: number;
  75013. protected _renderTop: number;
  75014. protected _renderWidth: number;
  75015. protected _renderHeight: number;
  75016. protected _backgroundBoxLength: number;
  75017. protected _backgroundBoxThickness: number;
  75018. protected _effectiveThumbThickness: number;
  75019. /** BABYLON.Observable raised when the sldier value changes */
  75020. onValueChangedObservable: BABYLON.Observable<number>;
  75021. /** Gets or sets a boolean indicating if the thumb must be rendered */
  75022. get displayThumb(): boolean;
  75023. set displayThumb(value: boolean);
  75024. /** Gets or sets a step to apply to values (0 by default) */
  75025. get step(): number;
  75026. set step(value: number);
  75027. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  75028. get barOffset(): string | number;
  75029. /** Gets main bar offset in pixels*/
  75030. get barOffsetInPixels(): number;
  75031. set barOffset(value: string | number);
  75032. /** Gets or sets thumb width */
  75033. get thumbWidth(): string | number;
  75034. /** Gets thumb width in pixels */
  75035. get thumbWidthInPixels(): number;
  75036. set thumbWidth(value: string | number);
  75037. /** Gets or sets minimum value */
  75038. get minimum(): number;
  75039. set minimum(value: number);
  75040. /** Gets or sets maximum value */
  75041. get maximum(): number;
  75042. set maximum(value: number);
  75043. /** Gets or sets current value */
  75044. get value(): number;
  75045. set value(value: number);
  75046. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  75047. get isVertical(): boolean;
  75048. set isVertical(value: boolean);
  75049. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  75050. get isThumbClamped(): boolean;
  75051. set isThumbClamped(value: boolean);
  75052. /**
  75053. * Creates a new BaseSlider
  75054. * @param name defines the control name
  75055. */
  75056. constructor(name?: string | undefined);
  75057. protected _getTypeName(): string;
  75058. protected _getThumbPosition(): number;
  75059. protected _getThumbThickness(type: string): number;
  75060. protected _prepareRenderingData(type: string): void;
  75061. private _pointerIsDown;
  75062. /** @hidden */
  75063. protected _updateValueFromPointer(x: number, y: number): void;
  75064. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75065. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75066. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75067. }
  75068. }
  75069. declare module BABYLON.GUI {
  75070. /**
  75071. * Class used to create slider controls
  75072. */
  75073. export class Slider extends BaseSlider {
  75074. name?: string | undefined;
  75075. private _background;
  75076. private _borderColor;
  75077. private _isThumbCircle;
  75078. protected _displayValueBar: boolean;
  75079. /** Gets or sets a boolean indicating if the value bar must be rendered */
  75080. get displayValueBar(): boolean;
  75081. set displayValueBar(value: boolean);
  75082. /** Gets or sets border color */
  75083. get borderColor(): string;
  75084. set borderColor(value: string);
  75085. /** Gets or sets background color */
  75086. get background(): string;
  75087. set background(value: string);
  75088. /** Gets or sets a boolean indicating if the thumb should be round or square */
  75089. get isThumbCircle(): boolean;
  75090. set isThumbCircle(value: boolean);
  75091. /**
  75092. * Creates a new Slider
  75093. * @param name defines the control name
  75094. */
  75095. constructor(name?: string | undefined);
  75096. protected _getTypeName(): string;
  75097. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75098. }
  75099. }
  75100. declare module BABYLON.GUI {
  75101. /** Class used to create a RadioGroup
  75102. * which contains groups of radio buttons
  75103. */
  75104. export class SelectorGroup {
  75105. /** name of SelectorGroup */
  75106. name: string;
  75107. private _groupPanel;
  75108. private _selectors;
  75109. private _groupHeader;
  75110. /**
  75111. * Creates a new SelectorGroup
  75112. * @param name of group, used as a group heading
  75113. */
  75114. constructor(
  75115. /** name of SelectorGroup */
  75116. name: string);
  75117. /** Gets the groupPanel of the SelectorGroup */
  75118. get groupPanel(): StackPanel;
  75119. /** Gets the selectors array */
  75120. get selectors(): StackPanel[];
  75121. /** Gets and sets the group header */
  75122. get header(): string;
  75123. set header(label: string);
  75124. /** @hidden */
  75125. private _addGroupHeader;
  75126. /** @hidden*/
  75127. _getSelector(selectorNb: number): StackPanel | undefined;
  75128. /** Removes the selector at the given position
  75129. * @param selectorNb the position of the selector within the group
  75130. */
  75131. removeSelector(selectorNb: number): void;
  75132. }
  75133. /** Class used to create a CheckboxGroup
  75134. * which contains groups of checkbox buttons
  75135. */
  75136. export class CheckboxGroup extends SelectorGroup {
  75137. /** Adds a checkbox as a control
  75138. * @param text is the label for the selector
  75139. * @param func is the function called when the Selector is checked
  75140. * @param checked is true when Selector is checked
  75141. */
  75142. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  75143. /** @hidden */
  75144. _setSelectorLabel(selectorNb: number, label: string): void;
  75145. /** @hidden */
  75146. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75147. /** @hidden */
  75148. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75149. /** @hidden */
  75150. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75151. }
  75152. /** Class used to create a RadioGroup
  75153. * which contains groups of radio buttons
  75154. */
  75155. export class RadioGroup extends SelectorGroup {
  75156. private _selectNb;
  75157. /** Adds a radio button as a control
  75158. * @param label is the label for the selector
  75159. * @param func is the function called when the Selector is checked
  75160. * @param checked is true when Selector is checked
  75161. */
  75162. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  75163. /** @hidden */
  75164. _setSelectorLabel(selectorNb: number, label: string): void;
  75165. /** @hidden */
  75166. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75167. /** @hidden */
  75168. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75169. /** @hidden */
  75170. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75171. }
  75172. /** Class used to create a SliderGroup
  75173. * which contains groups of slider buttons
  75174. */
  75175. export class SliderGroup extends SelectorGroup {
  75176. /**
  75177. * Adds a slider to the SelectorGroup
  75178. * @param label is the label for the SliderBar
  75179. * @param func is the function called when the Slider moves
  75180. * @param unit is a string describing the units used, eg degrees or metres
  75181. * @param min is the minimum value for the Slider
  75182. * @param max is the maximum value for the Slider
  75183. * @param value is the start value for the Slider between min and max
  75184. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  75185. */
  75186. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  75187. /** @hidden */
  75188. _setSelectorLabel(selectorNb: number, label: string): void;
  75189. /** @hidden */
  75190. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75191. /** @hidden */
  75192. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75193. /** @hidden */
  75194. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75195. }
  75196. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  75197. * @see http://doc.babylonjs.com/how_to/selector
  75198. */
  75199. export class SelectionPanel extends Rectangle {
  75200. /** name of SelectionPanel */
  75201. name: string;
  75202. /** an array of SelectionGroups */
  75203. groups: SelectorGroup[];
  75204. private _panel;
  75205. private _buttonColor;
  75206. private _buttonBackground;
  75207. private _headerColor;
  75208. private _barColor;
  75209. private _barHeight;
  75210. private _spacerHeight;
  75211. private _labelColor;
  75212. private _groups;
  75213. private _bars;
  75214. /**
  75215. * Creates a new SelectionPanel
  75216. * @param name of SelectionPanel
  75217. * @param groups is an array of SelectionGroups
  75218. */
  75219. constructor(
  75220. /** name of SelectionPanel */
  75221. name: string,
  75222. /** an array of SelectionGroups */
  75223. groups?: SelectorGroup[]);
  75224. protected _getTypeName(): string;
  75225. /** Gets or sets the headerColor */
  75226. get headerColor(): string;
  75227. set headerColor(color: string);
  75228. private _setHeaderColor;
  75229. /** Gets or sets the button color */
  75230. get buttonColor(): string;
  75231. set buttonColor(color: string);
  75232. private _setbuttonColor;
  75233. /** Gets or sets the label color */
  75234. get labelColor(): string;
  75235. set labelColor(color: string);
  75236. private _setLabelColor;
  75237. /** Gets or sets the button background */
  75238. get buttonBackground(): string;
  75239. set buttonBackground(color: string);
  75240. private _setButtonBackground;
  75241. /** Gets or sets the color of separator bar */
  75242. get barColor(): string;
  75243. set barColor(color: string);
  75244. private _setBarColor;
  75245. /** Gets or sets the height of separator bar */
  75246. get barHeight(): string;
  75247. set barHeight(value: string);
  75248. private _setBarHeight;
  75249. /** Gets or sets the height of spacers*/
  75250. get spacerHeight(): string;
  75251. set spacerHeight(value: string);
  75252. private _setSpacerHeight;
  75253. /** Adds a bar between groups */
  75254. private _addSpacer;
  75255. /** Add a group to the selection panel
  75256. * @param group is the selector group to add
  75257. */
  75258. addGroup(group: SelectorGroup): void;
  75259. /** Remove the group from the given position
  75260. * @param groupNb is the position of the group in the list
  75261. */
  75262. removeGroup(groupNb: number): void;
  75263. /** Change a group header label
  75264. * @param label is the new group header label
  75265. * @param groupNb is the number of the group to relabel
  75266. * */
  75267. setHeaderName(label: string, groupNb: number): void;
  75268. /** Change selector label to the one given
  75269. * @param label is the new selector label
  75270. * @param groupNb is the number of the groupcontaining the selector
  75271. * @param selectorNb is the number of the selector within a group to relabel
  75272. * */
  75273. relabel(label: string, groupNb: number, selectorNb: number): void;
  75274. /** For a given group position remove the selector at the given position
  75275. * @param groupNb is the number of the group to remove the selector from
  75276. * @param selectorNb is the number of the selector within the group
  75277. */
  75278. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  75279. /** For a given group position of correct type add a checkbox button
  75280. * @param groupNb is the number of the group to remove the selector from
  75281. * @param label is the label for the selector
  75282. * @param func is the function called when the Selector is checked
  75283. * @param checked is true when Selector is checked
  75284. */
  75285. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75286. /** For a given group position of correct type add a radio button
  75287. * @param groupNb is the number of the group to remove the selector from
  75288. * @param label is the label for the selector
  75289. * @param func is the function called when the Selector is checked
  75290. * @param checked is true when Selector is checked
  75291. */
  75292. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75293. /**
  75294. * For a given slider group add a slider
  75295. * @param groupNb is the number of the group to add the slider to
  75296. * @param label is the label for the Slider
  75297. * @param func is the function called when the Slider moves
  75298. * @param unit is a string describing the units used, eg degrees or metres
  75299. * @param min is the minimum value for the Slider
  75300. * @param max is the maximum value for the Slider
  75301. * @param value is the start value for the Slider between min and max
  75302. * @param onVal is the function used to format the value displayed, eg radians to degrees
  75303. */
  75304. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  75305. }
  75306. }
  75307. declare module BABYLON.GUI {
  75308. /**
  75309. * Class used to hold a the container for ScrollViewer
  75310. * @hidden
  75311. */
  75312. export class _ScrollViewerWindow extends Container {
  75313. parentClientWidth: number;
  75314. parentClientHeight: number;
  75315. private _freezeControls;
  75316. private _parentMeasure;
  75317. private _oldLeft;
  75318. private _oldTop;
  75319. get freezeControls(): boolean;
  75320. set freezeControls(value: boolean);
  75321. private _bucketWidth;
  75322. private _bucketHeight;
  75323. private _buckets;
  75324. private _bucketLen;
  75325. get bucketWidth(): number;
  75326. get bucketHeight(): number;
  75327. setBucketSizes(width: number, height: number): void;
  75328. private _useBuckets;
  75329. private _makeBuckets;
  75330. private _dispatchInBuckets;
  75331. private _updateMeasures;
  75332. private _updateChildrenMeasures;
  75333. private _restoreMeasures;
  75334. /**
  75335. * Creates a new ScrollViewerWindow
  75336. * @param name of ScrollViewerWindow
  75337. */
  75338. constructor(name?: string);
  75339. protected _getTypeName(): string;
  75340. /** @hidden */
  75341. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75342. /** @hidden */
  75343. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75344. private _scrollChildren;
  75345. private _scrollChildrenWithBuckets;
  75346. /** @hidden */
  75347. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75348. protected _postMeasure(): void;
  75349. }
  75350. }
  75351. declare module BABYLON.GUI {
  75352. /**
  75353. * Class used to create slider controls
  75354. */
  75355. export class ScrollBar extends BaseSlider {
  75356. name?: string | undefined;
  75357. private _background;
  75358. private _borderColor;
  75359. private _tempMeasure;
  75360. /** Gets or sets border color */
  75361. get borderColor(): string;
  75362. set borderColor(value: string);
  75363. /** Gets or sets background color */
  75364. get background(): string;
  75365. set background(value: string);
  75366. /**
  75367. * Creates a new Slider
  75368. * @param name defines the control name
  75369. */
  75370. constructor(name?: string | undefined);
  75371. protected _getTypeName(): string;
  75372. protected _getThumbThickness(): number;
  75373. _draw(context: CanvasRenderingContext2D): void;
  75374. private _first;
  75375. private _originX;
  75376. private _originY;
  75377. /** @hidden */
  75378. protected _updateValueFromPointer(x: number, y: number): void;
  75379. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75380. }
  75381. }
  75382. declare module BABYLON.GUI {
  75383. /**
  75384. * Class used to create slider controls
  75385. */
  75386. export class ImageScrollBar extends BaseSlider {
  75387. name?: string | undefined;
  75388. private _backgroundBaseImage;
  75389. private _backgroundImage;
  75390. private _thumbImage;
  75391. private _thumbBaseImage;
  75392. private _thumbLength;
  75393. private _thumbHeight;
  75394. private _barImageHeight;
  75395. private _tempMeasure;
  75396. /** Number of 90° rotation to apply on the images when in vertical mode */
  75397. num90RotationInVerticalMode: number;
  75398. /**
  75399. * Gets or sets the image used to render the background for horizontal bar
  75400. */
  75401. get backgroundImage(): Image;
  75402. set backgroundImage(value: Image);
  75403. /**
  75404. * Gets or sets the image used to render the thumb
  75405. */
  75406. get thumbImage(): Image;
  75407. set thumbImage(value: Image);
  75408. /**
  75409. * Gets or sets the length of the thumb
  75410. */
  75411. get thumbLength(): number;
  75412. set thumbLength(value: number);
  75413. /**
  75414. * Gets or sets the height of the thumb
  75415. */
  75416. get thumbHeight(): number;
  75417. set thumbHeight(value: number);
  75418. /**
  75419. * Gets or sets the height of the bar image
  75420. */
  75421. get barImageHeight(): number;
  75422. set barImageHeight(value: number);
  75423. /**
  75424. * Creates a new ImageScrollBar
  75425. * @param name defines the control name
  75426. */
  75427. constructor(name?: string | undefined);
  75428. protected _getTypeName(): string;
  75429. protected _getThumbThickness(): number;
  75430. _draw(context: CanvasRenderingContext2D): void;
  75431. private _first;
  75432. private _originX;
  75433. private _originY;
  75434. /** @hidden */
  75435. protected _updateValueFromPointer(x: number, y: number): void;
  75436. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75437. }
  75438. }
  75439. declare module BABYLON.GUI {
  75440. /**
  75441. * Class used to hold a viewer window and sliders in a grid
  75442. */
  75443. export class ScrollViewer extends Rectangle {
  75444. private _grid;
  75445. private _horizontalBarSpace;
  75446. private _verticalBarSpace;
  75447. private _dragSpace;
  75448. private _horizontalBar;
  75449. private _verticalBar;
  75450. private _barColor;
  75451. private _barBackground;
  75452. private _barImage;
  75453. private _horizontalBarImage;
  75454. private _verticalBarImage;
  75455. private _barBackgroundImage;
  75456. private _horizontalBarBackgroundImage;
  75457. private _verticalBarBackgroundImage;
  75458. private _barSize;
  75459. private _window;
  75460. private _pointerIsOver;
  75461. private _wheelPrecision;
  75462. private _onWheelObserver;
  75463. private _clientWidth;
  75464. private _clientHeight;
  75465. private _useImageBar;
  75466. private _thumbLength;
  75467. private _thumbHeight;
  75468. private _barImageHeight;
  75469. private _horizontalBarImageHeight;
  75470. private _verticalBarImageHeight;
  75471. private _oldWindowContentsWidth;
  75472. private _oldWindowContentsHeight;
  75473. /**
  75474. * Gets the horizontal scrollbar
  75475. */
  75476. get horizontalBar(): ScrollBar | ImageScrollBar;
  75477. /**
  75478. * Gets the vertical scrollbar
  75479. */
  75480. get verticalBar(): ScrollBar | ImageScrollBar;
  75481. /**
  75482. * Adds a new control to the current container
  75483. * @param control defines the control to add
  75484. * @returns the current container
  75485. */
  75486. addControl(control: BABYLON.Nullable<Control>): Container;
  75487. /**
  75488. * Removes a control from the current container
  75489. * @param control defines the control to remove
  75490. * @returns the current container
  75491. */
  75492. removeControl(control: Control): Container;
  75493. /** Gets the list of children */
  75494. get children(): Control[];
  75495. _flagDescendantsAsMatrixDirty(): void;
  75496. /**
  75497. * Freezes or unfreezes the controls in the window.
  75498. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  75499. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  75500. */
  75501. get freezeControls(): boolean;
  75502. set freezeControls(value: boolean);
  75503. /** Gets the bucket width */
  75504. get bucketWidth(): number;
  75505. /** Gets the bucket height */
  75506. get bucketHeight(): number;
  75507. /**
  75508. * Sets the bucket sizes.
  75509. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  75510. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  75511. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  75512. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  75513. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  75514. * used), that's why it is not enabled by default.
  75515. * @param width width of the bucket
  75516. * @param height height of the bucket
  75517. */
  75518. setBucketSizes(width: number, height: number): void;
  75519. private _forceHorizontalBar;
  75520. private _forceVerticalBar;
  75521. /**
  75522. * Forces the horizontal scroll bar to be displayed
  75523. */
  75524. get forceHorizontalBar(): boolean;
  75525. set forceHorizontalBar(value: boolean);
  75526. /**
  75527. * Forces the vertical scroll bar to be displayed
  75528. */
  75529. get forceVerticalBar(): boolean;
  75530. set forceVerticalBar(value: boolean);
  75531. /**
  75532. * Creates a new ScrollViewer
  75533. * @param name of ScrollViewer
  75534. */
  75535. constructor(name?: string, isImageBased?: boolean);
  75536. /** Reset the scroll viewer window to initial size */
  75537. resetWindow(): void;
  75538. protected _getTypeName(): string;
  75539. private _buildClientSizes;
  75540. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75541. protected _postMeasure(): void;
  75542. /**
  75543. * Gets or sets the mouse wheel precision
  75544. * from 0 to 1 with a default value of 0.05
  75545. * */
  75546. get wheelPrecision(): number;
  75547. set wheelPrecision(value: number);
  75548. /** Gets or sets the scroll bar container background color */
  75549. get scrollBackground(): string;
  75550. set scrollBackground(color: string);
  75551. /** Gets or sets the bar color */
  75552. get barColor(): string;
  75553. set barColor(color: string);
  75554. /** Gets or sets the bar image */
  75555. get thumbImage(): Image;
  75556. set thumbImage(value: Image);
  75557. /** Gets or sets the horizontal bar image */
  75558. get horizontalThumbImage(): Image;
  75559. set horizontalThumbImage(value: Image);
  75560. /** Gets or sets the vertical bar image */
  75561. get verticalThumbImage(): Image;
  75562. set verticalThumbImage(value: Image);
  75563. /** Gets or sets the size of the bar */
  75564. get barSize(): number;
  75565. set barSize(value: number);
  75566. /** Gets or sets the length of the thumb */
  75567. get thumbLength(): number;
  75568. set thumbLength(value: number);
  75569. /** Gets or sets the height of the thumb */
  75570. get thumbHeight(): number;
  75571. set thumbHeight(value: number);
  75572. /** Gets or sets the height of the bar image */
  75573. get barImageHeight(): number;
  75574. set barImageHeight(value: number);
  75575. /** Gets or sets the height of the horizontal bar image */
  75576. get horizontalBarImageHeight(): number;
  75577. set horizontalBarImageHeight(value: number);
  75578. /** Gets or sets the height of the vertical bar image */
  75579. get verticalBarImageHeight(): number;
  75580. set verticalBarImageHeight(value: number);
  75581. /** Gets or sets the bar background */
  75582. get barBackground(): string;
  75583. set barBackground(color: string);
  75584. /** Gets or sets the bar background image */
  75585. get barImage(): Image;
  75586. set barImage(value: Image);
  75587. /** Gets or sets the horizontal bar background image */
  75588. get horizontalBarImage(): Image;
  75589. set horizontalBarImage(value: Image);
  75590. /** Gets or sets the vertical bar background image */
  75591. get verticalBarImage(): Image;
  75592. set verticalBarImage(value: Image);
  75593. private _setWindowPosition;
  75594. /** @hidden */
  75595. private _updateScroller;
  75596. _link(host: AdvancedDynamicTexture): void;
  75597. /** @hidden */
  75598. private _addBar;
  75599. /** @hidden */
  75600. private _attachWheel;
  75601. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75602. /** Releases associated resources */
  75603. dispose(): void;
  75604. }
  75605. }
  75606. declare module BABYLON.GUI {
  75607. /** Class used to render a grid */
  75608. export class DisplayGrid extends Control {
  75609. name?: string | undefined;
  75610. private _cellWidth;
  75611. private _cellHeight;
  75612. private _minorLineTickness;
  75613. private _minorLineColor;
  75614. private _majorLineTickness;
  75615. private _majorLineColor;
  75616. private _majorLineFrequency;
  75617. private _background;
  75618. private _displayMajorLines;
  75619. private _displayMinorLines;
  75620. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  75621. get displayMinorLines(): boolean;
  75622. set displayMinorLines(value: boolean);
  75623. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  75624. get displayMajorLines(): boolean;
  75625. set displayMajorLines(value: boolean);
  75626. /** Gets or sets background color (Black by default) */
  75627. get background(): string;
  75628. set background(value: string);
  75629. /** Gets or sets the width of each cell (20 by default) */
  75630. get cellWidth(): number;
  75631. set cellWidth(value: number);
  75632. /** Gets or sets the height of each cell (20 by default) */
  75633. get cellHeight(): number;
  75634. set cellHeight(value: number);
  75635. /** Gets or sets the tickness of minor lines (1 by default) */
  75636. get minorLineTickness(): number;
  75637. set minorLineTickness(value: number);
  75638. /** Gets or sets the color of minor lines (DarkGray by default) */
  75639. get minorLineColor(): string;
  75640. set minorLineColor(value: string);
  75641. /** Gets or sets the tickness of major lines (2 by default) */
  75642. get majorLineTickness(): number;
  75643. set majorLineTickness(value: number);
  75644. /** Gets or sets the color of major lines (White by default) */
  75645. get majorLineColor(): string;
  75646. set majorLineColor(value: string);
  75647. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  75648. get majorLineFrequency(): number;
  75649. set majorLineFrequency(value: number);
  75650. /**
  75651. * Creates a new GridDisplayRectangle
  75652. * @param name defines the control name
  75653. */
  75654. constructor(name?: string | undefined);
  75655. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75656. protected _getTypeName(): string;
  75657. }
  75658. }
  75659. declare module BABYLON.GUI {
  75660. /**
  75661. * Class used to create slider controls based on images
  75662. */
  75663. export class ImageBasedSlider extends BaseSlider {
  75664. name?: string | undefined;
  75665. private _backgroundImage;
  75666. private _thumbImage;
  75667. private _valueBarImage;
  75668. private _tempMeasure;
  75669. get displayThumb(): boolean;
  75670. set displayThumb(value: boolean);
  75671. /**
  75672. * Gets or sets the image used to render the background
  75673. */
  75674. get backgroundImage(): Image;
  75675. set backgroundImage(value: Image);
  75676. /**
  75677. * Gets or sets the image used to render the value bar
  75678. */
  75679. get valueBarImage(): Image;
  75680. set valueBarImage(value: Image);
  75681. /**
  75682. * Gets or sets the image used to render the thumb
  75683. */
  75684. get thumbImage(): Image;
  75685. set thumbImage(value: Image);
  75686. /**
  75687. * Creates a new ImageBasedSlider
  75688. * @param name defines the control name
  75689. */
  75690. constructor(name?: string | undefined);
  75691. protected _getTypeName(): string;
  75692. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75693. }
  75694. }
  75695. declare module BABYLON.GUI {
  75696. /**
  75697. * Forcing an export so that this code will execute
  75698. * @hidden
  75699. */
  75700. const name = "Statics";
  75701. }
  75702. declare module BABYLON.GUI {
  75703. /**
  75704. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  75705. */
  75706. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  75707. /**
  75708. * Define the instrumented AdvancedDynamicTexture.
  75709. */
  75710. texture: AdvancedDynamicTexture;
  75711. private _captureRenderTime;
  75712. private _renderTime;
  75713. private _captureLayoutTime;
  75714. private _layoutTime;
  75715. private _onBeginRenderObserver;
  75716. private _onEndRenderObserver;
  75717. private _onBeginLayoutObserver;
  75718. private _onEndLayoutObserver;
  75719. /**
  75720. * Gets the perf counter used to capture render time
  75721. */
  75722. get renderTimeCounter(): BABYLON.PerfCounter;
  75723. /**
  75724. * Gets the perf counter used to capture layout time
  75725. */
  75726. get layoutTimeCounter(): BABYLON.PerfCounter;
  75727. /**
  75728. * Enable or disable the render time capture
  75729. */
  75730. get captureRenderTime(): boolean;
  75731. set captureRenderTime(value: boolean);
  75732. /**
  75733. * Enable or disable the layout time capture
  75734. */
  75735. get captureLayoutTime(): boolean;
  75736. set captureLayoutTime(value: boolean);
  75737. /**
  75738. * Instantiates a new advanced dynamic texture instrumentation.
  75739. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  75740. * @param texture Defines the AdvancedDynamicTexture to instrument
  75741. */
  75742. constructor(
  75743. /**
  75744. * Define the instrumented AdvancedDynamicTexture.
  75745. */
  75746. texture: AdvancedDynamicTexture);
  75747. /**
  75748. * Dispose and release associated resources.
  75749. */
  75750. dispose(): void;
  75751. }
  75752. }
  75753. declare module BABYLON.GUI {
  75754. /**
  75755. * Class used to load GUI via XML.
  75756. */
  75757. export class XmlLoader {
  75758. private _nodes;
  75759. private _nodeTypes;
  75760. private _isLoaded;
  75761. private _objectAttributes;
  75762. private _parentClass;
  75763. /**
  75764. * Create a new xml loader
  75765. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  75766. */
  75767. constructor(parentClass?: null);
  75768. private _getChainElement;
  75769. private _getClassAttribute;
  75770. private _createGuiElement;
  75771. private _parseGrid;
  75772. private _parseElement;
  75773. private _prepareSourceElement;
  75774. private _parseElementsFromSource;
  75775. private _parseXml;
  75776. /**
  75777. * Gets if the loading has finished.
  75778. * @returns whether the loading has finished or not
  75779. */
  75780. isLoaded(): boolean;
  75781. /**
  75782. * Gets a loaded node / control by id.
  75783. * @param id the Controls id set in the xml
  75784. * @returns element of type Control
  75785. */
  75786. getNodeById(id: string): any;
  75787. /**
  75788. * Gets all loaded nodes / controls
  75789. * @returns Array of controls
  75790. */
  75791. getNodes(): any;
  75792. /**
  75793. * Initiates the xml layout loading
  75794. * @param xmlFile defines the xml layout to load
  75795. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  75796. * @param callback defines the callback called on layout load.
  75797. */
  75798. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  75799. }
  75800. }
  75801. declare module BABYLON.GUI {
  75802. /**
  75803. * Class used to create containers for controls
  75804. */
  75805. export class Container3D extends Control3D {
  75806. private _blockLayout;
  75807. /**
  75808. * Gets the list of child controls
  75809. */
  75810. protected _children: Control3D[];
  75811. /**
  75812. * Gets the list of child controls
  75813. */
  75814. get children(): Array<Control3D>;
  75815. /**
  75816. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  75817. * This is helpful to optimize layout operation when adding multiple children in a row
  75818. */
  75819. get blockLayout(): boolean;
  75820. set blockLayout(value: boolean);
  75821. /**
  75822. * Creates a new container
  75823. * @param name defines the container name
  75824. */
  75825. constructor(name?: string);
  75826. /**
  75827. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  75828. * @returns the current container
  75829. */
  75830. updateLayout(): Container3D;
  75831. /**
  75832. * Gets a boolean indicating if the given control is in the children of this control
  75833. * @param control defines the control to check
  75834. * @returns true if the control is in the child list
  75835. */
  75836. containsControl(control: Control3D): boolean;
  75837. /**
  75838. * Adds a control to the children of this control
  75839. * @param control defines the control to add
  75840. * @returns the current container
  75841. */
  75842. addControl(control: Control3D): Container3D;
  75843. /**
  75844. * This function will be called everytime a new control is added
  75845. */
  75846. protected _arrangeChildren(): void;
  75847. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  75848. /**
  75849. * Removes a control from the children of this control
  75850. * @param control defines the control to remove
  75851. * @returns the current container
  75852. */
  75853. removeControl(control: Control3D): Container3D;
  75854. protected _getTypeName(): string;
  75855. /**
  75856. * Releases all associated resources
  75857. */
  75858. dispose(): void;
  75859. /** Control rotation will remain unchanged */
  75860. static readonly UNSET_ORIENTATION: number;
  75861. /** Control will rotate to make it look at sphere central axis */
  75862. static readonly FACEORIGIN_ORIENTATION: number;
  75863. /** Control will rotate to make it look back at sphere central axis */
  75864. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  75865. /** Control will rotate to look at z axis (0, 0, 1) */
  75866. static readonly FACEFORWARD_ORIENTATION: number;
  75867. /** Control will rotate to look at negative z axis (0, 0, -1) */
  75868. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  75869. }
  75870. }
  75871. declare module BABYLON.GUI {
  75872. /**
  75873. * Class used to manage 3D user interface
  75874. * @see http://doc.babylonjs.com/how_to/gui3d
  75875. */
  75876. export class GUI3DManager implements BABYLON.IDisposable {
  75877. private _scene;
  75878. private _sceneDisposeObserver;
  75879. private _utilityLayer;
  75880. private _rootContainer;
  75881. private _pointerObserver;
  75882. private _pointerOutObserver;
  75883. /** @hidden */
  75884. _lastPickedControl: Control3D;
  75885. /** @hidden */
  75886. _lastControlOver: {
  75887. [pointerId: number]: Control3D;
  75888. };
  75889. /** @hidden */
  75890. _lastControlDown: {
  75891. [pointerId: number]: Control3D;
  75892. };
  75893. /**
  75894. * BABYLON.Observable raised when the point picked by the pointer events changed
  75895. */
  75896. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  75897. /** @hidden */
  75898. _sharedMaterials: {
  75899. [key: string]: BABYLON.Material;
  75900. };
  75901. /** Gets the hosting scene */
  75902. get scene(): BABYLON.Scene;
  75903. /** Gets associated utility layer */
  75904. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  75905. /**
  75906. * Creates a new GUI3DManager
  75907. * @param scene
  75908. */
  75909. constructor(scene?: BABYLON.Scene);
  75910. private _handlePointerOut;
  75911. private _doPicking;
  75912. /**
  75913. * Gets the root container
  75914. */
  75915. get rootContainer(): Container3D;
  75916. /**
  75917. * Gets a boolean indicating if the given control is in the root child list
  75918. * @param control defines the control to check
  75919. * @returns true if the control is in the root child list
  75920. */
  75921. containsControl(control: Control3D): boolean;
  75922. /**
  75923. * Adds a control to the root child list
  75924. * @param control defines the control to add
  75925. * @returns the current manager
  75926. */
  75927. addControl(control: Control3D): GUI3DManager;
  75928. /**
  75929. * Removes a control from the root child list
  75930. * @param control defines the control to remove
  75931. * @returns the current container
  75932. */
  75933. removeControl(control: Control3D): GUI3DManager;
  75934. /**
  75935. * Releases all associated resources
  75936. */
  75937. dispose(): void;
  75938. }
  75939. }
  75940. declare module BABYLON.GUI {
  75941. /**
  75942. * Class used to transport BABYLON.Vector3 information for pointer events
  75943. */
  75944. export class Vector3WithInfo extends BABYLON.Vector3 {
  75945. /** defines the current mouse button index */
  75946. buttonIndex: number;
  75947. /**
  75948. * Creates a new Vector3WithInfo
  75949. * @param source defines the vector3 data to transport
  75950. * @param buttonIndex defines the current mouse button index
  75951. */
  75952. constructor(source: BABYLON.Vector3,
  75953. /** defines the current mouse button index */
  75954. buttonIndex?: number);
  75955. }
  75956. }
  75957. declare module BABYLON.GUI {
  75958. /**
  75959. * Class used as base class for controls
  75960. */
  75961. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  75962. /** Defines the control name */
  75963. name?: string | undefined;
  75964. /** @hidden */
  75965. _host: GUI3DManager;
  75966. private _node;
  75967. private _downCount;
  75968. private _enterCount;
  75969. private _downPointerIds;
  75970. private _isVisible;
  75971. /** Gets or sets the control position in world space */
  75972. get position(): BABYLON.Vector3;
  75973. set position(value: BABYLON.Vector3);
  75974. /** Gets or sets the control scaling in world space */
  75975. get scaling(): BABYLON.Vector3;
  75976. set scaling(value: BABYLON.Vector3);
  75977. /** Callback used to start pointer enter animation */
  75978. pointerEnterAnimation: () => void;
  75979. /** Callback used to start pointer out animation */
  75980. pointerOutAnimation: () => void;
  75981. /** Callback used to start pointer down animation */
  75982. pointerDownAnimation: () => void;
  75983. /** Callback used to start pointer up animation */
  75984. pointerUpAnimation: () => void;
  75985. /**
  75986. * An event triggered when the pointer move over the control
  75987. */
  75988. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  75989. /**
  75990. * An event triggered when the pointer move out of the control
  75991. */
  75992. onPointerOutObservable: BABYLON.Observable<Control3D>;
  75993. /**
  75994. * An event triggered when the pointer taps the control
  75995. */
  75996. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  75997. /**
  75998. * An event triggered when pointer is up
  75999. */
  76000. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  76001. /**
  76002. * An event triggered when a control is clicked on (with a mouse)
  76003. */
  76004. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  76005. /**
  76006. * An event triggered when pointer enters the control
  76007. */
  76008. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  76009. /**
  76010. * Gets or sets the parent container
  76011. */
  76012. parent: BABYLON.Nullable<Container3D>;
  76013. private _behaviors;
  76014. /**
  76015. * Gets the list of attached behaviors
  76016. * @see http://doc.babylonjs.com/features/behaviour
  76017. */
  76018. get behaviors(): BABYLON.Behavior<Control3D>[];
  76019. /**
  76020. * Attach a behavior to the control
  76021. * @see http://doc.babylonjs.com/features/behaviour
  76022. * @param behavior defines the behavior to attach
  76023. * @returns the current control
  76024. */
  76025. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76026. /**
  76027. * Remove an attached behavior
  76028. * @see http://doc.babylonjs.com/features/behaviour
  76029. * @param behavior defines the behavior to attach
  76030. * @returns the current control
  76031. */
  76032. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76033. /**
  76034. * Gets an attached behavior by name
  76035. * @param name defines the name of the behavior to look for
  76036. * @see http://doc.babylonjs.com/features/behaviour
  76037. * @returns null if behavior was not found else the requested behavior
  76038. */
  76039. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  76040. /** Gets or sets a boolean indicating if the control is visible */
  76041. get isVisible(): boolean;
  76042. set isVisible(value: boolean);
  76043. /**
  76044. * Creates a new control
  76045. * @param name defines the control name
  76046. */
  76047. constructor(
  76048. /** Defines the control name */
  76049. name?: string | undefined);
  76050. /**
  76051. * Gets a string representing the class name
  76052. */
  76053. get typeName(): string;
  76054. /**
  76055. * Get the current class name of the control.
  76056. * @returns current class name
  76057. */
  76058. getClassName(): string;
  76059. protected _getTypeName(): string;
  76060. /**
  76061. * Gets the transform node used by this control
  76062. */
  76063. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  76064. /**
  76065. * Gets the mesh used to render this control
  76066. */
  76067. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76068. /**
  76069. * Link the control as child of the given node
  76070. * @param node defines the node to link to. Use null to unlink the control
  76071. * @returns the current control
  76072. */
  76073. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  76074. /** @hidden **/
  76075. _prepareNode(scene: BABYLON.Scene): void;
  76076. /**
  76077. * Node creation.
  76078. * Can be overriden by children
  76079. * @param scene defines the scene where the node must be attached
  76080. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  76081. */
  76082. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76083. /**
  76084. * Affect a material to the given mesh
  76085. * @param mesh defines the mesh which will represent the control
  76086. */
  76087. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76088. /** @hidden */
  76089. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  76090. /** @hidden */
  76091. _onPointerEnter(target: Control3D): boolean;
  76092. /** @hidden */
  76093. _onPointerOut(target: Control3D): void;
  76094. /** @hidden */
  76095. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76096. /** @hidden */
  76097. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76098. /** @hidden */
  76099. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76100. /** @hidden */
  76101. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76102. /** @hidden */
  76103. _disposeNode(): void;
  76104. /**
  76105. * Releases all associated resources
  76106. */
  76107. dispose(): void;
  76108. }
  76109. }
  76110. declare module BABYLON.GUI {
  76111. /**
  76112. * Class used as a root to all buttons
  76113. */
  76114. export class AbstractButton3D extends Control3D {
  76115. /**
  76116. * Creates a new button
  76117. * @param name defines the control name
  76118. */
  76119. constructor(name?: string);
  76120. protected _getTypeName(): string;
  76121. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76122. }
  76123. }
  76124. declare module BABYLON.GUI {
  76125. /**
  76126. * Class used to create a button in 3D
  76127. */
  76128. export class Button3D extends AbstractButton3D {
  76129. /** @hidden */
  76130. protected _currentMaterial: BABYLON.Material;
  76131. private _facadeTexture;
  76132. private _content;
  76133. private _contentResolution;
  76134. private _contentScaleRatio;
  76135. /**
  76136. * Gets or sets the texture resolution used to render content (512 by default)
  76137. */
  76138. get contentResolution(): BABYLON.int;
  76139. set contentResolution(value: BABYLON.int);
  76140. /**
  76141. * Gets or sets the texture scale ratio used to render content (2 by default)
  76142. */
  76143. get contentScaleRatio(): number;
  76144. set contentScaleRatio(value: number);
  76145. protected _disposeFacadeTexture(): void;
  76146. protected _resetContent(): void;
  76147. /**
  76148. * Creates a new button
  76149. * @param name defines the control name
  76150. */
  76151. constructor(name?: string);
  76152. /**
  76153. * Gets or sets the GUI 2D content used to display the button's facade
  76154. */
  76155. get content(): Control;
  76156. set content(value: Control);
  76157. /**
  76158. * Apply the facade texture (created from the content property).
  76159. * This function can be overloaded by child classes
  76160. * @param facadeTexture defines the AdvancedDynamicTexture to use
  76161. */
  76162. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76163. protected _getTypeName(): string;
  76164. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76165. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76166. /**
  76167. * Releases all associated resources
  76168. */
  76169. dispose(): void;
  76170. }
  76171. }
  76172. declare module BABYLON.GUI {
  76173. /**
  76174. * Abstract class used to create a container panel deployed on the surface of a volume
  76175. */
  76176. export abstract class VolumeBasedPanel extends Container3D {
  76177. private _columns;
  76178. private _rows;
  76179. private _rowThenColum;
  76180. private _orientation;
  76181. protected _cellWidth: number;
  76182. protected _cellHeight: number;
  76183. /**
  76184. * Gets or sets the distance between elements
  76185. */
  76186. margin: number;
  76187. /**
  76188. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  76189. * | Value | Type | Description |
  76190. * | ----- | ----------------------------------- | ----------- |
  76191. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  76192. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  76193. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  76194. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  76195. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  76196. */
  76197. get orientation(): number;
  76198. set orientation(value: number);
  76199. /**
  76200. * Gets or sets the number of columns requested (10 by default).
  76201. * The panel will automatically compute the number of rows based on number of child controls.
  76202. */
  76203. get columns(): BABYLON.int;
  76204. set columns(value: BABYLON.int);
  76205. /**
  76206. * Gets or sets a the number of rows requested.
  76207. * The panel will automatically compute the number of columns based on number of child controls.
  76208. */
  76209. get rows(): BABYLON.int;
  76210. set rows(value: BABYLON.int);
  76211. /**
  76212. * Creates new VolumeBasedPanel
  76213. */
  76214. constructor();
  76215. protected _arrangeChildren(): void;
  76216. /** Child classes must implement this function to provide correct control positioning */
  76217. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76218. /** Child classes can implement this function to provide additional processing */
  76219. protected _finalProcessing(): void;
  76220. }
  76221. }
  76222. declare module BABYLON.GUI {
  76223. /**
  76224. * Class used to create a container panel deployed on the surface of a cylinder
  76225. */
  76226. export class CylinderPanel extends VolumeBasedPanel {
  76227. private _radius;
  76228. /**
  76229. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  76230. */
  76231. get radius(): BABYLON.float;
  76232. set radius(value: BABYLON.float);
  76233. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76234. private _cylindricalMapping;
  76235. }
  76236. }
  76237. declare module BABYLON.GUI {
  76238. /** @hidden */
  76239. export var fluentVertexShader: {
  76240. name: string;
  76241. shader: string;
  76242. };
  76243. }
  76244. declare module BABYLON.GUI {
  76245. /** @hidden */
  76246. export var fluentPixelShader: {
  76247. name: string;
  76248. shader: string;
  76249. };
  76250. }
  76251. declare module BABYLON.GUI {
  76252. /** @hidden */
  76253. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  76254. INNERGLOW: boolean;
  76255. BORDER: boolean;
  76256. HOVERLIGHT: boolean;
  76257. TEXTURE: boolean;
  76258. constructor();
  76259. }
  76260. /**
  76261. * Class used to render controls with fluent desgin
  76262. */
  76263. export class FluentMaterial extends BABYLON.PushMaterial {
  76264. /**
  76265. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  76266. */
  76267. innerGlowColorIntensity: number;
  76268. /**
  76269. * Gets or sets the inner glow color (white by default)
  76270. */
  76271. innerGlowColor: BABYLON.Color3;
  76272. /**
  76273. * Gets or sets alpha value (default is 1.0)
  76274. */
  76275. alpha: number;
  76276. /**
  76277. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  76278. */
  76279. albedoColor: BABYLON.Color3;
  76280. /**
  76281. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  76282. */
  76283. renderBorders: boolean;
  76284. /**
  76285. * Gets or sets border width (default is 0.5)
  76286. */
  76287. borderWidth: number;
  76288. /**
  76289. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  76290. */
  76291. edgeSmoothingValue: number;
  76292. /**
  76293. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  76294. */
  76295. borderMinValue: number;
  76296. /**
  76297. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  76298. */
  76299. renderHoverLight: boolean;
  76300. /**
  76301. * Gets or sets the radius used to render the hover light (default is 1.0)
  76302. */
  76303. hoverRadius: number;
  76304. /**
  76305. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  76306. */
  76307. hoverColor: BABYLON.Color4;
  76308. /**
  76309. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  76310. */
  76311. hoverPosition: BABYLON.Vector3;
  76312. private _albedoTexture;
  76313. /** Gets or sets the texture to use for albedo color */
  76314. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76315. /**
  76316. * Creates a new Fluent material
  76317. * @param name defines the name of the material
  76318. * @param scene defines the hosting scene
  76319. */
  76320. constructor(name: string, scene: BABYLON.Scene);
  76321. needAlphaBlending(): boolean;
  76322. needAlphaTesting(): boolean;
  76323. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76324. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76325. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76326. getActiveTextures(): BABYLON.BaseTexture[];
  76327. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76328. dispose(forceDisposeEffect?: boolean): void;
  76329. clone(name: string): FluentMaterial;
  76330. serialize(): any;
  76331. getClassName(): string;
  76332. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  76333. }
  76334. }
  76335. declare module BABYLON.GUI {
  76336. /**
  76337. * Class used to create a holographic button in 3D
  76338. */
  76339. export class HolographicButton extends Button3D {
  76340. private _backPlate;
  76341. private _textPlate;
  76342. private _frontPlate;
  76343. private _text;
  76344. private _imageUrl;
  76345. private _shareMaterials;
  76346. private _frontMaterial;
  76347. private _backMaterial;
  76348. private _plateMaterial;
  76349. private _pickedPointObserver;
  76350. private _tooltipFade;
  76351. private _tooltipTextBlock;
  76352. private _tooltipTexture;
  76353. private _tooltipMesh;
  76354. private _tooltipHoverObserver;
  76355. private _tooltipOutObserver;
  76356. private _disposeTooltip;
  76357. /**
  76358. * Rendering ground id of all the mesh in the button
  76359. */
  76360. set renderingGroupId(id: number);
  76361. get renderingGroupId(): number;
  76362. /**
  76363. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  76364. */
  76365. set tooltipText(text: BABYLON.Nullable<string>);
  76366. get tooltipText(): BABYLON.Nullable<string>;
  76367. /**
  76368. * Gets or sets text for the button
  76369. */
  76370. get text(): string;
  76371. set text(value: string);
  76372. /**
  76373. * Gets or sets the image url for the button
  76374. */
  76375. get imageUrl(): string;
  76376. set imageUrl(value: string);
  76377. /**
  76378. * Gets the back material used by this button
  76379. */
  76380. get backMaterial(): FluentMaterial;
  76381. /**
  76382. * Gets the front material used by this button
  76383. */
  76384. get frontMaterial(): FluentMaterial;
  76385. /**
  76386. * Gets the plate material used by this button
  76387. */
  76388. get plateMaterial(): BABYLON.StandardMaterial;
  76389. /**
  76390. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  76391. */
  76392. get shareMaterials(): boolean;
  76393. /**
  76394. * Creates a new button
  76395. * @param name defines the control name
  76396. */
  76397. constructor(name?: string, shareMaterials?: boolean);
  76398. protected _getTypeName(): string;
  76399. private _rebuildContent;
  76400. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76401. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76402. private _createBackMaterial;
  76403. private _createFrontMaterial;
  76404. private _createPlateMaterial;
  76405. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  76406. /**
  76407. * Releases all associated resources
  76408. */
  76409. dispose(): void;
  76410. }
  76411. }
  76412. declare module BABYLON.GUI {
  76413. /**
  76414. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  76415. */
  76416. export class MeshButton3D extends Button3D {
  76417. /** @hidden */
  76418. protected _currentMesh: BABYLON.Mesh;
  76419. /**
  76420. * Creates a new 3D button based on a mesh
  76421. * @param mesh mesh to become a 3D button
  76422. * @param name defines the control name
  76423. */
  76424. constructor(mesh: BABYLON.Mesh, name?: string);
  76425. protected _getTypeName(): string;
  76426. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76427. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76428. }
  76429. }
  76430. declare module BABYLON.GUI {
  76431. /**
  76432. * Class used to create a container panel deployed on the surface of a plane
  76433. */
  76434. export class PlanePanel extends VolumeBasedPanel {
  76435. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76436. }
  76437. }
  76438. declare module BABYLON.GUI {
  76439. /**
  76440. * Class used to create a container panel where items get randomized planar mapping
  76441. */
  76442. export class ScatterPanel extends VolumeBasedPanel {
  76443. private _iteration;
  76444. /**
  76445. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  76446. */
  76447. get iteration(): BABYLON.float;
  76448. set iteration(value: BABYLON.float);
  76449. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76450. private _scatterMapping;
  76451. protected _finalProcessing(): void;
  76452. }
  76453. }
  76454. declare module BABYLON.GUI {
  76455. /**
  76456. * Class used to create a container panel deployed on the surface of a sphere
  76457. */
  76458. export class SpherePanel extends VolumeBasedPanel {
  76459. private _radius;
  76460. /**
  76461. * Gets or sets the radius of the sphere where to project controls (5 by default)
  76462. */
  76463. get radius(): BABYLON.float;
  76464. set radius(value: BABYLON.float);
  76465. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76466. private _sphericalMapping;
  76467. }
  76468. }
  76469. declare module BABYLON.GUI {
  76470. /**
  76471. * Class used to create a stack panel in 3D on XY plane
  76472. */
  76473. export class StackPanel3D extends Container3D {
  76474. private _isVertical;
  76475. /**
  76476. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  76477. */
  76478. get isVertical(): boolean;
  76479. set isVertical(value: boolean);
  76480. /**
  76481. * Gets or sets the distance between elements
  76482. */
  76483. margin: number;
  76484. /**
  76485. * Creates new StackPanel
  76486. * @param isVertical
  76487. */
  76488. constructor(isVertical?: boolean);
  76489. protected _arrangeChildren(): void;
  76490. }
  76491. }
  76492. declare module BABYLON {
  76493. /**
  76494. * Configuration for glTF validation
  76495. */
  76496. export interface IGLTFValidationConfiguration {
  76497. /**
  76498. * The url of the glTF validator.
  76499. */
  76500. url: string;
  76501. }
  76502. /**
  76503. * glTF validation
  76504. */
  76505. export class GLTFValidation {
  76506. /**
  76507. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  76508. */
  76509. static Configuration: IGLTFValidationConfiguration;
  76510. private static _LoadScriptPromise;
  76511. /**
  76512. * Validate a glTF asset using the glTF-Validator.
  76513. * @param data The JSON of a glTF or the array buffer of a binary glTF
  76514. * @param rootUrl The root url for the glTF
  76515. * @param fileName The file name for the glTF
  76516. * @param getExternalResource The callback to get external resources for the glTF validator
  76517. * @returns A promise that resolves with the glTF validation results once complete
  76518. */
  76519. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  76520. }
  76521. }
  76522. declare module BABYLON {
  76523. /**
  76524. * Mode that determines the coordinate system to use.
  76525. */
  76526. export enum GLTFLoaderCoordinateSystemMode {
  76527. /**
  76528. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  76529. */
  76530. AUTO = 0,
  76531. /**
  76532. * Sets the useRightHandedSystem flag on the scene.
  76533. */
  76534. FORCE_RIGHT_HANDED = 1
  76535. }
  76536. /**
  76537. * Mode that determines what animations will start.
  76538. */
  76539. export enum GLTFLoaderAnimationStartMode {
  76540. /**
  76541. * No animation will start.
  76542. */
  76543. NONE = 0,
  76544. /**
  76545. * The first animation will start.
  76546. */
  76547. FIRST = 1,
  76548. /**
  76549. * All animations will start.
  76550. */
  76551. ALL = 2
  76552. }
  76553. /**
  76554. * Interface that contains the data for the glTF asset.
  76555. */
  76556. export interface IGLTFLoaderData {
  76557. /**
  76558. * The object that represents the glTF JSON.
  76559. */
  76560. json: Object;
  76561. /**
  76562. * The BIN chunk of a binary glTF.
  76563. */
  76564. bin: Nullable<IDataBuffer>;
  76565. }
  76566. /**
  76567. * Interface for extending the loader.
  76568. */
  76569. export interface IGLTFLoaderExtension {
  76570. /**
  76571. * The name of this extension.
  76572. */
  76573. readonly name: string;
  76574. /**
  76575. * Defines whether this extension is enabled.
  76576. */
  76577. enabled: boolean;
  76578. /**
  76579. * Defines the order of this extension.
  76580. * The loader sorts the extensions using these values when loading.
  76581. */
  76582. order?: number;
  76583. }
  76584. /**
  76585. * Loader state.
  76586. */
  76587. export enum GLTFLoaderState {
  76588. /**
  76589. * The asset is loading.
  76590. */
  76591. LOADING = 0,
  76592. /**
  76593. * The asset is ready for rendering.
  76594. */
  76595. READY = 1,
  76596. /**
  76597. * The asset is completely loaded.
  76598. */
  76599. COMPLETE = 2
  76600. }
  76601. /** @hidden */
  76602. export interface IImportMeshAsyncOutput {
  76603. meshes: AbstractMesh[];
  76604. particleSystems: IParticleSystem[];
  76605. skeletons: Skeleton[];
  76606. animationGroups: AnimationGroup[];
  76607. lights: Light[];
  76608. transformNodes: TransformNode[];
  76609. }
  76610. /** @hidden */
  76611. export interface IGLTFLoader extends IDisposable {
  76612. readonly state: Nullable<GLTFLoaderState>;
  76613. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  76614. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  76615. }
  76616. /**
  76617. * File loader for loading glTF files into a scene.
  76618. */
  76619. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76620. /** @hidden */
  76621. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76622. /** @hidden */
  76623. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76624. /**
  76625. * Raised when the asset has been parsed
  76626. */
  76627. onParsedObservable: Observable<IGLTFLoaderData>;
  76628. private _onParsedObserver;
  76629. /**
  76630. * Raised when the asset has been parsed
  76631. */
  76632. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  76633. /**
  76634. * 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.
  76635. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  76636. * Defaults to true.
  76637. * @hidden
  76638. */
  76639. static IncrementalLoading: boolean;
  76640. /**
  76641. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  76642. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  76643. * @hidden
  76644. */
  76645. static HomogeneousCoordinates: boolean;
  76646. /**
  76647. * The coordinate system mode. Defaults to AUTO.
  76648. */
  76649. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  76650. /**
  76651. * The animation start mode. Defaults to FIRST.
  76652. */
  76653. animationStartMode: GLTFLoaderAnimationStartMode;
  76654. /**
  76655. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  76656. */
  76657. compileMaterials: boolean;
  76658. /**
  76659. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  76660. */
  76661. useClipPlane: boolean;
  76662. /**
  76663. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  76664. */
  76665. compileShadowGenerators: boolean;
  76666. /**
  76667. * Defines if the Alpha blended materials are only applied as coverage.
  76668. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  76669. * If true, no extra effects are applied to transparent pixels.
  76670. */
  76671. transparencyAsCoverage: boolean;
  76672. /**
  76673. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  76674. * Enabling will disable offline support and glTF validator.
  76675. * Defaults to false.
  76676. */
  76677. useRangeRequests: boolean;
  76678. /**
  76679. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  76680. */
  76681. createInstances: boolean;
  76682. /**
  76683. * Function called before loading a url referenced by the asset.
  76684. */
  76685. preprocessUrlAsync: (url: string) => Promise<string>;
  76686. /**
  76687. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76688. */
  76689. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  76690. private _onMeshLoadedObserver;
  76691. /**
  76692. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76693. */
  76694. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  76695. /**
  76696. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  76697. */
  76698. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  76699. private _onTextureLoadedObserver;
  76700. /**
  76701. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  76702. */
  76703. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  76704. /**
  76705. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  76706. */
  76707. readonly onMaterialLoadedObservable: Observable<Material>;
  76708. private _onMaterialLoadedObserver;
  76709. /**
  76710. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  76711. */
  76712. set onMaterialLoaded(callback: (material: Material) => void);
  76713. /**
  76714. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  76715. */
  76716. readonly onCameraLoadedObservable: Observable<Camera>;
  76717. private _onCameraLoadedObserver;
  76718. /**
  76719. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  76720. */
  76721. set onCameraLoaded(callback: (camera: Camera) => void);
  76722. /**
  76723. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  76724. * For assets with LODs, raised when all of the LODs are complete.
  76725. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76726. */
  76727. readonly onCompleteObservable: Observable<void>;
  76728. private _onCompleteObserver;
  76729. /**
  76730. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  76731. * For assets with LODs, raised when all of the LODs are complete.
  76732. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76733. */
  76734. set onComplete(callback: () => void);
  76735. /**
  76736. * Observable raised when an error occurs.
  76737. */
  76738. readonly onErrorObservable: Observable<any>;
  76739. private _onErrorObserver;
  76740. /**
  76741. * Callback raised when an error occurs.
  76742. */
  76743. set onError(callback: (reason: any) => void);
  76744. /**
  76745. * Observable raised after the loader is disposed.
  76746. */
  76747. readonly onDisposeObservable: Observable<void>;
  76748. private _onDisposeObserver;
  76749. /**
  76750. * Callback raised after the loader is disposed.
  76751. */
  76752. set onDispose(callback: () => void);
  76753. /**
  76754. * Observable raised after a loader extension is created.
  76755. * Set additional options for a loader extension in this event.
  76756. */
  76757. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  76758. private _onExtensionLoadedObserver;
  76759. /**
  76760. * Callback raised after a loader extension is created.
  76761. */
  76762. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  76763. /**
  76764. * Defines if the loader logging is enabled.
  76765. */
  76766. get loggingEnabled(): boolean;
  76767. set loggingEnabled(value: boolean);
  76768. /**
  76769. * Defines if the loader should capture performance counters.
  76770. */
  76771. get capturePerformanceCounters(): boolean;
  76772. set capturePerformanceCounters(value: boolean);
  76773. /**
  76774. * Defines if the loader should validate the asset.
  76775. */
  76776. validate: boolean;
  76777. /**
  76778. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  76779. */
  76780. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  76781. private _onValidatedObserver;
  76782. /**
  76783. * Callback raised after a loader extension is created.
  76784. */
  76785. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  76786. private _loader;
  76787. /**
  76788. * Name of the loader ("gltf")
  76789. */
  76790. name: string;
  76791. /** @hidden */
  76792. extensions: ISceneLoaderPluginExtensions;
  76793. /**
  76794. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  76795. */
  76796. dispose(): void;
  76797. /** @hidden */
  76798. _clear(): void;
  76799. /** @hidden */
  76800. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76801. /** @hidden */
  76802. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76803. /** @hidden */
  76804. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76805. meshes: AbstractMesh[];
  76806. particleSystems: IParticleSystem[];
  76807. skeletons: Skeleton[];
  76808. animationGroups: AnimationGroup[];
  76809. }>;
  76810. /** @hidden */
  76811. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76812. /** @hidden */
  76813. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76814. /** @hidden */
  76815. canDirectLoad(data: string): boolean;
  76816. /** @hidden */
  76817. directLoad(scene: Scene, data: string): any;
  76818. /**
  76819. * The callback that allows custom handling of the root url based on the response url.
  76820. * @param rootUrl the original root url
  76821. * @param responseURL the response url if available
  76822. * @returns the new root url
  76823. */
  76824. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  76825. /** @hidden */
  76826. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  76827. /**
  76828. * The loader state or null if the loader is not active.
  76829. */
  76830. get loaderState(): Nullable<GLTFLoaderState>;
  76831. /**
  76832. * Returns a promise that resolves when the asset is completely loaded.
  76833. * @returns a promise that resolves when the asset is completely loaded.
  76834. */
  76835. whenCompleteAsync(): Promise<void>;
  76836. private _validate;
  76837. private _getLoader;
  76838. private _parseJson;
  76839. private _unpackBinaryAsync;
  76840. private _unpackBinaryV1Async;
  76841. private _unpackBinaryV2Async;
  76842. private static _parseVersion;
  76843. private static _compareVersion;
  76844. private static readonly _logSpaces;
  76845. private _logIndentLevel;
  76846. private _loggingEnabled;
  76847. /** @hidden */
  76848. _log: (message: string) => void;
  76849. /** @hidden */
  76850. _logOpen(message: string): void;
  76851. /** @hidden */
  76852. _logClose(): void;
  76853. private _logEnabled;
  76854. private _logDisabled;
  76855. private _capturePerformanceCounters;
  76856. /** @hidden */
  76857. _startPerformanceCounter: (counterName: string) => void;
  76858. /** @hidden */
  76859. _endPerformanceCounter: (counterName: string) => void;
  76860. private _startPerformanceCounterEnabled;
  76861. private _startPerformanceCounterDisabled;
  76862. private _endPerformanceCounterEnabled;
  76863. private _endPerformanceCounterDisabled;
  76864. }
  76865. }
  76866. declare module BABYLON.GLTF1 {
  76867. /**
  76868. * Enums
  76869. * @hidden
  76870. */
  76871. export enum EComponentType {
  76872. BYTE = 5120,
  76873. UNSIGNED_BYTE = 5121,
  76874. SHORT = 5122,
  76875. UNSIGNED_SHORT = 5123,
  76876. FLOAT = 5126
  76877. }
  76878. /** @hidden */
  76879. export enum EShaderType {
  76880. FRAGMENT = 35632,
  76881. VERTEX = 35633
  76882. }
  76883. /** @hidden */
  76884. export enum EParameterType {
  76885. BYTE = 5120,
  76886. UNSIGNED_BYTE = 5121,
  76887. SHORT = 5122,
  76888. UNSIGNED_SHORT = 5123,
  76889. INT = 5124,
  76890. UNSIGNED_INT = 5125,
  76891. FLOAT = 5126,
  76892. FLOAT_VEC2 = 35664,
  76893. FLOAT_VEC3 = 35665,
  76894. FLOAT_VEC4 = 35666,
  76895. INT_VEC2 = 35667,
  76896. INT_VEC3 = 35668,
  76897. INT_VEC4 = 35669,
  76898. BOOL = 35670,
  76899. BOOL_VEC2 = 35671,
  76900. BOOL_VEC3 = 35672,
  76901. BOOL_VEC4 = 35673,
  76902. FLOAT_MAT2 = 35674,
  76903. FLOAT_MAT3 = 35675,
  76904. FLOAT_MAT4 = 35676,
  76905. SAMPLER_2D = 35678
  76906. }
  76907. /** @hidden */
  76908. export enum ETextureWrapMode {
  76909. CLAMP_TO_EDGE = 33071,
  76910. MIRRORED_REPEAT = 33648,
  76911. REPEAT = 10497
  76912. }
  76913. /** @hidden */
  76914. export enum ETextureFilterType {
  76915. NEAREST = 9728,
  76916. LINEAR = 9728,
  76917. NEAREST_MIPMAP_NEAREST = 9984,
  76918. LINEAR_MIPMAP_NEAREST = 9985,
  76919. NEAREST_MIPMAP_LINEAR = 9986,
  76920. LINEAR_MIPMAP_LINEAR = 9987
  76921. }
  76922. /** @hidden */
  76923. export enum ETextureFormat {
  76924. ALPHA = 6406,
  76925. RGB = 6407,
  76926. RGBA = 6408,
  76927. LUMINANCE = 6409,
  76928. LUMINANCE_ALPHA = 6410
  76929. }
  76930. /** @hidden */
  76931. export enum ECullingType {
  76932. FRONT = 1028,
  76933. BACK = 1029,
  76934. FRONT_AND_BACK = 1032
  76935. }
  76936. /** @hidden */
  76937. export enum EBlendingFunction {
  76938. ZERO = 0,
  76939. ONE = 1,
  76940. SRC_COLOR = 768,
  76941. ONE_MINUS_SRC_COLOR = 769,
  76942. DST_COLOR = 774,
  76943. ONE_MINUS_DST_COLOR = 775,
  76944. SRC_ALPHA = 770,
  76945. ONE_MINUS_SRC_ALPHA = 771,
  76946. DST_ALPHA = 772,
  76947. ONE_MINUS_DST_ALPHA = 773,
  76948. CONSTANT_COLOR = 32769,
  76949. ONE_MINUS_CONSTANT_COLOR = 32770,
  76950. CONSTANT_ALPHA = 32771,
  76951. ONE_MINUS_CONSTANT_ALPHA = 32772,
  76952. SRC_ALPHA_SATURATE = 776
  76953. }
  76954. /** @hidden */
  76955. export interface IGLTFProperty {
  76956. extensions?: {
  76957. [key: string]: any;
  76958. };
  76959. extras?: Object;
  76960. }
  76961. /** @hidden */
  76962. export interface IGLTFChildRootProperty extends IGLTFProperty {
  76963. name?: string;
  76964. }
  76965. /** @hidden */
  76966. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  76967. bufferView: string;
  76968. byteOffset: number;
  76969. byteStride: number;
  76970. count: number;
  76971. type: string;
  76972. componentType: EComponentType;
  76973. max?: number[];
  76974. min?: number[];
  76975. name?: string;
  76976. }
  76977. /** @hidden */
  76978. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  76979. buffer: string;
  76980. byteOffset: number;
  76981. byteLength: number;
  76982. byteStride: number;
  76983. target?: number;
  76984. }
  76985. /** @hidden */
  76986. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  76987. uri: string;
  76988. byteLength?: number;
  76989. type?: string;
  76990. }
  76991. /** @hidden */
  76992. export interface IGLTFShader extends IGLTFChildRootProperty {
  76993. uri: string;
  76994. type: EShaderType;
  76995. }
  76996. /** @hidden */
  76997. export interface IGLTFProgram extends IGLTFChildRootProperty {
  76998. attributes: string[];
  76999. fragmentShader: string;
  77000. vertexShader: string;
  77001. }
  77002. /** @hidden */
  77003. export interface IGLTFTechniqueParameter {
  77004. type: number;
  77005. count?: number;
  77006. semantic?: string;
  77007. node?: string;
  77008. value?: number | boolean | string | Array<any>;
  77009. source?: string;
  77010. babylonValue?: any;
  77011. }
  77012. /** @hidden */
  77013. export interface IGLTFTechniqueCommonProfile {
  77014. lightingModel: string;
  77015. texcoordBindings: Object;
  77016. parameters?: Array<any>;
  77017. }
  77018. /** @hidden */
  77019. export interface IGLTFTechniqueStatesFunctions {
  77020. blendColor?: number[];
  77021. blendEquationSeparate?: number[];
  77022. blendFuncSeparate?: number[];
  77023. colorMask: boolean[];
  77024. cullFace: number[];
  77025. }
  77026. /** @hidden */
  77027. export interface IGLTFTechniqueStates {
  77028. enable: number[];
  77029. functions: IGLTFTechniqueStatesFunctions;
  77030. }
  77031. /** @hidden */
  77032. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  77033. parameters: {
  77034. [key: string]: IGLTFTechniqueParameter;
  77035. };
  77036. program: string;
  77037. attributes: {
  77038. [key: string]: string;
  77039. };
  77040. uniforms: {
  77041. [key: string]: string;
  77042. };
  77043. states: IGLTFTechniqueStates;
  77044. }
  77045. /** @hidden */
  77046. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  77047. technique?: string;
  77048. values: string[];
  77049. }
  77050. /** @hidden */
  77051. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  77052. attributes: {
  77053. [key: string]: string;
  77054. };
  77055. indices: string;
  77056. material: string;
  77057. mode?: number;
  77058. }
  77059. /** @hidden */
  77060. export interface IGLTFMesh extends IGLTFChildRootProperty {
  77061. primitives: IGLTFMeshPrimitive[];
  77062. }
  77063. /** @hidden */
  77064. export interface IGLTFImage extends IGLTFChildRootProperty {
  77065. uri: string;
  77066. }
  77067. /** @hidden */
  77068. export interface IGLTFSampler extends IGLTFChildRootProperty {
  77069. magFilter?: number;
  77070. minFilter?: number;
  77071. wrapS?: number;
  77072. wrapT?: number;
  77073. }
  77074. /** @hidden */
  77075. export interface IGLTFTexture extends IGLTFChildRootProperty {
  77076. sampler: string;
  77077. source: string;
  77078. format?: ETextureFormat;
  77079. internalFormat?: ETextureFormat;
  77080. target?: number;
  77081. type?: number;
  77082. babylonTexture?: Texture;
  77083. }
  77084. /** @hidden */
  77085. export interface IGLTFAmbienLight {
  77086. color?: number[];
  77087. }
  77088. /** @hidden */
  77089. export interface IGLTFDirectionalLight {
  77090. color?: number[];
  77091. }
  77092. /** @hidden */
  77093. export interface IGLTFPointLight {
  77094. color?: number[];
  77095. constantAttenuation?: number;
  77096. linearAttenuation?: number;
  77097. quadraticAttenuation?: number;
  77098. }
  77099. /** @hidden */
  77100. export interface IGLTFSpotLight {
  77101. color?: number[];
  77102. constantAttenuation?: number;
  77103. fallOfAngle?: number;
  77104. fallOffExponent?: number;
  77105. linearAttenuation?: number;
  77106. quadraticAttenuation?: number;
  77107. }
  77108. /** @hidden */
  77109. export interface IGLTFLight extends IGLTFChildRootProperty {
  77110. type: string;
  77111. }
  77112. /** @hidden */
  77113. export interface IGLTFCameraOrthographic {
  77114. xmag: number;
  77115. ymag: number;
  77116. zfar: number;
  77117. znear: number;
  77118. }
  77119. /** @hidden */
  77120. export interface IGLTFCameraPerspective {
  77121. aspectRatio: number;
  77122. yfov: number;
  77123. zfar: number;
  77124. znear: number;
  77125. }
  77126. /** @hidden */
  77127. export interface IGLTFCamera extends IGLTFChildRootProperty {
  77128. type: string;
  77129. }
  77130. /** @hidden */
  77131. export interface IGLTFAnimationChannelTarget {
  77132. id: string;
  77133. path: string;
  77134. }
  77135. /** @hidden */
  77136. export interface IGLTFAnimationChannel {
  77137. sampler: string;
  77138. target: IGLTFAnimationChannelTarget;
  77139. }
  77140. /** @hidden */
  77141. export interface IGLTFAnimationSampler {
  77142. input: string;
  77143. output: string;
  77144. interpolation?: string;
  77145. }
  77146. /** @hidden */
  77147. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  77148. channels?: IGLTFAnimationChannel[];
  77149. parameters?: {
  77150. [key: string]: string;
  77151. };
  77152. samplers?: {
  77153. [key: string]: IGLTFAnimationSampler;
  77154. };
  77155. }
  77156. /** @hidden */
  77157. export interface IGLTFNodeInstanceSkin {
  77158. skeletons: string[];
  77159. skin: string;
  77160. meshes: string[];
  77161. }
  77162. /** @hidden */
  77163. export interface IGLTFSkins extends IGLTFChildRootProperty {
  77164. bindShapeMatrix: number[];
  77165. inverseBindMatrices: string;
  77166. jointNames: string[];
  77167. babylonSkeleton?: Skeleton;
  77168. }
  77169. /** @hidden */
  77170. export interface IGLTFNode extends IGLTFChildRootProperty {
  77171. camera?: string;
  77172. children: string[];
  77173. skin?: string;
  77174. jointName?: string;
  77175. light?: string;
  77176. matrix: number[];
  77177. mesh?: string;
  77178. meshes?: string[];
  77179. rotation?: number[];
  77180. scale?: number[];
  77181. translation?: number[];
  77182. babylonNode?: Node;
  77183. }
  77184. /** @hidden */
  77185. export interface IGLTFScene extends IGLTFChildRootProperty {
  77186. nodes: string[];
  77187. }
  77188. /** @hidden */
  77189. export interface IGLTFRuntime {
  77190. extensions: {
  77191. [key: string]: any;
  77192. };
  77193. accessors: {
  77194. [key: string]: IGLTFAccessor;
  77195. };
  77196. buffers: {
  77197. [key: string]: IGLTFBuffer;
  77198. };
  77199. bufferViews: {
  77200. [key: string]: IGLTFBufferView;
  77201. };
  77202. meshes: {
  77203. [key: string]: IGLTFMesh;
  77204. };
  77205. lights: {
  77206. [key: string]: IGLTFLight;
  77207. };
  77208. cameras: {
  77209. [key: string]: IGLTFCamera;
  77210. };
  77211. nodes: {
  77212. [key: string]: IGLTFNode;
  77213. };
  77214. images: {
  77215. [key: string]: IGLTFImage;
  77216. };
  77217. textures: {
  77218. [key: string]: IGLTFTexture;
  77219. };
  77220. shaders: {
  77221. [key: string]: IGLTFShader;
  77222. };
  77223. programs: {
  77224. [key: string]: IGLTFProgram;
  77225. };
  77226. samplers: {
  77227. [key: string]: IGLTFSampler;
  77228. };
  77229. techniques: {
  77230. [key: string]: IGLTFTechnique;
  77231. };
  77232. materials: {
  77233. [key: string]: IGLTFMaterial;
  77234. };
  77235. animations: {
  77236. [key: string]: IGLTFAnimation;
  77237. };
  77238. skins: {
  77239. [key: string]: IGLTFSkins;
  77240. };
  77241. currentScene?: Object;
  77242. scenes: {
  77243. [key: string]: IGLTFScene;
  77244. };
  77245. extensionsUsed: string[];
  77246. extensionsRequired?: string[];
  77247. buffersCount: number;
  77248. shaderscount: number;
  77249. scene: Scene;
  77250. rootUrl: string;
  77251. loadedBufferCount: number;
  77252. loadedBufferViews: {
  77253. [name: string]: ArrayBufferView;
  77254. };
  77255. loadedShaderCount: number;
  77256. importOnlyMeshes: boolean;
  77257. importMeshesNames?: string[];
  77258. dummyNodes: Node[];
  77259. forAssetContainer: boolean;
  77260. }
  77261. /** @hidden */
  77262. export interface INodeToRoot {
  77263. bone: Bone;
  77264. node: IGLTFNode;
  77265. id: string;
  77266. }
  77267. /** @hidden */
  77268. export interface IJointNode {
  77269. node: IGLTFNode;
  77270. id: string;
  77271. }
  77272. }
  77273. declare module BABYLON.GLTF1 {
  77274. /**
  77275. * Utils functions for GLTF
  77276. * @hidden
  77277. */
  77278. export class GLTFUtils {
  77279. /**
  77280. * Sets the given "parameter" matrix
  77281. * @param scene: the Scene object
  77282. * @param source: the source node where to pick the matrix
  77283. * @param parameter: the GLTF technique parameter
  77284. * @param uniformName: the name of the shader's uniform
  77285. * @param shaderMaterial: the shader material
  77286. */
  77287. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  77288. /**
  77289. * Sets the given "parameter" matrix
  77290. * @param shaderMaterial: the shader material
  77291. * @param uniform: the name of the shader's uniform
  77292. * @param value: the value of the uniform
  77293. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  77294. */
  77295. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  77296. /**
  77297. * Returns the wrap mode of the texture
  77298. * @param mode: the mode value
  77299. */
  77300. static GetWrapMode(mode: number): number;
  77301. /**
  77302. * Returns the byte stride giving an accessor
  77303. * @param accessor: the GLTF accessor objet
  77304. */
  77305. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  77306. /**
  77307. * Returns the texture filter mode giving a mode value
  77308. * @param mode: the filter mode value
  77309. */
  77310. static GetTextureFilterMode(mode: number): ETextureFilterType;
  77311. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  77312. /**
  77313. * Returns a buffer from its accessor
  77314. * @param gltfRuntime: the GLTF runtime
  77315. * @param accessor: the GLTF accessor
  77316. */
  77317. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  77318. /**
  77319. * Decodes a buffer view into a string
  77320. * @param view: the buffer view
  77321. */
  77322. static DecodeBufferToText(view: ArrayBufferView): string;
  77323. /**
  77324. * Returns the default material of gltf. Related to
  77325. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  77326. * @param scene: the Babylon.js scene
  77327. */
  77328. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  77329. private static _DefaultMaterial;
  77330. }
  77331. }
  77332. declare module BABYLON.GLTF1 {
  77333. /**
  77334. * Implementation of the base glTF spec
  77335. * @hidden
  77336. */
  77337. export class GLTFLoaderBase {
  77338. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  77339. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77340. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  77341. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77342. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  77343. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77344. }
  77345. /**
  77346. * glTF V1 Loader
  77347. * @hidden
  77348. */
  77349. export class GLTFLoader implements IGLTFLoader {
  77350. static Extensions: {
  77351. [name: string]: GLTFLoaderExtension;
  77352. };
  77353. static RegisterExtension(extension: GLTFLoaderExtension): void;
  77354. state: Nullable<GLTFLoaderState>;
  77355. dispose(): void;
  77356. private _importMeshAsync;
  77357. /**
  77358. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  77359. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77360. * @param scene the scene the meshes should be added to
  77361. * @param forAssetContainer defines if the entities must be stored in the scene
  77362. * @param data gltf data containing information of the meshes in a loaded file
  77363. * @param rootUrl root url to load from
  77364. * @param onProgress event that fires when loading progress has occured
  77365. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77366. */
  77367. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  77368. private _loadAsync;
  77369. /**
  77370. * Imports all objects from a loaded gltf file and adds them to the scene
  77371. * @param scene the scene the objects should be added to
  77372. * @param data gltf data containing information of the meshes in a loaded file
  77373. * @param rootUrl root url to load from
  77374. * @param onProgress event that fires when loading progress has occured
  77375. * @returns a promise which completes when objects have been loaded to the scene
  77376. */
  77377. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  77378. private _loadShadersAsync;
  77379. private _loadBuffersAsync;
  77380. private _createNodes;
  77381. }
  77382. /** @hidden */
  77383. export abstract class GLTFLoaderExtension {
  77384. private _name;
  77385. constructor(name: string);
  77386. get name(): string;
  77387. /**
  77388. * Defines an override for loading the runtime
  77389. * Return true to stop further extensions from loading the runtime
  77390. */
  77391. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  77392. /**
  77393. * Defines an onverride for creating gltf runtime
  77394. * Return true to stop further extensions from creating the runtime
  77395. */
  77396. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  77397. /**
  77398. * Defines an override for loading buffers
  77399. * Return true to stop further extensions from loading this buffer
  77400. */
  77401. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  77402. /**
  77403. * Defines an override for loading texture buffers
  77404. * Return true to stop further extensions from loading this texture data
  77405. */
  77406. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77407. /**
  77408. * Defines an override for creating textures
  77409. * Return true to stop further extensions from loading this texture
  77410. */
  77411. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  77412. /**
  77413. * Defines an override for loading shader strings
  77414. * Return true to stop further extensions from loading this shader data
  77415. */
  77416. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77417. /**
  77418. * Defines an override for loading materials
  77419. * Return true to stop further extensions from loading this material
  77420. */
  77421. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77422. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  77423. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  77424. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77425. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77426. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  77427. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77428. private static LoadTextureBufferAsync;
  77429. private static CreateTextureAsync;
  77430. private static ApplyExtensions;
  77431. }
  77432. }
  77433. declare module BABYLON.GLTF1 {
  77434. /** @hidden */
  77435. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  77436. private _bin;
  77437. constructor();
  77438. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  77439. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77440. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77441. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77442. }
  77443. }
  77444. declare module BABYLON.GLTF1 {
  77445. /** @hidden */
  77446. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  77447. constructor();
  77448. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  77449. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77450. private _loadTexture;
  77451. }
  77452. }
  77453. declare module BABYLON.GLTF2.Loader {
  77454. /**
  77455. * Loader interface with an index field.
  77456. */
  77457. export interface IArrayItem {
  77458. /**
  77459. * The index of this item in the array.
  77460. */
  77461. index: number;
  77462. }
  77463. /**
  77464. * Loader interface with additional members.
  77465. */
  77466. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  77467. /** @hidden */
  77468. _data?: Promise<ArrayBufferView>;
  77469. /** @hidden */
  77470. _babylonVertexBuffer?: Promise<VertexBuffer>;
  77471. }
  77472. /**
  77473. * Loader interface with additional members.
  77474. */
  77475. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  77476. }
  77477. /** @hidden */
  77478. export interface _IAnimationSamplerData {
  77479. input: Float32Array;
  77480. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  77481. output: Float32Array;
  77482. }
  77483. /**
  77484. * Loader interface with additional members.
  77485. */
  77486. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  77487. /** @hidden */
  77488. _data?: Promise<_IAnimationSamplerData>;
  77489. }
  77490. /**
  77491. * Loader interface with additional members.
  77492. */
  77493. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  77494. channels: IAnimationChannel[];
  77495. samplers: IAnimationSampler[];
  77496. /** @hidden */
  77497. _babylonAnimationGroup?: AnimationGroup;
  77498. }
  77499. /**
  77500. * Loader interface with additional members.
  77501. */
  77502. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  77503. /** @hidden */
  77504. _data?: Promise<ArrayBufferView>;
  77505. }
  77506. /**
  77507. * Loader interface with additional members.
  77508. */
  77509. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  77510. /** @hidden */
  77511. _data?: Promise<ArrayBufferView>;
  77512. /** @hidden */
  77513. _babylonBuffer?: Promise<Buffer>;
  77514. }
  77515. /**
  77516. * Loader interface with additional members.
  77517. */
  77518. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  77519. }
  77520. /**
  77521. * Loader interface with additional members.
  77522. */
  77523. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  77524. /** @hidden */
  77525. _data?: Promise<ArrayBufferView>;
  77526. }
  77527. /**
  77528. * Loader interface with additional members.
  77529. */
  77530. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  77531. }
  77532. /**
  77533. * Loader interface with additional members.
  77534. */
  77535. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  77536. }
  77537. /**
  77538. * Loader interface with additional members.
  77539. */
  77540. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  77541. baseColorTexture?: ITextureInfo;
  77542. metallicRoughnessTexture?: ITextureInfo;
  77543. }
  77544. /**
  77545. * Loader interface with additional members.
  77546. */
  77547. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  77548. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77549. normalTexture?: IMaterialNormalTextureInfo;
  77550. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77551. emissiveTexture?: ITextureInfo;
  77552. /** @hidden */
  77553. _data?: {
  77554. [babylonDrawMode: number]: {
  77555. babylonMaterial: Material;
  77556. babylonMeshes: AbstractMesh[];
  77557. promise: Promise<void>;
  77558. };
  77559. };
  77560. }
  77561. /**
  77562. * Loader interface with additional members.
  77563. */
  77564. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  77565. primitives: IMeshPrimitive[];
  77566. }
  77567. /**
  77568. * Loader interface with additional members.
  77569. */
  77570. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  77571. /** @hidden */
  77572. _instanceData?: {
  77573. babylonSourceMesh: Mesh;
  77574. promise: Promise<any>;
  77575. };
  77576. }
  77577. /**
  77578. * Loader interface with additional members.
  77579. */
  77580. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  77581. /**
  77582. * The parent glTF node.
  77583. */
  77584. parent?: INode;
  77585. /** @hidden */
  77586. _babylonTransformNode?: TransformNode;
  77587. /** @hidden */
  77588. _primitiveBabylonMeshes?: AbstractMesh[];
  77589. /** @hidden */
  77590. _babylonBones?: Bone[];
  77591. /** @hidden */
  77592. _numMorphTargets?: number;
  77593. }
  77594. /** @hidden */
  77595. export interface _ISamplerData {
  77596. noMipMaps: boolean;
  77597. samplingMode: number;
  77598. wrapU: number;
  77599. wrapV: number;
  77600. }
  77601. /**
  77602. * Loader interface with additional members.
  77603. */
  77604. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  77605. /** @hidden */
  77606. _data?: _ISamplerData;
  77607. }
  77608. /**
  77609. * Loader interface with additional members.
  77610. */
  77611. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  77612. }
  77613. /**
  77614. * Loader interface with additional members.
  77615. */
  77616. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  77617. /** @hidden */
  77618. _data?: {
  77619. babylonSkeleton: Skeleton;
  77620. promise: Promise<void>;
  77621. };
  77622. }
  77623. /**
  77624. * Loader interface with additional members.
  77625. */
  77626. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  77627. }
  77628. /**
  77629. * Loader interface with additional members.
  77630. */
  77631. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  77632. }
  77633. /**
  77634. * Loader interface with additional members.
  77635. */
  77636. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  77637. accessors?: IAccessor[];
  77638. animations?: IAnimation[];
  77639. buffers?: IBuffer[];
  77640. bufferViews?: IBufferView[];
  77641. cameras?: ICamera[];
  77642. images?: IImage[];
  77643. materials?: IMaterial[];
  77644. meshes?: IMesh[];
  77645. nodes?: INode[];
  77646. samplers?: ISampler[];
  77647. scenes?: IScene[];
  77648. skins?: ISkin[];
  77649. textures?: ITexture[];
  77650. }
  77651. }
  77652. declare module BABYLON.GLTF2 {
  77653. /**
  77654. * Interface for a glTF loader extension.
  77655. */
  77656. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  77657. /**
  77658. * Called after the loader state changes to LOADING.
  77659. */
  77660. onLoading?(): void;
  77661. /**
  77662. * Called after the loader state changes to READY.
  77663. */
  77664. onReady?(): void;
  77665. /**
  77666. * Define this method to modify the default behavior when loading scenes.
  77667. * @param context The context when loading the asset
  77668. * @param scene The glTF scene property
  77669. * @returns A promise that resolves when the load is complete or null if not handled
  77670. */
  77671. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  77672. /**
  77673. * Define this method to modify the default behavior when loading nodes.
  77674. * @param context The context when loading the asset
  77675. * @param node The glTF node property
  77676. * @param assign A function called synchronously after parsing the glTF properties
  77677. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  77678. */
  77679. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77680. /**
  77681. * Define this method to modify the default behavior when loading cameras.
  77682. * @param context The context when loading the asset
  77683. * @param camera The glTF camera property
  77684. * @param assign A function called synchronously after parsing the glTF properties
  77685. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  77686. */
  77687. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77688. /**
  77689. * @hidden
  77690. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  77691. * @param context The context when loading the asset
  77692. * @param primitive The glTF mesh primitive property
  77693. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  77694. */
  77695. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77696. /**
  77697. * @hidden
  77698. * Define this method to modify the default behavior when loading data for mesh primitives.
  77699. * @param context The context when loading the asset
  77700. * @param name The mesh name when loading the asset
  77701. * @param node The glTF node when loading the asset
  77702. * @param mesh The glTF mesh when loading the asset
  77703. * @param primitive The glTF mesh primitive property
  77704. * @param assign A function called synchronously after parsing the glTF properties
  77705. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77706. */
  77707. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77708. /**
  77709. * @hidden
  77710. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  77711. * @param context The context when loading the asset
  77712. * @param material The glTF material property
  77713. * @param assign A function called synchronously after parsing the glTF properties
  77714. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  77715. */
  77716. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77717. /**
  77718. * Define this method to modify the default behavior when creating materials.
  77719. * @param context The context when loading the asset
  77720. * @param material The glTF material property
  77721. * @param babylonDrawMode The draw mode for the Babylon material
  77722. * @returns The Babylon material or null if not handled
  77723. */
  77724. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77725. /**
  77726. * Define this method to modify the default behavior when loading material properties.
  77727. * @param context The context when loading the asset
  77728. * @param material The glTF material property
  77729. * @param babylonMaterial The Babylon material
  77730. * @returns A promise that resolves when the load is complete or null if not handled
  77731. */
  77732. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77733. /**
  77734. * Define this method to modify the default behavior when loading texture infos.
  77735. * @param context The context when loading the asset
  77736. * @param textureInfo The glTF texture info property
  77737. * @param assign A function called synchronously after parsing the glTF properties
  77738. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77739. */
  77740. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77741. /**
  77742. * @hidden
  77743. * Define this method to modify the default behavior when loading textures.
  77744. * @param context The context when loading the asset
  77745. * @param texture The glTF texture property
  77746. * @param assign A function called synchronously after parsing the glTF properties
  77747. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77748. */
  77749. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77750. /**
  77751. * Define this method to modify the default behavior when loading animations.
  77752. * @param context The context when loading the asset
  77753. * @param animation The glTF animation property
  77754. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  77755. */
  77756. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77757. /**
  77758. * @hidden
  77759. * Define this method to modify the default behavior when loading skins.
  77760. * @param context The context when loading the asset
  77761. * @param node The glTF node property
  77762. * @param skin The glTF skin property
  77763. * @returns A promise that resolves when the load is complete or null if not handled
  77764. */
  77765. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  77766. /**
  77767. * @hidden
  77768. * Define this method to modify the default behavior when loading uris.
  77769. * @param context The context when loading the asset
  77770. * @param property The glTF property associated with the uri
  77771. * @param uri The uri to load
  77772. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77773. */
  77774. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77775. /**
  77776. * Define this method to modify the default behavior when loading buffer views.
  77777. * @param context The context when loading the asset
  77778. * @param bufferView The glTF buffer view property
  77779. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77780. */
  77781. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  77782. /**
  77783. * Define this method to modify the default behavior when loading buffers.
  77784. * @param context The context when loading the asset
  77785. * @param buffer The glTF buffer property
  77786. * @param byteOffset The byte offset to load
  77787. * @param byteLength The byte length to load
  77788. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77789. */
  77790. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77791. }
  77792. }
  77793. declare module BABYLON.GLTF2 {
  77794. /**
  77795. * Helper class for working with arrays when loading the glTF asset
  77796. */
  77797. export class ArrayItem {
  77798. /**
  77799. * Gets an item from the given array.
  77800. * @param context The context when loading the asset
  77801. * @param array The array to get the item from
  77802. * @param index The index to the array
  77803. * @returns The array item
  77804. */
  77805. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  77806. /**
  77807. * Assign an `index` field to each item of the given array.
  77808. * @param array The array of items
  77809. */
  77810. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  77811. }
  77812. /**
  77813. * The glTF 2.0 loader
  77814. */
  77815. export class GLTFLoader implements IGLTFLoader {
  77816. /** @hidden */
  77817. _completePromises: Promise<any>[];
  77818. /** @hidden */
  77819. _forAssetContainer: boolean;
  77820. /** Storage */
  77821. _babylonLights: Light[];
  77822. private _disposed;
  77823. private _parent;
  77824. private _state;
  77825. private _extensions;
  77826. private _rootUrl;
  77827. private _fileName;
  77828. private _uniqueRootUrl;
  77829. private _gltf;
  77830. private _bin;
  77831. private _babylonScene;
  77832. private _rootBabylonMesh;
  77833. private _defaultBabylonMaterialData;
  77834. private _progressCallback?;
  77835. private _requests;
  77836. private static _RegisteredExtensions;
  77837. /**
  77838. * The default glTF sampler.
  77839. */
  77840. static readonly DefaultSampler: ISampler;
  77841. /**
  77842. * Registers a loader extension.
  77843. * @param name The name of the loader extension.
  77844. * @param factory The factory function that creates the loader extension.
  77845. */
  77846. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  77847. /**
  77848. * Unregisters a loader extension.
  77849. * @param name The name of the loader extension.
  77850. * @returns A boolean indicating whether the extension has been unregistered
  77851. */
  77852. static UnregisterExtension(name: string): boolean;
  77853. /**
  77854. * The loader state.
  77855. */
  77856. get state(): Nullable<GLTFLoaderState>;
  77857. /**
  77858. * The object that represents the glTF JSON.
  77859. */
  77860. get gltf(): IGLTF;
  77861. /**
  77862. * The BIN chunk of a binary glTF.
  77863. */
  77864. get bin(): Nullable<IDataBuffer>;
  77865. /**
  77866. * The parent file loader.
  77867. */
  77868. get parent(): GLTFFileLoader;
  77869. /**
  77870. * The Babylon scene when loading the asset.
  77871. */
  77872. get babylonScene(): Scene;
  77873. /**
  77874. * The root Babylon mesh when loading the asset.
  77875. */
  77876. get rootBabylonMesh(): Mesh;
  77877. /** @hidden */
  77878. constructor(parent: GLTFFileLoader);
  77879. /** @hidden */
  77880. dispose(): void;
  77881. /** @hidden */
  77882. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  77883. /** @hidden */
  77884. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77885. private _loadAsync;
  77886. private _loadData;
  77887. private _setupData;
  77888. private _loadExtensions;
  77889. private _checkExtensions;
  77890. private _setState;
  77891. private _createRootNode;
  77892. /**
  77893. * Loads a glTF scene.
  77894. * @param context The context when loading the asset
  77895. * @param scene The glTF scene property
  77896. * @returns A promise that resolves when the load is complete
  77897. */
  77898. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  77899. private _forEachPrimitive;
  77900. private _getMeshes;
  77901. private _getTransformNodes;
  77902. private _getSkeletons;
  77903. private _getAnimationGroups;
  77904. private _startAnimations;
  77905. /**
  77906. * Loads a glTF node.
  77907. * @param context The context when loading the asset
  77908. * @param node The glTF node property
  77909. * @param assign A function called synchronously after parsing the glTF properties
  77910. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  77911. */
  77912. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  77913. private _loadMeshAsync;
  77914. /**
  77915. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  77916. * @param context The context when loading the asset
  77917. * @param name The mesh name when loading the asset
  77918. * @param node The glTF node when loading the asset
  77919. * @param mesh The glTF mesh when loading the asset
  77920. * @param primitive The glTF mesh primitive property
  77921. * @param assign A function called synchronously after parsing the glTF properties
  77922. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77923. */
  77924. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77925. private _loadVertexDataAsync;
  77926. private _createMorphTargets;
  77927. private _loadMorphTargetsAsync;
  77928. private _loadMorphTargetVertexDataAsync;
  77929. private static _LoadTransform;
  77930. private _loadSkinAsync;
  77931. private _loadBones;
  77932. private _loadBone;
  77933. private _loadSkinInverseBindMatricesDataAsync;
  77934. private _updateBoneMatrices;
  77935. private _getNodeMatrix;
  77936. /**
  77937. * Loads a glTF camera.
  77938. * @param context The context when loading the asset
  77939. * @param camera The glTF camera property
  77940. * @param assign A function called synchronously after parsing the glTF properties
  77941. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  77942. */
  77943. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  77944. private _loadAnimationsAsync;
  77945. /**
  77946. * Loads a glTF animation.
  77947. * @param context The context when loading the asset
  77948. * @param animation The glTF animation property
  77949. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  77950. */
  77951. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  77952. /**
  77953. * @hidden Loads a glTF animation channel.
  77954. * @param context The context when loading the asset
  77955. * @param animationContext The context of the animation when loading the asset
  77956. * @param animation The glTF animation property
  77957. * @param channel The glTF animation channel property
  77958. * @param babylonAnimationGroup The babylon animation group property
  77959. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  77960. * @returns A void promise when the channel load is complete
  77961. */
  77962. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  77963. private _loadAnimationSamplerAsync;
  77964. private _loadBufferAsync;
  77965. /**
  77966. * Loads a glTF buffer view.
  77967. * @param context The context when loading the asset
  77968. * @param bufferView The glTF buffer view property
  77969. * @returns A promise that resolves with the loaded data when the load is complete
  77970. */
  77971. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  77972. private _loadAccessorAsync;
  77973. /** @hidden */
  77974. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  77975. private _loadIndicesAccessorAsync;
  77976. private _loadVertexBufferViewAsync;
  77977. private _loadVertexAccessorAsync;
  77978. private _loadMaterialMetallicRoughnessPropertiesAsync;
  77979. /** @hidden */
  77980. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  77981. private _createDefaultMaterial;
  77982. /**
  77983. * Creates a Babylon material from a glTF material.
  77984. * @param context The context when loading the asset
  77985. * @param material The glTF material property
  77986. * @param babylonDrawMode The draw mode for the Babylon material
  77987. * @returns The Babylon material
  77988. */
  77989. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  77990. /**
  77991. * Loads properties from a glTF material into a Babylon material.
  77992. * @param context The context when loading the asset
  77993. * @param material The glTF material property
  77994. * @param babylonMaterial The Babylon material
  77995. * @returns A promise that resolves when the load is complete
  77996. */
  77997. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  77998. /**
  77999. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  78000. * @param context The context when loading the asset
  78001. * @param material The glTF material property
  78002. * @param babylonMaterial The Babylon material
  78003. * @returns A promise that resolves when the load is complete
  78004. */
  78005. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78006. /**
  78007. * Loads the alpha properties from a glTF material into a Babylon material.
  78008. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  78009. * @param context The context when loading the asset
  78010. * @param material The glTF material property
  78011. * @param babylonMaterial The Babylon material
  78012. */
  78013. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  78014. /**
  78015. * Loads a glTF texture info.
  78016. * @param context The context when loading the asset
  78017. * @param textureInfo The glTF texture info property
  78018. * @param assign A function called synchronously after parsing the glTF properties
  78019. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  78020. */
  78021. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78022. /** @hidden */
  78023. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78024. /** @hidden */
  78025. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78026. private _loadSampler;
  78027. /**
  78028. * Loads a glTF image.
  78029. * @param context The context when loading the asset
  78030. * @param image The glTF image property
  78031. * @returns A promise that resolves with the loaded data when the load is complete
  78032. */
  78033. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  78034. /**
  78035. * Loads a glTF uri.
  78036. * @param context The context when loading the asset
  78037. * @param property The glTF property associated with the uri
  78038. * @param uri The base64 or relative uri
  78039. * @returns A promise that resolves with the loaded data when the load is complete
  78040. */
  78041. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  78042. private _onProgress;
  78043. /**
  78044. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  78045. * @param babylonObject the Babylon object with metadata
  78046. * @param pointer the JSON pointer
  78047. */
  78048. static AddPointerMetadata(babylonObject: {
  78049. metadata: any;
  78050. }, pointer: string): void;
  78051. private static _GetTextureWrapMode;
  78052. private static _GetTextureSamplingMode;
  78053. private static _GetTypedArrayConstructor;
  78054. private static _GetTypedArray;
  78055. private static _GetNumComponents;
  78056. private static _ValidateUri;
  78057. private static _GetDrawMode;
  78058. private _compileMaterialsAsync;
  78059. private _compileShadowGeneratorsAsync;
  78060. private _forEachExtensions;
  78061. private _applyExtensions;
  78062. private _extensionsOnLoading;
  78063. private _extensionsOnReady;
  78064. private _extensionsLoadSceneAsync;
  78065. private _extensionsLoadNodeAsync;
  78066. private _extensionsLoadCameraAsync;
  78067. private _extensionsLoadVertexDataAsync;
  78068. private _extensionsLoadMeshPrimitiveAsync;
  78069. private _extensionsLoadMaterialAsync;
  78070. private _extensionsCreateMaterial;
  78071. private _extensionsLoadMaterialPropertiesAsync;
  78072. private _extensionsLoadTextureInfoAsync;
  78073. private _extensionsLoadTextureAsync;
  78074. private _extensionsLoadAnimationAsync;
  78075. private _extensionsLoadSkinAsync;
  78076. private _extensionsLoadUriAsync;
  78077. private _extensionsLoadBufferViewAsync;
  78078. private _extensionsLoadBufferAsync;
  78079. /**
  78080. * Helper method called by a loader extension to load an glTF extension.
  78081. * @param context The context when loading the asset
  78082. * @param property The glTF property to load the extension from
  78083. * @param extensionName The name of the extension to load
  78084. * @param actionAsync The action to run
  78085. * @returns The promise returned by actionAsync or null if the extension does not exist
  78086. */
  78087. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78088. /**
  78089. * Helper method called by a loader extension to load a glTF extra.
  78090. * @param context The context when loading the asset
  78091. * @param property The glTF property to load the extra from
  78092. * @param extensionName The name of the extension to load
  78093. * @param actionAsync The action to run
  78094. * @returns The promise returned by actionAsync or null if the extra does not exist
  78095. */
  78096. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78097. /**
  78098. * Checks for presence of an extension.
  78099. * @param name The name of the extension to check
  78100. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  78101. */
  78102. isExtensionUsed(name: string): boolean;
  78103. /**
  78104. * Increments the indentation level and logs a message.
  78105. * @param message The message to log
  78106. */
  78107. logOpen(message: string): void;
  78108. /**
  78109. * Decrements the indentation level.
  78110. */
  78111. logClose(): void;
  78112. /**
  78113. * Logs a message
  78114. * @param message The message to log
  78115. */
  78116. log(message: string): void;
  78117. /**
  78118. * Starts a performance counter.
  78119. * @param counterName The name of the performance counter
  78120. */
  78121. startPerformanceCounter(counterName: string): void;
  78122. /**
  78123. * Ends a performance counter.
  78124. * @param counterName The name of the performance counter
  78125. */
  78126. endPerformanceCounter(counterName: string): void;
  78127. }
  78128. }
  78129. declare module BABYLON.GLTF2.Loader.Extensions {
  78130. /**
  78131. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  78132. */
  78133. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  78134. /**
  78135. * The name of this extension.
  78136. */
  78137. readonly name: string;
  78138. /**
  78139. * Defines whether this extension is enabled.
  78140. */
  78141. enabled: boolean;
  78142. private _loader;
  78143. private _lights?;
  78144. /** @hidden */
  78145. constructor(loader: GLTFLoader);
  78146. /** @hidden */
  78147. dispose(): void;
  78148. /** @hidden */
  78149. onLoading(): void;
  78150. /** @hidden */
  78151. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78152. private _loadLightAsync;
  78153. }
  78154. }
  78155. declare module BABYLON.GLTF2.Loader.Extensions {
  78156. /**
  78157. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  78158. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  78159. * !!! Experimental Extension Subject to Changes !!!
  78160. */
  78161. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  78162. /**
  78163. * The name of this extension.
  78164. */
  78165. readonly name: string;
  78166. /**
  78167. * Defines whether this extension is enabled.
  78168. */
  78169. enabled: boolean;
  78170. private _loader;
  78171. /** @hidden */
  78172. constructor(loader: GLTFLoader);
  78173. /** @hidden */
  78174. dispose(): void;
  78175. /** @hidden */
  78176. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78177. }
  78178. }
  78179. declare module BABYLON.GLTF2.Loader.Extensions {
  78180. /**
  78181. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  78182. */
  78183. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  78184. /**
  78185. * The name of this extension.
  78186. */
  78187. readonly name: string;
  78188. /**
  78189. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  78190. */
  78191. dracoCompression?: DracoCompression;
  78192. /**
  78193. * Defines whether this extension is enabled.
  78194. */
  78195. enabled: boolean;
  78196. private _loader;
  78197. /** @hidden */
  78198. constructor(loader: GLTFLoader);
  78199. /** @hidden */
  78200. dispose(): void;
  78201. /** @hidden */
  78202. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78203. }
  78204. }
  78205. declare module BABYLON.GLTF2.Loader.Extensions {
  78206. /**
  78207. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  78208. */
  78209. export class KHR_lights implements IGLTFLoaderExtension {
  78210. /**
  78211. * The name of this extension.
  78212. */
  78213. readonly name: string;
  78214. /**
  78215. * Defines whether this extension is enabled.
  78216. */
  78217. enabled: boolean;
  78218. private _loader;
  78219. private _lights?;
  78220. /** @hidden */
  78221. constructor(loader: GLTFLoader);
  78222. /** @hidden */
  78223. dispose(): void;
  78224. /** @hidden */
  78225. onLoading(): void;
  78226. /** @hidden */
  78227. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78228. }
  78229. }
  78230. declare module BABYLON.GLTF2.Loader.Extensions {
  78231. /**
  78232. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  78233. */
  78234. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  78235. /**
  78236. * The name of this extension.
  78237. */
  78238. readonly name: string;
  78239. /**
  78240. * Defines whether this extension is enabled.
  78241. */
  78242. enabled: boolean;
  78243. /**
  78244. * Defines a number that determines the order the extensions are applied.
  78245. */
  78246. order: number;
  78247. private _loader;
  78248. /** @hidden */
  78249. constructor(loader: GLTFLoader);
  78250. /** @hidden */
  78251. dispose(): void;
  78252. /** @hidden */
  78253. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78254. private _loadSpecularGlossinessPropertiesAsync;
  78255. }
  78256. }
  78257. declare module BABYLON.GLTF2.Loader.Extensions {
  78258. /**
  78259. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  78260. */
  78261. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  78262. /**
  78263. * The name of this extension.
  78264. */
  78265. readonly name: string;
  78266. /**
  78267. * Defines whether this extension is enabled.
  78268. */
  78269. enabled: boolean;
  78270. /**
  78271. * Defines a number that determines the order the extensions are applied.
  78272. */
  78273. order: number;
  78274. private _loader;
  78275. /** @hidden */
  78276. constructor(loader: GLTFLoader);
  78277. /** @hidden */
  78278. dispose(): void;
  78279. /** @hidden */
  78280. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78281. private _loadUnlitPropertiesAsync;
  78282. }
  78283. }
  78284. declare module BABYLON.GLTF2.Loader.Extensions {
  78285. /**
  78286. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78287. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  78288. * !!! Experimental Extension Subject to Changes !!!
  78289. */
  78290. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  78291. /**
  78292. * The name of this extension.
  78293. */
  78294. readonly name: string;
  78295. /**
  78296. * Defines whether this extension is enabled.
  78297. */
  78298. enabled: boolean;
  78299. /**
  78300. * Defines a number that determines the order the extensions are applied.
  78301. */
  78302. order: number;
  78303. private _loader;
  78304. /** @hidden */
  78305. constructor(loader: GLTFLoader);
  78306. /** @hidden */
  78307. dispose(): void;
  78308. /** @hidden */
  78309. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78310. private _loadClearCoatPropertiesAsync;
  78311. }
  78312. }
  78313. declare module BABYLON.GLTF2.Loader.Extensions {
  78314. /**
  78315. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  78316. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78317. * !!! Experimental Extension Subject to Changes !!!
  78318. */
  78319. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  78320. /**
  78321. * The name of this extension.
  78322. */
  78323. readonly name: string;
  78324. /**
  78325. * Defines whether this extension is enabled.
  78326. */
  78327. enabled: boolean;
  78328. /**
  78329. * Defines a number that determines the order the extensions are applied.
  78330. */
  78331. order: number;
  78332. private _loader;
  78333. /** @hidden */
  78334. constructor(loader: GLTFLoader);
  78335. /** @hidden */
  78336. dispose(): void;
  78337. /** @hidden */
  78338. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78339. private _loadSheenPropertiesAsync;
  78340. }
  78341. }
  78342. declare module BABYLON.GLTF2.Loader.Extensions {
  78343. /**
  78344. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78345. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78346. * !!! Experimental Extension Subject to Changes !!!
  78347. */
  78348. export class KHR_materials_specular implements IGLTFLoaderExtension {
  78349. /**
  78350. * The name of this extension.
  78351. */
  78352. readonly name: string;
  78353. /**
  78354. * Defines whether this extension is enabled.
  78355. */
  78356. enabled: boolean;
  78357. /**
  78358. * Defines a number that determines the order the extensions are applied.
  78359. */
  78360. order: number;
  78361. private _loader;
  78362. /** @hidden */
  78363. constructor(loader: GLTFLoader);
  78364. /** @hidden */
  78365. dispose(): void;
  78366. /** @hidden */
  78367. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78368. private _loadSpecularPropertiesAsync;
  78369. }
  78370. }
  78371. declare module BABYLON.GLTF2.Loader.Extensions {
  78372. /**
  78373. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  78374. */
  78375. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  78376. /**
  78377. * The name of this extension.
  78378. */
  78379. readonly name: string;
  78380. /**
  78381. * Defines whether this extension is enabled.
  78382. */
  78383. enabled: boolean;
  78384. /** @hidden */
  78385. constructor(loader: GLTFLoader);
  78386. /** @hidden */
  78387. dispose(): void;
  78388. }
  78389. }
  78390. declare module BABYLON.GLTF2.Loader.Extensions {
  78391. /**
  78392. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  78393. * !!! Experimental Extension Subject to Changes !!!
  78394. */
  78395. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  78396. /** The name of this extension. */
  78397. readonly name: string;
  78398. /** Defines whether this extension is enabled. */
  78399. enabled: boolean;
  78400. private _loader;
  78401. /** @hidden */
  78402. constructor(loader: GLTFLoader);
  78403. /** @hidden */
  78404. dispose(): void;
  78405. /** @hidden */
  78406. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78407. }
  78408. }
  78409. declare module BABYLON.GLTF2.Loader.Extensions {
  78410. /**
  78411. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  78412. */
  78413. export class KHR_texture_transform implements IGLTFLoaderExtension {
  78414. /**
  78415. * The name of this extension.
  78416. */
  78417. readonly name: string;
  78418. /**
  78419. * Defines whether this extension is enabled.
  78420. */
  78421. enabled: boolean;
  78422. private _loader;
  78423. /** @hidden */
  78424. constructor(loader: GLTFLoader);
  78425. /** @hidden */
  78426. dispose(): void;
  78427. /** @hidden */
  78428. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78429. }
  78430. }
  78431. declare module BABYLON.GLTF2.Loader.Extensions {
  78432. /**
  78433. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  78434. */
  78435. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  78436. /**
  78437. * The name of this extension.
  78438. */
  78439. readonly name: string;
  78440. /**
  78441. * Defines whether this extension is enabled.
  78442. */
  78443. enabled: boolean;
  78444. private _loader;
  78445. private _clips;
  78446. private _emitters;
  78447. /** @hidden */
  78448. constructor(loader: GLTFLoader);
  78449. /** @hidden */
  78450. dispose(): void;
  78451. /** @hidden */
  78452. onLoading(): void;
  78453. /** @hidden */
  78454. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78455. /** @hidden */
  78456. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78457. /** @hidden */
  78458. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78459. private _loadClipAsync;
  78460. private _loadEmitterAsync;
  78461. private _getEventAction;
  78462. private _loadAnimationEventAsync;
  78463. }
  78464. }
  78465. declare module BABYLON.GLTF2.Loader.Extensions {
  78466. /**
  78467. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  78468. */
  78469. export class MSFT_lod implements IGLTFLoaderExtension {
  78470. /**
  78471. * The name of this extension.
  78472. */
  78473. readonly name: string;
  78474. /**
  78475. * Defines whether this extension is enabled.
  78476. */
  78477. enabled: boolean;
  78478. /**
  78479. * Defines a number that determines the order the extensions are applied.
  78480. */
  78481. order: number;
  78482. /**
  78483. * Maximum number of LODs to load, starting from the lowest LOD.
  78484. */
  78485. maxLODsToLoad: number;
  78486. /**
  78487. * Observable raised when all node LODs of one level are loaded.
  78488. * The event data is the index of the loaded LOD starting from zero.
  78489. * Dispose the loader to cancel the loading of the next level of LODs.
  78490. */
  78491. onNodeLODsLoadedObservable: Observable<number>;
  78492. /**
  78493. * Observable raised when all material LODs of one level are loaded.
  78494. * The event data is the index of the loaded LOD starting from zero.
  78495. * Dispose the loader to cancel the loading of the next level of LODs.
  78496. */
  78497. onMaterialLODsLoadedObservable: Observable<number>;
  78498. private _loader;
  78499. private _nodeIndexLOD;
  78500. private _nodeSignalLODs;
  78501. private _nodePromiseLODs;
  78502. private _materialIndexLOD;
  78503. private _materialSignalLODs;
  78504. private _materialPromiseLODs;
  78505. private _indexLOD;
  78506. private _bufferLODs;
  78507. /** @hidden */
  78508. constructor(loader: GLTFLoader);
  78509. /** @hidden */
  78510. dispose(): void;
  78511. /** @hidden */
  78512. onReady(): void;
  78513. /** @hidden */
  78514. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78515. /** @hidden */
  78516. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78517. /** @hidden */
  78518. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78519. /** @hidden */
  78520. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78521. /** @hidden */
  78522. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78523. private _loadBufferLOD;
  78524. /**
  78525. * Gets an array of LOD properties from lowest to highest.
  78526. */
  78527. private _getLODs;
  78528. private _disposeTransformNode;
  78529. private _disposeMaterials;
  78530. }
  78531. }
  78532. declare module BABYLON.GLTF2.Loader.Extensions {
  78533. /** @hidden */
  78534. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  78535. readonly name: string;
  78536. enabled: boolean;
  78537. private _loader;
  78538. constructor(loader: GLTFLoader);
  78539. dispose(): void;
  78540. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78541. }
  78542. }
  78543. declare module BABYLON.GLTF2.Loader.Extensions {
  78544. /** @hidden */
  78545. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  78546. readonly name: string;
  78547. enabled: boolean;
  78548. private _loader;
  78549. constructor(loader: GLTFLoader);
  78550. dispose(): void;
  78551. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78552. }
  78553. }
  78554. declare module BABYLON.GLTF2.Loader.Extensions {
  78555. /**
  78556. * Store glTF extras (if present) in BJS objects' metadata
  78557. */
  78558. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  78559. /**
  78560. * The name of this extension.
  78561. */
  78562. readonly name: string;
  78563. /**
  78564. * Defines whether this extension is enabled.
  78565. */
  78566. enabled: boolean;
  78567. private _loader;
  78568. private _assignExtras;
  78569. /** @hidden */
  78570. constructor(loader: GLTFLoader);
  78571. /** @hidden */
  78572. dispose(): void;
  78573. /** @hidden */
  78574. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78575. /** @hidden */
  78576. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78577. /** @hidden */
  78578. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78579. }
  78580. }
  78581. declare module BABYLON {
  78582. /**
  78583. * Class reading and parsing the MTL file bundled with the obj file.
  78584. */
  78585. export class MTLFileLoader {
  78586. /**
  78587. * Invert Y-Axis of referenced textures on load
  78588. */
  78589. static INVERT_TEXTURE_Y: boolean;
  78590. /**
  78591. * All material loaded from the mtl will be set here
  78592. */
  78593. materials: StandardMaterial[];
  78594. /**
  78595. * This function will read the mtl file and create each material described inside
  78596. * This function could be improve by adding :
  78597. * -some component missing (Ni, Tf...)
  78598. * -including the specific options available
  78599. *
  78600. * @param scene defines the scene the material will be created in
  78601. * @param data defines the mtl data to parse
  78602. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  78603. * @param forAssetContainer defines if the material should be registered in the scene
  78604. */
  78605. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  78606. /**
  78607. * Gets the texture for the material.
  78608. *
  78609. * If the material is imported from input file,
  78610. * We sanitize the url to ensure it takes the textre from aside the material.
  78611. *
  78612. * @param rootUrl The root url to load from
  78613. * @param value The value stored in the mtl
  78614. * @return The Texture
  78615. */
  78616. private static _getTexture;
  78617. }
  78618. }
  78619. declare module BABYLON {
  78620. /**
  78621. * Options for loading OBJ/MTL files
  78622. */
  78623. type MeshLoadOptions = {
  78624. /**
  78625. * Defines if UVs are optimized by default during load.
  78626. */
  78627. OptimizeWithUV: boolean;
  78628. /**
  78629. * Defines custom scaling of UV coordinates of loaded meshes.
  78630. */
  78631. UVScaling: Vector2;
  78632. /**
  78633. * Invert model on y-axis (does a model scaling inversion)
  78634. */
  78635. InvertY: boolean;
  78636. /**
  78637. * Invert Y-Axis of referenced textures on load
  78638. */
  78639. InvertTextureY: boolean;
  78640. /**
  78641. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78642. */
  78643. ImportVertexColors: boolean;
  78644. /**
  78645. * Compute the normals for the model, even if normals are present in the file.
  78646. */
  78647. ComputeNormals: boolean;
  78648. /**
  78649. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78650. */
  78651. SkipMaterials: boolean;
  78652. /**
  78653. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78654. */
  78655. MaterialLoadingFailsSilently: boolean;
  78656. };
  78657. /**
  78658. * OBJ file type loader.
  78659. * This is a babylon scene loader plugin.
  78660. */
  78661. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78662. /**
  78663. * Defines if UVs are optimized by default during load.
  78664. */
  78665. static OPTIMIZE_WITH_UV: boolean;
  78666. /**
  78667. * Invert model on y-axis (does a model scaling inversion)
  78668. */
  78669. static INVERT_Y: boolean;
  78670. /**
  78671. * Invert Y-Axis of referenced textures on load
  78672. */
  78673. static get INVERT_TEXTURE_Y(): boolean;
  78674. static set INVERT_TEXTURE_Y(value: boolean);
  78675. /**
  78676. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78677. */
  78678. static IMPORT_VERTEX_COLORS: boolean;
  78679. /**
  78680. * Compute the normals for the model, even if normals are present in the file.
  78681. */
  78682. static COMPUTE_NORMALS: boolean;
  78683. /**
  78684. * Defines custom scaling of UV coordinates of loaded meshes.
  78685. */
  78686. static UV_SCALING: Vector2;
  78687. /**
  78688. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78689. */
  78690. static SKIP_MATERIALS: boolean;
  78691. /**
  78692. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78693. *
  78694. * Defaults to true for backwards compatibility.
  78695. */
  78696. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  78697. /**
  78698. * Defines the name of the plugin.
  78699. */
  78700. name: string;
  78701. /**
  78702. * Defines the extension the plugin is able to load.
  78703. */
  78704. extensions: string;
  78705. /** @hidden */
  78706. obj: RegExp;
  78707. /** @hidden */
  78708. group: RegExp;
  78709. /** @hidden */
  78710. mtllib: RegExp;
  78711. /** @hidden */
  78712. usemtl: RegExp;
  78713. /** @hidden */
  78714. smooth: RegExp;
  78715. /** @hidden */
  78716. vertexPattern: RegExp;
  78717. /** @hidden */
  78718. normalPattern: RegExp;
  78719. /** @hidden */
  78720. uvPattern: RegExp;
  78721. /** @hidden */
  78722. facePattern1: RegExp;
  78723. /** @hidden */
  78724. facePattern2: RegExp;
  78725. /** @hidden */
  78726. facePattern3: RegExp;
  78727. /** @hidden */
  78728. facePattern4: RegExp;
  78729. /** @hidden */
  78730. facePattern5: RegExp;
  78731. private _forAssetContainer;
  78732. private _meshLoadOptions;
  78733. /**
  78734. * Creates loader for .OBJ files
  78735. *
  78736. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  78737. */
  78738. constructor(meshLoadOptions?: MeshLoadOptions);
  78739. private static get currentMeshLoadOptions();
  78740. /**
  78741. * Calls synchronously the MTL file attached to this obj.
  78742. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  78743. * Without this function materials are not displayed in the first frame (but displayed after).
  78744. * In consequence it is impossible to get material information in your HTML file
  78745. *
  78746. * @param url The URL of the MTL file
  78747. * @param rootUrl
  78748. * @param onSuccess Callback function to be called when the MTL file is loaded
  78749. * @private
  78750. */
  78751. private _loadMTL;
  78752. /**
  78753. * Instantiates a OBJ file loader plugin.
  78754. * @returns the created plugin
  78755. */
  78756. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  78757. /**
  78758. * If the data string can be loaded directly.
  78759. *
  78760. * @param data string containing the file data
  78761. * @returns if the data can be loaded directly
  78762. */
  78763. canDirectLoad(data: string): boolean;
  78764. /**
  78765. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  78766. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78767. * @param scene the scene the meshes should be added to
  78768. * @param data the OBJ data to load
  78769. * @param rootUrl root url to load from
  78770. * @param onProgress event that fires when loading progress has occured
  78771. * @param fileName Defines the name of the file to load
  78772. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78773. */
  78774. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78775. meshes: AbstractMesh[];
  78776. particleSystems: IParticleSystem[];
  78777. skeletons: Skeleton[];
  78778. animationGroups: AnimationGroup[];
  78779. }>;
  78780. /**
  78781. * Imports all objects from the loaded OBJ data and adds them to the scene
  78782. * @param scene the scene the objects should be added to
  78783. * @param data the OBJ data to load
  78784. * @param rootUrl root url to load from
  78785. * @param onProgress event that fires when loading progress has occured
  78786. * @param fileName Defines the name of the file to load
  78787. * @returns a promise which completes when objects have been loaded to the scene
  78788. */
  78789. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78790. /**
  78791. * Load into an asset container.
  78792. * @param scene The scene to load into
  78793. * @param data The data to import
  78794. * @param rootUrl The root url for scene and resources
  78795. * @param onProgress The callback when the load progresses
  78796. * @param fileName Defines the name of the file to load
  78797. * @returns The loaded asset container
  78798. */
  78799. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78800. /**
  78801. * Read the OBJ file and create an Array of meshes.
  78802. * Each mesh contains all information given by the OBJ and the MTL file.
  78803. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  78804. *
  78805. * @param meshesNames
  78806. * @param scene Scene The scene where are displayed the data
  78807. * @param data String The content of the obj file
  78808. * @param rootUrl String The path to the folder
  78809. * @returns Array<AbstractMesh>
  78810. * @private
  78811. */
  78812. private _parseSolid;
  78813. }
  78814. }
  78815. declare module BABYLON {
  78816. /**
  78817. * STL file type loader.
  78818. * This is a babylon scene loader plugin.
  78819. */
  78820. export class STLFileLoader implements ISceneLoaderPlugin {
  78821. /** @hidden */
  78822. solidPattern: RegExp;
  78823. /** @hidden */
  78824. facetsPattern: RegExp;
  78825. /** @hidden */
  78826. normalPattern: RegExp;
  78827. /** @hidden */
  78828. vertexPattern: RegExp;
  78829. /**
  78830. * Defines the name of the plugin.
  78831. */
  78832. name: string;
  78833. /**
  78834. * Defines the extensions the stl loader is able to load.
  78835. * force data to come in as an ArrayBuffer
  78836. * we'll convert to string if it looks like it's an ASCII .stl
  78837. */
  78838. extensions: ISceneLoaderPluginExtensions;
  78839. /**
  78840. * Import meshes into a scene.
  78841. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  78842. * @param scene The scene to import into
  78843. * @param data The data to import
  78844. * @param rootUrl The root url for scene and resources
  78845. * @param meshes The meshes array to import into
  78846. * @param particleSystems The particle systems array to import into
  78847. * @param skeletons The skeletons array to import into
  78848. * @param onError The callback when import fails
  78849. * @returns True if successful or false otherwise
  78850. */
  78851. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  78852. /**
  78853. * Load into a scene.
  78854. * @param scene The scene to load into
  78855. * @param data The data to import
  78856. * @param rootUrl The root url for scene and resources
  78857. * @param onError The callback when import fails
  78858. * @returns true if successful or false otherwise
  78859. */
  78860. load(scene: Scene, data: any, rootUrl: string): boolean;
  78861. /**
  78862. * Load into an asset container.
  78863. * @param scene The scene to load into
  78864. * @param data The data to import
  78865. * @param rootUrl The root url for scene and resources
  78866. * @param onError The callback when import fails
  78867. * @returns The loaded asset container
  78868. */
  78869. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  78870. private _isBinary;
  78871. private _parseBinary;
  78872. private _parseASCII;
  78873. }
  78874. }
  78875. declare module BABYLON {
  78876. /**
  78877. * Class for generating OBJ data from a Babylon scene.
  78878. */
  78879. export class OBJExport {
  78880. /**
  78881. * Exports the geometry of a Mesh array in .OBJ file format (text)
  78882. * @param mesh defines the list of meshes to serialize
  78883. * @param materials defines if materials should be exported
  78884. * @param matlibname defines the name of the associated mtl file
  78885. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  78886. * @returns the OBJ content
  78887. */
  78888. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  78889. /**
  78890. * Exports the material(s) of a mesh in .MTL file format (text)
  78891. * @param mesh defines the mesh to extract the material from
  78892. * @returns the mtl content
  78893. */
  78894. static MTL(mesh: Mesh): string;
  78895. }
  78896. }
  78897. declare module BABYLON {
  78898. /** @hidden */
  78899. export var __IGLTFExporterExtension: number;
  78900. /**
  78901. * Interface for extending the exporter
  78902. * @hidden
  78903. */
  78904. export interface IGLTFExporterExtension {
  78905. /**
  78906. * The name of this extension
  78907. */
  78908. readonly name: string;
  78909. /**
  78910. * Defines whether this extension is enabled
  78911. */
  78912. enabled: boolean;
  78913. /**
  78914. * Defines whether this extension is required
  78915. */
  78916. required: boolean;
  78917. }
  78918. }
  78919. declare module BABYLON.GLTF2.Exporter {
  78920. /** @hidden */
  78921. export var __IGLTFExporterExtensionV2: number;
  78922. /**
  78923. * Interface for a glTF exporter extension
  78924. * @hidden
  78925. */
  78926. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  78927. /**
  78928. * Define this method to modify the default behavior before exporting a texture
  78929. * @param context The context when loading the asset
  78930. * @param babylonTexture The Babylon.js texture
  78931. * @param mimeType The mime-type of the generated image
  78932. * @returns A promise that resolves with the exported texture
  78933. */
  78934. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  78935. /**
  78936. * Define this method to get notified when a texture info is created
  78937. * @param context The context when loading the asset
  78938. * @param textureInfo The glTF texture info
  78939. * @param babylonTexture The Babylon.js texture
  78940. */
  78941. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78942. /**
  78943. * Define this method to modify the default behavior when exporting texture info
  78944. * @param context The context when loading the asset
  78945. * @param meshPrimitive glTF mesh primitive
  78946. * @param babylonSubMesh Babylon submesh
  78947. * @param binaryWriter glTF serializer binary writer instance
  78948. * @returns nullable IMeshPrimitive promise
  78949. */
  78950. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  78951. /**
  78952. * Define this method to modify the default behavior when exporting a node
  78953. * @param context The context when exporting the node
  78954. * @param node glTF node
  78955. * @param babylonNode BabylonJS node
  78956. * @returns nullable INode promise
  78957. */
  78958. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78959. [key: number]: number;
  78960. }): Promise<Nullable<INode>>;
  78961. /**
  78962. * Define this method to modify the default behavior when exporting a material
  78963. * @param material glTF material
  78964. * @param babylonMaterial BabylonJS material
  78965. * @returns nullable IMaterial promise
  78966. */
  78967. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  78968. /**
  78969. * Define this method to return additional textures to export from a material
  78970. * @param material glTF material
  78971. * @param babylonMaterial BabylonJS material
  78972. * @returns List of textures
  78973. */
  78974. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78975. /** Gets a boolean indicating that this extension was used */
  78976. wasUsed: boolean;
  78977. /** Gets a boolean indicating that this extension is required for the file to work */
  78978. required: boolean;
  78979. /**
  78980. * Called after the exporter state changes to EXPORTING
  78981. */
  78982. onExporting?(): void;
  78983. }
  78984. }
  78985. declare module BABYLON.GLTF2.Exporter {
  78986. /**
  78987. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  78988. * @hidden
  78989. */
  78990. export class _GLTFMaterialExporter {
  78991. /**
  78992. * Represents the dielectric specular values for R, G and B
  78993. */
  78994. private static readonly _DielectricSpecular;
  78995. /**
  78996. * Allows the maximum specular power to be defined for material calculations
  78997. */
  78998. private static readonly _MaxSpecularPower;
  78999. /**
  79000. * Mapping to store textures
  79001. */
  79002. private _textureMap;
  79003. /**
  79004. * Numeric tolerance value
  79005. */
  79006. private static readonly _Epsilon;
  79007. /**
  79008. * Reference to the glTF Exporter
  79009. */
  79010. private _exporter;
  79011. constructor(exporter: _Exporter);
  79012. /**
  79013. * Specifies if two colors are approximately equal in value
  79014. * @param color1 first color to compare to
  79015. * @param color2 second color to compare to
  79016. * @param epsilon threshold value
  79017. */
  79018. private static FuzzyEquals;
  79019. /**
  79020. * Gets the materials from a Babylon scene and converts them to glTF materials
  79021. * @param scene babylonjs scene
  79022. * @param mimeType texture mime type
  79023. * @param images array of images
  79024. * @param textures array of textures
  79025. * @param materials array of materials
  79026. * @param imageData mapping of texture names to base64 textures
  79027. * @param hasTextureCoords specifies if texture coordinates are present on the material
  79028. */
  79029. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  79030. /**
  79031. * Makes a copy of the glTF material without the texture parameters
  79032. * @param originalMaterial original glTF material
  79033. * @returns glTF material without texture parameters
  79034. */
  79035. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  79036. /**
  79037. * Specifies if the material has any texture parameters present
  79038. * @param material glTF Material
  79039. * @returns boolean specifying if texture parameters are present
  79040. */
  79041. _hasTexturesPresent(material: IMaterial): boolean;
  79042. /**
  79043. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  79044. * @param babylonStandardMaterial
  79045. * @returns glTF Metallic Roughness Material representation
  79046. */
  79047. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  79048. /**
  79049. * Computes the metallic factor
  79050. * @param diffuse diffused value
  79051. * @param specular specular value
  79052. * @param oneMinusSpecularStrength one minus the specular strength
  79053. * @returns metallic value
  79054. */
  79055. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  79056. /**
  79057. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  79058. * @param glTFMaterial glTF material
  79059. * @param babylonMaterial Babylon material
  79060. */
  79061. private static _SetAlphaMode;
  79062. /**
  79063. * Converts a Babylon Standard Material to a glTF Material
  79064. * @param babylonStandardMaterial BJS Standard Material
  79065. * @param mimeType mime type to use for the textures
  79066. * @param images array of glTF image interfaces
  79067. * @param textures array of glTF texture interfaces
  79068. * @param materials array of glTF material interfaces
  79069. * @param imageData map of image file name to data
  79070. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79071. */
  79072. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79073. private _finishMaterial;
  79074. /**
  79075. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79076. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  79077. * @param mimeType mime type to use for the textures
  79078. * @param images array of glTF image interfaces
  79079. * @param textures array of glTF texture interfaces
  79080. * @param materials array of glTF material interfaces
  79081. * @param imageData map of image file name to data
  79082. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79083. */
  79084. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79085. /**
  79086. * Converts an image typed array buffer to a base64 image
  79087. * @param buffer typed array buffer
  79088. * @param width width of the image
  79089. * @param height height of the image
  79090. * @param mimeType mimetype of the image
  79091. * @returns base64 image string
  79092. */
  79093. private _createBase64FromCanvasAsync;
  79094. /**
  79095. * Generates a white texture based on the specified width and height
  79096. * @param width width of the texture in pixels
  79097. * @param height height of the texture in pixels
  79098. * @param scene babylonjs scene
  79099. * @returns white texture
  79100. */
  79101. private _createWhiteTexture;
  79102. /**
  79103. * 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
  79104. * @param texture1 first texture to resize
  79105. * @param texture2 second texture to resize
  79106. * @param scene babylonjs scene
  79107. * @returns resized textures or null
  79108. */
  79109. private _resizeTexturesToSameDimensions;
  79110. /**
  79111. * Converts an array of pixels to a Float32Array
  79112. * Throws an error if the pixel format is not supported
  79113. * @param pixels - array buffer containing pixel values
  79114. * @returns Float32 of pixels
  79115. */
  79116. private _convertPixelArrayToFloat32;
  79117. /**
  79118. * Convert Specular Glossiness Textures to Metallic Roughness
  79119. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  79120. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  79121. * @param diffuseTexture texture used to store diffuse information
  79122. * @param specularGlossinessTexture texture used to store specular and glossiness information
  79123. * @param factors specular glossiness material factors
  79124. * @param mimeType the mime type to use for the texture
  79125. * @returns pbr metallic roughness interface or null
  79126. */
  79127. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  79128. /**
  79129. * Converts specular glossiness material properties to metallic roughness
  79130. * @param specularGlossiness interface with specular glossiness material properties
  79131. * @returns interface with metallic roughness material properties
  79132. */
  79133. private _convertSpecularGlossinessToMetallicRoughness;
  79134. /**
  79135. * Calculates the surface reflectance, independent of lighting conditions
  79136. * @param color Color source to calculate brightness from
  79137. * @returns number representing the perceived brightness, or zero if color is undefined
  79138. */
  79139. private _getPerceivedBrightness;
  79140. /**
  79141. * Returns the maximum color component value
  79142. * @param color
  79143. * @returns maximum color component value, or zero if color is null or undefined
  79144. */
  79145. private _getMaxComponent;
  79146. /**
  79147. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  79148. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79149. * @param mimeType mime type to use for the textures
  79150. * @param images array of glTF image interfaces
  79151. * @param textures array of glTF texture interfaces
  79152. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79153. * @param imageData map of image file name to data
  79154. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79155. * @returns glTF PBR Metallic Roughness factors
  79156. */
  79157. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  79158. private _getGLTFTextureSampler;
  79159. private _getGLTFTextureWrapMode;
  79160. private _getGLTFTextureWrapModesSampler;
  79161. /**
  79162. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  79163. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79164. * @param mimeType mime type to use for the textures
  79165. * @param images array of glTF image interfaces
  79166. * @param textures array of glTF texture interfaces
  79167. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79168. * @param imageData map of image file name to data
  79169. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79170. * @returns glTF PBR Metallic Roughness factors
  79171. */
  79172. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  79173. /**
  79174. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79175. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79176. * @param mimeType mime type to use for the textures
  79177. * @param images array of glTF image interfaces
  79178. * @param textures array of glTF texture interfaces
  79179. * @param materials array of glTF material interfaces
  79180. * @param imageData map of image file name to data
  79181. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79182. */
  79183. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79184. private setMetallicRoughnessPbrMaterial;
  79185. private getPixelsFromTexture;
  79186. /**
  79187. * Extracts a texture from a Babylon texture into file data and glTF data
  79188. * @param babylonTexture Babylon texture to extract
  79189. * @param mimeType Mime Type of the babylonTexture
  79190. * @return glTF texture info, or null if the texture format is not supported
  79191. */
  79192. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79193. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79194. /**
  79195. * Builds a texture from base64 string
  79196. * @param base64Texture base64 texture string
  79197. * @param baseTextureName Name to use for the texture
  79198. * @param mimeType image mime type for the texture
  79199. * @param images array of images
  79200. * @param textures array of textures
  79201. * @param imageData map of image data
  79202. * @returns glTF texture info, or null if the texture format is not supported
  79203. */
  79204. private _getTextureInfoFromBase64;
  79205. }
  79206. }
  79207. declare module BABYLON {
  79208. /**
  79209. * Class for holding and downloading glTF file data
  79210. */
  79211. export class GLTFData {
  79212. /**
  79213. * Object which contains the file name as the key and its data as the value
  79214. */
  79215. glTFFiles: {
  79216. [fileName: string]: string | Blob;
  79217. };
  79218. /**
  79219. * Initializes the glTF file object
  79220. */
  79221. constructor();
  79222. /**
  79223. * Downloads the glTF data as files based on their names and data
  79224. */
  79225. downloadFiles(): void;
  79226. }
  79227. }
  79228. declare module BABYLON {
  79229. /**
  79230. * Holds a collection of exporter options and parameters
  79231. */
  79232. export interface IExportOptions {
  79233. /**
  79234. * Function which indicates whether a babylon node should be exported or not
  79235. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  79236. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  79237. */
  79238. shouldExportNode?(node: Node): boolean;
  79239. /**
  79240. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  79241. * @param metadata source metadata to read from
  79242. * @returns the data to store to glTF node extras
  79243. */
  79244. metadataSelector?(metadata: any): any;
  79245. /**
  79246. * The sample rate to bake animation curves
  79247. */
  79248. animationSampleRate?: number;
  79249. /**
  79250. * Begin serialization without waiting for the scene to be ready
  79251. */
  79252. exportWithoutWaitingForScene?: boolean;
  79253. /**
  79254. * Indicates if coordinate system swapping root nodes should be included in export
  79255. */
  79256. includeCoordinateSystemConversionNodes?: boolean;
  79257. }
  79258. /**
  79259. * Class for generating glTF data from a Babylon scene.
  79260. */
  79261. export class GLTF2Export {
  79262. /**
  79263. * Exports the geometry of the scene to .gltf file format asynchronously
  79264. * @param scene Babylon scene with scene hierarchy information
  79265. * @param filePrefix File prefix to use when generating the glTF file
  79266. * @param options Exporter options
  79267. * @returns Returns an object with a .gltf file and associates texture names
  79268. * as keys and their data and paths as values
  79269. */
  79270. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79271. private static _PreExportAsync;
  79272. private static _PostExportAsync;
  79273. /**
  79274. * Exports the geometry of the scene to .glb file format asychronously
  79275. * @param scene Babylon scene with scene hierarchy information
  79276. * @param filePrefix File prefix to use when generating glb file
  79277. * @param options Exporter options
  79278. * @returns Returns an object with a .glb filename as key and data as value
  79279. */
  79280. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79281. }
  79282. }
  79283. declare module BABYLON.GLTF2.Exporter {
  79284. /**
  79285. * @hidden
  79286. */
  79287. export class _GLTFUtilities {
  79288. /**
  79289. * Creates a buffer view based on the supplied arguments
  79290. * @param bufferIndex index value of the specified buffer
  79291. * @param byteOffset byte offset value
  79292. * @param byteLength byte length of the bufferView
  79293. * @param byteStride byte distance between conequential elements
  79294. * @param name name of the buffer view
  79295. * @returns bufferView for glTF
  79296. */
  79297. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  79298. /**
  79299. * Creates an accessor based on the supplied arguments
  79300. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  79301. * @param name The name of the accessor
  79302. * @param type The type of the accessor
  79303. * @param componentType The datatype of components in the attribute
  79304. * @param count The number of attributes referenced by this accessor
  79305. * @param byteOffset The offset relative to the start of the bufferView in bytes
  79306. * @param min Minimum value of each component in this attribute
  79307. * @param max Maximum value of each component in this attribute
  79308. * @returns accessor for glTF
  79309. */
  79310. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  79311. /**
  79312. * Calculates the minimum and maximum values of an array of position floats
  79313. * @param positions Positions array of a mesh
  79314. * @param vertexStart Starting vertex offset to calculate min and max values
  79315. * @param vertexCount Number of vertices to check for min and max values
  79316. * @returns min number array and max number array
  79317. */
  79318. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  79319. min: number[];
  79320. max: number[];
  79321. };
  79322. /**
  79323. * Converts a new right-handed Vector3
  79324. * @param vector vector3 array
  79325. * @returns right-handed Vector3
  79326. */
  79327. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  79328. /**
  79329. * Converts a Vector3 to right-handed
  79330. * @param vector Vector3 to convert to right-handed
  79331. */
  79332. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  79333. /**
  79334. * Converts a three element number array to right-handed
  79335. * @param vector number array to convert to right-handed
  79336. */
  79337. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  79338. /**
  79339. * Converts a new right-handed Vector3
  79340. * @param vector vector3 array
  79341. * @returns right-handed Vector3
  79342. */
  79343. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  79344. /**
  79345. * Converts a Vector3 to right-handed
  79346. * @param vector Vector3 to convert to right-handed
  79347. */
  79348. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  79349. /**
  79350. * Converts a three element number array to right-handed
  79351. * @param vector number array to convert to right-handed
  79352. */
  79353. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  79354. /**
  79355. * Converts a Vector4 to right-handed
  79356. * @param vector Vector4 to convert to right-handed
  79357. */
  79358. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  79359. /**
  79360. * Converts a Vector4 to right-handed
  79361. * @param vector Vector4 to convert to right-handed
  79362. */
  79363. static _GetRightHandedArray4FromRef(vector: number[]): void;
  79364. /**
  79365. * Converts a Quaternion to right-handed
  79366. * @param quaternion Source quaternion to convert to right-handed
  79367. */
  79368. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  79369. /**
  79370. * Converts a Quaternion to right-handed
  79371. * @param quaternion Source quaternion to convert to right-handed
  79372. */
  79373. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  79374. static _NormalizeTangentFromRef(tangent: Vector4): void;
  79375. }
  79376. }
  79377. declare module BABYLON.GLTF2.Exporter {
  79378. /**
  79379. * Converts Babylon Scene into glTF 2.0.
  79380. * @hidden
  79381. */
  79382. export class _Exporter {
  79383. /**
  79384. * Stores the glTF to export
  79385. */
  79386. _glTF: IGLTF;
  79387. /**
  79388. * Stores all generated buffer views, which represents views into the main glTF buffer data
  79389. */
  79390. _bufferViews: IBufferView[];
  79391. /**
  79392. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  79393. */
  79394. _accessors: IAccessor[];
  79395. /**
  79396. * Stores all the generated nodes, which contains transform and/or mesh information per node
  79397. */
  79398. _nodes: INode[];
  79399. /**
  79400. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  79401. */
  79402. private _scenes;
  79403. /**
  79404. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  79405. */
  79406. private _meshes;
  79407. /**
  79408. * Stores all the generated material information, which represents the appearance of each primitive
  79409. */
  79410. _materials: IMaterial[];
  79411. _materialMap: {
  79412. [materialID: number]: number;
  79413. };
  79414. /**
  79415. * Stores all the generated texture information, which is referenced by glTF materials
  79416. */
  79417. _textures: ITexture[];
  79418. /**
  79419. * Stores all the generated image information, which is referenced by glTF textures
  79420. */
  79421. _images: IImage[];
  79422. /**
  79423. * Stores all the texture samplers
  79424. */
  79425. _samplers: ISampler[];
  79426. /**
  79427. * Stores all the generated animation samplers, which is referenced by glTF animations
  79428. */
  79429. /**
  79430. * Stores the animations for glTF models
  79431. */
  79432. private _animations;
  79433. /**
  79434. * Stores the total amount of bytes stored in the glTF buffer
  79435. */
  79436. private _totalByteLength;
  79437. /**
  79438. * Stores a reference to the Babylon scene containing the source geometry and material information
  79439. */
  79440. _babylonScene: Scene;
  79441. /**
  79442. * Stores a map of the image data, where the key is the file name and the value
  79443. * is the image data
  79444. */
  79445. _imageData: {
  79446. [fileName: string]: {
  79447. data: Uint8Array;
  79448. mimeType: ImageMimeType;
  79449. };
  79450. };
  79451. /**
  79452. * Stores a map of the unique id of a node to its index in the node array
  79453. */
  79454. _nodeMap: {
  79455. [key: number]: number;
  79456. };
  79457. /**
  79458. * Specifies if the source Babylon scene was left handed, and needed conversion.
  79459. */
  79460. _convertToRightHandedSystem: boolean;
  79461. /**
  79462. * Specifies if a Babylon node should be converted to right-handed on export
  79463. */
  79464. _convertToRightHandedSystemMap: {
  79465. [nodeId: number]: boolean;
  79466. };
  79467. _includeCoordinateSystemConversionNodes: boolean;
  79468. /**
  79469. * Baked animation sample rate
  79470. */
  79471. private _animationSampleRate;
  79472. private _options;
  79473. private _localEngine;
  79474. _glTFMaterialExporter: _GLTFMaterialExporter;
  79475. private _extensions;
  79476. private static _ExtensionNames;
  79477. private static _ExtensionFactories;
  79478. private _applyExtension;
  79479. private _applyExtensions;
  79480. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  79481. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  79482. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79483. [key: number]: number;
  79484. }): Promise<Nullable<INode>>;
  79485. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  79486. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  79487. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79488. private _forEachExtensions;
  79489. private _extensionsOnExporting;
  79490. /**
  79491. * Load glTF serializer extensions
  79492. */
  79493. private _loadExtensions;
  79494. /**
  79495. * Creates a glTF Exporter instance, which can accept optional exporter options
  79496. * @param babylonScene Babylon scene object
  79497. * @param options Options to modify the behavior of the exporter
  79498. */
  79499. constructor(babylonScene: Scene, options?: IExportOptions);
  79500. dispose(): void;
  79501. /**
  79502. * Registers a glTF exporter extension
  79503. * @param name Name of the extension to export
  79504. * @param factory The factory function that creates the exporter extension
  79505. */
  79506. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  79507. /**
  79508. * Un-registers an exporter extension
  79509. * @param name The name fo the exporter extension
  79510. * @returns A boolean indicating whether the extension has been un-registered
  79511. */
  79512. static UnregisterExtension(name: string): boolean;
  79513. /**
  79514. * Lazy load a local engine
  79515. */
  79516. _getLocalEngine(): Engine;
  79517. private reorderIndicesBasedOnPrimitiveMode;
  79518. /**
  79519. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  79520. * clock-wise during export to glTF
  79521. * @param submesh BabylonJS submesh
  79522. * @param primitiveMode Primitive mode of the mesh
  79523. * @param sideOrientation the winding order of the submesh
  79524. * @param vertexBufferKind The type of vertex attribute
  79525. * @param meshAttributeArray The vertex attribute data
  79526. * @param byteOffset The offset to the binary data
  79527. * @param binaryWriter The binary data for the glTF file
  79528. * @param convertToRightHandedSystem Converts the values to right-handed
  79529. */
  79530. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  79531. /**
  79532. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  79533. * clock-wise during export to glTF
  79534. * @param submesh BabylonJS submesh
  79535. * @param primitiveMode Primitive mode of the mesh
  79536. * @param sideOrientation the winding order of the submesh
  79537. * @param vertexBufferKind The type of vertex attribute
  79538. * @param meshAttributeArray The vertex attribute data
  79539. * @param byteOffset The offset to the binary data
  79540. * @param binaryWriter The binary data for the glTF file
  79541. * @param convertToRightHandedSystem Converts the values to right-handed
  79542. */
  79543. private reorderTriangleFillMode;
  79544. /**
  79545. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  79546. * clock-wise during export to glTF
  79547. * @param submesh BabylonJS submesh
  79548. * @param primitiveMode Primitive mode of the mesh
  79549. * @param sideOrientation the winding order of the submesh
  79550. * @param vertexBufferKind The type of vertex attribute
  79551. * @param meshAttributeArray The vertex attribute data
  79552. * @param byteOffset The offset to the binary data
  79553. * @param binaryWriter The binary data for the glTF file
  79554. * @param convertToRightHandedSystem Converts the values to right-handed
  79555. */
  79556. private reorderTriangleStripDrawMode;
  79557. /**
  79558. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  79559. * clock-wise during export to glTF
  79560. * @param submesh BabylonJS submesh
  79561. * @param primitiveMode Primitive mode of the mesh
  79562. * @param sideOrientation the winding order of the submesh
  79563. * @param vertexBufferKind The type of vertex attribute
  79564. * @param meshAttributeArray The vertex attribute data
  79565. * @param byteOffset The offset to the binary data
  79566. * @param binaryWriter The binary data for the glTF file
  79567. * @param convertToRightHandedSystem Converts the values to right-handed
  79568. */
  79569. private reorderTriangleFanMode;
  79570. /**
  79571. * Writes the vertex attribute data to binary
  79572. * @param vertices The vertices to write to the binary writer
  79573. * @param byteOffset The offset into the binary writer to overwrite binary data
  79574. * @param vertexAttributeKind The vertex attribute type
  79575. * @param meshAttributeArray The vertex attribute data
  79576. * @param binaryWriter The writer containing the binary data
  79577. * @param convertToRightHandedSystem Converts the values to right-handed
  79578. */
  79579. private writeVertexAttributeData;
  79580. /**
  79581. * Writes mesh attribute data to a data buffer
  79582. * Returns the bytelength of the data
  79583. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  79584. * @param meshAttributeArray Array containing the attribute data
  79585. * @param binaryWriter The buffer to write the binary data to
  79586. * @param indices Used to specify the order of the vertex data
  79587. * @param convertToRightHandedSystem Converts the values to right-handed
  79588. */
  79589. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  79590. /**
  79591. * Generates glTF json data
  79592. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  79593. * @param glTFPrefix Text to use when prefixing a glTF file
  79594. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  79595. * @returns json data as string
  79596. */
  79597. private generateJSON;
  79598. /**
  79599. * Generates data for .gltf and .bin files based on the glTF prefix string
  79600. * @param glTFPrefix Text to use when prefixing a glTF file
  79601. * @param dispose Dispose the exporter
  79602. * @returns GLTFData with glTF file data
  79603. */
  79604. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79605. /**
  79606. * Creates a binary buffer for glTF
  79607. * @returns array buffer for binary data
  79608. */
  79609. private _generateBinaryAsync;
  79610. /**
  79611. * Pads the number to a multiple of 4
  79612. * @param num number to pad
  79613. * @returns padded number
  79614. */
  79615. private _getPadding;
  79616. /**
  79617. * @hidden
  79618. */
  79619. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79620. /**
  79621. * Sets the TRS for each node
  79622. * @param node glTF Node for storing the transformation data
  79623. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  79624. * @param convertToRightHandedSystem Converts the values to right-handed
  79625. */
  79626. private setNodeTransformation;
  79627. private getVertexBufferFromMesh;
  79628. /**
  79629. * Creates a bufferview based on the vertices type for the Babylon mesh
  79630. * @param kind Indicates the type of vertices data
  79631. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  79632. * @param binaryWriter The buffer to write the bufferview data to
  79633. * @param convertToRightHandedSystem Converts the values to right-handed
  79634. */
  79635. private createBufferViewKind;
  79636. /**
  79637. * The primitive mode of the Babylon mesh
  79638. * @param babylonMesh The BabylonJS mesh
  79639. */
  79640. private getMeshPrimitiveMode;
  79641. /**
  79642. * Sets the primitive mode of the glTF mesh primitive
  79643. * @param meshPrimitive glTF mesh primitive
  79644. * @param primitiveMode The primitive mode
  79645. */
  79646. private setPrimitiveMode;
  79647. /**
  79648. * Sets the vertex attribute accessor based of the glTF mesh primitive
  79649. * @param meshPrimitive glTF mesh primitive
  79650. * @param attributeKind vertex attribute
  79651. * @returns boolean specifying if uv coordinates are present
  79652. */
  79653. private setAttributeKind;
  79654. /**
  79655. * Sets data for the primitive attributes of each submesh
  79656. * @param mesh glTF Mesh object to store the primitive attribute information
  79657. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  79658. * @param binaryWriter Buffer to write the attribute data to
  79659. * @param convertToRightHandedSystem Converts the values to right-handed
  79660. */
  79661. private setPrimitiveAttributesAsync;
  79662. /**
  79663. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  79664. * @param node The node to check
  79665. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  79666. */
  79667. private isBabylonCoordinateSystemConvertingNode;
  79668. /**
  79669. * Creates a glTF scene based on the array of meshes
  79670. * Returns the the total byte offset
  79671. * @param babylonScene Babylon scene to get the mesh data from
  79672. * @param binaryWriter Buffer to write binary data to
  79673. */
  79674. private createSceneAsync;
  79675. /**
  79676. * Creates a mapping of Node unique id to node index and handles animations
  79677. * @param babylonScene Babylon Scene
  79678. * @param nodes Babylon transform nodes
  79679. * @param binaryWriter Buffer to write binary data to
  79680. * @returns Node mapping of unique id to index
  79681. */
  79682. private createNodeMapAndAnimationsAsync;
  79683. /**
  79684. * Creates a glTF node from a Babylon mesh
  79685. * @param babylonMesh Source Babylon mesh
  79686. * @param binaryWriter Buffer for storing geometry data
  79687. * @param convertToRightHandedSystem Converts the values to right-handed
  79688. * @param nodeMap Node mapping of unique id to glTF node index
  79689. * @returns glTF node
  79690. */
  79691. private createNodeAsync;
  79692. }
  79693. /**
  79694. * @hidden
  79695. *
  79696. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  79697. */
  79698. export class _BinaryWriter {
  79699. /**
  79700. * Array buffer which stores all binary data
  79701. */
  79702. private _arrayBuffer;
  79703. /**
  79704. * View of the array buffer
  79705. */
  79706. private _dataView;
  79707. /**
  79708. * byte offset of data in array buffer
  79709. */
  79710. private _byteOffset;
  79711. /**
  79712. * Initialize binary writer with an initial byte length
  79713. * @param byteLength Initial byte length of the array buffer
  79714. */
  79715. constructor(byteLength: number);
  79716. /**
  79717. * Resize the array buffer to the specified byte length
  79718. * @param byteLength
  79719. */
  79720. private resizeBuffer;
  79721. /**
  79722. * Get an array buffer with the length of the byte offset
  79723. * @returns ArrayBuffer resized to the byte offset
  79724. */
  79725. getArrayBuffer(): ArrayBuffer;
  79726. /**
  79727. * Get the byte offset of the array buffer
  79728. * @returns byte offset
  79729. */
  79730. getByteOffset(): number;
  79731. /**
  79732. * Stores an UInt8 in the array buffer
  79733. * @param entry
  79734. * @param byteOffset If defined, specifies where to set the value as an offset.
  79735. */
  79736. setUInt8(entry: number, byteOffset?: number): void;
  79737. /**
  79738. * Gets an UInt32 in the array buffer
  79739. * @param entry
  79740. * @param byteOffset If defined, specifies where to set the value as an offset.
  79741. */
  79742. getUInt32(byteOffset: number): number;
  79743. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79744. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79745. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79746. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79747. /**
  79748. * Stores a Float32 in the array buffer
  79749. * @param entry
  79750. */
  79751. setFloat32(entry: number, byteOffset?: number): void;
  79752. /**
  79753. * Stores an UInt32 in the array buffer
  79754. * @param entry
  79755. * @param byteOffset If defined, specifies where to set the value as an offset.
  79756. */
  79757. setUInt32(entry: number, byteOffset?: number): void;
  79758. }
  79759. }
  79760. declare module BABYLON.GLTF2.Exporter {
  79761. /**
  79762. * @hidden
  79763. * Interface to store animation data.
  79764. */
  79765. export interface _IAnimationData {
  79766. /**
  79767. * Keyframe data.
  79768. */
  79769. inputs: number[];
  79770. /**
  79771. * Value data.
  79772. */
  79773. outputs: number[][];
  79774. /**
  79775. * Animation interpolation data.
  79776. */
  79777. samplerInterpolation: AnimationSamplerInterpolation;
  79778. /**
  79779. * Minimum keyframe value.
  79780. */
  79781. inputsMin: number;
  79782. /**
  79783. * Maximum keyframe value.
  79784. */
  79785. inputsMax: number;
  79786. }
  79787. /**
  79788. * @hidden
  79789. */
  79790. export interface _IAnimationInfo {
  79791. /**
  79792. * The target channel for the animation
  79793. */
  79794. animationChannelTargetPath: AnimationChannelTargetPath;
  79795. /**
  79796. * The glTF accessor type for the data.
  79797. */
  79798. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  79799. /**
  79800. * Specifies if quaternions should be used.
  79801. */
  79802. useQuaternion: boolean;
  79803. }
  79804. /**
  79805. * @hidden
  79806. * Utility class for generating glTF animation data from BabylonJS.
  79807. */
  79808. export class _GLTFAnimation {
  79809. /**
  79810. * @ignore
  79811. *
  79812. * Creates glTF channel animation from BabylonJS animation.
  79813. * @param babylonTransformNode - BabylonJS mesh.
  79814. * @param animation - animation.
  79815. * @param animationChannelTargetPath - The target animation channel.
  79816. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  79817. * @param useQuaternion - Specifies if quaternions are used.
  79818. * @returns nullable IAnimationData
  79819. */
  79820. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  79821. private static _DeduceAnimationInfo;
  79822. /**
  79823. * @ignore
  79824. * Create node animations from the transform node animations
  79825. * @param babylonNode
  79826. * @param runtimeGLTFAnimation
  79827. * @param idleGLTFAnimations
  79828. * @param nodeMap
  79829. * @param nodes
  79830. * @param binaryWriter
  79831. * @param bufferViews
  79832. * @param accessors
  79833. * @param convertToRightHandedSystem
  79834. * @param animationSampleRate
  79835. */
  79836. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  79837. [key: number]: number;
  79838. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  79839. /**
  79840. * @ignore
  79841. * Create node animations from the animation groups
  79842. * @param babylonScene
  79843. * @param glTFAnimations
  79844. * @param nodeMap
  79845. * @param nodes
  79846. * @param binaryWriter
  79847. * @param bufferViews
  79848. * @param accessors
  79849. * @param convertToRightHandedSystemMap
  79850. * @param animationSampleRate
  79851. */
  79852. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  79853. [key: number]: number;
  79854. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  79855. [nodeId: number]: boolean;
  79856. }, animationSampleRate: number): void;
  79857. private static AddAnimation;
  79858. /**
  79859. * Create a baked animation
  79860. * @param babylonTransformNode BabylonJS mesh
  79861. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  79862. * @param animationChannelTargetPath animation target channel
  79863. * @param minFrame minimum animation frame
  79864. * @param maxFrame maximum animation frame
  79865. * @param fps frames per second of the animation
  79866. * @param inputs input key frames of the animation
  79867. * @param outputs output key frame data of the animation
  79868. * @param convertToRightHandedSystem converts the values to right-handed
  79869. * @param useQuaternion specifies if quaternions should be used
  79870. */
  79871. private static _CreateBakedAnimation;
  79872. private static _ConvertFactorToVector3OrQuaternion;
  79873. private static _SetInterpolatedValue;
  79874. /**
  79875. * Creates linear animation from the animation key frames
  79876. * @param babylonTransformNode BabylonJS mesh
  79877. * @param animation BabylonJS animation
  79878. * @param animationChannelTargetPath The target animation channel
  79879. * @param frameDelta The difference between the last and first frame of the animation
  79880. * @param inputs Array to store the key frame times
  79881. * @param outputs Array to store the key frame data
  79882. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  79883. * @param useQuaternion Specifies if quaternions are used in the animation
  79884. */
  79885. private static _CreateLinearOrStepAnimation;
  79886. /**
  79887. * Creates cubic spline animation from the animation key frames
  79888. * @param babylonTransformNode BabylonJS mesh
  79889. * @param animation BabylonJS animation
  79890. * @param animationChannelTargetPath The target animation channel
  79891. * @param frameDelta The difference between the last and first frame of the animation
  79892. * @param inputs Array to store the key frame times
  79893. * @param outputs Array to store the key frame data
  79894. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  79895. * @param useQuaternion Specifies if quaternions are used in the animation
  79896. */
  79897. private static _CreateCubicSplineAnimation;
  79898. private static _GetBasePositionRotationOrScale;
  79899. /**
  79900. * Adds a key frame value
  79901. * @param keyFrame
  79902. * @param animation
  79903. * @param outputs
  79904. * @param animationChannelTargetPath
  79905. * @param basePositionRotationOrScale
  79906. * @param convertToRightHandedSystem
  79907. * @param useQuaternion
  79908. */
  79909. private static _AddKeyframeValue;
  79910. /**
  79911. * Determine the interpolation based on the key frames
  79912. * @param keyFrames
  79913. * @param animationChannelTargetPath
  79914. * @param useQuaternion
  79915. */
  79916. private static _DeduceInterpolation;
  79917. /**
  79918. * Adds an input tangent or output tangent to the output data
  79919. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  79920. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  79921. * @param outputs The animation data by keyframe
  79922. * @param animationChannelTargetPath The target animation channel
  79923. * @param interpolation The interpolation type
  79924. * @param keyFrame The key frame with the animation data
  79925. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  79926. * @param useQuaternion Specifies if quaternions are used
  79927. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  79928. */
  79929. private static AddSplineTangent;
  79930. /**
  79931. * Get the minimum and maximum key frames' frame values
  79932. * @param keyFrames animation key frames
  79933. * @returns the minimum and maximum key frame value
  79934. */
  79935. private static calculateMinMaxKeyFrames;
  79936. }
  79937. }
  79938. declare module BABYLON.GLTF2.Exporter {
  79939. /** @hidden */
  79940. export var textureTransformPixelShader: {
  79941. name: string;
  79942. shader: string;
  79943. };
  79944. }
  79945. declare module BABYLON.GLTF2.Exporter.Extensions {
  79946. /**
  79947. * @hidden
  79948. */
  79949. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  79950. private _recordedTextures;
  79951. /** Name of this extension */
  79952. readonly name: string;
  79953. /** Defines whether this extension is enabled */
  79954. enabled: boolean;
  79955. /** Defines whether this extension is required */
  79956. required: boolean;
  79957. /** Reference to the glTF exporter */
  79958. private _wasUsed;
  79959. constructor(exporter: _Exporter);
  79960. dispose(): void;
  79961. /** @hidden */
  79962. get wasUsed(): boolean;
  79963. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  79964. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  79965. /**
  79966. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  79967. * @param babylonTexture
  79968. * @param offset
  79969. * @param rotation
  79970. * @param scale
  79971. * @param scene
  79972. */
  79973. private _textureTransformTextureAsync;
  79974. }
  79975. }
  79976. declare module BABYLON.GLTF2.Exporter.Extensions {
  79977. /**
  79978. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  79979. */
  79980. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  79981. /** The name of this extension. */
  79982. readonly name: string;
  79983. /** Defines whether this extension is enabled. */
  79984. enabled: boolean;
  79985. /** Defines whether this extension is required */
  79986. required: boolean;
  79987. /** Reference to the glTF exporter */
  79988. private _exporter;
  79989. private _lights;
  79990. /** @hidden */
  79991. constructor(exporter: _Exporter);
  79992. /** @hidden */
  79993. dispose(): void;
  79994. /** @hidden */
  79995. get wasUsed(): boolean;
  79996. /** @hidden */
  79997. onExporting(): void;
  79998. /**
  79999. * Define this method to modify the default behavior when exporting a node
  80000. * @param context The context when exporting the node
  80001. * @param node glTF node
  80002. * @param babylonNode BabylonJS node
  80003. * @param nodeMap Node mapping of unique id to glTF node index
  80004. * @returns nullable INode promise
  80005. */
  80006. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80007. [key: number]: number;
  80008. }): Promise<Nullable<INode>>;
  80009. }
  80010. }
  80011. declare module BABYLON.GLTF2.Exporter.Extensions {
  80012. /**
  80013. * @hidden
  80014. */
  80015. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  80016. /** Name of this extension */
  80017. readonly name: string;
  80018. /** Defines whether this extension is enabled */
  80019. enabled: boolean;
  80020. /** Defines whether this extension is required */
  80021. required: boolean;
  80022. /** Reference to the glTF exporter */
  80023. private _textureInfos;
  80024. private _exportedTextures;
  80025. private _wasUsed;
  80026. constructor(exporter: _Exporter);
  80027. dispose(): void;
  80028. /** @hidden */
  80029. get wasUsed(): boolean;
  80030. private _getTextureIndex;
  80031. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80032. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80033. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  80034. }
  80035. }
  80036. declare module BABYLON {
  80037. /**
  80038. * Class for generating STL data from a Babylon scene.
  80039. */
  80040. export class STLExport {
  80041. /**
  80042. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  80043. * @param meshes list defines the mesh to serialize
  80044. * @param download triggers the automatic download of the file.
  80045. * @param fileName changes the downloads fileName.
  80046. * @param binary changes the STL to a binary type.
  80047. * @param isLittleEndian toggle for binary type exporter.
  80048. * @returns the STL as UTF8 string
  80049. */
  80050. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  80051. }
  80052. }
  80053. declare module "babylonjs-gltf2interface" {
  80054. export = BABYLON.GLTF2;
  80055. }
  80056. /**
  80057. * Module for glTF 2.0 Interface
  80058. */
  80059. declare module BABYLON.GLTF2 {
  80060. /**
  80061. * The datatype of the components in the attribute
  80062. */
  80063. const enum AccessorComponentType {
  80064. /**
  80065. * Byte
  80066. */
  80067. BYTE = 5120,
  80068. /**
  80069. * Unsigned Byte
  80070. */
  80071. UNSIGNED_BYTE = 5121,
  80072. /**
  80073. * Short
  80074. */
  80075. SHORT = 5122,
  80076. /**
  80077. * Unsigned Short
  80078. */
  80079. UNSIGNED_SHORT = 5123,
  80080. /**
  80081. * Unsigned Int
  80082. */
  80083. UNSIGNED_INT = 5125,
  80084. /**
  80085. * Float
  80086. */
  80087. FLOAT = 5126,
  80088. }
  80089. /**
  80090. * Specifies if the attirbute is a scalar, vector, or matrix
  80091. */
  80092. const enum AccessorType {
  80093. /**
  80094. * Scalar
  80095. */
  80096. SCALAR = "SCALAR",
  80097. /**
  80098. * Vector2
  80099. */
  80100. VEC2 = "VEC2",
  80101. /**
  80102. * Vector3
  80103. */
  80104. VEC3 = "VEC3",
  80105. /**
  80106. * Vector4
  80107. */
  80108. VEC4 = "VEC4",
  80109. /**
  80110. * Matrix2x2
  80111. */
  80112. MAT2 = "MAT2",
  80113. /**
  80114. * Matrix3x3
  80115. */
  80116. MAT3 = "MAT3",
  80117. /**
  80118. * Matrix4x4
  80119. */
  80120. MAT4 = "MAT4",
  80121. }
  80122. /**
  80123. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80124. */
  80125. const enum AnimationChannelTargetPath {
  80126. /**
  80127. * Translation
  80128. */
  80129. TRANSLATION = "translation",
  80130. /**
  80131. * Rotation
  80132. */
  80133. ROTATION = "rotation",
  80134. /**
  80135. * Scale
  80136. */
  80137. SCALE = "scale",
  80138. /**
  80139. * Weights
  80140. */
  80141. WEIGHTS = "weights",
  80142. }
  80143. /**
  80144. * Interpolation algorithm
  80145. */
  80146. const enum AnimationSamplerInterpolation {
  80147. /**
  80148. * The animated values are linearly interpolated between keyframes
  80149. */
  80150. LINEAR = "LINEAR",
  80151. /**
  80152. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  80153. */
  80154. STEP = "STEP",
  80155. /**
  80156. * The animation's interpolation is computed using a cubic spline with specified tangents
  80157. */
  80158. CUBICSPLINE = "CUBICSPLINE",
  80159. }
  80160. /**
  80161. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80162. */
  80163. const enum CameraType {
  80164. /**
  80165. * A perspective camera containing properties to create a perspective projection matrix
  80166. */
  80167. PERSPECTIVE = "perspective",
  80168. /**
  80169. * An orthographic camera containing properties to create an orthographic projection matrix
  80170. */
  80171. ORTHOGRAPHIC = "orthographic",
  80172. }
  80173. /**
  80174. * The mime-type of the image
  80175. */
  80176. const enum ImageMimeType {
  80177. /**
  80178. * JPEG Mime-type
  80179. */
  80180. JPEG = "image/jpeg",
  80181. /**
  80182. * PNG Mime-type
  80183. */
  80184. PNG = "image/png",
  80185. }
  80186. /**
  80187. * The alpha rendering mode of the material
  80188. */
  80189. const enum MaterialAlphaMode {
  80190. /**
  80191. * The alpha value is ignored and the rendered output is fully opaque
  80192. */
  80193. OPAQUE = "OPAQUE",
  80194. /**
  80195. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  80196. */
  80197. MASK = "MASK",
  80198. /**
  80199. * 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)
  80200. */
  80201. BLEND = "BLEND",
  80202. }
  80203. /**
  80204. * The type of the primitives to render
  80205. */
  80206. const enum MeshPrimitiveMode {
  80207. /**
  80208. * Points
  80209. */
  80210. POINTS = 0,
  80211. /**
  80212. * Lines
  80213. */
  80214. LINES = 1,
  80215. /**
  80216. * Line Loop
  80217. */
  80218. LINE_LOOP = 2,
  80219. /**
  80220. * Line Strip
  80221. */
  80222. LINE_STRIP = 3,
  80223. /**
  80224. * Triangles
  80225. */
  80226. TRIANGLES = 4,
  80227. /**
  80228. * Triangle Strip
  80229. */
  80230. TRIANGLE_STRIP = 5,
  80231. /**
  80232. * Triangle Fan
  80233. */
  80234. TRIANGLE_FAN = 6,
  80235. }
  80236. /**
  80237. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80238. */
  80239. const enum TextureMagFilter {
  80240. /**
  80241. * Nearest
  80242. */
  80243. NEAREST = 9728,
  80244. /**
  80245. * Linear
  80246. */
  80247. LINEAR = 9729,
  80248. }
  80249. /**
  80250. * Minification filter. All valid values correspond to WebGL enums
  80251. */
  80252. const enum TextureMinFilter {
  80253. /**
  80254. * Nearest
  80255. */
  80256. NEAREST = 9728,
  80257. /**
  80258. * Linear
  80259. */
  80260. LINEAR = 9729,
  80261. /**
  80262. * Nearest Mip-Map Nearest
  80263. */
  80264. NEAREST_MIPMAP_NEAREST = 9984,
  80265. /**
  80266. * Linear Mipmap Nearest
  80267. */
  80268. LINEAR_MIPMAP_NEAREST = 9985,
  80269. /**
  80270. * Nearest Mipmap Linear
  80271. */
  80272. NEAREST_MIPMAP_LINEAR = 9986,
  80273. /**
  80274. * Linear Mipmap Linear
  80275. */
  80276. LINEAR_MIPMAP_LINEAR = 9987,
  80277. }
  80278. /**
  80279. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80280. */
  80281. const enum TextureWrapMode {
  80282. /**
  80283. * Clamp to Edge
  80284. */
  80285. CLAMP_TO_EDGE = 33071,
  80286. /**
  80287. * Mirrored Repeat
  80288. */
  80289. MIRRORED_REPEAT = 33648,
  80290. /**
  80291. * Repeat
  80292. */
  80293. REPEAT = 10497,
  80294. }
  80295. /**
  80296. * glTF Property
  80297. */
  80298. interface IProperty {
  80299. /**
  80300. * Dictionary object with extension-specific objects
  80301. */
  80302. extensions?: {
  80303. [key: string]: any;
  80304. };
  80305. /**
  80306. * Application-Specific data
  80307. */
  80308. extras?: any;
  80309. }
  80310. /**
  80311. * glTF Child of Root Property
  80312. */
  80313. interface IChildRootProperty extends IProperty {
  80314. /**
  80315. * The user-defined name of this object
  80316. */
  80317. name?: string;
  80318. }
  80319. /**
  80320. * Indices of those attributes that deviate from their initialization value
  80321. */
  80322. interface IAccessorSparseIndices extends IProperty {
  80323. /**
  80324. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80325. */
  80326. bufferView: number;
  80327. /**
  80328. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80329. */
  80330. byteOffset?: number;
  80331. /**
  80332. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  80333. */
  80334. componentType: AccessorComponentType;
  80335. }
  80336. /**
  80337. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  80338. */
  80339. interface IAccessorSparseValues extends IProperty {
  80340. /**
  80341. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80342. */
  80343. bufferView: number;
  80344. /**
  80345. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80346. */
  80347. byteOffset?: number;
  80348. }
  80349. /**
  80350. * Sparse storage of attributes that deviate from their initialization value
  80351. */
  80352. interface IAccessorSparse extends IProperty {
  80353. /**
  80354. * The number of attributes encoded in this sparse accessor
  80355. */
  80356. count: number;
  80357. /**
  80358. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  80359. */
  80360. indices: IAccessorSparseIndices;
  80361. /**
  80362. * 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
  80363. */
  80364. values: IAccessorSparseValues;
  80365. }
  80366. /**
  80367. * 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
  80368. */
  80369. interface IAccessor extends IChildRootProperty {
  80370. /**
  80371. * The index of the bufferview
  80372. */
  80373. bufferView?: number;
  80374. /**
  80375. * The offset relative to the start of the bufferView in bytes
  80376. */
  80377. byteOffset?: number;
  80378. /**
  80379. * The datatype of components in the attribute
  80380. */
  80381. componentType: AccessorComponentType;
  80382. /**
  80383. * Specifies whether integer data values should be normalized
  80384. */
  80385. normalized?: boolean;
  80386. /**
  80387. * The number of attributes referenced by this accessor
  80388. */
  80389. count: number;
  80390. /**
  80391. * Specifies if the attribute is a scalar, vector, or matrix
  80392. */
  80393. type: AccessorType;
  80394. /**
  80395. * Maximum value of each component in this attribute
  80396. */
  80397. max?: number[];
  80398. /**
  80399. * Minimum value of each component in this attribute
  80400. */
  80401. min?: number[];
  80402. /**
  80403. * Sparse storage of attributes that deviate from their initialization value
  80404. */
  80405. sparse?: IAccessorSparse;
  80406. }
  80407. /**
  80408. * Targets an animation's sampler at a node's property
  80409. */
  80410. interface IAnimationChannel extends IProperty {
  80411. /**
  80412. * The index of a sampler in this animation used to compute the value for the target
  80413. */
  80414. sampler: number;
  80415. /**
  80416. * The index of the node and TRS property to target
  80417. */
  80418. target: IAnimationChannelTarget;
  80419. }
  80420. /**
  80421. * The index of the node and TRS property that an animation channel targets
  80422. */
  80423. interface IAnimationChannelTarget extends IProperty {
  80424. /**
  80425. * The index of the node to target
  80426. */
  80427. node: number;
  80428. /**
  80429. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80430. */
  80431. path: AnimationChannelTargetPath;
  80432. }
  80433. /**
  80434. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80435. */
  80436. interface IAnimationSampler extends IProperty {
  80437. /**
  80438. * The index of an accessor containing keyframe input values, e.g., time
  80439. */
  80440. input: number;
  80441. /**
  80442. * Interpolation algorithm
  80443. */
  80444. interpolation?: AnimationSamplerInterpolation;
  80445. /**
  80446. * The index of an accessor, containing keyframe output values
  80447. */
  80448. output: number;
  80449. }
  80450. /**
  80451. * A keyframe animation
  80452. */
  80453. interface IAnimation extends IChildRootProperty {
  80454. /**
  80455. * An array of channels, each of which targets an animation's sampler at a node's property
  80456. */
  80457. channels: IAnimationChannel[];
  80458. /**
  80459. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80460. */
  80461. samplers: IAnimationSampler[];
  80462. }
  80463. /**
  80464. * Metadata about the glTF asset
  80465. */
  80466. interface IAsset extends IChildRootProperty {
  80467. /**
  80468. * A copyright message suitable for display to credit the content creator
  80469. */
  80470. copyright?: string;
  80471. /**
  80472. * Tool that generated this glTF model. Useful for debugging
  80473. */
  80474. generator?: string;
  80475. /**
  80476. * The glTF version that this asset targets
  80477. */
  80478. version: string;
  80479. /**
  80480. * The minimum glTF version that this asset targets
  80481. */
  80482. minVersion?: string;
  80483. }
  80484. /**
  80485. * A buffer points to binary geometry, animation, or skins
  80486. */
  80487. interface IBuffer extends IChildRootProperty {
  80488. /**
  80489. * 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
  80490. */
  80491. uri?: string;
  80492. /**
  80493. * The length of the buffer in bytes
  80494. */
  80495. byteLength: number;
  80496. }
  80497. /**
  80498. * A view into a buffer generally representing a subset of the buffer
  80499. */
  80500. interface IBufferView extends IChildRootProperty {
  80501. /**
  80502. * The index of the buffer
  80503. */
  80504. buffer: number;
  80505. /**
  80506. * The offset into the buffer in bytes
  80507. */
  80508. byteOffset?: number;
  80509. /**
  80510. * The lenth of the bufferView in bytes
  80511. */
  80512. byteLength: number;
  80513. /**
  80514. * The stride, in bytes
  80515. */
  80516. byteStride?: number;
  80517. }
  80518. /**
  80519. * An orthographic camera containing properties to create an orthographic projection matrix
  80520. */
  80521. interface ICameraOrthographic extends IProperty {
  80522. /**
  80523. * The floating-point horizontal magnification of the view. Must not be zero
  80524. */
  80525. xmag: number;
  80526. /**
  80527. * The floating-point vertical magnification of the view. Must not be zero
  80528. */
  80529. ymag: number;
  80530. /**
  80531. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  80532. */
  80533. zfar: number;
  80534. /**
  80535. * The floating-point distance to the near clipping plane
  80536. */
  80537. znear: number;
  80538. }
  80539. /**
  80540. * A perspective camera containing properties to create a perspective projection matrix
  80541. */
  80542. interface ICameraPerspective extends IProperty {
  80543. /**
  80544. * The floating-point aspect ratio of the field of view
  80545. */
  80546. aspectRatio?: number;
  80547. /**
  80548. * The floating-point vertical field of view in radians
  80549. */
  80550. yfov: number;
  80551. /**
  80552. * The floating-point distance to the far clipping plane
  80553. */
  80554. zfar?: number;
  80555. /**
  80556. * The floating-point distance to the near clipping plane
  80557. */
  80558. znear: number;
  80559. }
  80560. /**
  80561. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80562. */
  80563. interface ICamera extends IChildRootProperty {
  80564. /**
  80565. * An orthographic camera containing properties to create an orthographic projection matrix
  80566. */
  80567. orthographic?: ICameraOrthographic;
  80568. /**
  80569. * A perspective camera containing properties to create a perspective projection matrix
  80570. */
  80571. perspective?: ICameraPerspective;
  80572. /**
  80573. * Specifies if the camera uses a perspective or orthographic projection
  80574. */
  80575. type: CameraType;
  80576. }
  80577. /**
  80578. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  80579. */
  80580. interface IImage extends IChildRootProperty {
  80581. /**
  80582. * 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
  80583. */
  80584. uri?: string;
  80585. /**
  80586. * The image's MIME type
  80587. */
  80588. mimeType?: ImageMimeType;
  80589. /**
  80590. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  80591. */
  80592. bufferView?: number;
  80593. }
  80594. /**
  80595. * Material Normal Texture Info
  80596. */
  80597. interface IMaterialNormalTextureInfo extends ITextureInfo {
  80598. /**
  80599. * The scalar multiplier applied to each normal vector of the normal texture
  80600. */
  80601. scale?: number;
  80602. }
  80603. /**
  80604. * Material Occlusion Texture Info
  80605. */
  80606. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  80607. /**
  80608. * A scalar multiplier controlling the amount of occlusion applied
  80609. */
  80610. strength?: number;
  80611. }
  80612. /**
  80613. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  80614. */
  80615. interface IMaterialPbrMetallicRoughness {
  80616. /**
  80617. * The material's base color factor
  80618. */
  80619. baseColorFactor?: number[];
  80620. /**
  80621. * The base color texture
  80622. */
  80623. baseColorTexture?: ITextureInfo;
  80624. /**
  80625. * The metalness of the material
  80626. */
  80627. metallicFactor?: number;
  80628. /**
  80629. * The roughness of the material
  80630. */
  80631. roughnessFactor?: number;
  80632. /**
  80633. * The metallic-roughness texture
  80634. */
  80635. metallicRoughnessTexture?: ITextureInfo;
  80636. }
  80637. /**
  80638. * The material appearance of a primitive
  80639. */
  80640. interface IMaterial extends IChildRootProperty {
  80641. /**
  80642. * 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
  80643. */
  80644. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80645. /**
  80646. * The normal map texture
  80647. */
  80648. normalTexture?: IMaterialNormalTextureInfo;
  80649. /**
  80650. * The occlusion map texture
  80651. */
  80652. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80653. /**
  80654. * The emissive map texture
  80655. */
  80656. emissiveTexture?: ITextureInfo;
  80657. /**
  80658. * 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
  80659. */
  80660. emissiveFactor?: number[];
  80661. /**
  80662. * The alpha rendering mode of the material
  80663. */
  80664. alphaMode?: MaterialAlphaMode;
  80665. /**
  80666. * The alpha cutoff value of the material
  80667. */
  80668. alphaCutoff?: number;
  80669. /**
  80670. * Specifies whether the material is double sided
  80671. */
  80672. doubleSided?: boolean;
  80673. }
  80674. /**
  80675. * Geometry to be rendered with the given material
  80676. */
  80677. interface IMeshPrimitive extends IProperty {
  80678. /**
  80679. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  80680. */
  80681. attributes: {
  80682. [name: string]: number;
  80683. };
  80684. /**
  80685. * The index of the accessor that contains the indices
  80686. */
  80687. indices?: number;
  80688. /**
  80689. * The index of the material to apply to this primitive when rendering
  80690. */
  80691. material?: number;
  80692. /**
  80693. * The type of primitives to render. All valid values correspond to WebGL enums
  80694. */
  80695. mode?: MeshPrimitiveMode;
  80696. /**
  80697. * 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
  80698. */
  80699. targets?: {
  80700. [name: string]: number;
  80701. }[];
  80702. }
  80703. /**
  80704. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  80705. */
  80706. interface IMesh extends IChildRootProperty {
  80707. /**
  80708. * An array of primitives, each defining geometry to be rendered with a material
  80709. */
  80710. primitives: IMeshPrimitive[];
  80711. /**
  80712. * Array of weights to be applied to the Morph Targets
  80713. */
  80714. weights?: number[];
  80715. }
  80716. /**
  80717. * A node in the node hierarchy
  80718. */
  80719. interface INode extends IChildRootProperty {
  80720. /**
  80721. * The index of the camera referenced by this node
  80722. */
  80723. camera?: number;
  80724. /**
  80725. * The indices of this node's children
  80726. */
  80727. children?: number[];
  80728. /**
  80729. * The index of the skin referenced by this node
  80730. */
  80731. skin?: number;
  80732. /**
  80733. * A floating-point 4x4 transformation matrix stored in column-major order
  80734. */
  80735. matrix?: number[];
  80736. /**
  80737. * The index of the mesh in this node
  80738. */
  80739. mesh?: number;
  80740. /**
  80741. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  80742. */
  80743. rotation?: number[];
  80744. /**
  80745. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  80746. */
  80747. scale?: number[];
  80748. /**
  80749. * The node's translation along the x, y, and z axes
  80750. */
  80751. translation?: number[];
  80752. /**
  80753. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  80754. */
  80755. weights?: number[];
  80756. }
  80757. /**
  80758. * Texture sampler properties for filtering and wrapping modes
  80759. */
  80760. interface ISampler extends IChildRootProperty {
  80761. /**
  80762. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80763. */
  80764. magFilter?: TextureMagFilter;
  80765. /**
  80766. * Minification filter. All valid values correspond to WebGL enums
  80767. */
  80768. minFilter?: TextureMinFilter;
  80769. /**
  80770. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80771. */
  80772. wrapS?: TextureWrapMode;
  80773. /**
  80774. * T (V) wrapping mode. All valid values correspond to WebGL enums
  80775. */
  80776. wrapT?: TextureWrapMode;
  80777. }
  80778. /**
  80779. * The root nodes of a scene
  80780. */
  80781. interface IScene extends IChildRootProperty {
  80782. /**
  80783. * The indices of each root node
  80784. */
  80785. nodes: number[];
  80786. }
  80787. /**
  80788. * Joints and matrices defining a skin
  80789. */
  80790. interface ISkin extends IChildRootProperty {
  80791. /**
  80792. * 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
  80793. */
  80794. inverseBindMatrices?: number;
  80795. /**
  80796. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  80797. */
  80798. skeleton?: number;
  80799. /**
  80800. * 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)
  80801. */
  80802. joints: number[];
  80803. }
  80804. /**
  80805. * A texture and its sampler
  80806. */
  80807. interface ITexture extends IChildRootProperty {
  80808. /**
  80809. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  80810. */
  80811. sampler?: number;
  80812. /**
  80813. * The index of the image used by this texture
  80814. */
  80815. source: number;
  80816. }
  80817. /**
  80818. * Reference to a texture
  80819. */
  80820. interface ITextureInfo extends IProperty {
  80821. /**
  80822. * The index of the texture
  80823. */
  80824. index: number;
  80825. /**
  80826. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  80827. */
  80828. texCoord?: number;
  80829. }
  80830. /**
  80831. * The root object for a glTF asset
  80832. */
  80833. interface IGLTF extends IProperty {
  80834. /**
  80835. * An array of accessors. An accessor is a typed view into a bufferView
  80836. */
  80837. accessors?: IAccessor[];
  80838. /**
  80839. * An array of keyframe animations
  80840. */
  80841. animations?: IAnimation[];
  80842. /**
  80843. * Metadata about the glTF asset
  80844. */
  80845. asset: IAsset;
  80846. /**
  80847. * An array of buffers. A buffer points to binary geometry, animation, or skins
  80848. */
  80849. buffers?: IBuffer[];
  80850. /**
  80851. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  80852. */
  80853. bufferViews?: IBufferView[];
  80854. /**
  80855. * An array of cameras
  80856. */
  80857. cameras?: ICamera[];
  80858. /**
  80859. * Names of glTF extensions used somewhere in this asset
  80860. */
  80861. extensionsUsed?: string[];
  80862. /**
  80863. * Names of glTF extensions required to properly load this asset
  80864. */
  80865. extensionsRequired?: string[];
  80866. /**
  80867. * An array of images. An image defines data used to create a texture
  80868. */
  80869. images?: IImage[];
  80870. /**
  80871. * An array of materials. A material defines the appearance of a primitive
  80872. */
  80873. materials?: IMaterial[];
  80874. /**
  80875. * An array of meshes. A mesh is a set of primitives to be rendered
  80876. */
  80877. meshes?: IMesh[];
  80878. /**
  80879. * An array of nodes
  80880. */
  80881. nodes?: INode[];
  80882. /**
  80883. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  80884. */
  80885. samplers?: ISampler[];
  80886. /**
  80887. * The index of the default scene
  80888. */
  80889. scene?: number;
  80890. /**
  80891. * An array of scenes
  80892. */
  80893. scenes?: IScene[];
  80894. /**
  80895. * An array of skins. A skin is defined by joints and matrices
  80896. */
  80897. skins?: ISkin[];
  80898. /**
  80899. * An array of textures
  80900. */
  80901. textures?: ITexture[];
  80902. }
  80903. /**
  80904. * The glTF validation results
  80905. * @ignore
  80906. */
  80907. interface IGLTFValidationResults {
  80908. info: {
  80909. generator: string;
  80910. hasAnimations: boolean;
  80911. hasDefaultScene: boolean;
  80912. hasMaterials: boolean;
  80913. hasMorphTargets: boolean;
  80914. hasSkins: boolean;
  80915. hasTextures: boolean;
  80916. maxAttributesUsed: number;
  80917. primitivesCount: number
  80918. };
  80919. issues: {
  80920. messages: Array<string>;
  80921. numErrors: number;
  80922. numHints: number;
  80923. numInfos: number;
  80924. numWarnings: number;
  80925. truncated: boolean
  80926. };
  80927. mimeType: string;
  80928. uri: string;
  80929. validatedAt: string;
  80930. validatorVersion: string;
  80931. }
  80932. /**
  80933. * The glTF validation options
  80934. */
  80935. interface IGLTFValidationOptions {
  80936. /** Uri to use */
  80937. uri?: string;
  80938. /** Function used to load external resources */
  80939. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  80940. /** Boolean indicating that we need to validate accessor data */
  80941. validateAccessorData?: boolean;
  80942. /** max number of issues allowed */
  80943. maxIssues?: number;
  80944. /** Ignored issues */
  80945. ignoredIssues?: Array<string>;
  80946. /** Value to override severy settings */
  80947. severityOverrides?: Object;
  80948. }
  80949. /**
  80950. * The glTF validator object
  80951. * @ignore
  80952. */
  80953. interface IGLTFValidator {
  80954. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  80955. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  80956. }
  80957. }
  80958. declare module BABYLON {
  80959. /** @hidden */
  80960. export var cellPixelShader: {
  80961. name: string;
  80962. shader: string;
  80963. };
  80964. }
  80965. declare module BABYLON {
  80966. /** @hidden */
  80967. export var cellVertexShader: {
  80968. name: string;
  80969. shader: string;
  80970. };
  80971. }
  80972. declare module BABYLON {
  80973. export class CellMaterial extends BABYLON.PushMaterial {
  80974. private _diffuseTexture;
  80975. diffuseTexture: BABYLON.BaseTexture;
  80976. diffuseColor: BABYLON.Color3;
  80977. _computeHighLevel: boolean;
  80978. computeHighLevel: boolean;
  80979. private _disableLighting;
  80980. disableLighting: boolean;
  80981. private _maxSimultaneousLights;
  80982. maxSimultaneousLights: number;
  80983. constructor(name: string, scene: BABYLON.Scene);
  80984. needAlphaBlending(): boolean;
  80985. needAlphaTesting(): boolean;
  80986. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80987. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80988. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80989. getAnimatables(): BABYLON.IAnimatable[];
  80990. getActiveTextures(): BABYLON.BaseTexture[];
  80991. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80992. dispose(forceDisposeEffect?: boolean): void;
  80993. getClassName(): string;
  80994. clone(name: string): CellMaterial;
  80995. serialize(): any;
  80996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  80997. }
  80998. }
  80999. declare module BABYLON {
  81000. export class CustomShaderStructure {
  81001. FragmentStore: string;
  81002. VertexStore: string;
  81003. constructor();
  81004. }
  81005. export class ShaderSpecialParts {
  81006. constructor();
  81007. Fragment_Begin: string;
  81008. Fragment_Definitions: string;
  81009. Fragment_MainBegin: string;
  81010. Fragment_Custom_Diffuse: string;
  81011. Fragment_Before_Lights: string;
  81012. Fragment_Before_Fog: string;
  81013. Fragment_Custom_Alpha: string;
  81014. Fragment_Before_FragColor: string;
  81015. Vertex_Begin: string;
  81016. Vertex_Definitions: string;
  81017. Vertex_MainBegin: string;
  81018. Vertex_Before_PositionUpdated: string;
  81019. Vertex_Before_NormalUpdated: string;
  81020. Vertex_After_WorldPosComputed: string;
  81021. Vertex_MainEnd: string;
  81022. }
  81023. export class CustomMaterial extends BABYLON.StandardMaterial {
  81024. static ShaderIndexer: number;
  81025. CustomParts: ShaderSpecialParts;
  81026. _isCreatedShader: boolean;
  81027. _createdShaderName: string;
  81028. _customUniform: string[];
  81029. _newUniforms: string[];
  81030. _newUniformInstances: {
  81031. [name: string]: any;
  81032. };
  81033. _newSamplerInstances: {
  81034. [name: string]: BABYLON.Texture;
  81035. };
  81036. _customAttributes: string[];
  81037. FragmentShader: string;
  81038. VertexShader: string;
  81039. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81040. ReviewUniform(name: string, arr: string[]): string[];
  81041. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81042. constructor(name: string, scene: BABYLON.Scene);
  81043. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  81044. AddAttribute(name: string): CustomMaterial;
  81045. Fragment_Begin(shaderPart: string): CustomMaterial;
  81046. Fragment_Definitions(shaderPart: string): CustomMaterial;
  81047. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  81048. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  81049. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  81050. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  81051. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  81052. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  81053. Vertex_Begin(shaderPart: string): CustomMaterial;
  81054. Vertex_Definitions(shaderPart: string): CustomMaterial;
  81055. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  81056. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  81057. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  81058. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  81059. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  81060. }
  81061. }
  81062. declare module BABYLON {
  81063. export class ShaderAlebdoParts {
  81064. constructor();
  81065. Fragment_Begin: string;
  81066. Fragment_Definitions: string;
  81067. Fragment_MainBegin: string;
  81068. Fragment_Custom_Albedo: string;
  81069. Fragment_Before_Lights: string;
  81070. Fragment_Custom_MetallicRoughness: string;
  81071. Fragment_Custom_MicroSurface: string;
  81072. Fragment_Before_Fog: string;
  81073. Fragment_Custom_Alpha: string;
  81074. Fragment_Before_FragColor: string;
  81075. Vertex_Begin: string;
  81076. Vertex_Definitions: string;
  81077. Vertex_MainBegin: string;
  81078. Vertex_Before_PositionUpdated: string;
  81079. Vertex_Before_NormalUpdated: string;
  81080. Vertex_After_WorldPosComputed: string;
  81081. Vertex_MainEnd: string;
  81082. }
  81083. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  81084. static ShaderIndexer: number;
  81085. CustomParts: ShaderAlebdoParts;
  81086. _isCreatedShader: boolean;
  81087. _createdShaderName: string;
  81088. _customUniform: string[];
  81089. _newUniforms: string[];
  81090. _newUniformInstances: {
  81091. [name: string]: any;
  81092. };
  81093. _newSamplerInstances: {
  81094. [name: string]: BABYLON.Texture;
  81095. };
  81096. _customAttributes: string[];
  81097. FragmentShader: string;
  81098. VertexShader: string;
  81099. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81100. ReviewUniform(name: string, arr: string[]): string[];
  81101. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81102. constructor(name: string, scene: BABYLON.Scene);
  81103. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  81104. AddAttribute(name: string): PBRCustomMaterial;
  81105. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  81106. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  81107. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  81108. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  81109. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  81110. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  81111. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  81112. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  81113. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  81114. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  81115. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  81116. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  81117. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  81118. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  81119. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  81120. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  81121. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  81122. }
  81123. }
  81124. declare module BABYLON {
  81125. /** @hidden */
  81126. export var firePixelShader: {
  81127. name: string;
  81128. shader: string;
  81129. };
  81130. }
  81131. declare module BABYLON {
  81132. /** @hidden */
  81133. export var fireVertexShader: {
  81134. name: string;
  81135. shader: string;
  81136. };
  81137. }
  81138. declare module BABYLON {
  81139. export class FireMaterial extends BABYLON.PushMaterial {
  81140. private _diffuseTexture;
  81141. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81142. private _distortionTexture;
  81143. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81144. private _opacityTexture;
  81145. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81146. diffuseColor: BABYLON.Color3;
  81147. speed: number;
  81148. private _scaledDiffuse;
  81149. private _lastTime;
  81150. constructor(name: string, scene: BABYLON.Scene);
  81151. needAlphaBlending(): boolean;
  81152. needAlphaTesting(): boolean;
  81153. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81154. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81155. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81156. getAnimatables(): BABYLON.IAnimatable[];
  81157. getActiveTextures(): BABYLON.BaseTexture[];
  81158. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81159. getClassName(): string;
  81160. dispose(forceDisposeEffect?: boolean): void;
  81161. clone(name: string): FireMaterial;
  81162. serialize(): any;
  81163. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  81164. }
  81165. }
  81166. declare module BABYLON {
  81167. /** @hidden */
  81168. export var furPixelShader: {
  81169. name: string;
  81170. shader: string;
  81171. };
  81172. }
  81173. declare module BABYLON {
  81174. /** @hidden */
  81175. export var furVertexShader: {
  81176. name: string;
  81177. shader: string;
  81178. };
  81179. }
  81180. declare module BABYLON {
  81181. export class FurMaterial extends BABYLON.PushMaterial {
  81182. private _diffuseTexture;
  81183. diffuseTexture: BABYLON.BaseTexture;
  81184. private _heightTexture;
  81185. heightTexture: BABYLON.BaseTexture;
  81186. diffuseColor: BABYLON.Color3;
  81187. furLength: number;
  81188. furAngle: number;
  81189. furColor: BABYLON.Color3;
  81190. furOffset: number;
  81191. furSpacing: number;
  81192. furGravity: BABYLON.Vector3;
  81193. furSpeed: number;
  81194. furDensity: number;
  81195. furOcclusion: number;
  81196. furTexture: BABYLON.DynamicTexture;
  81197. private _disableLighting;
  81198. disableLighting: boolean;
  81199. private _maxSimultaneousLights;
  81200. maxSimultaneousLights: number;
  81201. highLevelFur: boolean;
  81202. _meshes: BABYLON.AbstractMesh[];
  81203. private _furTime;
  81204. constructor(name: string, scene: BABYLON.Scene);
  81205. get furTime(): number;
  81206. set furTime(furTime: number);
  81207. needAlphaBlending(): boolean;
  81208. needAlphaTesting(): boolean;
  81209. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81210. updateFur(): void;
  81211. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81212. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81213. getAnimatables(): BABYLON.IAnimatable[];
  81214. getActiveTextures(): BABYLON.BaseTexture[];
  81215. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81216. dispose(forceDisposeEffect?: boolean): void;
  81217. clone(name: string): FurMaterial;
  81218. serialize(): any;
  81219. getClassName(): string;
  81220. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  81221. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  81222. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  81223. }
  81224. }
  81225. declare module BABYLON {
  81226. /** @hidden */
  81227. export var gradientPixelShader: {
  81228. name: string;
  81229. shader: string;
  81230. };
  81231. }
  81232. declare module BABYLON {
  81233. /** @hidden */
  81234. export var gradientVertexShader: {
  81235. name: string;
  81236. shader: string;
  81237. };
  81238. }
  81239. declare module BABYLON {
  81240. export class GradientMaterial extends BABYLON.PushMaterial {
  81241. private _maxSimultaneousLights;
  81242. maxSimultaneousLights: number;
  81243. topColor: BABYLON.Color3;
  81244. topColorAlpha: number;
  81245. bottomColor: BABYLON.Color3;
  81246. bottomColorAlpha: number;
  81247. offset: number;
  81248. scale: number;
  81249. smoothness: number;
  81250. private _disableLighting;
  81251. disableLighting: boolean;
  81252. constructor(name: string, scene: BABYLON.Scene);
  81253. needAlphaBlending(): boolean;
  81254. needAlphaTesting(): boolean;
  81255. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81256. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81257. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81258. getAnimatables(): BABYLON.IAnimatable[];
  81259. dispose(forceDisposeEffect?: boolean): void;
  81260. clone(name: string): GradientMaterial;
  81261. serialize(): any;
  81262. getClassName(): string;
  81263. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  81264. }
  81265. }
  81266. declare module BABYLON {
  81267. /** @hidden */
  81268. export var gridPixelShader: {
  81269. name: string;
  81270. shader: string;
  81271. };
  81272. }
  81273. declare module BABYLON {
  81274. /** @hidden */
  81275. export var gridVertexShader: {
  81276. name: string;
  81277. shader: string;
  81278. };
  81279. }
  81280. declare module BABYLON {
  81281. /**
  81282. * The grid materials allows you to wrap any shape with a grid.
  81283. * Colors are customizable.
  81284. */
  81285. export class GridMaterial extends BABYLON.PushMaterial {
  81286. /**
  81287. * Main color of the grid (e.g. between lines)
  81288. */
  81289. mainColor: BABYLON.Color3;
  81290. /**
  81291. * Color of the grid lines.
  81292. */
  81293. lineColor: BABYLON.Color3;
  81294. /**
  81295. * The scale of the grid compared to unit.
  81296. */
  81297. gridRatio: number;
  81298. /**
  81299. * Allows setting an offset for the grid lines.
  81300. */
  81301. gridOffset: BABYLON.Vector3;
  81302. /**
  81303. * The frequency of thicker lines.
  81304. */
  81305. majorUnitFrequency: number;
  81306. /**
  81307. * The visibility of minor units in the grid.
  81308. */
  81309. minorUnitVisibility: number;
  81310. /**
  81311. * The grid opacity outside of the lines.
  81312. */
  81313. opacity: number;
  81314. /**
  81315. * Determine RBG output is premultiplied by alpha value.
  81316. */
  81317. preMultiplyAlpha: boolean;
  81318. private _opacityTexture;
  81319. opacityTexture: BABYLON.BaseTexture;
  81320. private _gridControl;
  81321. /**
  81322. * constructor
  81323. * @param name The name given to the material in order to identify it afterwards.
  81324. * @param scene The scene the material is used in.
  81325. */
  81326. constructor(name: string, scene: BABYLON.Scene);
  81327. /**
  81328. * Returns wehter or not the grid requires alpha blending.
  81329. */
  81330. needAlphaBlending(): boolean;
  81331. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81334. /**
  81335. * Dispose the material and its associated resources.
  81336. * @param forceDisposeEffect will also dispose the used effect when true
  81337. */
  81338. dispose(forceDisposeEffect?: boolean): void;
  81339. clone(name: string): GridMaterial;
  81340. serialize(): any;
  81341. getClassName(): string;
  81342. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  81343. }
  81344. }
  81345. declare module BABYLON {
  81346. /** @hidden */
  81347. export var lavaPixelShader: {
  81348. name: string;
  81349. shader: string;
  81350. };
  81351. }
  81352. declare module BABYLON {
  81353. /** @hidden */
  81354. export var lavaVertexShader: {
  81355. name: string;
  81356. shader: string;
  81357. };
  81358. }
  81359. declare module BABYLON {
  81360. export class LavaMaterial extends BABYLON.PushMaterial {
  81361. private _diffuseTexture;
  81362. diffuseTexture: BABYLON.BaseTexture;
  81363. noiseTexture: BABYLON.BaseTexture;
  81364. fogColor: BABYLON.Color3;
  81365. speed: number;
  81366. movingSpeed: number;
  81367. lowFrequencySpeed: number;
  81368. fogDensity: number;
  81369. private _lastTime;
  81370. diffuseColor: BABYLON.Color3;
  81371. private _disableLighting;
  81372. disableLighting: boolean;
  81373. private _unlit;
  81374. unlit: boolean;
  81375. private _maxSimultaneousLights;
  81376. maxSimultaneousLights: number;
  81377. private _scaledDiffuse;
  81378. constructor(name: string, scene: BABYLON.Scene);
  81379. needAlphaBlending(): boolean;
  81380. needAlphaTesting(): boolean;
  81381. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81382. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81383. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81384. getAnimatables(): BABYLON.IAnimatable[];
  81385. getActiveTextures(): BABYLON.BaseTexture[];
  81386. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81387. dispose(forceDisposeEffect?: boolean): void;
  81388. clone(name: string): LavaMaterial;
  81389. serialize(): any;
  81390. getClassName(): string;
  81391. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  81392. }
  81393. }
  81394. declare module BABYLON {
  81395. /** @hidden */
  81396. export var mixPixelShader: {
  81397. name: string;
  81398. shader: string;
  81399. };
  81400. }
  81401. declare module BABYLON {
  81402. /** @hidden */
  81403. export var mixVertexShader: {
  81404. name: string;
  81405. shader: string;
  81406. };
  81407. }
  81408. declare module BABYLON {
  81409. export class MixMaterial extends BABYLON.PushMaterial {
  81410. /**
  81411. * Mix textures
  81412. */
  81413. private _mixTexture1;
  81414. mixTexture1: BABYLON.BaseTexture;
  81415. private _mixTexture2;
  81416. mixTexture2: BABYLON.BaseTexture;
  81417. /**
  81418. * Diffuse textures
  81419. */
  81420. private _diffuseTexture1;
  81421. diffuseTexture1: BABYLON.Texture;
  81422. private _diffuseTexture2;
  81423. diffuseTexture2: BABYLON.Texture;
  81424. private _diffuseTexture3;
  81425. diffuseTexture3: BABYLON.Texture;
  81426. private _diffuseTexture4;
  81427. diffuseTexture4: BABYLON.Texture;
  81428. private _diffuseTexture5;
  81429. diffuseTexture5: BABYLON.Texture;
  81430. private _diffuseTexture6;
  81431. diffuseTexture6: BABYLON.Texture;
  81432. private _diffuseTexture7;
  81433. diffuseTexture7: BABYLON.Texture;
  81434. private _diffuseTexture8;
  81435. diffuseTexture8: BABYLON.Texture;
  81436. /**
  81437. * Uniforms
  81438. */
  81439. diffuseColor: BABYLON.Color3;
  81440. specularColor: BABYLON.Color3;
  81441. specularPower: number;
  81442. private _disableLighting;
  81443. disableLighting: boolean;
  81444. private _maxSimultaneousLights;
  81445. maxSimultaneousLights: number;
  81446. constructor(name: string, scene: BABYLON.Scene);
  81447. needAlphaBlending(): boolean;
  81448. needAlphaTesting(): boolean;
  81449. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81450. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81451. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81452. getAnimatables(): BABYLON.IAnimatable[];
  81453. getActiveTextures(): BABYLON.BaseTexture[];
  81454. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81455. dispose(forceDisposeEffect?: boolean): void;
  81456. clone(name: string): MixMaterial;
  81457. serialize(): any;
  81458. getClassName(): string;
  81459. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  81460. }
  81461. }
  81462. declare module BABYLON {
  81463. /** @hidden */
  81464. export var normalPixelShader: {
  81465. name: string;
  81466. shader: string;
  81467. };
  81468. }
  81469. declare module BABYLON {
  81470. /** @hidden */
  81471. export var normalVertexShader: {
  81472. name: string;
  81473. shader: string;
  81474. };
  81475. }
  81476. declare module BABYLON {
  81477. export class NormalMaterial extends BABYLON.PushMaterial {
  81478. private _diffuseTexture;
  81479. diffuseTexture: BABYLON.BaseTexture;
  81480. diffuseColor: BABYLON.Color3;
  81481. private _disableLighting;
  81482. disableLighting: boolean;
  81483. private _maxSimultaneousLights;
  81484. maxSimultaneousLights: number;
  81485. constructor(name: string, scene: BABYLON.Scene);
  81486. needAlphaBlending(): boolean;
  81487. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81488. needAlphaTesting(): boolean;
  81489. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81490. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81491. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81492. getAnimatables(): BABYLON.IAnimatable[];
  81493. getActiveTextures(): BABYLON.BaseTexture[];
  81494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81495. dispose(forceDisposeEffect?: boolean): void;
  81496. clone(name: string): NormalMaterial;
  81497. serialize(): any;
  81498. getClassName(): string;
  81499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  81500. }
  81501. }
  81502. declare module BABYLON {
  81503. /** @hidden */
  81504. export var shadowOnlyPixelShader: {
  81505. name: string;
  81506. shader: string;
  81507. };
  81508. }
  81509. declare module BABYLON {
  81510. /** @hidden */
  81511. export var shadowOnlyVertexShader: {
  81512. name: string;
  81513. shader: string;
  81514. };
  81515. }
  81516. declare module BABYLON {
  81517. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  81518. private _activeLight;
  81519. constructor(name: string, scene: BABYLON.Scene);
  81520. shadowColor: BABYLON.Color3;
  81521. needAlphaBlending(): boolean;
  81522. needAlphaTesting(): boolean;
  81523. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81524. get activeLight(): BABYLON.IShadowLight;
  81525. set activeLight(light: BABYLON.IShadowLight);
  81526. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81527. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81528. clone(name: string): ShadowOnlyMaterial;
  81529. serialize(): any;
  81530. getClassName(): string;
  81531. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  81532. }
  81533. }
  81534. declare module BABYLON {
  81535. /** @hidden */
  81536. export var simplePixelShader: {
  81537. name: string;
  81538. shader: string;
  81539. };
  81540. }
  81541. declare module BABYLON {
  81542. /** @hidden */
  81543. export var simpleVertexShader: {
  81544. name: string;
  81545. shader: string;
  81546. };
  81547. }
  81548. declare module BABYLON {
  81549. export class SimpleMaterial extends BABYLON.PushMaterial {
  81550. private _diffuseTexture;
  81551. diffuseTexture: BABYLON.BaseTexture;
  81552. diffuseColor: BABYLON.Color3;
  81553. private _disableLighting;
  81554. disableLighting: boolean;
  81555. private _maxSimultaneousLights;
  81556. maxSimultaneousLights: number;
  81557. constructor(name: string, scene: BABYLON.Scene);
  81558. needAlphaBlending(): boolean;
  81559. needAlphaTesting(): boolean;
  81560. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81561. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81562. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81563. getAnimatables(): BABYLON.IAnimatable[];
  81564. getActiveTextures(): BABYLON.BaseTexture[];
  81565. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81566. dispose(forceDisposeEffect?: boolean): void;
  81567. clone(name: string): SimpleMaterial;
  81568. serialize(): any;
  81569. getClassName(): string;
  81570. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  81571. }
  81572. }
  81573. declare module BABYLON {
  81574. /** @hidden */
  81575. export var skyPixelShader: {
  81576. name: string;
  81577. shader: string;
  81578. };
  81579. }
  81580. declare module BABYLON {
  81581. /** @hidden */
  81582. export var skyVertexShader: {
  81583. name: string;
  81584. shader: string;
  81585. };
  81586. }
  81587. declare module BABYLON {
  81588. /**
  81589. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  81590. * @see https://doc.babylonjs.com/extensions/sky
  81591. */
  81592. export class SkyMaterial extends BABYLON.PushMaterial {
  81593. /**
  81594. * Defines the overall luminance of sky in interval ]0, 1[.
  81595. */
  81596. luminance: number;
  81597. /**
  81598. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  81599. */
  81600. turbidity: number;
  81601. /**
  81602. * Defines the sky appearance (light intensity).
  81603. */
  81604. rayleigh: number;
  81605. /**
  81606. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  81607. */
  81608. mieCoefficient: number;
  81609. /**
  81610. * Defines the amount of haze particles following the Mie scattering theory.
  81611. */
  81612. mieDirectionalG: number;
  81613. /**
  81614. * Defines the distance of the sun according to the active scene camera.
  81615. */
  81616. distance: number;
  81617. /**
  81618. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  81619. * "inclined".
  81620. */
  81621. inclination: number;
  81622. /**
  81623. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  81624. * an object direction and a reference direction.
  81625. */
  81626. azimuth: number;
  81627. /**
  81628. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  81629. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  81630. */
  81631. sunPosition: BABYLON.Vector3;
  81632. /**
  81633. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  81634. * .sunPosition property.
  81635. */
  81636. useSunPosition: boolean;
  81637. /**
  81638. * Defines an offset vector used to get a horizon offset.
  81639. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  81640. */
  81641. cameraOffset: BABYLON.Vector3;
  81642. private _cameraPosition;
  81643. /**
  81644. * Instantiates a new sky material.
  81645. * This material allows to create dynamic and texture free
  81646. * effects for skyboxes by taking care of the atmosphere state.
  81647. * @see https://doc.babylonjs.com/extensions/sky
  81648. * @param name Define the name of the material in the scene
  81649. * @param scene Define the scene the material belong to
  81650. */
  81651. constructor(name: string, scene: BABYLON.Scene);
  81652. /**
  81653. * Specifies if the material will require alpha blending
  81654. * @returns a boolean specifying if alpha blending is needed
  81655. */
  81656. needAlphaBlending(): boolean;
  81657. /**
  81658. * Specifies if this material should be rendered in alpha test mode
  81659. * @returns false as the sky material doesn't need alpha testing.
  81660. */
  81661. needAlphaTesting(): boolean;
  81662. /**
  81663. * Get the texture used for alpha test purpose.
  81664. * @returns null as the sky material has no texture.
  81665. */
  81666. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81667. /**
  81668. * Get if the submesh is ready to be used and all its information available.
  81669. * Child classes can use it to update shaders
  81670. * @param mesh defines the mesh to check
  81671. * @param subMesh defines which submesh to check
  81672. * @param useInstances specifies that instances should be used
  81673. * @returns a boolean indicating that the submesh is ready or not
  81674. */
  81675. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81676. /**
  81677. * Binds the submesh to this material by preparing the effect and shader to draw
  81678. * @param world defines the world transformation matrix
  81679. * @param mesh defines the mesh containing the submesh
  81680. * @param subMesh defines the submesh to bind the material to
  81681. */
  81682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81683. /**
  81684. * Get the list of animatables in the material.
  81685. * @returns the list of animatables object used in the material
  81686. */
  81687. getAnimatables(): BABYLON.IAnimatable[];
  81688. /**
  81689. * Disposes the material
  81690. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81691. */
  81692. dispose(forceDisposeEffect?: boolean): void;
  81693. /**
  81694. * Makes a duplicate of the material, and gives it a new name
  81695. * @param name defines the new name for the duplicated material
  81696. * @returns the cloned material
  81697. */
  81698. clone(name: string): SkyMaterial;
  81699. /**
  81700. * Serializes this material in a JSON representation
  81701. * @returns the serialized material object
  81702. */
  81703. serialize(): any;
  81704. /**
  81705. * Gets the current class name of the material e.g. "SkyMaterial"
  81706. * Mainly use in serialization.
  81707. * @returns the class name
  81708. */
  81709. getClassName(): string;
  81710. /**
  81711. * Creates a sky material from parsed material data
  81712. * @param source defines the JSON representation of the material
  81713. * @param scene defines the hosting scene
  81714. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  81715. * @returns a new sky material
  81716. */
  81717. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  81718. }
  81719. }
  81720. declare module BABYLON {
  81721. /** @hidden */
  81722. export var terrainPixelShader: {
  81723. name: string;
  81724. shader: string;
  81725. };
  81726. }
  81727. declare module BABYLON {
  81728. /** @hidden */
  81729. export var terrainVertexShader: {
  81730. name: string;
  81731. shader: string;
  81732. };
  81733. }
  81734. declare module BABYLON {
  81735. export class TerrainMaterial extends BABYLON.PushMaterial {
  81736. private _mixTexture;
  81737. mixTexture: BABYLON.BaseTexture;
  81738. private _diffuseTexture1;
  81739. diffuseTexture1: BABYLON.Texture;
  81740. private _diffuseTexture2;
  81741. diffuseTexture2: BABYLON.Texture;
  81742. private _diffuseTexture3;
  81743. diffuseTexture3: BABYLON.Texture;
  81744. private _bumpTexture1;
  81745. bumpTexture1: BABYLON.Texture;
  81746. private _bumpTexture2;
  81747. bumpTexture2: BABYLON.Texture;
  81748. private _bumpTexture3;
  81749. bumpTexture3: BABYLON.Texture;
  81750. diffuseColor: BABYLON.Color3;
  81751. specularColor: BABYLON.Color3;
  81752. specularPower: number;
  81753. private _disableLighting;
  81754. disableLighting: boolean;
  81755. private _maxSimultaneousLights;
  81756. maxSimultaneousLights: number;
  81757. constructor(name: string, scene: BABYLON.Scene);
  81758. needAlphaBlending(): boolean;
  81759. needAlphaTesting(): boolean;
  81760. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81761. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81762. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81763. getAnimatables(): BABYLON.IAnimatable[];
  81764. getActiveTextures(): BABYLON.BaseTexture[];
  81765. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81766. dispose(forceDisposeEffect?: boolean): void;
  81767. clone(name: string): TerrainMaterial;
  81768. serialize(): any;
  81769. getClassName(): string;
  81770. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  81771. }
  81772. }
  81773. declare module BABYLON {
  81774. /** @hidden */
  81775. export var triplanarPixelShader: {
  81776. name: string;
  81777. shader: string;
  81778. };
  81779. }
  81780. declare module BABYLON {
  81781. /** @hidden */
  81782. export var triplanarVertexShader: {
  81783. name: string;
  81784. shader: string;
  81785. };
  81786. }
  81787. declare module BABYLON {
  81788. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  81789. mixTexture: BABYLON.BaseTexture;
  81790. private _diffuseTextureX;
  81791. diffuseTextureX: BABYLON.BaseTexture;
  81792. private _diffuseTextureY;
  81793. diffuseTextureY: BABYLON.BaseTexture;
  81794. private _diffuseTextureZ;
  81795. diffuseTextureZ: BABYLON.BaseTexture;
  81796. private _normalTextureX;
  81797. normalTextureX: BABYLON.BaseTexture;
  81798. private _normalTextureY;
  81799. normalTextureY: BABYLON.BaseTexture;
  81800. private _normalTextureZ;
  81801. normalTextureZ: BABYLON.BaseTexture;
  81802. tileSize: number;
  81803. diffuseColor: BABYLON.Color3;
  81804. specularColor: BABYLON.Color3;
  81805. specularPower: number;
  81806. private _disableLighting;
  81807. disableLighting: boolean;
  81808. private _maxSimultaneousLights;
  81809. maxSimultaneousLights: number;
  81810. constructor(name: string, scene: BABYLON.Scene);
  81811. needAlphaBlending(): boolean;
  81812. needAlphaTesting(): boolean;
  81813. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81814. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81815. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81816. getAnimatables(): BABYLON.IAnimatable[];
  81817. getActiveTextures(): BABYLON.BaseTexture[];
  81818. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81819. dispose(forceDisposeEffect?: boolean): void;
  81820. clone(name: string): TriPlanarMaterial;
  81821. serialize(): any;
  81822. getClassName(): string;
  81823. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  81824. }
  81825. }
  81826. declare module BABYLON {
  81827. /** @hidden */
  81828. export var waterPixelShader: {
  81829. name: string;
  81830. shader: string;
  81831. };
  81832. }
  81833. declare module BABYLON {
  81834. /** @hidden */
  81835. export var waterVertexShader: {
  81836. name: string;
  81837. shader: string;
  81838. };
  81839. }
  81840. declare module BABYLON {
  81841. export class WaterMaterial extends BABYLON.PushMaterial {
  81842. renderTargetSize: BABYLON.Vector2;
  81843. private _bumpTexture;
  81844. bumpTexture: BABYLON.BaseTexture;
  81845. diffuseColor: BABYLON.Color3;
  81846. specularColor: BABYLON.Color3;
  81847. specularPower: number;
  81848. private _disableLighting;
  81849. disableLighting: boolean;
  81850. private _maxSimultaneousLights;
  81851. maxSimultaneousLights: number;
  81852. /**
  81853. * @param {number}: Represents the wind force
  81854. */
  81855. windForce: number;
  81856. /**
  81857. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  81858. */
  81859. windDirection: BABYLON.Vector2;
  81860. /**
  81861. * @param {number}: Wave height, represents the height of the waves
  81862. */
  81863. waveHeight: number;
  81864. /**
  81865. * @param {number}: Bump height, represents the bump height related to the bump map
  81866. */
  81867. bumpHeight: number;
  81868. /**
  81869. * @param {boolean}: Add a smaller moving bump to less steady waves.
  81870. */
  81871. private _bumpSuperimpose;
  81872. bumpSuperimpose: boolean;
  81873. /**
  81874. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  81875. */
  81876. private _fresnelSeparate;
  81877. fresnelSeparate: boolean;
  81878. /**
  81879. * @param {boolean}: bump Waves modify the reflection.
  81880. */
  81881. private _bumpAffectsReflection;
  81882. bumpAffectsReflection: boolean;
  81883. /**
  81884. * @param {number}: The water color blended with the refraction (near)
  81885. */
  81886. waterColor: BABYLON.Color3;
  81887. /**
  81888. * @param {number}: The blend factor related to the water color
  81889. */
  81890. colorBlendFactor: number;
  81891. /**
  81892. * @param {number}: The water color blended with the reflection (far)
  81893. */
  81894. waterColor2: BABYLON.Color3;
  81895. /**
  81896. * @param {number}: The blend factor related to the water color (reflection, far)
  81897. */
  81898. colorBlendFactor2: number;
  81899. /**
  81900. * @param {number}: Represents the maximum length of a wave
  81901. */
  81902. waveLength: number;
  81903. /**
  81904. * @param {number}: Defines the waves speed
  81905. */
  81906. waveSpeed: number;
  81907. /**
  81908. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  81909. * will avoid calculating useless pixels in the pixel shader of the water material.
  81910. */
  81911. disableClipPlane: boolean;
  81912. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  81913. private _mesh;
  81914. private _refractionRTT;
  81915. private _reflectionRTT;
  81916. private _reflectionTransform;
  81917. private _lastTime;
  81918. private _lastDeltaTime;
  81919. private _useLogarithmicDepth;
  81920. private _waitingRenderList;
  81921. private _imageProcessingConfiguration;
  81922. private _imageProcessingObserver;
  81923. /**
  81924. * Gets a boolean indicating that current material needs to register RTT
  81925. */
  81926. get hasRenderTargetTextures(): boolean;
  81927. /**
  81928. * Constructor
  81929. */
  81930. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  81931. get useLogarithmicDepth(): boolean;
  81932. set useLogarithmicDepth(value: boolean);
  81933. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  81934. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  81935. addToRenderList(node: any): void;
  81936. enableRenderTargets(enable: boolean): void;
  81937. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  81938. get renderTargetsEnabled(): boolean;
  81939. needAlphaBlending(): boolean;
  81940. needAlphaTesting(): boolean;
  81941. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81942. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81943. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81944. private _createRenderTargets;
  81945. getAnimatables(): BABYLON.IAnimatable[];
  81946. getActiveTextures(): BABYLON.BaseTexture[];
  81947. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81948. dispose(forceDisposeEffect?: boolean): void;
  81949. clone(name: string): WaterMaterial;
  81950. serialize(): any;
  81951. getClassName(): string;
  81952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  81953. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  81954. }
  81955. }
  81956. declare module BABYLON {
  81957. /** @hidden */
  81958. export var asciiartPixelShader: {
  81959. name: string;
  81960. shader: string;
  81961. };
  81962. }
  81963. declare module BABYLON {
  81964. /**
  81965. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  81966. *
  81967. * It basically takes care rendering the font front the given font size to a texture.
  81968. * This is used later on in the postprocess.
  81969. */
  81970. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  81971. private _font;
  81972. private _text;
  81973. private _charSize;
  81974. /**
  81975. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  81976. */
  81977. get charSize(): number;
  81978. /**
  81979. * Create a new instance of the Ascii Art FontTexture class
  81980. * @param name the name of the texture
  81981. * @param font the font to use, use the W3C CSS notation
  81982. * @param text the caracter set to use in the rendering.
  81983. * @param scene the scene that owns the texture
  81984. */
  81985. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  81986. /**
  81987. * Gets the max char width of a font.
  81988. * @param font the font to use, use the W3C CSS notation
  81989. * @return the max char width
  81990. */
  81991. private getFontWidth;
  81992. /**
  81993. * Gets the max char height of a font.
  81994. * @param font the font to use, use the W3C CSS notation
  81995. * @return the max char height
  81996. */
  81997. private getFontHeight;
  81998. /**
  81999. * Clones the current AsciiArtTexture.
  82000. * @return the clone of the texture.
  82001. */
  82002. clone(): AsciiArtFontTexture;
  82003. /**
  82004. * Parses a json object representing the texture and returns an instance of it.
  82005. * @param source the source JSON representation
  82006. * @param scene the scene to create the texture for
  82007. * @return the parsed texture
  82008. */
  82009. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  82010. }
  82011. /**
  82012. * Option available in the Ascii Art Post Process.
  82013. */
  82014. export interface IAsciiArtPostProcessOptions {
  82015. /**
  82016. * The font to use following the w3c font definition.
  82017. */
  82018. font?: string;
  82019. /**
  82020. * The character set to use in the postprocess.
  82021. */
  82022. characterSet?: string;
  82023. /**
  82024. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82025. * This number is defined between 0 and 1;
  82026. */
  82027. mixToTile?: number;
  82028. /**
  82029. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82030. * This number is defined between 0 and 1;
  82031. */
  82032. mixToNormal?: number;
  82033. }
  82034. /**
  82035. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  82036. *
  82037. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82038. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  82039. */
  82040. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  82041. /**
  82042. * The font texture used to render the char in the post process.
  82043. */
  82044. private _asciiArtFontTexture;
  82045. /**
  82046. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82047. * This number is defined between 0 and 1;
  82048. */
  82049. mixToTile: number;
  82050. /**
  82051. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82052. * This number is defined between 0 and 1;
  82053. */
  82054. mixToNormal: number;
  82055. /**
  82056. * Instantiates a new Ascii Art Post Process.
  82057. * @param name the name to give to the postprocess
  82058. * @camera the camera to apply the post process to.
  82059. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  82060. */
  82061. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  82062. }
  82063. }
  82064. declare module BABYLON {
  82065. /** @hidden */
  82066. export var digitalrainPixelShader: {
  82067. name: string;
  82068. shader: string;
  82069. };
  82070. }
  82071. declare module BABYLON {
  82072. /**
  82073. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  82074. *
  82075. * It basically takes care rendering the font front the given font size to a texture.
  82076. * This is used later on in the postprocess.
  82077. */
  82078. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  82079. private _font;
  82080. private _text;
  82081. private _charSize;
  82082. /**
  82083. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82084. */
  82085. get charSize(): number;
  82086. /**
  82087. * Create a new instance of the Digital Rain FontTexture class
  82088. * @param name the name of the texture
  82089. * @param font the font to use, use the W3C CSS notation
  82090. * @param text the caracter set to use in the rendering.
  82091. * @param scene the scene that owns the texture
  82092. */
  82093. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82094. /**
  82095. * Gets the max char width of a font.
  82096. * @param font the font to use, use the W3C CSS notation
  82097. * @return the max char width
  82098. */
  82099. private getFontWidth;
  82100. /**
  82101. * Gets the max char height of a font.
  82102. * @param font the font to use, use the W3C CSS notation
  82103. * @return the max char height
  82104. */
  82105. private getFontHeight;
  82106. /**
  82107. * Clones the current DigitalRainFontTexture.
  82108. * @return the clone of the texture.
  82109. */
  82110. clone(): DigitalRainFontTexture;
  82111. /**
  82112. * Parses a json object representing the texture and returns an instance of it.
  82113. * @param source the source JSON representation
  82114. * @param scene the scene to create the texture for
  82115. * @return the parsed texture
  82116. */
  82117. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  82118. }
  82119. /**
  82120. * Option available in the Digital Rain Post Process.
  82121. */
  82122. export interface IDigitalRainPostProcessOptions {
  82123. /**
  82124. * The font to use following the w3c font definition.
  82125. */
  82126. font?: string;
  82127. /**
  82128. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82129. * This number is defined between 0 and 1;
  82130. */
  82131. mixToTile?: number;
  82132. /**
  82133. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82134. * This number is defined between 0 and 1;
  82135. */
  82136. mixToNormal?: number;
  82137. }
  82138. /**
  82139. * DigitalRainPostProcess helps rendering everithing in digital rain.
  82140. *
  82141. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82142. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  82143. */
  82144. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  82145. /**
  82146. * The font texture used to render the char in the post process.
  82147. */
  82148. private _digitalRainFontTexture;
  82149. /**
  82150. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82151. * This number is defined between 0 and 1;
  82152. */
  82153. mixToTile: number;
  82154. /**
  82155. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82156. * This number is defined between 0 and 1;
  82157. */
  82158. mixToNormal: number;
  82159. /**
  82160. * Instantiates a new Digital Rain Post Process.
  82161. * @param name the name to give to the postprocess
  82162. * @camera the camera to apply the post process to.
  82163. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  82164. */
  82165. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  82166. }
  82167. }
  82168. declare module BABYLON {
  82169. /** @hidden */
  82170. export var brickProceduralTexturePixelShader: {
  82171. name: string;
  82172. shader: string;
  82173. };
  82174. }
  82175. declare module BABYLON {
  82176. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  82177. private _numberOfBricksHeight;
  82178. private _numberOfBricksWidth;
  82179. private _jointColor;
  82180. private _brickColor;
  82181. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82182. updateShaderUniforms(): void;
  82183. get numberOfBricksHeight(): number;
  82184. set numberOfBricksHeight(value: number);
  82185. get numberOfBricksWidth(): number;
  82186. set numberOfBricksWidth(value: number);
  82187. get jointColor(): BABYLON.Color3;
  82188. set jointColor(value: BABYLON.Color3);
  82189. get brickColor(): BABYLON.Color3;
  82190. set brickColor(value: BABYLON.Color3);
  82191. /**
  82192. * Serializes this brick procedural texture
  82193. * @returns a serialized brick procedural texture object
  82194. */
  82195. serialize(): any;
  82196. /**
  82197. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  82198. * @param parsedTexture defines parsed texture data
  82199. * @param scene defines the current scene
  82200. * @param rootUrl defines the root URL containing brick procedural texture information
  82201. * @returns a parsed Brick Procedural BABYLON.Texture
  82202. */
  82203. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  82204. }
  82205. }
  82206. declare module BABYLON {
  82207. /** @hidden */
  82208. export var cloudProceduralTexturePixelShader: {
  82209. name: string;
  82210. shader: string;
  82211. };
  82212. }
  82213. declare module BABYLON {
  82214. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  82215. private _skyColor;
  82216. private _cloudColor;
  82217. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82218. updateShaderUniforms(): void;
  82219. get skyColor(): BABYLON.Color4;
  82220. set skyColor(value: BABYLON.Color4);
  82221. get cloudColor(): BABYLON.Color4;
  82222. set cloudColor(value: BABYLON.Color4);
  82223. /**
  82224. * Serializes this cloud procedural texture
  82225. * @returns a serialized cloud procedural texture object
  82226. */
  82227. serialize(): any;
  82228. /**
  82229. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  82230. * @param parsedTexture defines parsed texture data
  82231. * @param scene defines the current scene
  82232. * @param rootUrl defines the root URL containing cloud procedural texture information
  82233. * @returns a parsed Cloud Procedural BABYLON.Texture
  82234. */
  82235. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  82236. }
  82237. }
  82238. declare module BABYLON {
  82239. /** @hidden */
  82240. export var fireProceduralTexturePixelShader: {
  82241. name: string;
  82242. shader: string;
  82243. };
  82244. }
  82245. declare module BABYLON {
  82246. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  82247. private _time;
  82248. private _speed;
  82249. private _autoGenerateTime;
  82250. private _fireColors;
  82251. private _alphaThreshold;
  82252. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82253. updateShaderUniforms(): void;
  82254. render(useCameraPostProcess?: boolean): void;
  82255. static get PurpleFireColors(): BABYLON.Color3[];
  82256. static get GreenFireColors(): BABYLON.Color3[];
  82257. static get RedFireColors(): BABYLON.Color3[];
  82258. static get BlueFireColors(): BABYLON.Color3[];
  82259. get autoGenerateTime(): boolean;
  82260. set autoGenerateTime(value: boolean);
  82261. get fireColors(): BABYLON.Color3[];
  82262. set fireColors(value: BABYLON.Color3[]);
  82263. get time(): number;
  82264. set time(value: number);
  82265. get speed(): BABYLON.Vector2;
  82266. set speed(value: BABYLON.Vector2);
  82267. get alphaThreshold(): number;
  82268. set alphaThreshold(value: number);
  82269. /**
  82270. * Serializes this fire procedural texture
  82271. * @returns a serialized fire procedural texture object
  82272. */
  82273. serialize(): any;
  82274. /**
  82275. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  82276. * @param parsedTexture defines parsed texture data
  82277. * @param scene defines the current scene
  82278. * @param rootUrl defines the root URL containing fire procedural texture information
  82279. * @returns a parsed Fire Procedural BABYLON.Texture
  82280. */
  82281. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  82282. }
  82283. }
  82284. declare module BABYLON {
  82285. /** @hidden */
  82286. export var grassProceduralTexturePixelShader: {
  82287. name: string;
  82288. shader: string;
  82289. };
  82290. }
  82291. declare module BABYLON {
  82292. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  82293. private _grassColors;
  82294. private _groundColor;
  82295. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82296. updateShaderUniforms(): void;
  82297. get grassColors(): BABYLON.Color3[];
  82298. set grassColors(value: BABYLON.Color3[]);
  82299. get groundColor(): BABYLON.Color3;
  82300. set groundColor(value: BABYLON.Color3);
  82301. /**
  82302. * Serializes this grass procedural texture
  82303. * @returns a serialized grass procedural texture object
  82304. */
  82305. serialize(): any;
  82306. /**
  82307. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  82308. * @param parsedTexture defines parsed texture data
  82309. * @param scene defines the current scene
  82310. * @param rootUrl defines the root URL containing grass procedural texture information
  82311. * @returns a parsed Grass Procedural BABYLON.Texture
  82312. */
  82313. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  82314. }
  82315. }
  82316. declare module BABYLON {
  82317. /** @hidden */
  82318. export var marbleProceduralTexturePixelShader: {
  82319. name: string;
  82320. shader: string;
  82321. };
  82322. }
  82323. declare module BABYLON {
  82324. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  82325. private _numberOfTilesHeight;
  82326. private _numberOfTilesWidth;
  82327. private _amplitude;
  82328. private _jointColor;
  82329. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82330. updateShaderUniforms(): void;
  82331. get numberOfTilesHeight(): number;
  82332. set numberOfTilesHeight(value: number);
  82333. get amplitude(): number;
  82334. set amplitude(value: number);
  82335. get numberOfTilesWidth(): number;
  82336. set numberOfTilesWidth(value: number);
  82337. get jointColor(): BABYLON.Color3;
  82338. set jointColor(value: BABYLON.Color3);
  82339. /**
  82340. * Serializes this marble procedural texture
  82341. * @returns a serialized marble procedural texture object
  82342. */
  82343. serialize(): any;
  82344. /**
  82345. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  82346. * @param parsedTexture defines parsed texture data
  82347. * @param scene defines the current scene
  82348. * @param rootUrl defines the root URL containing marble procedural texture information
  82349. * @returns a parsed Marble Procedural BABYLON.Texture
  82350. */
  82351. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  82352. }
  82353. }
  82354. declare module BABYLON {
  82355. /** @hidden */
  82356. export var normalMapProceduralTexturePixelShader: {
  82357. name: string;
  82358. shader: string;
  82359. };
  82360. }
  82361. declare module BABYLON {
  82362. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  82363. private _baseTexture;
  82364. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82365. updateShaderUniforms(): void;
  82366. render(useCameraPostProcess?: boolean): void;
  82367. resize(size: any, generateMipMaps: any): void;
  82368. get baseTexture(): BABYLON.Texture;
  82369. set baseTexture(texture: BABYLON.Texture);
  82370. /**
  82371. * Serializes this normal map procedural texture
  82372. * @returns a serialized normal map procedural texture object
  82373. */
  82374. serialize(): any;
  82375. /**
  82376. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  82377. * @param parsedTexture defines parsed texture data
  82378. * @param scene defines the current scene
  82379. * @param rootUrl defines the root URL containing normal map procedural texture information
  82380. * @returns a parsed Normal Map Procedural BABYLON.Texture
  82381. */
  82382. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  82383. }
  82384. }
  82385. declare module BABYLON {
  82386. /** @hidden */
  82387. export var perlinNoiseProceduralTexturePixelShader: {
  82388. name: string;
  82389. shader: string;
  82390. };
  82391. }
  82392. declare module BABYLON {
  82393. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  82394. time: number;
  82395. timeScale: number;
  82396. translationSpeed: number;
  82397. private _currentTranslation;
  82398. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82399. updateShaderUniforms(): void;
  82400. render(useCameraPostProcess?: boolean): void;
  82401. resize(size: any, generateMipMaps: any): void;
  82402. /**
  82403. * Serializes this perlin noise procedural texture
  82404. * @returns a serialized perlin noise procedural texture object
  82405. */
  82406. serialize(): any;
  82407. /**
  82408. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  82409. * @param parsedTexture defines parsed texture data
  82410. * @param scene defines the current scene
  82411. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  82412. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  82413. */
  82414. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  82415. }
  82416. }
  82417. declare module BABYLON {
  82418. /** @hidden */
  82419. export var roadProceduralTexturePixelShader: {
  82420. name: string;
  82421. shader: string;
  82422. };
  82423. }
  82424. declare module BABYLON {
  82425. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  82426. private _roadColor;
  82427. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82428. updateShaderUniforms(): void;
  82429. get roadColor(): BABYLON.Color3;
  82430. set roadColor(value: BABYLON.Color3);
  82431. /**
  82432. * Serializes this road procedural texture
  82433. * @returns a serialized road procedural texture object
  82434. */
  82435. serialize(): any;
  82436. /**
  82437. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  82438. * @param parsedTexture defines parsed texture data
  82439. * @param scene defines the current scene
  82440. * @param rootUrl defines the root URL containing road procedural texture information
  82441. * @returns a parsed Road Procedural BABYLON.Texture
  82442. */
  82443. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  82444. }
  82445. }
  82446. declare module BABYLON {
  82447. /** @hidden */
  82448. export var starfieldProceduralTexturePixelShader: {
  82449. name: string;
  82450. shader: string;
  82451. };
  82452. }
  82453. declare module BABYLON {
  82454. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  82455. private _time;
  82456. private _alpha;
  82457. private _beta;
  82458. private _zoom;
  82459. private _formuparam;
  82460. private _stepsize;
  82461. private _tile;
  82462. private _brightness;
  82463. private _darkmatter;
  82464. private _distfading;
  82465. private _saturation;
  82466. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82467. updateShaderUniforms(): void;
  82468. get time(): number;
  82469. set time(value: number);
  82470. get alpha(): number;
  82471. set alpha(value: number);
  82472. get beta(): number;
  82473. set beta(value: number);
  82474. get formuparam(): number;
  82475. set formuparam(value: number);
  82476. get stepsize(): number;
  82477. set stepsize(value: number);
  82478. get zoom(): number;
  82479. set zoom(value: number);
  82480. get tile(): number;
  82481. set tile(value: number);
  82482. get brightness(): number;
  82483. set brightness(value: number);
  82484. get darkmatter(): number;
  82485. set darkmatter(value: number);
  82486. get distfading(): number;
  82487. set distfading(value: number);
  82488. get saturation(): number;
  82489. set saturation(value: number);
  82490. /**
  82491. * Serializes this starfield procedural texture
  82492. * @returns a serialized starfield procedural texture object
  82493. */
  82494. serialize(): any;
  82495. /**
  82496. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  82497. * @param parsedTexture defines parsed texture data
  82498. * @param scene defines the current scene
  82499. * @param rootUrl defines the root URL containing startfield procedural texture information
  82500. * @returns a parsed Starfield Procedural BABYLON.Texture
  82501. */
  82502. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  82503. }
  82504. }
  82505. declare module BABYLON {
  82506. /** @hidden */
  82507. export var woodProceduralTexturePixelShader: {
  82508. name: string;
  82509. shader: string;
  82510. };
  82511. }
  82512. declare module BABYLON {
  82513. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  82514. private _ampScale;
  82515. private _woodColor;
  82516. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82517. updateShaderUniforms(): void;
  82518. get ampScale(): number;
  82519. set ampScale(value: number);
  82520. get woodColor(): BABYLON.Color3;
  82521. set woodColor(value: BABYLON.Color3);
  82522. /**
  82523. * Serializes this wood procedural texture
  82524. * @returns a serialized wood procedural texture object
  82525. */
  82526. serialize(): any;
  82527. /**
  82528. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  82529. * @param parsedTexture defines parsed texture data
  82530. * @param scene defines the current scene
  82531. * @param rootUrl defines the root URL containing wood procedural texture information
  82532. * @returns a parsed Wood Procedural BABYLON.Texture
  82533. */
  82534. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  82535. }
  82536. }