documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695
  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. private _engine;
  7749. /** @hidden */
  7750. _prefiltered: boolean;
  7751. /**
  7752. * Creates a cube texture from an array of image urls
  7753. * @param files defines an array of image urls
  7754. * @param scene defines the hosting scene
  7755. * @param noMipmap specifies if mip maps are not used
  7756. * @returns a cube texture
  7757. */
  7758. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7759. /**
  7760. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7761. * @param url defines the url of the prefiltered texture
  7762. * @param scene defines the scene the texture is attached to
  7763. * @param forcedExtension defines the extension of the file if different from the url
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @return the prefiltered texture
  7766. */
  7767. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7768. /**
  7769. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7770. * as prefiltered data.
  7771. * @param rootUrl defines the url of the texture or the root name of the six images
  7772. * @param scene defines the scene the texture is attached to
  7773. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7774. * @param noMipmap defines if mipmaps should be created or not
  7775. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7776. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7777. * @param onError defines a callback triggered in case of error during load
  7778. * @param format defines the internal format to use for the texture once loaded
  7779. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7780. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7781. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7782. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7783. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7784. * @return the cube texture
  7785. */
  7786. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7787. /**
  7788. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7789. */
  7790. get isPrefiltered(): boolean;
  7791. /**
  7792. * Get the current class name of the texture useful for serialization or dynamic coding.
  7793. * @returns "CubeTexture"
  7794. */
  7795. getClassName(): string;
  7796. /**
  7797. * Update the url (and optional buffer) of this texture if url was null during construction.
  7798. * @param url the url of the texture
  7799. * @param forcedExtension defines the extension to use
  7800. * @param onLoad callback called when the texture is loaded (defaults to null)
  7801. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. private static _isScene;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * 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).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * 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.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * 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.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * 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.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * 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.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * 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.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * 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.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * 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).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * 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).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * 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.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * 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.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * 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.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * 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.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * 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).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * 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).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * 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.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * 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.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * 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.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * 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.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /** Defines supported spaces */
  8519. export enum Space {
  8520. /** Local (object) space */
  8521. LOCAL = 0,
  8522. /** World space */
  8523. WORLD = 1,
  8524. /** Bone space */
  8525. BONE = 2
  8526. }
  8527. /** Defines the 3 main axes */
  8528. export class Axis {
  8529. /** X axis */
  8530. static X: Vector3;
  8531. /** Y axis */
  8532. static Y: Vector3;
  8533. /** Z axis */
  8534. static Z: Vector3;
  8535. }
  8536. }
  8537. declare module BABYLON {
  8538. /**
  8539. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8540. * This is the base of the follow, arc rotate cameras and Free camera
  8541. * @see http://doc.babylonjs.com/features/cameras
  8542. */
  8543. export class TargetCamera extends Camera {
  8544. private static _RigCamTransformMatrix;
  8545. private static _TargetTransformMatrix;
  8546. private static _TargetFocalPoint;
  8547. /**
  8548. * Define the current direction the camera is moving to
  8549. */
  8550. cameraDirection: Vector3;
  8551. /**
  8552. * Define the current rotation the camera is rotating to
  8553. */
  8554. cameraRotation: Vector2;
  8555. /**
  8556. * When set, the up vector of the camera will be updated by the rotation of the camera
  8557. */
  8558. updateUpVectorFromRotation: boolean;
  8559. private _tmpQuaternion;
  8560. /**
  8561. * Define the current rotation of the camera
  8562. */
  8563. rotation: Vector3;
  8564. /**
  8565. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8566. */
  8567. rotationQuaternion: Quaternion;
  8568. /**
  8569. * Define the current speed of the camera
  8570. */
  8571. speed: number;
  8572. /**
  8573. * Add constraint to the camera to prevent it to move freely in all directions and
  8574. * around all axis.
  8575. */
  8576. noRotationConstraint: boolean;
  8577. /**
  8578. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8579. * panning
  8580. */
  8581. invertRotation: boolean;
  8582. /**
  8583. * Speed multiplier for inverse camera panning
  8584. */
  8585. inverseRotationSpeed: number;
  8586. /**
  8587. * Define the current target of the camera as an object or a position.
  8588. */
  8589. lockedTarget: any;
  8590. /** @hidden */
  8591. _currentTarget: Vector3;
  8592. /** @hidden */
  8593. _initialFocalDistance: number;
  8594. /** @hidden */
  8595. _viewMatrix: Matrix;
  8596. /** @hidden */
  8597. _camMatrix: Matrix;
  8598. /** @hidden */
  8599. _cameraTransformMatrix: Matrix;
  8600. /** @hidden */
  8601. _cameraRotationMatrix: Matrix;
  8602. /** @hidden */
  8603. _referencePoint: Vector3;
  8604. /** @hidden */
  8605. _transformedReferencePoint: Vector3;
  8606. protected _globalCurrentTarget: Vector3;
  8607. protected _globalCurrentUpVector: Vector3;
  8608. /** @hidden */
  8609. _reset: () => void;
  8610. private _defaultUp;
  8611. /**
  8612. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8613. * This is the base of the follow, arc rotate cameras and Free camera
  8614. * @see http://doc.babylonjs.com/features/cameras
  8615. * @param name Defines the name of the camera in the scene
  8616. * @param position Defines the start position of the camera in the scene
  8617. * @param scene Defines the scene the camera belongs to
  8618. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8619. */
  8620. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8621. /**
  8622. * Gets the position in front of the camera at a given distance.
  8623. * @param distance The distance from the camera we want the position to be
  8624. * @returns the position
  8625. */
  8626. getFrontPosition(distance: number): Vector3;
  8627. /** @hidden */
  8628. _getLockedTargetPosition(): Nullable<Vector3>;
  8629. private _storedPosition;
  8630. private _storedRotation;
  8631. private _storedRotationQuaternion;
  8632. /**
  8633. * Store current camera state of the camera (fov, position, rotation, etc..)
  8634. * @returns the camera
  8635. */
  8636. storeState(): Camera;
  8637. /**
  8638. * Restored camera state. You must call storeState() first
  8639. * @returns whether it was successful or not
  8640. * @hidden
  8641. */
  8642. _restoreStateValues(): boolean;
  8643. /** @hidden */
  8644. _initCache(): void;
  8645. /** @hidden */
  8646. _updateCache(ignoreParentClass?: boolean): void;
  8647. /** @hidden */
  8648. _isSynchronizedViewMatrix(): boolean;
  8649. /** @hidden */
  8650. _computeLocalCameraSpeed(): number;
  8651. /**
  8652. * Defines the target the camera should look at.
  8653. * @param target Defines the new target as a Vector or a mesh
  8654. */
  8655. setTarget(target: Vector3): void;
  8656. /**
  8657. * Return the current target position of the camera. This value is expressed in local space.
  8658. * @returns the target position
  8659. */
  8660. getTarget(): Vector3;
  8661. /** @hidden */
  8662. _decideIfNeedsToMove(): boolean;
  8663. /** @hidden */
  8664. _updatePosition(): void;
  8665. /** @hidden */
  8666. _checkInputs(): void;
  8667. protected _updateCameraRotationMatrix(): void;
  8668. /**
  8669. * 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)
  8670. * @returns the current camera
  8671. */
  8672. private _rotateUpVectorWithCameraRotationMatrix;
  8673. private _cachedRotationZ;
  8674. private _cachedQuaternionRotationZ;
  8675. /** @hidden */
  8676. _getViewMatrix(): Matrix;
  8677. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8678. /**
  8679. * @hidden
  8680. */
  8681. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8682. /**
  8683. * @hidden
  8684. */
  8685. _updateRigCameras(): void;
  8686. private _getRigCamPositionAndTarget;
  8687. /**
  8688. * Gets the current object class name.
  8689. * @return the class name
  8690. */
  8691. getClassName(): string;
  8692. }
  8693. }
  8694. declare module BABYLON {
  8695. /**
  8696. * Gather the list of keyboard event types as constants.
  8697. */
  8698. export class KeyboardEventTypes {
  8699. /**
  8700. * The keydown event is fired when a key becomes active (pressed).
  8701. */
  8702. static readonly KEYDOWN: number;
  8703. /**
  8704. * The keyup event is fired when a key has been released.
  8705. */
  8706. static readonly KEYUP: number;
  8707. }
  8708. /**
  8709. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8710. */
  8711. export class KeyboardInfo {
  8712. /**
  8713. * Defines the type of event (KeyboardEventTypes)
  8714. */
  8715. type: number;
  8716. /**
  8717. * Defines the related dom event
  8718. */
  8719. event: KeyboardEvent;
  8720. /**
  8721. * Instantiates a new keyboard info.
  8722. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8723. * @param type Defines the type of event (KeyboardEventTypes)
  8724. * @param event Defines the related dom event
  8725. */
  8726. constructor(
  8727. /**
  8728. * Defines the type of event (KeyboardEventTypes)
  8729. */
  8730. type: number,
  8731. /**
  8732. * Defines the related dom event
  8733. */
  8734. event: KeyboardEvent);
  8735. }
  8736. /**
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8739. */
  8740. export class KeyboardInfoPre extends KeyboardInfo {
  8741. /**
  8742. * Defines the type of event (KeyboardEventTypes)
  8743. */
  8744. type: number;
  8745. /**
  8746. * Defines the related dom event
  8747. */
  8748. event: KeyboardEvent;
  8749. /**
  8750. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8751. */
  8752. skipOnPointerObservable: boolean;
  8753. /**
  8754. * Instantiates a new keyboard pre info.
  8755. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8756. * @param type Defines the type of event (KeyboardEventTypes)
  8757. * @param event Defines the related dom event
  8758. */
  8759. constructor(
  8760. /**
  8761. * Defines the type of event (KeyboardEventTypes)
  8762. */
  8763. type: number,
  8764. /**
  8765. * Defines the related dom event
  8766. */
  8767. event: KeyboardEvent);
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /**
  8772. * Manage the keyboard inputs to control the movement of a free camera.
  8773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8774. */
  8775. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8776. /**
  8777. * Defines the camera the input is attached to.
  8778. */
  8779. camera: FreeCamera;
  8780. /**
  8781. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8782. */
  8783. keysUp: number[];
  8784. /**
  8785. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8786. */
  8787. keysUpward: number[];
  8788. /**
  8789. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8790. */
  8791. keysDown: number[];
  8792. /**
  8793. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8794. */
  8795. keysDownward: number[];
  8796. /**
  8797. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8798. */
  8799. keysLeft: number[];
  8800. /**
  8801. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8802. */
  8803. keysRight: number[];
  8804. private _keys;
  8805. private _onCanvasBlurObserver;
  8806. private _onKeyboardObserver;
  8807. private _engine;
  8808. private _scene;
  8809. /**
  8810. * Attach the input controls to a specific dom element to get the input from.
  8811. * @param element Defines the element the controls should be listened from
  8812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8813. */
  8814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8815. /**
  8816. * Detach the current controls from the specified dom element.
  8817. * @param element Defines the element to stop listening the inputs from
  8818. */
  8819. detachControl(element: Nullable<HTMLElement>): void;
  8820. /**
  8821. * Update the current camera state depending on the inputs that have been used this frame.
  8822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8823. */
  8824. checkInputs(): void;
  8825. /**
  8826. * Gets the class name of the current intput.
  8827. * @returns the class name
  8828. */
  8829. getClassName(): string;
  8830. /** @hidden */
  8831. _onLostFocus(): void;
  8832. /**
  8833. * Get the friendly name associated with the input class.
  8834. * @returns the input friendly name
  8835. */
  8836. getSimpleName(): string;
  8837. }
  8838. }
  8839. declare module BABYLON {
  8840. /**
  8841. * Interface describing all the common properties and methods a shadow light needs to implement.
  8842. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8843. * as well as binding the different shadow properties to the effects.
  8844. */
  8845. export interface IShadowLight extends Light {
  8846. /**
  8847. * The light id in the scene (used in scene.findLighById for instance)
  8848. */
  8849. id: string;
  8850. /**
  8851. * The position the shdow will be casted from.
  8852. */
  8853. position: Vector3;
  8854. /**
  8855. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8856. */
  8857. direction: Vector3;
  8858. /**
  8859. * The transformed position. Position of the light in world space taking parenting in account.
  8860. */
  8861. transformedPosition: Vector3;
  8862. /**
  8863. * The transformed direction. Direction of the light in world space taking parenting in account.
  8864. */
  8865. transformedDirection: Vector3;
  8866. /**
  8867. * The friendly name of the light in the scene.
  8868. */
  8869. name: string;
  8870. /**
  8871. * Defines the shadow projection clipping minimum z value.
  8872. */
  8873. shadowMinZ: number;
  8874. /**
  8875. * Defines the shadow projection clipping maximum z value.
  8876. */
  8877. shadowMaxZ: number;
  8878. /**
  8879. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8880. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8881. */
  8882. computeTransformedInformation(): boolean;
  8883. /**
  8884. * Gets the scene the light belongs to.
  8885. * @returns The scene
  8886. */
  8887. getScene(): Scene;
  8888. /**
  8889. * Callback defining a custom Projection Matrix Builder.
  8890. * This can be used to override the default projection matrix computation.
  8891. */
  8892. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8893. /**
  8894. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8895. * @param matrix The materix to updated with the projection information
  8896. * @param viewMatrix The transform matrix of the light
  8897. * @param renderList The list of mesh to render in the map
  8898. * @returns The current light
  8899. */
  8900. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8901. /**
  8902. * Gets the current depth scale used in ESM.
  8903. * @returns The scale
  8904. */
  8905. getDepthScale(): number;
  8906. /**
  8907. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8908. * @returns true if a cube texture needs to be use
  8909. */
  8910. needCube(): boolean;
  8911. /**
  8912. * Detects if the projection matrix requires to be recomputed this frame.
  8913. * @returns true if it requires to be recomputed otherwise, false.
  8914. */
  8915. needProjectionMatrixCompute(): boolean;
  8916. /**
  8917. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8918. */
  8919. forceProjectionMatrixCompute(): void;
  8920. /**
  8921. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8922. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8923. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8924. */
  8925. getShadowDirection(faceIndex?: number): Vector3;
  8926. /**
  8927. * Gets the minZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the min for
  8929. * @returns the depth min z
  8930. */
  8931. getDepthMinZ(activeCamera: Camera): number;
  8932. /**
  8933. * Gets the maxZ used for shadow according to both the scene and the light.
  8934. * @param activeCamera The camera we are returning the max for
  8935. * @returns the depth max z
  8936. */
  8937. getDepthMaxZ(activeCamera: Camera): number;
  8938. }
  8939. /**
  8940. * Base implementation IShadowLight
  8941. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8942. */
  8943. export abstract class ShadowLight extends Light implements IShadowLight {
  8944. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8945. protected _position: Vector3;
  8946. protected _setPosition(value: Vector3): void;
  8947. /**
  8948. * Sets the position the shadow will be casted from. Also use as the light position for both
  8949. * point and spot lights.
  8950. */
  8951. get position(): Vector3;
  8952. /**
  8953. * Sets the position the shadow will be casted from. Also use as the light position for both
  8954. * point and spot lights.
  8955. */
  8956. set position(value: Vector3);
  8957. protected _direction: Vector3;
  8958. protected _setDirection(value: Vector3): void;
  8959. /**
  8960. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8961. * Also use as the light direction on spot and directional lights.
  8962. */
  8963. get direction(): Vector3;
  8964. /**
  8965. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8966. * Also use as the light direction on spot and directional lights.
  8967. */
  8968. set direction(value: Vector3);
  8969. protected _shadowMinZ: number;
  8970. /**
  8971. * Gets the shadow projection clipping minimum z value.
  8972. */
  8973. get shadowMinZ(): number;
  8974. /**
  8975. * Sets the shadow projection clipping minimum z value.
  8976. */
  8977. set shadowMinZ(value: number);
  8978. protected _shadowMaxZ: number;
  8979. /**
  8980. * Sets the shadow projection clipping maximum z value.
  8981. */
  8982. get shadowMaxZ(): number;
  8983. /**
  8984. * Gets the shadow projection clipping maximum z value.
  8985. */
  8986. set shadowMaxZ(value: number);
  8987. /**
  8988. * Callback defining a custom Projection Matrix Builder.
  8989. * This can be used to override the default projection matrix computation.
  8990. */
  8991. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8992. /**
  8993. * The transformed position. Position of the light in world space taking parenting in account.
  8994. */
  8995. transformedPosition: Vector3;
  8996. /**
  8997. * The transformed direction. Direction of the light in world space taking parenting in account.
  8998. */
  8999. transformedDirection: Vector3;
  9000. private _needProjectionMatrixCompute;
  9001. /**
  9002. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9003. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9004. */
  9005. computeTransformedInformation(): boolean;
  9006. /**
  9007. * Return the depth scale used for the shadow map.
  9008. * @returns the depth scale.
  9009. */
  9010. getDepthScale(): number;
  9011. /**
  9012. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9015. */
  9016. getShadowDirection(faceIndex?: number): Vector3;
  9017. /**
  9018. * Returns the ShadowLight absolute position in the World.
  9019. * @returns the position vector in world space
  9020. */
  9021. getAbsolutePosition(): Vector3;
  9022. /**
  9023. * Sets the ShadowLight direction toward the passed target.
  9024. * @param target The point to target in local space
  9025. * @returns the updated ShadowLight direction
  9026. */
  9027. setDirectionToTarget(target: Vector3): Vector3;
  9028. /**
  9029. * Returns the light rotation in euler definition.
  9030. * @returns the x y z rotation in local space.
  9031. */
  9032. getRotation(): Vector3;
  9033. /**
  9034. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9035. * @returns true if a cube texture needs to be use
  9036. */
  9037. needCube(): boolean;
  9038. /**
  9039. * Detects if the projection matrix requires to be recomputed this frame.
  9040. * @returns true if it requires to be recomputed otherwise, false.
  9041. */
  9042. needProjectionMatrixCompute(): boolean;
  9043. /**
  9044. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9045. */
  9046. forceProjectionMatrixCompute(): void;
  9047. /** @hidden */
  9048. _initCache(): void;
  9049. /** @hidden */
  9050. _isSynchronized(): boolean;
  9051. /**
  9052. * Computes the world matrix of the node
  9053. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9054. * @returns the world matrix
  9055. */
  9056. computeWorldMatrix(force?: boolean): Matrix;
  9057. /**
  9058. * Gets the minZ used for shadow according to both the scene and the light.
  9059. * @param activeCamera The camera we are returning the min for
  9060. * @returns the depth min z
  9061. */
  9062. getDepthMinZ(activeCamera: Camera): number;
  9063. /**
  9064. * Gets the maxZ used for shadow according to both the scene and the light.
  9065. * @param activeCamera The camera we are returning the max for
  9066. * @returns the depth max z
  9067. */
  9068. getDepthMaxZ(activeCamera: Camera): number;
  9069. /**
  9070. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9071. * @param matrix The materix to updated with the projection information
  9072. * @param viewMatrix The transform matrix of the light
  9073. * @param renderList The list of mesh to render in the map
  9074. * @returns The current light
  9075. */
  9076. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9077. }
  9078. }
  9079. declare module BABYLON {
  9080. /**
  9081. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9082. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9083. */
  9084. export class EffectFallbacks implements IEffectFallbacks {
  9085. private _defines;
  9086. private _currentRank;
  9087. private _maxRank;
  9088. private _mesh;
  9089. /**
  9090. * Removes the fallback from the bound mesh.
  9091. */
  9092. unBindMesh(): void;
  9093. /**
  9094. * Adds a fallback on the specified property.
  9095. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9096. * @param define The name of the define in the shader
  9097. */
  9098. addFallback(rank: number, define: string): void;
  9099. /**
  9100. * Sets the mesh to use CPU skinning when needing to fallback.
  9101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9102. * @param mesh The mesh to use the fallbacks.
  9103. */
  9104. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9105. /**
  9106. * Checks to see if more fallbacks are still availible.
  9107. */
  9108. get hasMoreFallbacks(): boolean;
  9109. /**
  9110. * Removes the defines that should be removed when falling back.
  9111. * @param currentDefines defines the current define statements for the shader.
  9112. * @param effect defines the current effect we try to compile
  9113. * @returns The resulting defines with defines of the current rank removed.
  9114. */
  9115. reduce(currentDefines: string, effect: Effect): string;
  9116. }
  9117. }
  9118. declare module BABYLON {
  9119. /**
  9120. * "Static Class" containing the most commonly used helper while dealing with material for
  9121. * rendering purpose.
  9122. *
  9123. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9124. *
  9125. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9126. */
  9127. export class MaterialHelper {
  9128. /**
  9129. * Bind the current view position to an effect.
  9130. * @param effect The effect to be bound
  9131. * @param scene The scene the eyes position is used from
  9132. * @param variableName name of the shader variable that will hold the eye position
  9133. */
  9134. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9135. /**
  9136. * Helps preparing the defines values about the UVs in used in the effect.
  9137. * UVs are shared as much as we can accross channels in the shaders.
  9138. * @param texture The texture we are preparing the UVs for
  9139. * @param defines The defines to update
  9140. * @param key The channel key "diffuse", "specular"... used in the shader
  9141. */
  9142. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9143. /**
  9144. * Binds a texture matrix value to its corrsponding uniform
  9145. * @param texture The texture to bind the matrix for
  9146. * @param uniformBuffer The uniform buffer receivin the data
  9147. * @param key The channel key "diffuse", "specular"... used in the shader
  9148. */
  9149. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9150. /**
  9151. * Gets the current status of the fog (should it be enabled?)
  9152. * @param mesh defines the mesh to evaluate for fog support
  9153. * @param scene defines the hosting scene
  9154. * @returns true if fog must be enabled
  9155. */
  9156. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9157. /**
  9158. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9159. * @param mesh defines the current mesh
  9160. * @param scene defines the current scene
  9161. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9162. * @param pointsCloud defines if point cloud rendering has to be turned on
  9163. * @param fogEnabled defines if fog has to be turned on
  9164. * @param alphaTest defines if alpha testing has to be turned on
  9165. * @param defines defines the current list of defines
  9166. */
  9167. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9168. /**
  9169. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9170. * @param scene defines the current scene
  9171. * @param engine defines the current engine
  9172. * @param defines specifies the list of active defines
  9173. * @param useInstances defines if instances have to be turned on
  9174. * @param useClipPlane defines if clip plane have to be turned on
  9175. */
  9176. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9177. /**
  9178. * Prepares the defines for bones
  9179. * @param mesh The mesh containing the geometry data we will draw
  9180. * @param defines The defines to update
  9181. */
  9182. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9183. /**
  9184. * Prepares the defines for morph targets
  9185. * @param mesh The mesh containing the geometry data we will draw
  9186. * @param defines The defines to update
  9187. */
  9188. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9189. /**
  9190. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9191. * @param mesh The mesh containing the geometry data we will draw
  9192. * @param defines The defines to update
  9193. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9194. * @param useBones Precise whether bones should be used or not (override mesh info)
  9195. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9196. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9197. * @returns false if defines are considered not dirty and have not been checked
  9198. */
  9199. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9200. /**
  9201. * Prepares the defines related to multiview
  9202. * @param scene The scene we are intending to draw
  9203. * @param defines The defines to update
  9204. */
  9205. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9206. /**
  9207. * Prepares the defines related to the light information passed in parameter
  9208. * @param scene The scene we are intending to draw
  9209. * @param mesh The mesh the effect is compiling for
  9210. * @param light The light the effect is compiling for
  9211. * @param lightIndex The index of the light
  9212. * @param defines The defines to update
  9213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9214. * @param state Defines the current state regarding what is needed (normals, etc...)
  9215. */
  9216. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9217. needNormals: boolean;
  9218. needRebuild: boolean;
  9219. shadowEnabled: boolean;
  9220. specularEnabled: boolean;
  9221. lightmapMode: boolean;
  9222. }): void;
  9223. /**
  9224. * Prepares the defines related to the light information passed in parameter
  9225. * @param scene The scene we are intending to draw
  9226. * @param mesh The mesh the effect is compiling for
  9227. * @param defines The defines to update
  9228. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9229. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9230. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9231. * @returns true if normals will be required for the rest of the effect
  9232. */
  9233. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9234. /**
  9235. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9236. * @param lightIndex defines the light index
  9237. * @param uniformsList The uniform list
  9238. * @param samplersList The sampler list
  9239. * @param projectedLightTexture defines if projected texture must be used
  9240. * @param uniformBuffersList defines an optional list of uniform buffers
  9241. */
  9242. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9243. /**
  9244. * Prepares the uniforms and samplers list to be used in the effect
  9245. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9246. * @param samplersList The sampler list
  9247. * @param defines The defines helping in the list generation
  9248. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9249. */
  9250. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9251. /**
  9252. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9253. * @param defines The defines to update while falling back
  9254. * @param fallbacks The authorized effect fallbacks
  9255. * @param maxSimultaneousLights The maximum number of lights allowed
  9256. * @param rank the current rank of the Effect
  9257. * @returns The newly affected rank
  9258. */
  9259. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9260. private static _TmpMorphInfluencers;
  9261. /**
  9262. * Prepares the list of attributes required for morph targets according to the effect defines.
  9263. * @param attribs The current list of supported attribs
  9264. * @param mesh The mesh to prepare the morph targets attributes for
  9265. * @param influencers The number of influencers
  9266. */
  9267. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9268. /**
  9269. * Prepares the list of attributes required for morph targets according to the effect defines.
  9270. * @param attribs The current list of supported attribs
  9271. * @param mesh The mesh to prepare the morph targets attributes for
  9272. * @param defines The current Defines of the effect
  9273. */
  9274. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9275. /**
  9276. * Prepares the list of attributes required for bones according to the effect defines.
  9277. * @param attribs The current list of supported attribs
  9278. * @param mesh The mesh to prepare the bones attributes for
  9279. * @param defines The current Defines of the effect
  9280. * @param fallbacks The current efffect fallback strategy
  9281. */
  9282. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9283. /**
  9284. * Check and prepare the list of attributes required for instances according to the effect defines.
  9285. * @param attribs The current list of supported attribs
  9286. * @param defines The current MaterialDefines of the effect
  9287. */
  9288. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9289. /**
  9290. * Add the list of attributes required for instances to the attribs array.
  9291. * @param attribs The current list of supported attribs
  9292. */
  9293. static PushAttributesForInstances(attribs: string[]): void;
  9294. /**
  9295. * Binds the light information to the effect.
  9296. * @param light The light containing the generator
  9297. * @param effect The effect we are binding the data to
  9298. * @param lightIndex The light index in the effect used to render
  9299. */
  9300. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9301. /**
  9302. * Binds the lights information from the scene to the effect for the given mesh.
  9303. * @param light Light to bind
  9304. * @param lightIndex Light index
  9305. * @param scene The scene where the light belongs to
  9306. * @param effect The effect we are binding the data to
  9307. * @param useSpecular Defines if specular is supported
  9308. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9309. */
  9310. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9311. /**
  9312. * Binds the lights information from the scene to the effect for the given mesh.
  9313. * @param scene The scene the lights belongs to
  9314. * @param mesh The mesh we are binding the information to render
  9315. * @param effect The effect we are binding the data to
  9316. * @param defines The generated defines for the effect
  9317. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9318. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9319. */
  9320. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9321. private static _tempFogColor;
  9322. /**
  9323. * Binds the fog information from the scene to the effect for the given mesh.
  9324. * @param scene The scene the lights belongs to
  9325. * @param mesh The mesh we are binding the information to render
  9326. * @param effect The effect we are binding the data to
  9327. * @param linearSpace Defines if the fog effect is applied in linear space
  9328. */
  9329. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9330. /**
  9331. * Binds the bones information from the mesh to the effect.
  9332. * @param mesh The mesh we are binding the information to render
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9336. /**
  9337. * Binds the morph targets information from the mesh to the effect.
  9338. * @param abstractMesh The mesh we are binding the information to render
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9342. /**
  9343. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9344. * @param defines The generated defines used in the effect
  9345. * @param effect The effect we are binding the data to
  9346. * @param scene The scene we are willing to render with logarithmic scale for
  9347. */
  9348. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9349. /**
  9350. * Binds the clip plane information from the scene to the effect.
  9351. * @param scene The scene the clip plane information are extracted from
  9352. * @param effect The effect we are binding the data to
  9353. */
  9354. static BindClipPlane(effect: Effect, scene: Scene): void;
  9355. }
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var packingFunctions: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var bayerDitherFunctions: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var shadowMapFragmentDeclaration: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var clipPlaneFragmentDeclaration: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var clipPlaneFragment: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var shadowMapFragment: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var shadowMapPixelShader: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /** @hidden */
  9408. export var bonesDeclaration: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module BABYLON {
  9414. /** @hidden */
  9415. export var morphTargetsVertexGlobalDeclaration: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module BABYLON {
  9421. /** @hidden */
  9422. export var morphTargetsVertexDeclaration: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module BABYLON {
  9428. /** @hidden */
  9429. export var instancesDeclaration: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module BABYLON {
  9435. /** @hidden */
  9436. export var helperFunctions: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module BABYLON {
  9442. /** @hidden */
  9443. export var shadowMapVertexDeclaration: {
  9444. name: string;
  9445. shader: string;
  9446. };
  9447. }
  9448. declare module BABYLON {
  9449. /** @hidden */
  9450. export var clipPlaneVertexDeclaration: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module BABYLON {
  9456. /** @hidden */
  9457. export var morphTargetsVertex: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module BABYLON {
  9463. /** @hidden */
  9464. export var instancesVertex: {
  9465. name: string;
  9466. shader: string;
  9467. };
  9468. }
  9469. declare module BABYLON {
  9470. /** @hidden */
  9471. export var bonesVertex: {
  9472. name: string;
  9473. shader: string;
  9474. };
  9475. }
  9476. declare module BABYLON {
  9477. /** @hidden */
  9478. export var shadowMapVertexNormalBias: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module BABYLON {
  9484. /** @hidden */
  9485. export var shadowMapVertexMetric: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module BABYLON {
  9491. /** @hidden */
  9492. export var clipPlaneVertex: {
  9493. name: string;
  9494. shader: string;
  9495. };
  9496. }
  9497. declare module BABYLON {
  9498. /** @hidden */
  9499. export var shadowMapVertexShader: {
  9500. name: string;
  9501. shader: string;
  9502. };
  9503. }
  9504. declare module BABYLON {
  9505. /** @hidden */
  9506. export var depthBoxBlurPixelShader: {
  9507. name: string;
  9508. shader: string;
  9509. };
  9510. }
  9511. declare module BABYLON {
  9512. /** @hidden */
  9513. export var shadowMapFragmentSoftTransparentShadow: {
  9514. name: string;
  9515. shader: string;
  9516. };
  9517. }
  9518. declare module BABYLON {
  9519. /**
  9520. * Class representing a ray with position and direction
  9521. */
  9522. export class Ray {
  9523. /** origin point */
  9524. origin: Vector3;
  9525. /** direction */
  9526. direction: Vector3;
  9527. /** length of the ray */
  9528. length: number;
  9529. private static readonly TmpVector3;
  9530. private _tmpRay;
  9531. /**
  9532. * Creates a new ray
  9533. * @param origin origin point
  9534. * @param direction direction
  9535. * @param length length of the ray
  9536. */
  9537. constructor(
  9538. /** origin point */
  9539. origin: Vector3,
  9540. /** direction */
  9541. direction: Vector3,
  9542. /** length of the ray */
  9543. length?: number);
  9544. /**
  9545. * Checks if the ray intersects a box
  9546. * This does not account for the ray lenght by design to improve perfs.
  9547. * @param minimum bound of the box
  9548. * @param maximum bound of the box
  9549. * @param intersectionTreshold extra extend to be added to the box in all direction
  9550. * @returns if the box was hit
  9551. */
  9552. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9553. /**
  9554. * Checks if the ray intersects a box
  9555. * This does not account for the ray lenght by design to improve perfs.
  9556. * @param box the bounding box to check
  9557. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9558. * @returns if the box was hit
  9559. */
  9560. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9561. /**
  9562. * If the ray hits a sphere
  9563. * @param sphere the bounding sphere to check
  9564. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9565. * @returns true if it hits the sphere
  9566. */
  9567. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9568. /**
  9569. * If the ray hits a triange
  9570. * @param vertex0 triangle vertex
  9571. * @param vertex1 triangle vertex
  9572. * @param vertex2 triangle vertex
  9573. * @returns intersection information if hit
  9574. */
  9575. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9576. /**
  9577. * Checks if ray intersects a plane
  9578. * @param plane the plane to check
  9579. * @returns the distance away it was hit
  9580. */
  9581. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9582. /**
  9583. * Calculate the intercept of a ray on a given axis
  9584. * @param axis to check 'x' | 'y' | 'z'
  9585. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9586. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9587. */
  9588. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9589. /**
  9590. * Checks if ray intersects a mesh
  9591. * @param mesh the mesh to check
  9592. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9593. * @returns picking info of the intersecton
  9594. */
  9595. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9596. /**
  9597. * Checks if ray intersects a mesh
  9598. * @param meshes the meshes to check
  9599. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9600. * @param results array to store result in
  9601. * @returns Array of picking infos
  9602. */
  9603. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9604. private _comparePickingInfo;
  9605. private static smallnum;
  9606. private static rayl;
  9607. /**
  9608. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9609. * @param sega the first point of the segment to test the intersection against
  9610. * @param segb the second point of the segment to test the intersection against
  9611. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9612. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9613. */
  9614. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9615. /**
  9616. * Update the ray from viewport position
  9617. * @param x position
  9618. * @param y y position
  9619. * @param viewportWidth viewport width
  9620. * @param viewportHeight viewport height
  9621. * @param world world matrix
  9622. * @param view view matrix
  9623. * @param projection projection matrix
  9624. * @returns this ray updated
  9625. */
  9626. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9627. /**
  9628. * Creates a ray with origin and direction of 0,0,0
  9629. * @returns the new ray
  9630. */
  9631. static Zero(): Ray;
  9632. /**
  9633. * Creates a new ray from screen space and viewport
  9634. * @param x position
  9635. * @param y y position
  9636. * @param viewportWidth viewport width
  9637. * @param viewportHeight viewport height
  9638. * @param world world matrix
  9639. * @param view view matrix
  9640. * @param projection projection matrix
  9641. * @returns new ray
  9642. */
  9643. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9644. /**
  9645. * 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
  9646. * transformed to the given world matrix.
  9647. * @param origin The origin point
  9648. * @param end The end point
  9649. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9650. * @returns the new ray
  9651. */
  9652. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9653. /**
  9654. * Transforms a ray by a matrix
  9655. * @param ray ray to transform
  9656. * @param matrix matrix to apply
  9657. * @returns the resulting new ray
  9658. */
  9659. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9660. /**
  9661. * Transforms a ray by a matrix
  9662. * @param ray ray to transform
  9663. * @param matrix matrix to apply
  9664. * @param result ray to store result in
  9665. */
  9666. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9667. /**
  9668. * Unproject a ray from screen space to object space
  9669. * @param sourceX defines the screen space x coordinate to use
  9670. * @param sourceY defines the screen space y coordinate to use
  9671. * @param viewportWidth defines the current width of the viewport
  9672. * @param viewportHeight defines the current height of the viewport
  9673. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9674. * @param view defines the view matrix to use
  9675. * @param projection defines the projection matrix to use
  9676. */
  9677. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9678. }
  9679. /**
  9680. * Type used to define predicate used to select faces when a mesh intersection is detected
  9681. */
  9682. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9683. interface Scene {
  9684. /** @hidden */
  9685. _tempPickingRay: Nullable<Ray>;
  9686. /** @hidden */
  9687. _cachedRayForTransform: Ray;
  9688. /** @hidden */
  9689. _pickWithRayInverseMatrix: Matrix;
  9690. /** @hidden */
  9691. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9692. /** @hidden */
  9693. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9694. }
  9695. }
  9696. declare module BABYLON {
  9697. /**
  9698. * Groups all the scene component constants in one place to ease maintenance.
  9699. * @hidden
  9700. */
  9701. export class SceneComponentConstants {
  9702. static readonly NAME_EFFECTLAYER: string;
  9703. static readonly NAME_LAYER: string;
  9704. static readonly NAME_LENSFLARESYSTEM: string;
  9705. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9706. static readonly NAME_PARTICLESYSTEM: string;
  9707. static readonly NAME_GAMEPAD: string;
  9708. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9709. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9710. static readonly NAME_DEPTHRENDERER: string;
  9711. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9712. static readonly NAME_SPRITE: string;
  9713. static readonly NAME_OUTLINERENDERER: string;
  9714. static readonly NAME_PROCEDURALTEXTURE: string;
  9715. static readonly NAME_SHADOWGENERATOR: string;
  9716. static readonly NAME_OCTREE: string;
  9717. static readonly NAME_PHYSICSENGINE: string;
  9718. static readonly NAME_AUDIO: string;
  9719. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9720. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9721. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9722. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9723. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9724. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9725. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9726. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9727. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9728. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9729. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9730. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9731. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9732. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9733. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9734. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9735. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9736. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9737. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9738. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9739. static readonly STEP_AFTERRENDER_AUDIO: number;
  9740. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9741. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9742. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9743. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9744. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9745. static readonly STEP_POINTERMOVE_SPRITE: number;
  9746. static readonly STEP_POINTERDOWN_SPRITE: number;
  9747. static readonly STEP_POINTERUP_SPRITE: number;
  9748. }
  9749. /**
  9750. * This represents a scene component.
  9751. *
  9752. * This is used to decouple the dependency the scene is having on the different workloads like
  9753. * layers, post processes...
  9754. */
  9755. export interface ISceneComponent {
  9756. /**
  9757. * The name of the component. Each component must have a unique name.
  9758. */
  9759. name: string;
  9760. /**
  9761. * The scene the component belongs to.
  9762. */
  9763. scene: Scene;
  9764. /**
  9765. * Register the component to one instance of a scene.
  9766. */
  9767. register(): void;
  9768. /**
  9769. * Rebuilds the elements related to this component in case of
  9770. * context lost for instance.
  9771. */
  9772. rebuild(): void;
  9773. /**
  9774. * Disposes the component and the associated ressources.
  9775. */
  9776. dispose(): void;
  9777. }
  9778. /**
  9779. * This represents a SERIALIZABLE scene component.
  9780. *
  9781. * This extends Scene Component to add Serialization methods on top.
  9782. */
  9783. export interface ISceneSerializableComponent extends ISceneComponent {
  9784. /**
  9785. * Adds all the elements from the container to the scene
  9786. * @param container the container holding the elements
  9787. */
  9788. addFromContainer(container: AbstractScene): void;
  9789. /**
  9790. * Removes all the elements in the container from the scene
  9791. * @param container contains the elements to remove
  9792. * @param dispose if the removed element should be disposed (default: false)
  9793. */
  9794. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9795. /**
  9796. * Serializes the component data to the specified json object
  9797. * @param serializationObject The object to serialize to
  9798. */
  9799. serialize(serializationObject: any): void;
  9800. }
  9801. /**
  9802. * Strong typing of a Mesh related stage step action
  9803. */
  9804. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9805. /**
  9806. * Strong typing of a Evaluate Sub Mesh related stage step action
  9807. */
  9808. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9809. /**
  9810. * Strong typing of a Active Mesh related stage step action
  9811. */
  9812. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9813. /**
  9814. * Strong typing of a Camera related stage step action
  9815. */
  9816. export type CameraStageAction = (camera: Camera) => void;
  9817. /**
  9818. * Strong typing of a Camera Frame buffer related stage step action
  9819. */
  9820. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9821. /**
  9822. * Strong typing of a Render Target related stage step action
  9823. */
  9824. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9825. /**
  9826. * Strong typing of a RenderingGroup related stage step action
  9827. */
  9828. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9829. /**
  9830. * Strong typing of a Mesh Render related stage step action
  9831. */
  9832. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9833. /**
  9834. * Strong typing of a simple stage step action
  9835. */
  9836. export type SimpleStageAction = () => void;
  9837. /**
  9838. * Strong typing of a render target action.
  9839. */
  9840. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9841. /**
  9842. * Strong typing of a pointer move action.
  9843. */
  9844. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9845. /**
  9846. * Strong typing of a pointer up/down action.
  9847. */
  9848. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9849. /**
  9850. * Representation of a stage in the scene (Basically a list of ordered steps)
  9851. * @hidden
  9852. */
  9853. export class Stage<T extends Function> extends Array<{
  9854. index: number;
  9855. component: ISceneComponent;
  9856. action: T;
  9857. }> {
  9858. /**
  9859. * Hide ctor from the rest of the world.
  9860. * @param items The items to add.
  9861. */
  9862. private constructor();
  9863. /**
  9864. * Creates a new Stage.
  9865. * @returns A new instance of a Stage
  9866. */
  9867. static Create<T extends Function>(): Stage<T>;
  9868. /**
  9869. * Registers a step in an ordered way in the targeted stage.
  9870. * @param index Defines the position to register the step in
  9871. * @param component Defines the component attached to the step
  9872. * @param action Defines the action to launch during the step
  9873. */
  9874. registerStep(index: number, component: ISceneComponent, action: T): void;
  9875. /**
  9876. * Clears all the steps from the stage.
  9877. */
  9878. clear(): void;
  9879. }
  9880. }
  9881. declare module BABYLON {
  9882. interface Scene {
  9883. /** @hidden */
  9884. _pointerOverSprite: Nullable<Sprite>;
  9885. /** @hidden */
  9886. _pickedDownSprite: Nullable<Sprite>;
  9887. /** @hidden */
  9888. _tempSpritePickingRay: Nullable<Ray>;
  9889. /**
  9890. * All of the sprite managers added to this scene
  9891. * @see http://doc.babylonjs.com/babylon101/sprites
  9892. */
  9893. spriteManagers: Array<ISpriteManager>;
  9894. /**
  9895. * An event triggered when sprites rendering is about to start
  9896. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9897. */
  9898. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9899. /**
  9900. * An event triggered when sprites rendering is done
  9901. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9902. */
  9903. onAfterSpritesRenderingObservable: Observable<Scene>;
  9904. /** @hidden */
  9905. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9906. /** Launch a ray to try to pick a sprite in the scene
  9907. * @param x position on screen
  9908. * @param y position on screen
  9909. * @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
  9910. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9911. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9912. * @returns a PickingInfo
  9913. */
  9914. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9915. /** Use the given ray to pick a sprite in the scene
  9916. * @param ray The ray (in world space) to use to pick meshes
  9917. * @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
  9918. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9919. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9920. * @returns a PickingInfo
  9921. */
  9922. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9923. /** @hidden */
  9924. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9925. /** Launch a ray to try to pick sprites in the scene
  9926. * @param x position on screen
  9927. * @param y position on screen
  9928. * @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
  9929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9930. * @returns a PickingInfo array
  9931. */
  9932. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9933. /** Use the given ray to pick sprites in the scene
  9934. * @param ray The ray (in world space) to use to pick meshes
  9935. * @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
  9936. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9937. * @returns a PickingInfo array
  9938. */
  9939. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9940. /**
  9941. * Force the sprite under the pointer
  9942. * @param sprite defines the sprite to use
  9943. */
  9944. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9945. /**
  9946. * Gets the sprite under the pointer
  9947. * @returns a Sprite or null if no sprite is under the pointer
  9948. */
  9949. getPointerOverSprite(): Nullable<Sprite>;
  9950. }
  9951. /**
  9952. * Defines the sprite scene component responsible to manage sprites
  9953. * in a given scene.
  9954. */
  9955. export class SpriteSceneComponent implements ISceneComponent {
  9956. /**
  9957. * The component name helpfull to identify the component in the list of scene components.
  9958. */
  9959. readonly name: string;
  9960. /**
  9961. * The scene the component belongs to.
  9962. */
  9963. scene: Scene;
  9964. /** @hidden */
  9965. private _spritePredicate;
  9966. /**
  9967. * Creates a new instance of the component for the given scene
  9968. * @param scene Defines the scene to register the component in
  9969. */
  9970. constructor(scene: Scene);
  9971. /**
  9972. * Registers the component in a given scene
  9973. */
  9974. register(): void;
  9975. /**
  9976. * Rebuilds the elements related to this component in case of
  9977. * context lost for instance.
  9978. */
  9979. rebuild(): void;
  9980. /**
  9981. * Disposes the component and the associated ressources.
  9982. */
  9983. dispose(): void;
  9984. private _pickSpriteButKeepRay;
  9985. private _pointerMove;
  9986. private _pointerDown;
  9987. private _pointerUp;
  9988. }
  9989. }
  9990. declare module BABYLON {
  9991. /** @hidden */
  9992. export var fogFragmentDeclaration: {
  9993. name: string;
  9994. shader: string;
  9995. };
  9996. }
  9997. declare module BABYLON {
  9998. /** @hidden */
  9999. export var fogFragment: {
  10000. name: string;
  10001. shader: string;
  10002. };
  10003. }
  10004. declare module BABYLON {
  10005. /** @hidden */
  10006. export var spritesPixelShader: {
  10007. name: string;
  10008. shader: string;
  10009. };
  10010. }
  10011. declare module BABYLON {
  10012. /** @hidden */
  10013. export var fogVertexDeclaration: {
  10014. name: string;
  10015. shader: string;
  10016. };
  10017. }
  10018. declare module BABYLON {
  10019. /** @hidden */
  10020. export var spritesVertexShader: {
  10021. name: string;
  10022. shader: string;
  10023. };
  10024. }
  10025. declare module BABYLON {
  10026. /**
  10027. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10028. */
  10029. export interface ISpriteManager extends IDisposable {
  10030. /**
  10031. * Restricts the camera to viewing objects with the same layerMask.
  10032. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10033. */
  10034. layerMask: number;
  10035. /**
  10036. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10037. */
  10038. isPickable: boolean;
  10039. /**
  10040. * Specifies the rendering group id for this mesh (0 by default)
  10041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10042. */
  10043. renderingGroupId: number;
  10044. /**
  10045. * Defines the list of sprites managed by the manager.
  10046. */
  10047. sprites: Array<Sprite>;
  10048. /**
  10049. * Tests the intersection of a sprite with a specific ray.
  10050. * @param ray The ray we are sending to test the collision
  10051. * @param camera The camera space we are sending rays in
  10052. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10053. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10054. * @returns picking info or null.
  10055. */
  10056. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10057. /**
  10058. * Intersects the sprites with a ray
  10059. * @param ray defines the ray to intersect with
  10060. * @param camera defines the current active camera
  10061. * @param predicate defines a predicate used to select candidate sprites
  10062. * @returns null if no hit or a PickingInfo array
  10063. */
  10064. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10065. /**
  10066. * Renders the list of sprites on screen.
  10067. */
  10068. render(): void;
  10069. }
  10070. /**
  10071. * Class used to manage multiple sprites on the same spritesheet
  10072. * @see http://doc.babylonjs.com/babylon101/sprites
  10073. */
  10074. export class SpriteManager implements ISpriteManager {
  10075. /** defines the manager's name */
  10076. name: string;
  10077. /** Gets the list of sprites */
  10078. sprites: Sprite[];
  10079. /** Gets or sets the rendering group id (0 by default) */
  10080. renderingGroupId: number;
  10081. /** Gets or sets camera layer mask */
  10082. layerMask: number;
  10083. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10084. fogEnabled: boolean;
  10085. /** Gets or sets a boolean indicating if the sprites are pickable */
  10086. isPickable: boolean;
  10087. /** Defines the default width of a cell in the spritesheet */
  10088. cellWidth: number;
  10089. /** Defines the default height of a cell in the spritesheet */
  10090. cellHeight: number;
  10091. /** Associative array from JSON sprite data file */
  10092. private _cellData;
  10093. /** Array of sprite names from JSON sprite data file */
  10094. private _spriteMap;
  10095. /** True when packed cell data from JSON file is ready*/
  10096. private _packedAndReady;
  10097. private _textureContent;
  10098. /**
  10099. * An event triggered when the manager is disposed.
  10100. */
  10101. onDisposeObservable: Observable<SpriteManager>;
  10102. private _onDisposeObserver;
  10103. /**
  10104. * Callback called when the manager is disposed
  10105. */
  10106. set onDispose(callback: () => void);
  10107. private _capacity;
  10108. private _fromPacked;
  10109. private _spriteTexture;
  10110. private _epsilon;
  10111. private _scene;
  10112. private _vertexData;
  10113. private _buffer;
  10114. private _vertexBuffers;
  10115. private _indexBuffer;
  10116. private _effectBase;
  10117. private _effectFog;
  10118. /**
  10119. * Gets or sets the spritesheet texture
  10120. */
  10121. get texture(): Texture;
  10122. set texture(value: Texture);
  10123. private _blendMode;
  10124. /**
  10125. * Blend mode use to render the particle, it can be any of
  10126. * the static Constants.ALPHA_x properties provided in this class.
  10127. * Default value is Constants.ALPHA_COMBINE
  10128. */
  10129. get blendMode(): number;
  10130. set blendMode(blendMode: number);
  10131. /** Disables writing to the depth buffer when rendering the sprites.
  10132. * It can be handy to disable depth writing when using textures without alpha channel
  10133. * and setting some specific blend modes.
  10134. */
  10135. disableDepthWrite: boolean;
  10136. /**
  10137. * Creates a new sprite manager
  10138. * @param name defines the manager's name
  10139. * @param imgUrl defines the sprite sheet url
  10140. * @param capacity defines the maximum allowed number of sprites
  10141. * @param cellSize defines the size of a sprite cell
  10142. * @param scene defines the hosting scene
  10143. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10144. * @param samplingMode defines the smapling mode to use with spritesheet
  10145. * @param fromPacked set to false; do not alter
  10146. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10147. */
  10148. constructor(
  10149. /** defines the manager's name */
  10150. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10151. private _makePacked;
  10152. private _appendSpriteVertex;
  10153. private _checkTextureAlpha;
  10154. /**
  10155. * Intersects the sprites with a ray
  10156. * @param ray defines the ray to intersect with
  10157. * @param camera defines the current active camera
  10158. * @param predicate defines a predicate used to select candidate sprites
  10159. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10160. * @returns null if no hit or a PickingInfo
  10161. */
  10162. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10163. /**
  10164. * Intersects the sprites with a ray
  10165. * @param ray defines the ray to intersect with
  10166. * @param camera defines the current active camera
  10167. * @param predicate defines a predicate used to select candidate sprites
  10168. * @returns null if no hit or a PickingInfo array
  10169. */
  10170. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10171. /**
  10172. * Render all child sprites
  10173. */
  10174. render(): void;
  10175. /**
  10176. * Release associated resources
  10177. */
  10178. dispose(): void;
  10179. }
  10180. }
  10181. declare module BABYLON {
  10182. /** Interface used by value gradients (color, factor, ...) */
  10183. export interface IValueGradient {
  10184. /**
  10185. * Gets or sets the gradient value (between 0 and 1)
  10186. */
  10187. gradient: number;
  10188. }
  10189. /** Class used to store color4 gradient */
  10190. export class ColorGradient implements IValueGradient {
  10191. /**
  10192. * Gets or sets the gradient value (between 0 and 1)
  10193. */
  10194. gradient: number;
  10195. /**
  10196. * Gets or sets first associated color
  10197. */
  10198. color1: Color4;
  10199. /**
  10200. * Gets or sets second associated color
  10201. */
  10202. color2?: Color4 | undefined;
  10203. /**
  10204. * Creates a new color4 gradient
  10205. * @param gradient gets or sets the gradient value (between 0 and 1)
  10206. * @param color1 gets or sets first associated color
  10207. * @param color2 gets or sets first second color
  10208. */
  10209. constructor(
  10210. /**
  10211. * Gets or sets the gradient value (between 0 and 1)
  10212. */
  10213. gradient: number,
  10214. /**
  10215. * Gets or sets first associated color
  10216. */
  10217. color1: Color4,
  10218. /**
  10219. * Gets or sets second associated color
  10220. */
  10221. color2?: Color4 | undefined);
  10222. /**
  10223. * Will get a color picked randomly between color1 and color2.
  10224. * If color2 is undefined then color1 will be used
  10225. * @param result defines the target Color4 to store the result in
  10226. */
  10227. getColorToRef(result: Color4): void;
  10228. }
  10229. /** Class used to store color 3 gradient */
  10230. export class Color3Gradient implements IValueGradient {
  10231. /**
  10232. * Gets or sets the gradient value (between 0 and 1)
  10233. */
  10234. gradient: number;
  10235. /**
  10236. * Gets or sets the associated color
  10237. */
  10238. color: Color3;
  10239. /**
  10240. * Creates a new color3 gradient
  10241. * @param gradient gets or sets the gradient value (between 0 and 1)
  10242. * @param color gets or sets associated color
  10243. */
  10244. constructor(
  10245. /**
  10246. * Gets or sets the gradient value (between 0 and 1)
  10247. */
  10248. gradient: number,
  10249. /**
  10250. * Gets or sets the associated color
  10251. */
  10252. color: Color3);
  10253. }
  10254. /** Class used to store factor gradient */
  10255. export class FactorGradient implements IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. /**
  10261. * Gets or sets first associated factor
  10262. */
  10263. factor1: number;
  10264. /**
  10265. * Gets or sets second associated factor
  10266. */
  10267. factor2?: number | undefined;
  10268. /**
  10269. * Creates a new factor gradient
  10270. * @param gradient gets or sets the gradient value (between 0 and 1)
  10271. * @param factor1 gets or sets first associated factor
  10272. * @param factor2 gets or sets second associated factor
  10273. */
  10274. constructor(
  10275. /**
  10276. * Gets or sets the gradient value (between 0 and 1)
  10277. */
  10278. gradient: number,
  10279. /**
  10280. * Gets or sets first associated factor
  10281. */
  10282. factor1: number,
  10283. /**
  10284. * Gets or sets second associated factor
  10285. */
  10286. factor2?: number | undefined);
  10287. /**
  10288. * Will get a number picked randomly between factor1 and factor2.
  10289. * If factor2 is undefined then factor1 will be used
  10290. * @returns the picked number
  10291. */
  10292. getFactor(): number;
  10293. }
  10294. /**
  10295. * Helper used to simplify some generic gradient tasks
  10296. */
  10297. export class GradientHelper {
  10298. /**
  10299. * Gets the current gradient from an array of IValueGradient
  10300. * @param ratio defines the current ratio to get
  10301. * @param gradients defines the array of IValueGradient
  10302. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10303. */
  10304. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10305. }
  10306. }
  10307. declare module BABYLON {
  10308. /**
  10309. * Interface for the size containing width and height
  10310. */
  10311. export interface ISize {
  10312. /**
  10313. * Width
  10314. */
  10315. width: number;
  10316. /**
  10317. * Heighht
  10318. */
  10319. height: number;
  10320. }
  10321. /**
  10322. * Size containing widht and height
  10323. */
  10324. export class Size implements ISize {
  10325. /**
  10326. * Width
  10327. */
  10328. width: number;
  10329. /**
  10330. * Height
  10331. */
  10332. height: number;
  10333. /**
  10334. * Creates a Size object from the given width and height (floats).
  10335. * @param width width of the new size
  10336. * @param height height of the new size
  10337. */
  10338. constructor(width: number, height: number);
  10339. /**
  10340. * Returns a string with the Size width and height
  10341. * @returns a string with the Size width and height
  10342. */
  10343. toString(): string;
  10344. /**
  10345. * "Size"
  10346. * @returns the string "Size"
  10347. */
  10348. getClassName(): string;
  10349. /**
  10350. * Returns the Size hash code.
  10351. * @returns a hash code for a unique width and height
  10352. */
  10353. getHashCode(): number;
  10354. /**
  10355. * Updates the current size from the given one.
  10356. * @param src the given size
  10357. */
  10358. copyFrom(src: Size): void;
  10359. /**
  10360. * Updates in place the current Size from the given floats.
  10361. * @param width width of the new size
  10362. * @param height height of the new size
  10363. * @returns the updated Size.
  10364. */
  10365. copyFromFloats(width: number, height: number): Size;
  10366. /**
  10367. * Updates in place the current Size from the given floats.
  10368. * @param width width to set
  10369. * @param height height to set
  10370. * @returns the updated Size.
  10371. */
  10372. set(width: number, height: number): Size;
  10373. /**
  10374. * Multiplies the width and height by numbers
  10375. * @param w factor to multiple the width by
  10376. * @param h factor to multiple the height by
  10377. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10378. */
  10379. multiplyByFloats(w: number, h: number): Size;
  10380. /**
  10381. * Clones the size
  10382. * @returns a new Size copied from the given one.
  10383. */
  10384. clone(): Size;
  10385. /**
  10386. * True if the current Size and the given one width and height are strictly equal.
  10387. * @param other the other size to compare against
  10388. * @returns True if the current Size and the given one width and height are strictly equal.
  10389. */
  10390. equals(other: Size): boolean;
  10391. /**
  10392. * The surface of the Size : width * height (float).
  10393. */
  10394. get surface(): number;
  10395. /**
  10396. * Create a new size of zero
  10397. * @returns a new Size set to (0.0, 0.0)
  10398. */
  10399. static Zero(): Size;
  10400. /**
  10401. * Sums the width and height of two sizes
  10402. * @param otherSize size to add to this size
  10403. * @returns a new Size set as the addition result of the current Size and the given one.
  10404. */
  10405. add(otherSize: Size): Size;
  10406. /**
  10407. * Subtracts the width and height of two
  10408. * @param otherSize size to subtract to this size
  10409. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10410. */
  10411. subtract(otherSize: Size): Size;
  10412. /**
  10413. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10414. * @param start starting size to lerp between
  10415. * @param end end size to lerp between
  10416. * @param amount amount to lerp between the start and end values
  10417. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10418. */
  10419. static Lerp(start: Size, end: Size, amount: number): Size;
  10420. }
  10421. }
  10422. declare module BABYLON {
  10423. interface ThinEngine {
  10424. /**
  10425. * Creates a dynamic texture
  10426. * @param width defines the width of the texture
  10427. * @param height defines the height of the texture
  10428. * @param generateMipMaps defines if the engine should generate the mip levels
  10429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10430. * @returns the dynamic texture inside an InternalTexture
  10431. */
  10432. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10433. /**
  10434. * Update the content of a dynamic texture
  10435. * @param texture defines the texture to update
  10436. * @param canvas defines the canvas containing the source
  10437. * @param invertY defines if data must be stored with Y axis inverted
  10438. * @param premulAlpha defines if alpha is stored as premultiplied
  10439. * @param format defines the format of the data
  10440. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10441. */
  10442. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10443. }
  10444. }
  10445. declare module BABYLON {
  10446. /**
  10447. * Helper class used to generate a canvas to manipulate images
  10448. */
  10449. export class CanvasGenerator {
  10450. /**
  10451. * Create a new canvas (or offscreen canvas depending on the context)
  10452. * @param width defines the expected width
  10453. * @param height defines the expected height
  10454. * @return a new canvas or offscreen canvas
  10455. */
  10456. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10457. }
  10458. }
  10459. declare module BABYLON {
  10460. /**
  10461. * A class extending Texture allowing drawing on a texture
  10462. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10463. */
  10464. export class DynamicTexture extends Texture {
  10465. private _generateMipMaps;
  10466. private _canvas;
  10467. private _context;
  10468. private _engine;
  10469. /**
  10470. * Creates a DynamicTexture
  10471. * @param name defines the name of the texture
  10472. * @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
  10473. * @param scene defines the scene where you want the texture
  10474. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10475. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10476. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10477. */
  10478. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10479. /**
  10480. * Get the current class name of the texture useful for serialization or dynamic coding.
  10481. * @returns "DynamicTexture"
  10482. */
  10483. getClassName(): string;
  10484. /**
  10485. * Gets the current state of canRescale
  10486. */
  10487. get canRescale(): boolean;
  10488. private _recreate;
  10489. /**
  10490. * Scales the texture
  10491. * @param ratio the scale factor to apply to both width and height
  10492. */
  10493. scale(ratio: number): void;
  10494. /**
  10495. * Resizes the texture
  10496. * @param width the new width
  10497. * @param height the new height
  10498. */
  10499. scaleTo(width: number, height: number): void;
  10500. /**
  10501. * Gets the context of the canvas used by the texture
  10502. * @returns the canvas context of the dynamic texture
  10503. */
  10504. getContext(): CanvasRenderingContext2D;
  10505. /**
  10506. * Clears the texture
  10507. */
  10508. clear(): void;
  10509. /**
  10510. * Updates the texture
  10511. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10512. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10513. */
  10514. update(invertY?: boolean, premulAlpha?: boolean): void;
  10515. /**
  10516. * Draws text onto the texture
  10517. * @param text defines the text to be drawn
  10518. * @param x defines the placement of the text from the left
  10519. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10520. * @param font defines the font to be used with font-style, font-size, font-name
  10521. * @param color defines the color used for the text
  10522. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10523. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10524. * @param update defines whether texture is immediately update (default is true)
  10525. */
  10526. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10527. /**
  10528. * Clones the texture
  10529. * @returns the clone of the texture.
  10530. */
  10531. clone(): DynamicTexture;
  10532. /**
  10533. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10534. * @returns a serialized dynamic texture object
  10535. */
  10536. serialize(): any;
  10537. /** @hidden */
  10538. _rebuild(): void;
  10539. }
  10540. }
  10541. declare module BABYLON {
  10542. interface ThinEngine {
  10543. /**
  10544. * Creates a raw texture
  10545. * @param data defines the data to store in the texture
  10546. * @param width defines the width of the texture
  10547. * @param height defines the height of the texture
  10548. * @param format defines the format of the data
  10549. * @param generateMipMaps defines if the engine should generate the mip levels
  10550. * @param invertY defines if data must be stored with Y axis inverted
  10551. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10552. * @param compression defines the compression used (null by default)
  10553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10554. * @returns the raw texture inside an InternalTexture
  10555. */
  10556. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10557. /**
  10558. * Update a raw texture
  10559. * @param texture defines the texture to update
  10560. * @param data defines the data to store in the texture
  10561. * @param format defines the format of the data
  10562. * @param invertY defines if data must be stored with Y axis inverted
  10563. */
  10564. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10565. /**
  10566. * Update a raw texture
  10567. * @param texture defines the texture to update
  10568. * @param data defines the data to store in the texture
  10569. * @param format defines the format of the data
  10570. * @param invertY defines if data must be stored with Y axis inverted
  10571. * @param compression defines the compression used (null by default)
  10572. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10573. */
  10574. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10575. /**
  10576. * Creates a new raw cube texture
  10577. * @param data defines the array of data to use to create each face
  10578. * @param size defines the size of the textures
  10579. * @param format defines the format of the data
  10580. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10581. * @param generateMipMaps defines if the engine should generate the mip levels
  10582. * @param invertY defines if data must be stored with Y axis inverted
  10583. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10584. * @param compression defines the compression used (null by default)
  10585. * @returns the cube texture as an InternalTexture
  10586. */
  10587. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10588. /**
  10589. * Update a raw cube texture
  10590. * @param texture defines the texture to udpdate
  10591. * @param data defines the data to store
  10592. * @param format defines the data format
  10593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10594. * @param invertY defines if data must be stored with Y axis inverted
  10595. */
  10596. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10597. /**
  10598. * Update a raw cube texture
  10599. * @param texture defines the texture to udpdate
  10600. * @param data defines the data to store
  10601. * @param format defines the data format
  10602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10603. * @param invertY defines if data must be stored with Y axis inverted
  10604. * @param compression defines the compression used (null by default)
  10605. */
  10606. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10607. /**
  10608. * Update a raw cube texture
  10609. * @param texture defines the texture to udpdate
  10610. * @param data defines the data to store
  10611. * @param format defines the data format
  10612. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param compression defines the compression used (null by default)
  10615. * @param level defines which level of the texture to update
  10616. */
  10617. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10618. /**
  10619. * Creates a new raw cube texture from a specified url
  10620. * @param url defines the url where the data is located
  10621. * @param scene defines the current scene
  10622. * @param size defines the size of the textures
  10623. * @param format defines the format of the data
  10624. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10625. * @param noMipmap defines if the engine should avoid generating the mip levels
  10626. * @param callback defines a callback used to extract texture data from loaded data
  10627. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10628. * @param onLoad defines a callback called when texture is loaded
  10629. * @param onError defines a callback called if there is an error
  10630. * @returns the cube texture as an InternalTexture
  10631. */
  10632. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10633. /**
  10634. * Creates a new raw cube texture from a specified url
  10635. * @param url defines the url where the data is located
  10636. * @param scene defines the current scene
  10637. * @param size defines the size of the textures
  10638. * @param format defines the format of the data
  10639. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10640. * @param noMipmap defines if the engine should avoid generating the mip levels
  10641. * @param callback defines a callback used to extract texture data from loaded data
  10642. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10643. * @param onLoad defines a callback called when texture is loaded
  10644. * @param onError defines a callback called if there is an error
  10645. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10646. * @param invertY defines if data must be stored with Y axis inverted
  10647. * @returns the cube texture as an InternalTexture
  10648. */
  10649. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10650. /**
  10651. * Creates a new raw 3D texture
  10652. * @param data defines the data used to create the texture
  10653. * @param width defines the width of the texture
  10654. * @param height defines the height of the texture
  10655. * @param depth defines the depth of the texture
  10656. * @param format defines the format of the texture
  10657. * @param generateMipMaps defines if the engine must generate mip levels
  10658. * @param invertY defines if data must be stored with Y axis inverted
  10659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10660. * @param compression defines the compressed used (can be null)
  10661. * @param textureType defines the compressed used (can be null)
  10662. * @returns a new raw 3D texture (stored in an InternalTexture)
  10663. */
  10664. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10665. /**
  10666. * Update a raw 3D texture
  10667. * @param texture defines the texture to update
  10668. * @param data defines the data to store
  10669. * @param format defines the data format
  10670. * @param invertY defines if data must be stored with Y axis inverted
  10671. */
  10672. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10673. /**
  10674. * Update a raw 3D texture
  10675. * @param texture defines the texture to update
  10676. * @param data defines the data to store
  10677. * @param format defines the data format
  10678. * @param invertY defines if data must be stored with Y axis inverted
  10679. * @param compression defines the used compression (can be null)
  10680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10681. */
  10682. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10683. /**
  10684. * Creates a new raw 2D array texture
  10685. * @param data defines the data used to create the texture
  10686. * @param width defines the width of the texture
  10687. * @param height defines the height of the texture
  10688. * @param depth defines the number of layers of the texture
  10689. * @param format defines the format of the texture
  10690. * @param generateMipMaps defines if the engine must generate mip levels
  10691. * @param invertY defines if data must be stored with Y axis inverted
  10692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10693. * @param compression defines the compressed used (can be null)
  10694. * @param textureType defines the compressed used (can be null)
  10695. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10696. */
  10697. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10698. /**
  10699. * Update a raw 2D array texture
  10700. * @param texture defines the texture to update
  10701. * @param data defines the data to store
  10702. * @param format defines the data format
  10703. * @param invertY defines if data must be stored with Y axis inverted
  10704. */
  10705. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10706. /**
  10707. * Update a raw 2D array texture
  10708. * @param texture defines the texture to update
  10709. * @param data defines the data to store
  10710. * @param format defines the data format
  10711. * @param invertY defines if data must be stored with Y axis inverted
  10712. * @param compression defines the used compression (can be null)
  10713. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10714. */
  10715. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10716. }
  10717. }
  10718. declare module BABYLON {
  10719. /**
  10720. * Raw texture can help creating a texture directly from an array of data.
  10721. * This can be super useful if you either get the data from an uncompressed source or
  10722. * if you wish to create your texture pixel by pixel.
  10723. */
  10724. export class RawTexture extends Texture {
  10725. /**
  10726. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10727. */
  10728. format: number;
  10729. private _engine;
  10730. /**
  10731. * Instantiates a new RawTexture.
  10732. * Raw texture can help creating a texture directly from an array of data.
  10733. * This can be super useful if you either get the data from an uncompressed source or
  10734. * if you wish to create your texture pixel by pixel.
  10735. * @param data define the array of data to use to create the texture
  10736. * @param width define the width of the texture
  10737. * @param height define the height of the texture
  10738. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10739. * @param scene define the scene the texture belongs to
  10740. * @param generateMipMaps define whether mip maps should be generated or not
  10741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10744. */
  10745. constructor(data: ArrayBufferView, width: number, height: number,
  10746. /**
  10747. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10748. */
  10749. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10750. /**
  10751. * Updates the texture underlying data.
  10752. * @param data Define the new data of the texture
  10753. */
  10754. update(data: ArrayBufferView): void;
  10755. /**
  10756. * Creates a luminance texture from some data.
  10757. * @param data Define the texture data
  10758. * @param width Define the width of the texture
  10759. * @param height Define the height of the texture
  10760. * @param scene Define the scene the texture belongs to
  10761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10764. * @returns the luminance texture
  10765. */
  10766. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10767. /**
  10768. * Creates a luminance alpha texture from some data.
  10769. * @param data Define the texture data
  10770. * @param width Define the width of the texture
  10771. * @param height Define the height of the texture
  10772. * @param scene Define the scene the texture belongs to
  10773. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10776. * @returns the luminance alpha texture
  10777. */
  10778. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10779. /**
  10780. * Creates an alpha texture from some data.
  10781. * @param data Define the texture data
  10782. * @param width Define the width of the texture
  10783. * @param height Define the height of the texture
  10784. * @param scene Define the scene the texture belongs to
  10785. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10788. * @returns the alpha texture
  10789. */
  10790. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10791. /**
  10792. * Creates a RGB texture from some data.
  10793. * @param data Define the texture data
  10794. * @param width Define the width of the texture
  10795. * @param height Define the height of the texture
  10796. * @param scene Define the scene the texture belongs to
  10797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10800. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10801. * @returns the RGB alpha texture
  10802. */
  10803. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10804. /**
  10805. * Creates a RGBA texture from some data.
  10806. * @param data Define the texture data
  10807. * @param width Define the width of the texture
  10808. * @param height Define the height of the texture
  10809. * @param scene Define the scene the texture belongs to
  10810. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10811. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10812. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10813. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10814. * @returns the RGBA texture
  10815. */
  10816. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10817. /**
  10818. * Creates a R texture from some data.
  10819. * @param data Define the texture data
  10820. * @param width Define the width of the texture
  10821. * @param height Define the height of the texture
  10822. * @param scene Define the scene the texture belongs to
  10823. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10824. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10825. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10826. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10827. * @returns the R texture
  10828. */
  10829. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10830. }
  10831. }
  10832. declare module BABYLON {
  10833. interface AbstractScene {
  10834. /**
  10835. * The list of procedural textures added to the scene
  10836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10837. */
  10838. proceduralTextures: Array<ProceduralTexture>;
  10839. }
  10840. /**
  10841. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10842. * in a given scene.
  10843. */
  10844. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10845. /**
  10846. * The component name helpfull to identify the component in the list of scene components.
  10847. */
  10848. readonly name: string;
  10849. /**
  10850. * The scene the component belongs to.
  10851. */
  10852. scene: Scene;
  10853. /**
  10854. * Creates a new instance of the component for the given scene
  10855. * @param scene Defines the scene to register the component in
  10856. */
  10857. constructor(scene: Scene);
  10858. /**
  10859. * Registers the component in a given scene
  10860. */
  10861. register(): void;
  10862. /**
  10863. * Rebuilds the elements related to this component in case of
  10864. * context lost for instance.
  10865. */
  10866. rebuild(): void;
  10867. /**
  10868. * Disposes the component and the associated ressources.
  10869. */
  10870. dispose(): void;
  10871. private _beforeClear;
  10872. }
  10873. }
  10874. declare module BABYLON {
  10875. interface ThinEngine {
  10876. /**
  10877. * Creates a new render target cube texture
  10878. * @param size defines the size of the texture
  10879. * @param options defines the options used to create the texture
  10880. * @returns a new render target cube texture stored in an InternalTexture
  10881. */
  10882. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10883. }
  10884. }
  10885. declare module BABYLON {
  10886. /** @hidden */
  10887. export var proceduralVertexShader: {
  10888. name: string;
  10889. shader: string;
  10890. };
  10891. }
  10892. declare module BABYLON {
  10893. /**
  10894. * 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.
  10895. * This is the base class of any Procedural texture and contains most of the shareable code.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10897. */
  10898. export class ProceduralTexture extends Texture {
  10899. isCube: boolean;
  10900. /**
  10901. * Define if the texture is enabled or not (disabled texture will not render)
  10902. */
  10903. isEnabled: boolean;
  10904. /**
  10905. * Define if the texture must be cleared before rendering (default is true)
  10906. */
  10907. autoClear: boolean;
  10908. /**
  10909. * Callback called when the texture is generated
  10910. */
  10911. onGenerated: () => void;
  10912. /**
  10913. * Event raised when the texture is generated
  10914. */
  10915. onGeneratedObservable: Observable<ProceduralTexture>;
  10916. /** @hidden */
  10917. _generateMipMaps: boolean;
  10918. /** @hidden **/
  10919. _effect: Effect;
  10920. /** @hidden */
  10921. _textures: {
  10922. [key: string]: Texture;
  10923. };
  10924. /** @hidden */
  10925. protected _fallbackTexture: Nullable<Texture>;
  10926. private _size;
  10927. private _currentRefreshId;
  10928. private _frameId;
  10929. private _refreshRate;
  10930. private _vertexBuffers;
  10931. private _indexBuffer;
  10932. private _uniforms;
  10933. private _samplers;
  10934. private _fragment;
  10935. private _floats;
  10936. private _ints;
  10937. private _floatsArrays;
  10938. private _colors3;
  10939. private _colors4;
  10940. private _vectors2;
  10941. private _vectors3;
  10942. private _matrices;
  10943. private _fallbackTextureUsed;
  10944. private _engine;
  10945. private _cachedDefines;
  10946. private _contentUpdateId;
  10947. private _contentData;
  10948. /**
  10949. * Instantiates a new procedural texture.
  10950. * 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.
  10951. * This is the base class of any Procedural texture and contains most of the shareable code.
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10953. * @param name Define the name of the texture
  10954. * @param size Define the size of the texture to create
  10955. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10956. * @param scene Define the scene the texture belongs to
  10957. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10958. * @param generateMipMaps Define if the texture should creates mip maps or not
  10959. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10960. */
  10961. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10962. /**
  10963. * The effect that is created when initializing the post process.
  10964. * @returns The created effect corresponding the the postprocess.
  10965. */
  10966. getEffect(): Effect;
  10967. /**
  10968. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10969. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10970. */
  10971. getContent(): Nullable<ArrayBufferView>;
  10972. private _createIndexBuffer;
  10973. /** @hidden */
  10974. _rebuild(): void;
  10975. /**
  10976. * Resets the texture in order to recreate its associated resources.
  10977. * This can be called in case of context loss
  10978. */
  10979. reset(): void;
  10980. protected _getDefines(): string;
  10981. /**
  10982. * Is the texture ready to be used ? (rendered at least once)
  10983. * @returns true if ready, otherwise, false.
  10984. */
  10985. isReady(): boolean;
  10986. /**
  10987. * Resets the refresh counter of the texture and start bak from scratch.
  10988. * Could be useful to regenerate the texture if it is setup to render only once.
  10989. */
  10990. resetRefreshCounter(): void;
  10991. /**
  10992. * Set the fragment shader to use in order to render the texture.
  10993. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10994. */
  10995. setFragment(fragment: any): void;
  10996. /**
  10997. * Define the refresh rate of the texture or the rendering frequency.
  10998. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10999. */
  11000. get refreshRate(): number;
  11001. set refreshRate(value: number);
  11002. /** @hidden */
  11003. _shouldRender(): boolean;
  11004. /**
  11005. * Get the size the texture is rendering at.
  11006. * @returns the size (texture is always squared)
  11007. */
  11008. getRenderSize(): number;
  11009. /**
  11010. * Resize the texture to new value.
  11011. * @param size Define the new size the texture should have
  11012. * @param generateMipMaps Define whether the new texture should create mip maps
  11013. */
  11014. resize(size: number, generateMipMaps: boolean): void;
  11015. private _checkUniform;
  11016. /**
  11017. * Set a texture in the shader program used to render.
  11018. * @param name Define the name of the uniform samplers as defined in the shader
  11019. * @param texture Define the texture to bind to this sampler
  11020. * @return the texture itself allowing "fluent" like uniform updates
  11021. */
  11022. setTexture(name: string, texture: Texture): ProceduralTexture;
  11023. /**
  11024. * Set a float in the shader.
  11025. * @param name Define the name of the uniform as defined in the shader
  11026. * @param value Define the value to give to the uniform
  11027. * @return the texture itself allowing "fluent" like uniform updates
  11028. */
  11029. setFloat(name: string, value: number): ProceduralTexture;
  11030. /**
  11031. * Set a int in the shader.
  11032. * @param name Define the name of the uniform as defined in the shader
  11033. * @param value Define the value to give to the uniform
  11034. * @return the texture itself allowing "fluent" like uniform updates
  11035. */
  11036. setInt(name: string, value: number): ProceduralTexture;
  11037. /**
  11038. * Set an array of floats in the shader.
  11039. * @param name Define the name of the uniform as defined in the shader
  11040. * @param value Define the value to give to the uniform
  11041. * @return the texture itself allowing "fluent" like uniform updates
  11042. */
  11043. setFloats(name: string, value: number[]): ProceduralTexture;
  11044. /**
  11045. * Set a vec3 in the shader from a Color3.
  11046. * @param name Define the name of the uniform as defined in the shader
  11047. * @param value Define the value to give to the uniform
  11048. * @return the texture itself allowing "fluent" like uniform updates
  11049. */
  11050. setColor3(name: string, value: Color3): ProceduralTexture;
  11051. /**
  11052. * Set a vec4 in the shader from a Color4.
  11053. * @param name Define the name of the uniform as defined in the shader
  11054. * @param value Define the value to give to the uniform
  11055. * @return the texture itself allowing "fluent" like uniform updates
  11056. */
  11057. setColor4(name: string, value: Color4): ProceduralTexture;
  11058. /**
  11059. * Set a vec2 in the shader from a Vector2.
  11060. * @param name Define the name of the uniform as defined in the shader
  11061. * @param value Define the value to give to the uniform
  11062. * @return the texture itself allowing "fluent" like uniform updates
  11063. */
  11064. setVector2(name: string, value: Vector2): ProceduralTexture;
  11065. /**
  11066. * Set a vec3 in the shader from a Vector3.
  11067. * @param name Define the name of the uniform as defined in the shader
  11068. * @param value Define the value to give to the uniform
  11069. * @return the texture itself allowing "fluent" like uniform updates
  11070. */
  11071. setVector3(name: string, value: Vector3): ProceduralTexture;
  11072. /**
  11073. * Set a mat4 in the shader from a MAtrix.
  11074. * @param name Define the name of the uniform as defined in the shader
  11075. * @param value Define the value to give to the uniform
  11076. * @return the texture itself allowing "fluent" like uniform updates
  11077. */
  11078. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11079. /**
  11080. * Render the texture to its associated render target.
  11081. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11082. */
  11083. render(useCameraPostProcess?: boolean): void;
  11084. /**
  11085. * Clone the texture.
  11086. * @returns the cloned texture
  11087. */
  11088. clone(): ProceduralTexture;
  11089. /**
  11090. * Dispose the texture and release its asoociated resources.
  11091. */
  11092. dispose(): void;
  11093. }
  11094. }
  11095. declare module BABYLON {
  11096. /**
  11097. * This represents the base class for particle system in Babylon.
  11098. * 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.
  11099. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11100. * @example https://doc.babylonjs.com/babylon101/particles
  11101. */
  11102. export class BaseParticleSystem {
  11103. /**
  11104. * Source color is added to the destination color without alpha affecting the result
  11105. */
  11106. static BLENDMODE_ONEONE: number;
  11107. /**
  11108. * Blend current color and particle color using particle’s alpha
  11109. */
  11110. static BLENDMODE_STANDARD: number;
  11111. /**
  11112. * Add current color and particle color multiplied by particle’s alpha
  11113. */
  11114. static BLENDMODE_ADD: number;
  11115. /**
  11116. * Multiply current color with particle color
  11117. */
  11118. static BLENDMODE_MULTIPLY: number;
  11119. /**
  11120. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11121. */
  11122. static BLENDMODE_MULTIPLYADD: number;
  11123. /**
  11124. * List of animations used by the particle system.
  11125. */
  11126. animations: Animation[];
  11127. /**
  11128. * Gets or sets the unique id of the particle system
  11129. */
  11130. uniqueId: number;
  11131. /**
  11132. * The id of the Particle system.
  11133. */
  11134. id: string;
  11135. /**
  11136. * The friendly name of the Particle system.
  11137. */
  11138. name: string;
  11139. /**
  11140. * Snippet ID if the particle system was created from the snippet server
  11141. */
  11142. snippetId: string;
  11143. /**
  11144. * The rendering group used by the Particle system to chose when to render.
  11145. */
  11146. renderingGroupId: number;
  11147. /**
  11148. * The emitter represents the Mesh or position we are attaching the particle system to.
  11149. */
  11150. emitter: Nullable<AbstractMesh | Vector3>;
  11151. /**
  11152. * The maximum number of particles to emit per frame
  11153. */
  11154. emitRate: number;
  11155. /**
  11156. * If you want to launch only a few particles at once, that can be done, as well.
  11157. */
  11158. manualEmitCount: number;
  11159. /**
  11160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11161. */
  11162. updateSpeed: number;
  11163. /**
  11164. * The amount of time the particle system is running (depends of the overall update speed).
  11165. */
  11166. targetStopDuration: number;
  11167. /**
  11168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11169. */
  11170. disposeOnStop: boolean;
  11171. /**
  11172. * Minimum power of emitting particles.
  11173. */
  11174. minEmitPower: number;
  11175. /**
  11176. * Maximum power of emitting particles.
  11177. */
  11178. maxEmitPower: number;
  11179. /**
  11180. * Minimum life time of emitting particles.
  11181. */
  11182. minLifeTime: number;
  11183. /**
  11184. * Maximum life time of emitting particles.
  11185. */
  11186. maxLifeTime: number;
  11187. /**
  11188. * Minimum Size of emitting particles.
  11189. */
  11190. minSize: number;
  11191. /**
  11192. * Maximum Size of emitting particles.
  11193. */
  11194. maxSize: number;
  11195. /**
  11196. * Minimum scale of emitting particles on X axis.
  11197. */
  11198. minScaleX: number;
  11199. /**
  11200. * Maximum scale of emitting particles on X axis.
  11201. */
  11202. maxScaleX: number;
  11203. /**
  11204. * Minimum scale of emitting particles on Y axis.
  11205. */
  11206. minScaleY: number;
  11207. /**
  11208. * Maximum scale of emitting particles on Y axis.
  11209. */
  11210. maxScaleY: number;
  11211. /**
  11212. * Gets or sets the minimal initial rotation in radians.
  11213. */
  11214. minInitialRotation: number;
  11215. /**
  11216. * Gets or sets the maximal initial rotation in radians.
  11217. */
  11218. maxInitialRotation: number;
  11219. /**
  11220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11221. */
  11222. minAngularSpeed: number;
  11223. /**
  11224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11225. */
  11226. maxAngularSpeed: number;
  11227. /**
  11228. * The texture used to render each particle. (this can be a spritesheet)
  11229. */
  11230. particleTexture: Nullable<Texture>;
  11231. /**
  11232. * The layer mask we are rendering the particles through.
  11233. */
  11234. layerMask: number;
  11235. /**
  11236. * This can help using your own shader to render the particle system.
  11237. * The according effect will be created
  11238. */
  11239. customShader: any;
  11240. /**
  11241. * By default particle system starts as soon as they are created. This prevents the
  11242. * automatic start to happen and let you decide when to start emitting particles.
  11243. */
  11244. preventAutoStart: boolean;
  11245. private _noiseTexture;
  11246. /**
  11247. * Gets or sets a texture used to add random noise to particle positions
  11248. */
  11249. get noiseTexture(): Nullable<ProceduralTexture>;
  11250. set noiseTexture(value: Nullable<ProceduralTexture>);
  11251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11252. noiseStrength: Vector3;
  11253. /**
  11254. * Callback triggered when the particle animation is ending.
  11255. */
  11256. onAnimationEnd: Nullable<() => void>;
  11257. /**
  11258. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11259. */
  11260. blendMode: number;
  11261. /**
  11262. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11263. * to override the particles.
  11264. */
  11265. forceDepthWrite: boolean;
  11266. /** 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 */
  11267. preWarmCycles: number;
  11268. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11269. preWarmStepOffset: number;
  11270. /**
  11271. * 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)
  11272. */
  11273. spriteCellChangeSpeed: number;
  11274. /**
  11275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11276. */
  11277. startSpriteCellID: number;
  11278. /**
  11279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11280. */
  11281. endSpriteCellID: number;
  11282. /**
  11283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11284. */
  11285. spriteCellWidth: number;
  11286. /**
  11287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11288. */
  11289. spriteCellHeight: number;
  11290. /**
  11291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11292. */
  11293. spriteRandomStartCell: boolean;
  11294. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11295. translationPivot: Vector2;
  11296. /** @hidden */
  11297. protected _isAnimationSheetEnabled: boolean;
  11298. /**
  11299. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11300. */
  11301. beginAnimationOnStart: boolean;
  11302. /**
  11303. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11304. */
  11305. beginAnimationFrom: number;
  11306. /**
  11307. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11308. */
  11309. beginAnimationTo: number;
  11310. /**
  11311. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11312. */
  11313. beginAnimationLoop: boolean;
  11314. /**
  11315. * Gets or sets a world offset applied to all particles
  11316. */
  11317. worldOffset: Vector3;
  11318. /**
  11319. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11320. */
  11321. get isAnimationSheetEnabled(): boolean;
  11322. set isAnimationSheetEnabled(value: boolean);
  11323. /**
  11324. * Get hosting scene
  11325. * @returns the scene
  11326. */
  11327. getScene(): Scene;
  11328. /**
  11329. * You can use gravity if you want to give an orientation to your particles.
  11330. */
  11331. gravity: Vector3;
  11332. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11333. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11334. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11335. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11336. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11337. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11338. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11339. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11340. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11341. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11342. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11343. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11344. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11345. /**
  11346. * Defines the delay in milliseconds before starting the system (0 by default)
  11347. */
  11348. startDelay: number;
  11349. /**
  11350. * Gets the current list of drag gradients.
  11351. * You must use addDragGradient and removeDragGradient to udpate this list
  11352. * @returns the list of drag gradients
  11353. */
  11354. getDragGradients(): Nullable<Array<FactorGradient>>;
  11355. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11356. limitVelocityDamping: number;
  11357. /**
  11358. * Gets the current list of limit velocity gradients.
  11359. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11360. * @returns the list of limit velocity gradients
  11361. */
  11362. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11363. /**
  11364. * Gets the current list of color gradients.
  11365. * You must use addColorGradient and removeColorGradient to udpate this list
  11366. * @returns the list of color gradients
  11367. */
  11368. getColorGradients(): Nullable<Array<ColorGradient>>;
  11369. /**
  11370. * Gets the current list of size gradients.
  11371. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11372. * @returns the list of size gradients
  11373. */
  11374. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11375. /**
  11376. * Gets the current list of color remap gradients.
  11377. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11378. * @returns the list of color remap gradients
  11379. */
  11380. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11381. /**
  11382. * Gets the current list of alpha remap gradients.
  11383. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11384. * @returns the list of alpha remap gradients
  11385. */
  11386. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11387. /**
  11388. * Gets the current list of life time gradients.
  11389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11390. * @returns the list of life time gradients
  11391. */
  11392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11393. /**
  11394. * Gets the current list of angular speed gradients.
  11395. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11396. * @returns the list of angular speed gradients
  11397. */
  11398. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11399. /**
  11400. * Gets the current list of velocity gradients.
  11401. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11402. * @returns the list of velocity gradients
  11403. */
  11404. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11405. /**
  11406. * Gets the current list of start size gradients.
  11407. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11408. * @returns the list of start size gradients
  11409. */
  11410. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11411. /**
  11412. * Gets the current list of emit rate gradients.
  11413. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11414. * @returns the list of emit rate gradients
  11415. */
  11416. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11417. /**
  11418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11419. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11420. */
  11421. get direction1(): Vector3;
  11422. set direction1(value: Vector3);
  11423. /**
  11424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11425. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11426. */
  11427. get direction2(): Vector3;
  11428. set direction2(value: Vector3);
  11429. /**
  11430. * 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.
  11431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11432. */
  11433. get minEmitBox(): Vector3;
  11434. set minEmitBox(value: Vector3);
  11435. /**
  11436. * 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.
  11437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11438. */
  11439. get maxEmitBox(): Vector3;
  11440. set maxEmitBox(value: Vector3);
  11441. /**
  11442. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11443. */
  11444. color1: Color4;
  11445. /**
  11446. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11447. */
  11448. color2: Color4;
  11449. /**
  11450. * Color the particle will have at the end of its lifetime
  11451. */
  11452. colorDead: Color4;
  11453. /**
  11454. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11455. */
  11456. textureMask: Color4;
  11457. /**
  11458. * The particle emitter type defines the emitter used by the particle system.
  11459. * It can be for example box, sphere, or cone...
  11460. */
  11461. particleEmitterType: IParticleEmitterType;
  11462. /** @hidden */
  11463. _isSubEmitter: boolean;
  11464. /**
  11465. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11466. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11467. */
  11468. billboardMode: number;
  11469. protected _isBillboardBased: boolean;
  11470. /**
  11471. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11472. */
  11473. get isBillboardBased(): boolean;
  11474. set isBillboardBased(value: boolean);
  11475. /**
  11476. * The scene the particle system belongs to.
  11477. */
  11478. protected _scene: Scene;
  11479. /**
  11480. * Local cache of defines for image processing.
  11481. */
  11482. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11483. /**
  11484. * Default configuration related to image processing available in the standard Material.
  11485. */
  11486. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11487. /**
  11488. * Gets the image processing configuration used either in this material.
  11489. */
  11490. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11491. /**
  11492. * Sets the Default image processing configuration used either in the this material.
  11493. *
  11494. * If sets to null, the scene one is in use.
  11495. */
  11496. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11497. /**
  11498. * Attaches a new image processing configuration to the Standard Material.
  11499. * @param configuration
  11500. */
  11501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11502. /** @hidden */
  11503. protected _reset(): void;
  11504. /** @hidden */
  11505. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11506. /**
  11507. * Instantiates a particle system.
  11508. * 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.
  11509. * @param name The name of the particle system
  11510. */
  11511. constructor(name: string);
  11512. /**
  11513. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11514. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11515. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11516. * @returns the emitter
  11517. */
  11518. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11519. /**
  11520. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11521. * @param radius The radius of the hemisphere to emit from
  11522. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11523. * @returns the emitter
  11524. */
  11525. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11526. /**
  11527. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11528. * @param radius The radius of the sphere to emit from
  11529. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11530. * @returns the emitter
  11531. */
  11532. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11533. /**
  11534. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11535. * @param radius The radius of the sphere to emit from
  11536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11538. * @returns the emitter
  11539. */
  11540. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11541. /**
  11542. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11543. * @param radius The radius of the emission cylinder
  11544. * @param height The height of the emission cylinder
  11545. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11546. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11547. * @returns the emitter
  11548. */
  11549. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11550. /**
  11551. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11552. * @param radius The radius of the cylinder to emit from
  11553. * @param height The height of the emission cylinder
  11554. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11557. * @returns the emitter
  11558. */
  11559. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11560. /**
  11561. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11562. * @param radius The radius of the cone to emit from
  11563. * @param angle The base angle of the cone
  11564. * @returns the emitter
  11565. */
  11566. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11567. /**
  11568. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11571. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11572. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11573. * @returns the emitter
  11574. */
  11575. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11576. }
  11577. }
  11578. declare module BABYLON {
  11579. /**
  11580. * Type of sub emitter
  11581. */
  11582. export enum SubEmitterType {
  11583. /**
  11584. * Attached to the particle over it's lifetime
  11585. */
  11586. ATTACHED = 0,
  11587. /**
  11588. * Created when the particle dies
  11589. */
  11590. END = 1
  11591. }
  11592. /**
  11593. * Sub emitter class used to emit particles from an existing particle
  11594. */
  11595. export class SubEmitter {
  11596. /**
  11597. * the particle system to be used by the sub emitter
  11598. */
  11599. particleSystem: ParticleSystem;
  11600. /**
  11601. * Type of the submitter (Default: END)
  11602. */
  11603. type: SubEmitterType;
  11604. /**
  11605. * 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)
  11606. * Note: This only is supported when using an emitter of type Mesh
  11607. */
  11608. inheritDirection: boolean;
  11609. /**
  11610. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11611. */
  11612. inheritedVelocityAmount: number;
  11613. /**
  11614. * Creates a sub emitter
  11615. * @param particleSystem the particle system to be used by the sub emitter
  11616. */
  11617. constructor(
  11618. /**
  11619. * the particle system to be used by the sub emitter
  11620. */
  11621. particleSystem: ParticleSystem);
  11622. /**
  11623. * Clones the sub emitter
  11624. * @returns the cloned sub emitter
  11625. */
  11626. clone(): SubEmitter;
  11627. /**
  11628. * Serialize current object to a JSON object
  11629. * @returns the serialized object
  11630. */
  11631. serialize(): any;
  11632. /** @hidden */
  11633. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11634. /**
  11635. * Creates a new SubEmitter from a serialized JSON version
  11636. * @param serializationObject defines the JSON object to read from
  11637. * @param scene defines the hosting scene
  11638. * @param rootUrl defines the rootUrl for data loading
  11639. * @returns a new SubEmitter
  11640. */
  11641. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11642. /** Release associated resources */
  11643. dispose(): void;
  11644. }
  11645. }
  11646. declare module BABYLON {
  11647. /** @hidden */
  11648. export var imageProcessingDeclaration: {
  11649. name: string;
  11650. shader: string;
  11651. };
  11652. }
  11653. declare module BABYLON {
  11654. /** @hidden */
  11655. export var imageProcessingFunctions: {
  11656. name: string;
  11657. shader: string;
  11658. };
  11659. }
  11660. declare module BABYLON {
  11661. /** @hidden */
  11662. export var particlesPixelShader: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module BABYLON {
  11668. /** @hidden */
  11669. export var particlesVertexShader: {
  11670. name: string;
  11671. shader: string;
  11672. };
  11673. }
  11674. declare module BABYLON {
  11675. /**
  11676. * This represents a particle system in Babylon.
  11677. * 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.
  11678. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11679. * @example https://doc.babylonjs.com/babylon101/particles
  11680. */
  11681. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11682. /**
  11683. * Billboard mode will only apply to Y axis
  11684. */
  11685. static readonly BILLBOARDMODE_Y: number;
  11686. /**
  11687. * Billboard mode will apply to all axes
  11688. */
  11689. static readonly BILLBOARDMODE_ALL: number;
  11690. /**
  11691. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11692. */
  11693. static readonly BILLBOARDMODE_STRETCHED: number;
  11694. /**
  11695. * This function can be defined to provide custom update for active particles.
  11696. * This function will be called instead of regular update (age, position, color, etc.).
  11697. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11698. */
  11699. updateFunction: (particles: Particle[]) => void;
  11700. private _emitterWorldMatrix;
  11701. /**
  11702. * This function can be defined to specify initial direction for every new particle.
  11703. * It by default use the emitterType defined function
  11704. */
  11705. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11706. /**
  11707. * This function can be defined to specify initial position for every new particle.
  11708. * It by default use the emitterType defined function
  11709. */
  11710. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11711. /**
  11712. * @hidden
  11713. */
  11714. _inheritedVelocityOffset: Vector3;
  11715. /**
  11716. * An event triggered when the system is disposed
  11717. */
  11718. onDisposeObservable: Observable<ParticleSystem>;
  11719. private _onDisposeObserver;
  11720. /**
  11721. * Sets a callback that will be triggered when the system is disposed
  11722. */
  11723. set onDispose(callback: () => void);
  11724. private _particles;
  11725. private _epsilon;
  11726. private _capacity;
  11727. private _stockParticles;
  11728. private _newPartsExcess;
  11729. private _vertexData;
  11730. private _vertexBuffer;
  11731. private _vertexBuffers;
  11732. private _spriteBuffer;
  11733. private _indexBuffer;
  11734. private _effect;
  11735. private _customEffect;
  11736. private _cachedDefines;
  11737. private _scaledColorStep;
  11738. private _colorDiff;
  11739. private _scaledDirection;
  11740. private _scaledGravity;
  11741. private _currentRenderId;
  11742. private _alive;
  11743. private _useInstancing;
  11744. private _started;
  11745. private _stopped;
  11746. private _actualFrame;
  11747. private _scaledUpdateSpeed;
  11748. private _vertexBufferSize;
  11749. /** @hidden */
  11750. _currentEmitRateGradient: Nullable<FactorGradient>;
  11751. /** @hidden */
  11752. _currentEmitRate1: number;
  11753. /** @hidden */
  11754. _currentEmitRate2: number;
  11755. /** @hidden */
  11756. _currentStartSizeGradient: Nullable<FactorGradient>;
  11757. /** @hidden */
  11758. _currentStartSize1: number;
  11759. /** @hidden */
  11760. _currentStartSize2: number;
  11761. private readonly _rawTextureWidth;
  11762. private _rampGradientsTexture;
  11763. private _useRampGradients;
  11764. /** Gets or sets a boolean indicating that ramp gradients must be used
  11765. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11766. */
  11767. get useRampGradients(): boolean;
  11768. set useRampGradients(value: boolean);
  11769. /**
  11770. * 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.
  11771. * 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: [])
  11772. */
  11773. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11774. private _subEmitters;
  11775. /**
  11776. * @hidden
  11777. * If the particle systems emitter should be disposed when the particle system is disposed
  11778. */
  11779. _disposeEmitterOnDispose: boolean;
  11780. /**
  11781. * The current active Sub-systems, this property is used by the root particle system only.
  11782. */
  11783. activeSubSystems: Array<ParticleSystem>;
  11784. /**
  11785. * Specifies if the particles are updated in emitter local space or world space
  11786. */
  11787. isLocal: boolean;
  11788. private _rootParticleSystem;
  11789. /**
  11790. * Gets the current list of active particles
  11791. */
  11792. get particles(): Particle[];
  11793. /**
  11794. * Gets the number of particles active at the same time.
  11795. * @returns The number of active particles.
  11796. */
  11797. getActiveCount(): number;
  11798. /**
  11799. * Returns the string "ParticleSystem"
  11800. * @returns a string containing the class name
  11801. */
  11802. getClassName(): string;
  11803. /**
  11804. * Gets a boolean indicating that the system is stopping
  11805. * @returns true if the system is currently stopping
  11806. */
  11807. isStopping(): boolean;
  11808. /**
  11809. * Instantiates a particle system.
  11810. * 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.
  11811. * @param name The name of the particle system
  11812. * @param capacity The max number of particles alive at the same time
  11813. * @param scene The scene the particle system belongs to
  11814. * @param customEffect a custom effect used to change the way particles are rendered by default
  11815. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11816. * @param epsilon Offset used to render the particles
  11817. */
  11818. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11819. private _addFactorGradient;
  11820. private _removeFactorGradient;
  11821. /**
  11822. * Adds a new life time gradient
  11823. * @param gradient defines the gradient to use (between 0 and 1)
  11824. * @param factor defines the life time factor to affect to the specified gradient
  11825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11826. * @returns the current particle system
  11827. */
  11828. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11829. /**
  11830. * Remove a specific life time gradient
  11831. * @param gradient defines the gradient to remove
  11832. * @returns the current particle system
  11833. */
  11834. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11835. /**
  11836. * Adds a new size gradient
  11837. * @param gradient defines the gradient to use (between 0 and 1)
  11838. * @param factor defines the size factor to affect to the specified gradient
  11839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11840. * @returns the current particle system
  11841. */
  11842. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11843. /**
  11844. * Remove a specific size gradient
  11845. * @param gradient defines the gradient to remove
  11846. * @returns the current particle system
  11847. */
  11848. removeSizeGradient(gradient: number): IParticleSystem;
  11849. /**
  11850. * Adds a new color remap gradient
  11851. * @param gradient defines the gradient to use (between 0 and 1)
  11852. * @param min defines the color remap minimal range
  11853. * @param max defines the color remap maximal range
  11854. * @returns the current particle system
  11855. */
  11856. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11857. /**
  11858. * Remove a specific color remap gradient
  11859. * @param gradient defines the gradient to remove
  11860. * @returns the current particle system
  11861. */
  11862. removeColorRemapGradient(gradient: number): IParticleSystem;
  11863. /**
  11864. * Adds a new alpha remap gradient
  11865. * @param gradient defines the gradient to use (between 0 and 1)
  11866. * @param min defines the alpha remap minimal range
  11867. * @param max defines the alpha remap maximal range
  11868. * @returns the current particle system
  11869. */
  11870. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11871. /**
  11872. * Remove a specific alpha remap gradient
  11873. * @param gradient defines the gradient to remove
  11874. * @returns the current particle system
  11875. */
  11876. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11877. /**
  11878. * Adds a new angular speed gradient
  11879. * @param gradient defines the gradient to use (between 0 and 1)
  11880. * @param factor defines the angular speed to affect to the specified gradient
  11881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11882. * @returns the current particle system
  11883. */
  11884. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11885. /**
  11886. * Remove a specific angular speed gradient
  11887. * @param gradient defines the gradient to remove
  11888. * @returns the current particle system
  11889. */
  11890. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11891. /**
  11892. * Adds a new velocity gradient
  11893. * @param gradient defines the gradient to use (between 0 and 1)
  11894. * @param factor defines the velocity to affect to the specified gradient
  11895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11896. * @returns the current particle system
  11897. */
  11898. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11899. /**
  11900. * Remove a specific velocity gradient
  11901. * @param gradient defines the gradient to remove
  11902. * @returns the current particle system
  11903. */
  11904. removeVelocityGradient(gradient: number): IParticleSystem;
  11905. /**
  11906. * Adds a new limit velocity gradient
  11907. * @param gradient defines the gradient to use (between 0 and 1)
  11908. * @param factor defines the limit velocity value to affect to the specified gradient
  11909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11910. * @returns the current particle system
  11911. */
  11912. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11913. /**
  11914. * Remove a specific limit velocity gradient
  11915. * @param gradient defines the gradient to remove
  11916. * @returns the current particle system
  11917. */
  11918. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11919. /**
  11920. * Adds a new drag gradient
  11921. * @param gradient defines the gradient to use (between 0 and 1)
  11922. * @param factor defines the drag value to affect to the specified gradient
  11923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11924. * @returns the current particle system
  11925. */
  11926. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11927. /**
  11928. * Remove a specific drag gradient
  11929. * @param gradient defines the gradient to remove
  11930. * @returns the current particle system
  11931. */
  11932. removeDragGradient(gradient: number): IParticleSystem;
  11933. /**
  11934. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11935. * @param gradient defines the gradient to use (between 0 and 1)
  11936. * @param factor defines the emit rate value to affect to the specified gradient
  11937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11938. * @returns the current particle system
  11939. */
  11940. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11941. /**
  11942. * Remove a specific emit rate gradient
  11943. * @param gradient defines the gradient to remove
  11944. * @returns the current particle system
  11945. */
  11946. removeEmitRateGradient(gradient: number): IParticleSystem;
  11947. /**
  11948. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11949. * @param gradient defines the gradient to use (between 0 and 1)
  11950. * @param factor defines the start size value to affect to the specified gradient
  11951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11952. * @returns the current particle system
  11953. */
  11954. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11955. /**
  11956. * Remove a specific start size gradient
  11957. * @param gradient defines the gradient to remove
  11958. * @returns the current particle system
  11959. */
  11960. removeStartSizeGradient(gradient: number): IParticleSystem;
  11961. private _createRampGradientTexture;
  11962. /**
  11963. * Gets the current list of ramp gradients.
  11964. * You must use addRampGradient and removeRampGradient to udpate this list
  11965. * @returns the list of ramp gradients
  11966. */
  11967. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11968. /** Force the system to rebuild all gradients that need to be resync */
  11969. forceRefreshGradients(): void;
  11970. private _syncRampGradientTexture;
  11971. /**
  11972. * Adds a new ramp gradient used to remap particle colors
  11973. * @param gradient defines the gradient to use (between 0 and 1)
  11974. * @param color defines the color to affect to the specified gradient
  11975. * @returns the current particle system
  11976. */
  11977. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11978. /**
  11979. * Remove a specific ramp gradient
  11980. * @param gradient defines the gradient to remove
  11981. * @returns the current particle system
  11982. */
  11983. removeRampGradient(gradient: number): ParticleSystem;
  11984. /**
  11985. * Adds a new color gradient
  11986. * @param gradient defines the gradient to use (between 0 and 1)
  11987. * @param color1 defines the color to affect to the specified gradient
  11988. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11989. * @returns this particle system
  11990. */
  11991. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11992. /**
  11993. * Remove a specific color gradient
  11994. * @param gradient defines the gradient to remove
  11995. * @returns this particle system
  11996. */
  11997. removeColorGradient(gradient: number): IParticleSystem;
  11998. private _fetchR;
  11999. protected _reset(): void;
  12000. private _resetEffect;
  12001. private _createVertexBuffers;
  12002. private _createIndexBuffer;
  12003. /**
  12004. * Gets the maximum number of particles active at the same time.
  12005. * @returns The max number of active particles.
  12006. */
  12007. getCapacity(): number;
  12008. /**
  12009. * Gets whether there are still active particles in the system.
  12010. * @returns True if it is alive, otherwise false.
  12011. */
  12012. isAlive(): boolean;
  12013. /**
  12014. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12015. * @returns True if it has been started, otherwise false.
  12016. */
  12017. isStarted(): boolean;
  12018. private _prepareSubEmitterInternalArray;
  12019. /**
  12020. * Starts the particle system and begins to emit
  12021. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12022. */
  12023. start(delay?: number): void;
  12024. /**
  12025. * Stops the particle system.
  12026. * @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.
  12027. */
  12028. stop(stopSubEmitters?: boolean): void;
  12029. /**
  12030. * Remove all active particles
  12031. */
  12032. reset(): void;
  12033. /**
  12034. * @hidden (for internal use only)
  12035. */
  12036. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12037. /**
  12038. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12039. * Its lifetime will start back at 0.
  12040. */
  12041. recycleParticle: (particle: Particle) => void;
  12042. private _stopSubEmitters;
  12043. private _createParticle;
  12044. private _removeFromRoot;
  12045. private _emitFromParticle;
  12046. private _update;
  12047. /** @hidden */
  12048. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12049. /** @hidden */
  12050. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12051. /** @hidden */
  12052. private _getEffect;
  12053. /**
  12054. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12055. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12056. */
  12057. animate(preWarmOnly?: boolean): void;
  12058. private _appendParticleVertices;
  12059. /**
  12060. * Rebuilds the particle system.
  12061. */
  12062. rebuild(): void;
  12063. /**
  12064. * Is this system ready to be used/rendered
  12065. * @return true if the system is ready
  12066. */
  12067. isReady(): boolean;
  12068. private _render;
  12069. /**
  12070. * Renders the particle system in its current state.
  12071. * @returns the current number of particles
  12072. */
  12073. render(): number;
  12074. /**
  12075. * Disposes the particle system and free the associated resources
  12076. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12077. */
  12078. dispose(disposeTexture?: boolean): void;
  12079. /**
  12080. * Clones the particle system.
  12081. * @param name The name of the cloned object
  12082. * @param newEmitter The new emitter to use
  12083. * @returns the cloned particle system
  12084. */
  12085. clone(name: string, newEmitter: any): ParticleSystem;
  12086. /**
  12087. * Serializes the particle system to a JSON object
  12088. * @param serializeTexture defines if the texture must be serialized as well
  12089. * @returns the JSON object
  12090. */
  12091. serialize(serializeTexture?: boolean): any;
  12092. /** @hidden */
  12093. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12094. /** @hidden */
  12095. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12096. /**
  12097. * Parses a JSON object to create a particle system.
  12098. * @param parsedParticleSystem The JSON object to parse
  12099. * @param scene The scene to create the particle system in
  12100. * @param rootUrl The root url to use to load external dependencies like texture
  12101. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12102. * @returns the Parsed particle system
  12103. */
  12104. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12105. }
  12106. }
  12107. declare module BABYLON {
  12108. /**
  12109. * A particle represents one of the element emitted by a particle system.
  12110. * This is mainly define by its coordinates, direction, velocity and age.
  12111. */
  12112. export class Particle {
  12113. /**
  12114. * The particle system the particle belongs to.
  12115. */
  12116. particleSystem: ParticleSystem;
  12117. private static _Count;
  12118. /**
  12119. * Unique ID of the particle
  12120. */
  12121. id: number;
  12122. /**
  12123. * The world position of the particle in the scene.
  12124. */
  12125. position: Vector3;
  12126. /**
  12127. * The world direction of the particle in the scene.
  12128. */
  12129. direction: Vector3;
  12130. /**
  12131. * The color of the particle.
  12132. */
  12133. color: Color4;
  12134. /**
  12135. * The color change of the particle per step.
  12136. */
  12137. colorStep: Color4;
  12138. /**
  12139. * Defines how long will the life of the particle be.
  12140. */
  12141. lifeTime: number;
  12142. /**
  12143. * The current age of the particle.
  12144. */
  12145. age: number;
  12146. /**
  12147. * The current size of the particle.
  12148. */
  12149. size: number;
  12150. /**
  12151. * The current scale of the particle.
  12152. */
  12153. scale: Vector2;
  12154. /**
  12155. * The current angle of the particle.
  12156. */
  12157. angle: number;
  12158. /**
  12159. * Defines how fast is the angle changing.
  12160. */
  12161. angularSpeed: number;
  12162. /**
  12163. * Defines the cell index used by the particle to be rendered from a sprite.
  12164. */
  12165. cellIndex: number;
  12166. /**
  12167. * The information required to support color remapping
  12168. */
  12169. remapData: Vector4;
  12170. /** @hidden */
  12171. _randomCellOffset?: number;
  12172. /** @hidden */
  12173. _initialDirection: Nullable<Vector3>;
  12174. /** @hidden */
  12175. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12176. /** @hidden */
  12177. _initialStartSpriteCellID: number;
  12178. /** @hidden */
  12179. _initialEndSpriteCellID: number;
  12180. /** @hidden */
  12181. _currentColorGradient: Nullable<ColorGradient>;
  12182. /** @hidden */
  12183. _currentColor1: Color4;
  12184. /** @hidden */
  12185. _currentColor2: Color4;
  12186. /** @hidden */
  12187. _currentSizeGradient: Nullable<FactorGradient>;
  12188. /** @hidden */
  12189. _currentSize1: number;
  12190. /** @hidden */
  12191. _currentSize2: number;
  12192. /** @hidden */
  12193. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12194. /** @hidden */
  12195. _currentAngularSpeed1: number;
  12196. /** @hidden */
  12197. _currentAngularSpeed2: number;
  12198. /** @hidden */
  12199. _currentVelocityGradient: Nullable<FactorGradient>;
  12200. /** @hidden */
  12201. _currentVelocity1: number;
  12202. /** @hidden */
  12203. _currentVelocity2: number;
  12204. /** @hidden */
  12205. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12206. /** @hidden */
  12207. _currentLimitVelocity1: number;
  12208. /** @hidden */
  12209. _currentLimitVelocity2: number;
  12210. /** @hidden */
  12211. _currentDragGradient: Nullable<FactorGradient>;
  12212. /** @hidden */
  12213. _currentDrag1: number;
  12214. /** @hidden */
  12215. _currentDrag2: number;
  12216. /** @hidden */
  12217. _randomNoiseCoordinates1: Vector3;
  12218. /** @hidden */
  12219. _randomNoiseCoordinates2: Vector3;
  12220. /** @hidden */
  12221. _localPosition?: Vector3;
  12222. /**
  12223. * Creates a new instance Particle
  12224. * @param particleSystem the particle system the particle belongs to
  12225. */
  12226. constructor(
  12227. /**
  12228. * The particle system the particle belongs to.
  12229. */
  12230. particleSystem: ParticleSystem);
  12231. private updateCellInfoFromSystem;
  12232. /**
  12233. * Defines how the sprite cell index is updated for the particle
  12234. */
  12235. updateCellIndex(): void;
  12236. /** @hidden */
  12237. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12238. /** @hidden */
  12239. _inheritParticleInfoToSubEmitters(): void;
  12240. /** @hidden */
  12241. _reset(): void;
  12242. /**
  12243. * Copy the properties of particle to another one.
  12244. * @param other the particle to copy the information to.
  12245. */
  12246. copyTo(other: Particle): void;
  12247. }
  12248. }
  12249. declare module BABYLON {
  12250. /**
  12251. * Particle emitter represents a volume emitting particles.
  12252. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12253. */
  12254. export interface IParticleEmitterType {
  12255. /**
  12256. * Called by the particle System when the direction is computed for the created particle.
  12257. * @param worldMatrix is the world matrix of the particle system
  12258. * @param directionToUpdate is the direction vector to update with the result
  12259. * @param particle is the particle we are computed the direction for
  12260. * @param isLocal defines if the direction should be set in local space
  12261. */
  12262. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12263. /**
  12264. * Called by the particle System when the position is computed for the created particle.
  12265. * @param worldMatrix is the world matrix of the particle system
  12266. * @param positionToUpdate is the position vector to update with the result
  12267. * @param particle is the particle we are computed the position for
  12268. * @param isLocal defines if the position should be set in local space
  12269. */
  12270. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12271. /**
  12272. * Clones the current emitter and returns a copy of it
  12273. * @returns the new emitter
  12274. */
  12275. clone(): IParticleEmitterType;
  12276. /**
  12277. * Called by the GPUParticleSystem to setup the update shader
  12278. * @param effect defines the update shader
  12279. */
  12280. applyToShader(effect: Effect): void;
  12281. /**
  12282. * Returns a string to use to update the GPU particles update shader
  12283. * @returns the effect defines string
  12284. */
  12285. getEffectDefines(): string;
  12286. /**
  12287. * Returns a string representing the class name
  12288. * @returns a string containing the class name
  12289. */
  12290. getClassName(): string;
  12291. /**
  12292. * Serializes the particle system to a JSON object.
  12293. * @returns the JSON object
  12294. */
  12295. serialize(): any;
  12296. /**
  12297. * Parse properties from a JSON object
  12298. * @param serializationObject defines the JSON object
  12299. * @param scene defines the hosting scene
  12300. */
  12301. parse(serializationObject: any, scene: Scene): void;
  12302. }
  12303. }
  12304. declare module BABYLON {
  12305. /**
  12306. * Particle emitter emitting particles from the inside of a box.
  12307. * It emits the particles randomly between 2 given directions.
  12308. */
  12309. export class BoxParticleEmitter implements IParticleEmitterType {
  12310. /**
  12311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12312. */
  12313. direction1: Vector3;
  12314. /**
  12315. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12316. */
  12317. direction2: Vector3;
  12318. /**
  12319. * 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.
  12320. */
  12321. minEmitBox: Vector3;
  12322. /**
  12323. * 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.
  12324. */
  12325. maxEmitBox: Vector3;
  12326. /**
  12327. * Creates a new instance BoxParticleEmitter
  12328. */
  12329. constructor();
  12330. /**
  12331. * Called by the particle System when the direction is computed for the created particle.
  12332. * @param worldMatrix is the world matrix of the particle system
  12333. * @param directionToUpdate is the direction vector to update with the result
  12334. * @param particle is the particle we are computed the direction for
  12335. * @param isLocal defines if the direction should be set in local space
  12336. */
  12337. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12338. /**
  12339. * Called by the particle System when the position is computed for the created particle.
  12340. * @param worldMatrix is the world matrix of the particle system
  12341. * @param positionToUpdate is the position vector to update with the result
  12342. * @param particle is the particle we are computed the position for
  12343. * @param isLocal defines if the position should be set in local space
  12344. */
  12345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12346. /**
  12347. * Clones the current emitter and returns a copy of it
  12348. * @returns the new emitter
  12349. */
  12350. clone(): BoxParticleEmitter;
  12351. /**
  12352. * Called by the GPUParticleSystem to setup the update shader
  12353. * @param effect defines the update shader
  12354. */
  12355. applyToShader(effect: Effect): void;
  12356. /**
  12357. * Returns a string to use to update the GPU particles update shader
  12358. * @returns a string containng the defines string
  12359. */
  12360. getEffectDefines(): string;
  12361. /**
  12362. * Returns the string "BoxParticleEmitter"
  12363. * @returns a string containing the class name
  12364. */
  12365. getClassName(): string;
  12366. /**
  12367. * Serializes the particle system to a JSON object.
  12368. * @returns the JSON object
  12369. */
  12370. serialize(): any;
  12371. /**
  12372. * Parse properties from a JSON object
  12373. * @param serializationObject defines the JSON object
  12374. */
  12375. parse(serializationObject: any): void;
  12376. }
  12377. }
  12378. declare module BABYLON {
  12379. /**
  12380. * Particle emitter emitting particles from the inside of a cone.
  12381. * It emits the particles alongside the cone volume from the base to the particle.
  12382. * The emission direction might be randomized.
  12383. */
  12384. export class ConeParticleEmitter implements IParticleEmitterType {
  12385. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12386. directionRandomizer: number;
  12387. private _radius;
  12388. private _angle;
  12389. private _height;
  12390. /**
  12391. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12392. */
  12393. radiusRange: number;
  12394. /**
  12395. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12396. */
  12397. heightRange: number;
  12398. /**
  12399. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12400. */
  12401. emitFromSpawnPointOnly: boolean;
  12402. /**
  12403. * Gets or sets the radius of the emission cone
  12404. */
  12405. get radius(): number;
  12406. set radius(value: number);
  12407. /**
  12408. * Gets or sets the angle of the emission cone
  12409. */
  12410. get angle(): number;
  12411. set angle(value: number);
  12412. private _buildHeight;
  12413. /**
  12414. * Creates a new instance ConeParticleEmitter
  12415. * @param radius the radius of the emission cone (1 by default)
  12416. * @param angle the cone base angle (PI by default)
  12417. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12418. */
  12419. constructor(radius?: number, angle?: number,
  12420. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12421. directionRandomizer?: number);
  12422. /**
  12423. * Called by the particle System when the direction is computed for the created particle.
  12424. * @param worldMatrix is the world matrix of the particle system
  12425. * @param directionToUpdate is the direction vector to update with the result
  12426. * @param particle is the particle we are computed the direction for
  12427. * @param isLocal defines if the direction should be set in local space
  12428. */
  12429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12430. /**
  12431. * Called by the particle System when the position is computed for the created particle.
  12432. * @param worldMatrix is the world matrix of the particle system
  12433. * @param positionToUpdate is the position vector to update with the result
  12434. * @param particle is the particle we are computed the position for
  12435. * @param isLocal defines if the position should be set in local space
  12436. */
  12437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12438. /**
  12439. * Clones the current emitter and returns a copy of it
  12440. * @returns the new emitter
  12441. */
  12442. clone(): ConeParticleEmitter;
  12443. /**
  12444. * Called by the GPUParticleSystem to setup the update shader
  12445. * @param effect defines the update shader
  12446. */
  12447. applyToShader(effect: Effect): void;
  12448. /**
  12449. * Returns a string to use to update the GPU particles update shader
  12450. * @returns a string containng the defines string
  12451. */
  12452. getEffectDefines(): string;
  12453. /**
  12454. * Returns the string "ConeParticleEmitter"
  12455. * @returns a string containing the class name
  12456. */
  12457. getClassName(): string;
  12458. /**
  12459. * Serializes the particle system to a JSON object.
  12460. * @returns the JSON object
  12461. */
  12462. serialize(): any;
  12463. /**
  12464. * Parse properties from a JSON object
  12465. * @param serializationObject defines the JSON object
  12466. */
  12467. parse(serializationObject: any): void;
  12468. }
  12469. }
  12470. declare module BABYLON {
  12471. /**
  12472. * Particle emitter emitting particles from the inside of a cylinder.
  12473. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12474. */
  12475. export class CylinderParticleEmitter implements IParticleEmitterType {
  12476. /**
  12477. * The radius of the emission cylinder.
  12478. */
  12479. radius: number;
  12480. /**
  12481. * The height of the emission cylinder.
  12482. */
  12483. height: number;
  12484. /**
  12485. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12486. */
  12487. radiusRange: number;
  12488. /**
  12489. * How much to randomize the particle direction [0-1].
  12490. */
  12491. directionRandomizer: number;
  12492. /**
  12493. * Creates a new instance CylinderParticleEmitter
  12494. * @param radius the radius of the emission cylinder (1 by default)
  12495. * @param height the height of the emission cylinder (1 by default)
  12496. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12498. */
  12499. constructor(
  12500. /**
  12501. * The radius of the emission cylinder.
  12502. */
  12503. radius?: number,
  12504. /**
  12505. * The height of the emission cylinder.
  12506. */
  12507. height?: number,
  12508. /**
  12509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12510. */
  12511. radiusRange?: number,
  12512. /**
  12513. * How much to randomize the particle direction [0-1].
  12514. */
  12515. directionRandomizer?: number);
  12516. /**
  12517. * Called by the particle System when the direction is computed for the created particle.
  12518. * @param worldMatrix is the world matrix of the particle system
  12519. * @param directionToUpdate is the direction vector to update with the result
  12520. * @param particle is the particle we are computed the direction for
  12521. * @param isLocal defines if the direction should be set in local space
  12522. */
  12523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12524. /**
  12525. * Called by the particle System when the position is computed for the created particle.
  12526. * @param worldMatrix is the world matrix of the particle system
  12527. * @param positionToUpdate is the position vector to update with the result
  12528. * @param particle is the particle we are computed the position for
  12529. * @param isLocal defines if the position should be set in local space
  12530. */
  12531. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12532. /**
  12533. * Clones the current emitter and returns a copy of it
  12534. * @returns the new emitter
  12535. */
  12536. clone(): CylinderParticleEmitter;
  12537. /**
  12538. * Called by the GPUParticleSystem to setup the update shader
  12539. * @param effect defines the update shader
  12540. */
  12541. applyToShader(effect: Effect): void;
  12542. /**
  12543. * Returns a string to use to update the GPU particles update shader
  12544. * @returns a string containng the defines string
  12545. */
  12546. getEffectDefines(): string;
  12547. /**
  12548. * Returns the string "CylinderParticleEmitter"
  12549. * @returns a string containing the class name
  12550. */
  12551. getClassName(): string;
  12552. /**
  12553. * Serializes the particle system to a JSON object.
  12554. * @returns the JSON object
  12555. */
  12556. serialize(): any;
  12557. /**
  12558. * Parse properties from a JSON object
  12559. * @param serializationObject defines the JSON object
  12560. */
  12561. parse(serializationObject: any): void;
  12562. }
  12563. /**
  12564. * Particle emitter emitting particles from the inside of a cylinder.
  12565. * It emits the particles randomly between two vectors.
  12566. */
  12567. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12568. /**
  12569. * The min limit of the emission direction.
  12570. */
  12571. direction1: Vector3;
  12572. /**
  12573. * The max limit of the emission direction.
  12574. */
  12575. direction2: Vector3;
  12576. /**
  12577. * Creates a new instance CylinderDirectedParticleEmitter
  12578. * @param radius the radius of the emission cylinder (1 by default)
  12579. * @param height the height of the emission cylinder (1 by default)
  12580. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12581. * @param direction1 the min limit of the emission direction (up vector by default)
  12582. * @param direction2 the max limit of the emission direction (up vector by default)
  12583. */
  12584. constructor(radius?: number, height?: number, radiusRange?: number,
  12585. /**
  12586. * The min limit of the emission direction.
  12587. */
  12588. direction1?: Vector3,
  12589. /**
  12590. * The max limit of the emission direction.
  12591. */
  12592. direction2?: Vector3);
  12593. /**
  12594. * Called by the particle System when the direction is computed for the created particle.
  12595. * @param worldMatrix is the world matrix of the particle system
  12596. * @param directionToUpdate is the direction vector to update with the result
  12597. * @param particle is the particle we are computed the direction for
  12598. */
  12599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12600. /**
  12601. * Clones the current emitter and returns a copy of it
  12602. * @returns the new emitter
  12603. */
  12604. clone(): CylinderDirectedParticleEmitter;
  12605. /**
  12606. * Called by the GPUParticleSystem to setup the update shader
  12607. * @param effect defines the update shader
  12608. */
  12609. applyToShader(effect: Effect): void;
  12610. /**
  12611. * Returns a string to use to update the GPU particles update shader
  12612. * @returns a string containng the defines string
  12613. */
  12614. getEffectDefines(): string;
  12615. /**
  12616. * Returns the string "CylinderDirectedParticleEmitter"
  12617. * @returns a string containing the class name
  12618. */
  12619. getClassName(): string;
  12620. /**
  12621. * Serializes the particle system to a JSON object.
  12622. * @returns the JSON object
  12623. */
  12624. serialize(): any;
  12625. /**
  12626. * Parse properties from a JSON object
  12627. * @param serializationObject defines the JSON object
  12628. */
  12629. parse(serializationObject: any): void;
  12630. }
  12631. }
  12632. declare module BABYLON {
  12633. /**
  12634. * Particle emitter emitting particles from the inside of a hemisphere.
  12635. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12636. */
  12637. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12638. /**
  12639. * The radius of the emission hemisphere.
  12640. */
  12641. radius: number;
  12642. /**
  12643. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12644. */
  12645. radiusRange: number;
  12646. /**
  12647. * How much to randomize the particle direction [0-1].
  12648. */
  12649. directionRandomizer: number;
  12650. /**
  12651. * Creates a new instance HemisphericParticleEmitter
  12652. * @param radius the radius of the emission hemisphere (1 by default)
  12653. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12654. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12655. */
  12656. constructor(
  12657. /**
  12658. * The radius of the emission hemisphere.
  12659. */
  12660. radius?: number,
  12661. /**
  12662. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12663. */
  12664. radiusRange?: number,
  12665. /**
  12666. * How much to randomize the particle direction [0-1].
  12667. */
  12668. directionRandomizer?: number);
  12669. /**
  12670. * Called by the particle System when the direction is computed for the created particle.
  12671. * @param worldMatrix is the world matrix of the particle system
  12672. * @param directionToUpdate is the direction vector to update with the result
  12673. * @param particle is the particle we are computed the direction for
  12674. * @param isLocal defines if the direction should be set in local space
  12675. */
  12676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12677. /**
  12678. * Called by the particle System when the position is computed for the created particle.
  12679. * @param worldMatrix is the world matrix of the particle system
  12680. * @param positionToUpdate is the position vector to update with the result
  12681. * @param particle is the particle we are computed the position for
  12682. * @param isLocal defines if the position should be set in local space
  12683. */
  12684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12685. /**
  12686. * Clones the current emitter and returns a copy of it
  12687. * @returns the new emitter
  12688. */
  12689. clone(): HemisphericParticleEmitter;
  12690. /**
  12691. * Called by the GPUParticleSystem to setup the update shader
  12692. * @param effect defines the update shader
  12693. */
  12694. applyToShader(effect: Effect): void;
  12695. /**
  12696. * Returns a string to use to update the GPU particles update shader
  12697. * @returns a string containng the defines string
  12698. */
  12699. getEffectDefines(): string;
  12700. /**
  12701. * Returns the string "HemisphericParticleEmitter"
  12702. * @returns a string containing the class name
  12703. */
  12704. getClassName(): string;
  12705. /**
  12706. * Serializes the particle system to a JSON object.
  12707. * @returns the JSON object
  12708. */
  12709. serialize(): any;
  12710. /**
  12711. * Parse properties from a JSON object
  12712. * @param serializationObject defines the JSON object
  12713. */
  12714. parse(serializationObject: any): void;
  12715. }
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Particle emitter emitting particles from a point.
  12720. * It emits the particles randomly between 2 given directions.
  12721. */
  12722. export class PointParticleEmitter implements IParticleEmitterType {
  12723. /**
  12724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12725. */
  12726. direction1: Vector3;
  12727. /**
  12728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12729. */
  12730. direction2: Vector3;
  12731. /**
  12732. * Creates a new instance PointParticleEmitter
  12733. */
  12734. constructor();
  12735. /**
  12736. * Called by the particle System when the direction is computed for the created particle.
  12737. * @param worldMatrix is the world matrix of the particle system
  12738. * @param directionToUpdate is the direction vector to update with the result
  12739. * @param particle is the particle we are computed the direction for
  12740. * @param isLocal defines if the direction should be set in local space
  12741. */
  12742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12743. /**
  12744. * Called by the particle System when the position is computed for the created particle.
  12745. * @param worldMatrix is the world matrix of the particle system
  12746. * @param positionToUpdate is the position vector to update with the result
  12747. * @param particle is the particle we are computed the position for
  12748. * @param isLocal defines if the position should be set in local space
  12749. */
  12750. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12751. /**
  12752. * Clones the current emitter and returns a copy of it
  12753. * @returns the new emitter
  12754. */
  12755. clone(): PointParticleEmitter;
  12756. /**
  12757. * Called by the GPUParticleSystem to setup the update shader
  12758. * @param effect defines the update shader
  12759. */
  12760. applyToShader(effect: Effect): void;
  12761. /**
  12762. * Returns a string to use to update the GPU particles update shader
  12763. * @returns a string containng the defines string
  12764. */
  12765. getEffectDefines(): string;
  12766. /**
  12767. * Returns the string "PointParticleEmitter"
  12768. * @returns a string containing the class name
  12769. */
  12770. getClassName(): string;
  12771. /**
  12772. * Serializes the particle system to a JSON object.
  12773. * @returns the JSON object
  12774. */
  12775. serialize(): any;
  12776. /**
  12777. * Parse properties from a JSON object
  12778. * @param serializationObject defines the JSON object
  12779. */
  12780. parse(serializationObject: any): void;
  12781. }
  12782. }
  12783. declare module BABYLON {
  12784. /**
  12785. * Particle emitter emitting particles from the inside of a sphere.
  12786. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12787. */
  12788. export class SphereParticleEmitter implements IParticleEmitterType {
  12789. /**
  12790. * The radius of the emission sphere.
  12791. */
  12792. radius: number;
  12793. /**
  12794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12795. */
  12796. radiusRange: number;
  12797. /**
  12798. * How much to randomize the particle direction [0-1].
  12799. */
  12800. directionRandomizer: number;
  12801. /**
  12802. * Creates a new instance SphereParticleEmitter
  12803. * @param radius the radius of the emission sphere (1 by default)
  12804. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12805. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12806. */
  12807. constructor(
  12808. /**
  12809. * The radius of the emission sphere.
  12810. */
  12811. radius?: number,
  12812. /**
  12813. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12814. */
  12815. radiusRange?: number,
  12816. /**
  12817. * How much to randomize the particle direction [0-1].
  12818. */
  12819. directionRandomizer?: number);
  12820. /**
  12821. * Called by the particle System when the direction is computed for the created particle.
  12822. * @param worldMatrix is the world matrix of the particle system
  12823. * @param directionToUpdate is the direction vector to update with the result
  12824. * @param particle is the particle we are computed the direction for
  12825. * @param isLocal defines if the direction should be set in local space
  12826. */
  12827. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12828. /**
  12829. * Called by the particle System when the position is computed for the created particle.
  12830. * @param worldMatrix is the world matrix of the particle system
  12831. * @param positionToUpdate is the position vector to update with the result
  12832. * @param particle is the particle we are computed the position for
  12833. * @param isLocal defines if the position should be set in local space
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): SphereParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "SphereParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. */
  12865. parse(serializationObject: any): void;
  12866. }
  12867. /**
  12868. * Particle emitter emitting particles from the inside of a sphere.
  12869. * It emits the particles randomly between two vectors.
  12870. */
  12871. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12872. /**
  12873. * The min limit of the emission direction.
  12874. */
  12875. direction1: Vector3;
  12876. /**
  12877. * The max limit of the emission direction.
  12878. */
  12879. direction2: Vector3;
  12880. /**
  12881. * Creates a new instance SphereDirectedParticleEmitter
  12882. * @param radius the radius of the emission sphere (1 by default)
  12883. * @param direction1 the min limit of the emission direction (up vector by default)
  12884. * @param direction2 the max limit of the emission direction (up vector by default)
  12885. */
  12886. constructor(radius?: number,
  12887. /**
  12888. * The min limit of the emission direction.
  12889. */
  12890. direction1?: Vector3,
  12891. /**
  12892. * The max limit of the emission direction.
  12893. */
  12894. direction2?: Vector3);
  12895. /**
  12896. * Called by the particle System when the direction is computed for the created particle.
  12897. * @param worldMatrix is the world matrix of the particle system
  12898. * @param directionToUpdate is the direction vector to update with the result
  12899. * @param particle is the particle we are computed the direction for
  12900. */
  12901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12902. /**
  12903. * Clones the current emitter and returns a copy of it
  12904. * @returns the new emitter
  12905. */
  12906. clone(): SphereDirectedParticleEmitter;
  12907. /**
  12908. * Called by the GPUParticleSystem to setup the update shader
  12909. * @param effect defines the update shader
  12910. */
  12911. applyToShader(effect: Effect): void;
  12912. /**
  12913. * Returns a string to use to update the GPU particles update shader
  12914. * @returns a string containng the defines string
  12915. */
  12916. getEffectDefines(): string;
  12917. /**
  12918. * Returns the string "SphereDirectedParticleEmitter"
  12919. * @returns a string containing the class name
  12920. */
  12921. getClassName(): string;
  12922. /**
  12923. * Serializes the particle system to a JSON object.
  12924. * @returns the JSON object
  12925. */
  12926. serialize(): any;
  12927. /**
  12928. * Parse properties from a JSON object
  12929. * @param serializationObject defines the JSON object
  12930. */
  12931. parse(serializationObject: any): void;
  12932. }
  12933. }
  12934. declare module BABYLON {
  12935. /**
  12936. * Particle emitter emitting particles from a custom list of positions.
  12937. */
  12938. export class CustomParticleEmitter implements IParticleEmitterType {
  12939. /**
  12940. * Gets or sets the position generator that will create the inital position of each particle.
  12941. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12942. */
  12943. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12944. /**
  12945. * Gets or sets the destination generator that will create the final destination of each particle.
  12946. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12947. */
  12948. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12949. /**
  12950. * Creates a new instance CustomParticleEmitter
  12951. */
  12952. constructor();
  12953. /**
  12954. * Called by the particle System when the direction is computed for the created particle.
  12955. * @param worldMatrix is the world matrix of the particle system
  12956. * @param directionToUpdate is the direction vector to update with the result
  12957. * @param particle is the particle we are computed the direction for
  12958. * @param isLocal defines if the direction should be set in local space
  12959. */
  12960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12961. /**
  12962. * Called by the particle System when the position is computed for the created particle.
  12963. * @param worldMatrix is the world matrix of the particle system
  12964. * @param positionToUpdate is the position vector to update with the result
  12965. * @param particle is the particle we are computed the position for
  12966. * @param isLocal defines if the position should be set in local space
  12967. */
  12968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12969. /**
  12970. * Clones the current emitter and returns a copy of it
  12971. * @returns the new emitter
  12972. */
  12973. clone(): CustomParticleEmitter;
  12974. /**
  12975. * Called by the GPUParticleSystem to setup the update shader
  12976. * @param effect defines the update shader
  12977. */
  12978. applyToShader(effect: Effect): void;
  12979. /**
  12980. * Returns a string to use to update the GPU particles update shader
  12981. * @returns a string containng the defines string
  12982. */
  12983. getEffectDefines(): string;
  12984. /**
  12985. * Returns the string "PointParticleEmitter"
  12986. * @returns a string containing the class name
  12987. */
  12988. getClassName(): string;
  12989. /**
  12990. * Serializes the particle system to a JSON object.
  12991. * @returns the JSON object
  12992. */
  12993. serialize(): any;
  12994. /**
  12995. * Parse properties from a JSON object
  12996. * @param serializationObject defines the JSON object
  12997. */
  12998. parse(serializationObject: any): void;
  12999. }
  13000. }
  13001. declare module BABYLON {
  13002. /**
  13003. * Particle emitter emitting particles from the inside of a box.
  13004. * It emits the particles randomly between 2 given directions.
  13005. */
  13006. export class MeshParticleEmitter implements IParticleEmitterType {
  13007. private _indices;
  13008. private _positions;
  13009. private _normals;
  13010. private _storedNormal;
  13011. private _mesh;
  13012. /**
  13013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13014. */
  13015. direction1: Vector3;
  13016. /**
  13017. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13018. */
  13019. direction2: Vector3;
  13020. /**
  13021. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13022. */
  13023. useMeshNormalsForDirection: boolean;
  13024. /** Defines the mesh to use as source */
  13025. get mesh(): Nullable<AbstractMesh>;
  13026. set mesh(value: Nullable<AbstractMesh>);
  13027. /**
  13028. * Creates a new instance MeshParticleEmitter
  13029. * @param mesh defines the mesh to use as source
  13030. */
  13031. constructor(mesh?: Nullable<AbstractMesh>);
  13032. /**
  13033. * Called by the particle System when the direction is computed for the created particle.
  13034. * @param worldMatrix is the world matrix of the particle system
  13035. * @param directionToUpdate is the direction vector to update with the result
  13036. * @param particle is the particle we are computed the direction for
  13037. * @param isLocal defines if the direction should be set in local space
  13038. */
  13039. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13040. /**
  13041. * Called by the particle System when the position is computed for the created particle.
  13042. * @param worldMatrix is the world matrix of the particle system
  13043. * @param positionToUpdate is the position vector to update with the result
  13044. * @param particle is the particle we are computed the position for
  13045. * @param isLocal defines if the position should be set in local space
  13046. */
  13047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13048. /**
  13049. * Clones the current emitter and returns a copy of it
  13050. * @returns the new emitter
  13051. */
  13052. clone(): MeshParticleEmitter;
  13053. /**
  13054. * Called by the GPUParticleSystem to setup the update shader
  13055. * @param effect defines the update shader
  13056. */
  13057. applyToShader(effect: Effect): void;
  13058. /**
  13059. * Returns a string to use to update the GPU particles update shader
  13060. * @returns a string containng the defines string
  13061. */
  13062. getEffectDefines(): string;
  13063. /**
  13064. * Returns the string "BoxParticleEmitter"
  13065. * @returns a string containing the class name
  13066. */
  13067. getClassName(): string;
  13068. /**
  13069. * Serializes the particle system to a JSON object.
  13070. * @returns the JSON object
  13071. */
  13072. serialize(): any;
  13073. /**
  13074. * Parse properties from a JSON object
  13075. * @param serializationObject defines the JSON object
  13076. * @param scene defines the hosting scene
  13077. */
  13078. parse(serializationObject: any, scene: Scene): void;
  13079. }
  13080. }
  13081. declare module BABYLON {
  13082. /**
  13083. * Interface representing a particle system in Babylon.js.
  13084. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13085. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13086. */
  13087. export interface IParticleSystem {
  13088. /**
  13089. * List of animations used by the particle system.
  13090. */
  13091. animations: Animation[];
  13092. /**
  13093. * The id of the Particle system.
  13094. */
  13095. id: string;
  13096. /**
  13097. * The name of the Particle system.
  13098. */
  13099. name: string;
  13100. /**
  13101. * The emitter represents the Mesh or position we are attaching the particle system to.
  13102. */
  13103. emitter: Nullable<AbstractMesh | Vector3>;
  13104. /**
  13105. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13106. */
  13107. isBillboardBased: boolean;
  13108. /**
  13109. * The rendering group used by the Particle system to chose when to render.
  13110. */
  13111. renderingGroupId: number;
  13112. /**
  13113. * The layer mask we are rendering the particles through.
  13114. */
  13115. layerMask: number;
  13116. /**
  13117. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13118. */
  13119. updateSpeed: number;
  13120. /**
  13121. * The amount of time the particle system is running (depends of the overall update speed).
  13122. */
  13123. targetStopDuration: number;
  13124. /**
  13125. * The texture used to render each particle. (this can be a spritesheet)
  13126. */
  13127. particleTexture: Nullable<Texture>;
  13128. /**
  13129. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13130. */
  13131. blendMode: number;
  13132. /**
  13133. * Minimum life time of emitting particles.
  13134. */
  13135. minLifeTime: number;
  13136. /**
  13137. * Maximum life time of emitting particles.
  13138. */
  13139. maxLifeTime: number;
  13140. /**
  13141. * Minimum Size of emitting particles.
  13142. */
  13143. minSize: number;
  13144. /**
  13145. * Maximum Size of emitting particles.
  13146. */
  13147. maxSize: number;
  13148. /**
  13149. * Minimum scale of emitting particles on X axis.
  13150. */
  13151. minScaleX: number;
  13152. /**
  13153. * Maximum scale of emitting particles on X axis.
  13154. */
  13155. maxScaleX: number;
  13156. /**
  13157. * Minimum scale of emitting particles on Y axis.
  13158. */
  13159. minScaleY: number;
  13160. /**
  13161. * Maximum scale of emitting particles on Y axis.
  13162. */
  13163. maxScaleY: number;
  13164. /**
  13165. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13166. */
  13167. color1: Color4;
  13168. /**
  13169. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13170. */
  13171. color2: Color4;
  13172. /**
  13173. * Color the particle will have at the end of its lifetime.
  13174. */
  13175. colorDead: Color4;
  13176. /**
  13177. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13178. */
  13179. emitRate: number;
  13180. /**
  13181. * You can use gravity if you want to give an orientation to your particles.
  13182. */
  13183. gravity: Vector3;
  13184. /**
  13185. * Minimum power of emitting particles.
  13186. */
  13187. minEmitPower: number;
  13188. /**
  13189. * Maximum power of emitting particles.
  13190. */
  13191. maxEmitPower: number;
  13192. /**
  13193. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13194. */
  13195. minAngularSpeed: number;
  13196. /**
  13197. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13198. */
  13199. maxAngularSpeed: number;
  13200. /**
  13201. * Gets or sets the minimal initial rotation in radians.
  13202. */
  13203. minInitialRotation: number;
  13204. /**
  13205. * Gets or sets the maximal initial rotation in radians.
  13206. */
  13207. maxInitialRotation: number;
  13208. /**
  13209. * The particle emitter type defines the emitter used by the particle system.
  13210. * It can be for example box, sphere, or cone...
  13211. */
  13212. particleEmitterType: Nullable<IParticleEmitterType>;
  13213. /**
  13214. * Defines the delay in milliseconds before starting the system (0 by default)
  13215. */
  13216. startDelay: number;
  13217. /**
  13218. * 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
  13219. */
  13220. preWarmCycles: number;
  13221. /**
  13222. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13223. */
  13224. preWarmStepOffset: number;
  13225. /**
  13226. * 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)
  13227. */
  13228. spriteCellChangeSpeed: number;
  13229. /**
  13230. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13231. */
  13232. startSpriteCellID: number;
  13233. /**
  13234. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13235. */
  13236. endSpriteCellID: number;
  13237. /**
  13238. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13239. */
  13240. spriteCellWidth: number;
  13241. /**
  13242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13243. */
  13244. spriteCellHeight: number;
  13245. /**
  13246. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13247. */
  13248. spriteRandomStartCell: boolean;
  13249. /**
  13250. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13251. */
  13252. isAnimationSheetEnabled: boolean;
  13253. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13254. translationPivot: Vector2;
  13255. /**
  13256. * Gets or sets a texture used to add random noise to particle positions
  13257. */
  13258. noiseTexture: Nullable<BaseTexture>;
  13259. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13260. noiseStrength: Vector3;
  13261. /**
  13262. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13263. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13264. */
  13265. billboardMode: number;
  13266. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13267. limitVelocityDamping: number;
  13268. /**
  13269. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13270. */
  13271. beginAnimationOnStart: boolean;
  13272. /**
  13273. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13274. */
  13275. beginAnimationFrom: number;
  13276. /**
  13277. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13278. */
  13279. beginAnimationTo: number;
  13280. /**
  13281. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13282. */
  13283. beginAnimationLoop: boolean;
  13284. /**
  13285. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13286. */
  13287. disposeOnStop: boolean;
  13288. /**
  13289. * Specifies if the particles are updated in emitter local space or world space
  13290. */
  13291. isLocal: boolean;
  13292. /** Snippet ID if the particle system was created from the snippet server */
  13293. snippetId: string;
  13294. /**
  13295. * Gets the maximum number of particles active at the same time.
  13296. * @returns The max number of active particles.
  13297. */
  13298. getCapacity(): number;
  13299. /**
  13300. * Gets the number of particles active at the same time.
  13301. * @returns The number of active particles.
  13302. */
  13303. getActiveCount(): number;
  13304. /**
  13305. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13306. * @returns True if it has been started, otherwise false.
  13307. */
  13308. isStarted(): boolean;
  13309. /**
  13310. * Animates the particle system for this frame.
  13311. */
  13312. animate(): void;
  13313. /**
  13314. * Renders the particle system in its current state.
  13315. * @returns the current number of particles
  13316. */
  13317. render(): number;
  13318. /**
  13319. * Dispose the particle system and frees its associated resources.
  13320. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13321. */
  13322. dispose(disposeTexture?: boolean): void;
  13323. /**
  13324. * Clones the particle system.
  13325. * @param name The name of the cloned object
  13326. * @param newEmitter The new emitter to use
  13327. * @returns the cloned particle system
  13328. */
  13329. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13330. /**
  13331. * Serializes the particle system to a JSON object
  13332. * @param serializeTexture defines if the texture must be serialized as well
  13333. * @returns the JSON object
  13334. */
  13335. serialize(serializeTexture: boolean): any;
  13336. /**
  13337. * Rebuild the particle system
  13338. */
  13339. rebuild(): void;
  13340. /** Force the system to rebuild all gradients that need to be resync */
  13341. forceRefreshGradients(): void;
  13342. /**
  13343. * Starts the particle system and begins to emit
  13344. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13345. */
  13346. start(delay?: number): void;
  13347. /**
  13348. * Stops the particle system.
  13349. */
  13350. stop(): void;
  13351. /**
  13352. * Remove all active particles
  13353. */
  13354. reset(): void;
  13355. /**
  13356. * Gets a boolean indicating that the system is stopping
  13357. * @returns true if the system is currently stopping
  13358. */
  13359. isStopping(): boolean;
  13360. /**
  13361. * Is this system ready to be used/rendered
  13362. * @return true if the system is ready
  13363. */
  13364. isReady(): boolean;
  13365. /**
  13366. * Returns the string "ParticleSystem"
  13367. * @returns a string containing the class name
  13368. */
  13369. getClassName(): string;
  13370. /**
  13371. * Adds a new color gradient
  13372. * @param gradient defines the gradient to use (between 0 and 1)
  13373. * @param color1 defines the color to affect to the specified gradient
  13374. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13375. * @returns the current particle system
  13376. */
  13377. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13378. /**
  13379. * Remove a specific color gradient
  13380. * @param gradient defines the gradient to remove
  13381. * @returns the current particle system
  13382. */
  13383. removeColorGradient(gradient: number): IParticleSystem;
  13384. /**
  13385. * Adds a new size gradient
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param factor defines the size factor to affect to the specified gradient
  13388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13389. * @returns the current particle system
  13390. */
  13391. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13392. /**
  13393. * Remove a specific size gradient
  13394. * @param gradient defines the gradient to remove
  13395. * @returns the current particle system
  13396. */
  13397. removeSizeGradient(gradient: number): IParticleSystem;
  13398. /**
  13399. * Gets the current list of color gradients.
  13400. * You must use addColorGradient and removeColorGradient to udpate this list
  13401. * @returns the list of color gradients
  13402. */
  13403. getColorGradients(): Nullable<Array<ColorGradient>>;
  13404. /**
  13405. * Gets the current list of size gradients.
  13406. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13407. * @returns the list of size gradients
  13408. */
  13409. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13410. /**
  13411. * Gets the current list of angular speed gradients.
  13412. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13413. * @returns the list of angular speed gradients
  13414. */
  13415. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13416. /**
  13417. * Adds a new angular speed gradient
  13418. * @param gradient defines the gradient to use (between 0 and 1)
  13419. * @param factor defines the angular speed to affect to the specified gradient
  13420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13421. * @returns the current particle system
  13422. */
  13423. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13424. /**
  13425. * Remove a specific angular speed gradient
  13426. * @param gradient defines the gradient to remove
  13427. * @returns the current particle system
  13428. */
  13429. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13430. /**
  13431. * Gets the current list of velocity gradients.
  13432. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13433. * @returns the list of velocity gradients
  13434. */
  13435. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13436. /**
  13437. * Adds a new velocity gradient
  13438. * @param gradient defines the gradient to use (between 0 and 1)
  13439. * @param factor defines the velocity to affect to the specified gradient
  13440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13441. * @returns the current particle system
  13442. */
  13443. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13444. /**
  13445. * Remove a specific velocity gradient
  13446. * @param gradient defines the gradient to remove
  13447. * @returns the current particle system
  13448. */
  13449. removeVelocityGradient(gradient: number): IParticleSystem;
  13450. /**
  13451. * Gets the current list of limit velocity gradients.
  13452. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13453. * @returns the list of limit velocity gradients
  13454. */
  13455. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13456. /**
  13457. * Adds a new limit velocity gradient
  13458. * @param gradient defines the gradient to use (between 0 and 1)
  13459. * @param factor defines the limit velocity to affect to the specified gradient
  13460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13461. * @returns the current particle system
  13462. */
  13463. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13464. /**
  13465. * Remove a specific limit velocity gradient
  13466. * @param gradient defines the gradient to remove
  13467. * @returns the current particle system
  13468. */
  13469. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13470. /**
  13471. * Adds a new drag gradient
  13472. * @param gradient defines the gradient to use (between 0 and 1)
  13473. * @param factor defines the drag to affect to the specified gradient
  13474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13475. * @returns the current particle system
  13476. */
  13477. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13478. /**
  13479. * Remove a specific drag gradient
  13480. * @param gradient defines the gradient to remove
  13481. * @returns the current particle system
  13482. */
  13483. removeDragGradient(gradient: number): IParticleSystem;
  13484. /**
  13485. * Gets the current list of drag gradients.
  13486. * You must use addDragGradient and removeDragGradient to udpate this list
  13487. * @returns the list of drag gradients
  13488. */
  13489. getDragGradients(): Nullable<Array<FactorGradient>>;
  13490. /**
  13491. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13492. * @param gradient defines the gradient to use (between 0 and 1)
  13493. * @param factor defines the emit rate to affect to the specified gradient
  13494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13495. * @returns the current particle system
  13496. */
  13497. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13498. /**
  13499. * Remove a specific emit rate gradient
  13500. * @param gradient defines the gradient to remove
  13501. * @returns the current particle system
  13502. */
  13503. removeEmitRateGradient(gradient: number): IParticleSystem;
  13504. /**
  13505. * Gets the current list of emit rate gradients.
  13506. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13507. * @returns the list of emit rate gradients
  13508. */
  13509. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13510. /**
  13511. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13512. * @param gradient defines the gradient to use (between 0 and 1)
  13513. * @param factor defines the start size to affect to the specified gradient
  13514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13515. * @returns the current particle system
  13516. */
  13517. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13518. /**
  13519. * Remove a specific start size gradient
  13520. * @param gradient defines the gradient to remove
  13521. * @returns the current particle system
  13522. */
  13523. removeStartSizeGradient(gradient: number): IParticleSystem;
  13524. /**
  13525. * Gets the current list of start size gradients.
  13526. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13527. * @returns the list of start size gradients
  13528. */
  13529. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13530. /**
  13531. * Adds a new life time gradient
  13532. * @param gradient defines the gradient to use (between 0 and 1)
  13533. * @param factor defines the life time factor to affect to the specified gradient
  13534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13535. * @returns the current particle system
  13536. */
  13537. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13538. /**
  13539. * Remove a specific life time gradient
  13540. * @param gradient defines the gradient to remove
  13541. * @returns the current particle system
  13542. */
  13543. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13544. /**
  13545. * Gets the current list of life time gradients.
  13546. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13547. * @returns the list of life time gradients
  13548. */
  13549. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13550. /**
  13551. * Gets the current list of color gradients.
  13552. * You must use addColorGradient and removeColorGradient to udpate this list
  13553. * @returns the list of color gradients
  13554. */
  13555. getColorGradients(): Nullable<Array<ColorGradient>>;
  13556. /**
  13557. * Adds a new ramp gradient used to remap particle colors
  13558. * @param gradient defines the gradient to use (between 0 and 1)
  13559. * @param color defines the color to affect to the specified gradient
  13560. * @returns the current particle system
  13561. */
  13562. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13563. /**
  13564. * Gets the current list of ramp gradients.
  13565. * You must use addRampGradient and removeRampGradient to udpate this list
  13566. * @returns the list of ramp gradients
  13567. */
  13568. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13569. /** Gets or sets a boolean indicating that ramp gradients must be used
  13570. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13571. */
  13572. useRampGradients: boolean;
  13573. /**
  13574. * Adds a new color remap gradient
  13575. * @param gradient defines the gradient to use (between 0 and 1)
  13576. * @param min defines the color remap minimal range
  13577. * @param max defines the color remap maximal range
  13578. * @returns the current particle system
  13579. */
  13580. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13581. /**
  13582. * Gets the current list of color remap gradients.
  13583. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13584. * @returns the list of color remap gradients
  13585. */
  13586. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13587. /**
  13588. * Adds a new alpha remap gradient
  13589. * @param gradient defines the gradient to use (between 0 and 1)
  13590. * @param min defines the alpha remap minimal range
  13591. * @param max defines the alpha remap maximal range
  13592. * @returns the current particle system
  13593. */
  13594. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13595. /**
  13596. * Gets the current list of alpha remap gradients.
  13597. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13598. * @returns the list of alpha remap gradients
  13599. */
  13600. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13601. /**
  13602. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13605. * @returns the emitter
  13606. */
  13607. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13608. /**
  13609. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13610. * @param radius The radius of the hemisphere to emit from
  13611. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13612. * @returns the emitter
  13613. */
  13614. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13615. /**
  13616. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13617. * @param radius The radius of the sphere to emit from
  13618. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13619. * @returns the emitter
  13620. */
  13621. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13622. /**
  13623. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13624. * @param radius The radius of the sphere to emit from
  13625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13627. * @returns the emitter
  13628. */
  13629. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13630. /**
  13631. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13632. * @param radius The radius of the emission cylinder
  13633. * @param height The height of the emission cylinder
  13634. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13635. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13636. * @returns the emitter
  13637. */
  13638. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13639. /**
  13640. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13641. * @param radius The radius of the cylinder to emit from
  13642. * @param height The height of the emission cylinder
  13643. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13644. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13645. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13646. * @returns the emitter
  13647. */
  13648. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13649. /**
  13650. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13651. * @param radius The radius of the cone to emit from
  13652. * @param angle The base angle of the cone
  13653. * @returns the emitter
  13654. */
  13655. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13656. /**
  13657. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13658. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13659. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13660. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13661. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13662. * @returns the emitter
  13663. */
  13664. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13665. /**
  13666. * Get hosting scene
  13667. * @returns the scene
  13668. */
  13669. getScene(): Scene;
  13670. }
  13671. }
  13672. declare module BABYLON {
  13673. /**
  13674. * 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.
  13675. * @see https://doc.babylonjs.com/how_to/transformnode
  13676. */
  13677. export class TransformNode extends Node {
  13678. /**
  13679. * Object will not rotate to face the camera
  13680. */
  13681. static BILLBOARDMODE_NONE: number;
  13682. /**
  13683. * Object will rotate to face the camera but only on the x axis
  13684. */
  13685. static BILLBOARDMODE_X: number;
  13686. /**
  13687. * Object will rotate to face the camera but only on the y axis
  13688. */
  13689. static BILLBOARDMODE_Y: number;
  13690. /**
  13691. * Object will rotate to face the camera but only on the z axis
  13692. */
  13693. static BILLBOARDMODE_Z: number;
  13694. /**
  13695. * Object will rotate to face the camera
  13696. */
  13697. static BILLBOARDMODE_ALL: number;
  13698. /**
  13699. * Object will rotate to face the camera's position instead of orientation
  13700. */
  13701. static BILLBOARDMODE_USE_POSITION: number;
  13702. private _forward;
  13703. private _forwardInverted;
  13704. private _up;
  13705. private _right;
  13706. private _rightInverted;
  13707. private _position;
  13708. private _rotation;
  13709. private _rotationQuaternion;
  13710. protected _scaling: Vector3;
  13711. protected _isDirty: boolean;
  13712. private _transformToBoneReferal;
  13713. private _isAbsoluteSynced;
  13714. private _billboardMode;
  13715. /**
  13716. * Gets or sets the billboard mode. Default is 0.
  13717. *
  13718. * | Value | Type | Description |
  13719. * | --- | --- | --- |
  13720. * | 0 | BILLBOARDMODE_NONE | |
  13721. * | 1 | BILLBOARDMODE_X | |
  13722. * | 2 | BILLBOARDMODE_Y | |
  13723. * | 4 | BILLBOARDMODE_Z | |
  13724. * | 7 | BILLBOARDMODE_ALL | |
  13725. *
  13726. */
  13727. get billboardMode(): number;
  13728. set billboardMode(value: number);
  13729. private _preserveParentRotationForBillboard;
  13730. /**
  13731. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13732. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13733. */
  13734. get preserveParentRotationForBillboard(): boolean;
  13735. set preserveParentRotationForBillboard(value: boolean);
  13736. /**
  13737. * 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
  13738. */
  13739. scalingDeterminant: number;
  13740. private _infiniteDistance;
  13741. /**
  13742. * Gets or sets the distance of the object to max, often used by skybox
  13743. */
  13744. get infiniteDistance(): boolean;
  13745. set infiniteDistance(value: boolean);
  13746. /**
  13747. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13748. * By default the system will update normals to compensate
  13749. */
  13750. ignoreNonUniformScaling: boolean;
  13751. /**
  13752. * 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
  13753. */
  13754. reIntegrateRotationIntoRotationQuaternion: boolean;
  13755. /** @hidden */
  13756. _poseMatrix: Nullable<Matrix>;
  13757. /** @hidden */
  13758. _localMatrix: Matrix;
  13759. private _usePivotMatrix;
  13760. private _absolutePosition;
  13761. private _absoluteScaling;
  13762. private _absoluteRotationQuaternion;
  13763. private _pivotMatrix;
  13764. private _pivotMatrixInverse;
  13765. protected _postMultiplyPivotMatrix: boolean;
  13766. protected _isWorldMatrixFrozen: boolean;
  13767. /** @hidden */
  13768. _indexInSceneTransformNodesArray: number;
  13769. /**
  13770. * An event triggered after the world matrix is updated
  13771. */
  13772. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13773. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13774. /**
  13775. * Gets a string identifying the name of the class
  13776. * @returns "TransformNode" string
  13777. */
  13778. getClassName(): string;
  13779. /**
  13780. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13781. */
  13782. get position(): Vector3;
  13783. set position(newPosition: Vector3);
  13784. /**
  13785. * 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)).
  13786. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13787. */
  13788. get rotation(): Vector3;
  13789. set rotation(newRotation: Vector3);
  13790. /**
  13791. * 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)).
  13792. */
  13793. get scaling(): Vector3;
  13794. set scaling(newScaling: Vector3);
  13795. /**
  13796. * 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).
  13797. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13798. */
  13799. get rotationQuaternion(): Nullable<Quaternion>;
  13800. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13801. /**
  13802. * The forward direction of that transform in world space.
  13803. */
  13804. get forward(): Vector3;
  13805. /**
  13806. * The up direction of that transform in world space.
  13807. */
  13808. get up(): Vector3;
  13809. /**
  13810. * The right direction of that transform in world space.
  13811. */
  13812. get right(): Vector3;
  13813. /**
  13814. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13815. * @param matrix the matrix to copy the pose from
  13816. * @returns this TransformNode.
  13817. */
  13818. updatePoseMatrix(matrix: Matrix): TransformNode;
  13819. /**
  13820. * Returns the mesh Pose matrix.
  13821. * @returns the pose matrix
  13822. */
  13823. getPoseMatrix(): Matrix;
  13824. /** @hidden */
  13825. _isSynchronized(): boolean;
  13826. /** @hidden */
  13827. _initCache(): void;
  13828. /**
  13829. * Flag the transform node as dirty (Forcing it to update everything)
  13830. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13831. * @returns this transform node
  13832. */
  13833. markAsDirty(property: string): TransformNode;
  13834. /**
  13835. * Returns the current mesh absolute position.
  13836. * Returns a Vector3.
  13837. */
  13838. get absolutePosition(): Vector3;
  13839. /**
  13840. * Returns the current mesh absolute scaling.
  13841. * Returns a Vector3.
  13842. */
  13843. get absoluteScaling(): Vector3;
  13844. /**
  13845. * Returns the current mesh absolute rotation.
  13846. * Returns a Quaternion.
  13847. */
  13848. get absoluteRotationQuaternion(): Quaternion;
  13849. /**
  13850. * Sets a new matrix to apply before all other transformation
  13851. * @param matrix defines the transform matrix
  13852. * @returns the current TransformNode
  13853. */
  13854. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13855. /**
  13856. * Sets a new pivot matrix to the current node
  13857. * @param matrix defines the new pivot matrix to use
  13858. * @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
  13859. * @returns the current TransformNode
  13860. */
  13861. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13862. /**
  13863. * Returns the mesh pivot matrix.
  13864. * Default : Identity.
  13865. * @returns the matrix
  13866. */
  13867. getPivotMatrix(): Matrix;
  13868. /**
  13869. * Instantiate (when possible) or clone that node with its hierarchy
  13870. * @param newParent defines the new parent to use for the instance (or clone)
  13871. * @param options defines options to configure how copy is done
  13872. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13873. * @returns an instance (or a clone) of the current node with its hiearchy
  13874. */
  13875. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13876. doNotInstantiate: boolean;
  13877. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13878. /**
  13879. * Prevents the World matrix to be computed any longer
  13880. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13881. * @returns the TransformNode.
  13882. */
  13883. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13884. /**
  13885. * Allows back the World matrix computation.
  13886. * @returns the TransformNode.
  13887. */
  13888. unfreezeWorldMatrix(): this;
  13889. /**
  13890. * True if the World matrix has been frozen.
  13891. */
  13892. get isWorldMatrixFrozen(): boolean;
  13893. /**
  13894. * Retuns the mesh absolute position in the World.
  13895. * @returns a Vector3.
  13896. */
  13897. getAbsolutePosition(): Vector3;
  13898. /**
  13899. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13900. * @param absolutePosition the absolute position to set
  13901. * @returns the TransformNode.
  13902. */
  13903. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13904. /**
  13905. * Sets the mesh position in its local space.
  13906. * @param vector3 the position to set in localspace
  13907. * @returns the TransformNode.
  13908. */
  13909. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13910. /**
  13911. * Returns the mesh position in the local space from the current World matrix values.
  13912. * @returns a new Vector3.
  13913. */
  13914. getPositionExpressedInLocalSpace(): Vector3;
  13915. /**
  13916. * Translates the mesh along the passed Vector3 in its local space.
  13917. * @param vector3 the distance to translate in localspace
  13918. * @returns the TransformNode.
  13919. */
  13920. locallyTranslate(vector3: Vector3): TransformNode;
  13921. private static _lookAtVectorCache;
  13922. /**
  13923. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13924. * @param targetPoint the position (must be in same space as current mesh) to look at
  13925. * @param yawCor optional yaw (y-axis) correction in radians
  13926. * @param pitchCor optional pitch (x-axis) correction in radians
  13927. * @param rollCor optional roll (z-axis) correction in radians
  13928. * @param space the choosen space of the target
  13929. * @returns the TransformNode.
  13930. */
  13931. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13932. /**
  13933. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13934. * This Vector3 is expressed in the World space.
  13935. * @param localAxis axis to rotate
  13936. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13937. */
  13938. getDirection(localAxis: Vector3): Vector3;
  13939. /**
  13940. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13941. * localAxis is expressed in the mesh local space.
  13942. * result is computed in the Wordl space from the mesh World matrix.
  13943. * @param localAxis axis to rotate
  13944. * @param result the resulting transformnode
  13945. * @returns this TransformNode.
  13946. */
  13947. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13948. /**
  13949. * Sets this transform node rotation to the given local axis.
  13950. * @param localAxis the axis in local space
  13951. * @param yawCor optional yaw (y-axis) correction in radians
  13952. * @param pitchCor optional pitch (x-axis) correction in radians
  13953. * @param rollCor optional roll (z-axis) correction in radians
  13954. * @returns this TransformNode
  13955. */
  13956. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13957. /**
  13958. * Sets a new pivot point to the current node
  13959. * @param point defines the new pivot point to use
  13960. * @param space defines if the point is in world or local space (local by default)
  13961. * @returns the current TransformNode
  13962. */
  13963. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13964. /**
  13965. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13966. * @returns the pivot point
  13967. */
  13968. getPivotPoint(): Vector3;
  13969. /**
  13970. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13971. * @param result the vector3 to store the result
  13972. * @returns this TransformNode.
  13973. */
  13974. getPivotPointToRef(result: Vector3): TransformNode;
  13975. /**
  13976. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13977. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13978. */
  13979. getAbsolutePivotPoint(): Vector3;
  13980. /**
  13981. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13982. * @param result vector3 to store the result
  13983. * @returns this TransformNode.
  13984. */
  13985. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13986. /**
  13987. * Defines the passed node as the parent of the current node.
  13988. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13989. * @see https://doc.babylonjs.com/how_to/parenting
  13990. * @param node the node ot set as the parent
  13991. * @returns this TransformNode.
  13992. */
  13993. setParent(node: Nullable<Node>): TransformNode;
  13994. private _nonUniformScaling;
  13995. /**
  13996. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13997. */
  13998. get nonUniformScaling(): boolean;
  13999. /** @hidden */
  14000. _updateNonUniformScalingState(value: boolean): boolean;
  14001. /**
  14002. * Attach the current TransformNode to another TransformNode associated with a bone
  14003. * @param bone Bone affecting the TransformNode
  14004. * @param affectedTransformNode TransformNode associated with the bone
  14005. * @returns this object
  14006. */
  14007. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14008. /**
  14009. * Detach the transform node if its associated with a bone
  14010. * @returns this object
  14011. */
  14012. detachFromBone(): TransformNode;
  14013. private static _rotationAxisCache;
  14014. /**
  14015. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14016. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14017. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14018. * The passed axis is also normalized.
  14019. * @param axis the axis to rotate around
  14020. * @param amount the amount to rotate in radians
  14021. * @param space Space to rotate in (Default: local)
  14022. * @returns the TransformNode.
  14023. */
  14024. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14025. /**
  14026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14027. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14028. * The passed axis is also normalized. .
  14029. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14030. * @param point the point to rotate around
  14031. * @param axis the axis to rotate around
  14032. * @param amount the amount to rotate in radians
  14033. * @returns the TransformNode
  14034. */
  14035. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14036. /**
  14037. * Translates the mesh along the axis vector for the passed distance in the given space.
  14038. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14039. * @param axis the axis to translate in
  14040. * @param distance the distance to translate
  14041. * @param space Space to rotate in (Default: local)
  14042. * @returns the TransformNode.
  14043. */
  14044. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14045. /**
  14046. * Adds a rotation step to the mesh current rotation.
  14047. * x, y, z are Euler angles expressed in radians.
  14048. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14049. * This means this rotation is made in the mesh local space only.
  14050. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14051. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14052. * ```javascript
  14053. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14054. * ```
  14055. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14056. * 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.
  14057. * @param x Rotation to add
  14058. * @param y Rotation to add
  14059. * @param z Rotation to add
  14060. * @returns the TransformNode.
  14061. */
  14062. addRotation(x: number, y: number, z: number): TransformNode;
  14063. /**
  14064. * @hidden
  14065. */
  14066. protected _getEffectiveParent(): Nullable<Node>;
  14067. /**
  14068. * Computes the world matrix of the node
  14069. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14070. * @returns the world matrix
  14071. */
  14072. computeWorldMatrix(force?: boolean): Matrix;
  14073. /**
  14074. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14075. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14076. */
  14077. resetLocalMatrix(independentOfChildren?: boolean): void;
  14078. protected _afterComputeWorldMatrix(): void;
  14079. /**
  14080. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14081. * @param func callback function to add
  14082. *
  14083. * @returns the TransformNode.
  14084. */
  14085. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14086. /**
  14087. * Removes a registered callback function.
  14088. * @param func callback function to remove
  14089. * @returns the TransformNode.
  14090. */
  14091. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14092. /**
  14093. * Gets the position of the current mesh in camera space
  14094. * @param camera defines the camera to use
  14095. * @returns a position
  14096. */
  14097. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14098. /**
  14099. * Returns the distance from the mesh to the active camera
  14100. * @param camera defines the camera to use
  14101. * @returns the distance
  14102. */
  14103. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14104. /**
  14105. * Clone the current transform node
  14106. * @param name Name of the new clone
  14107. * @param newParent New parent for the clone
  14108. * @param doNotCloneChildren Do not clone children hierarchy
  14109. * @returns the new transform node
  14110. */
  14111. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14112. /**
  14113. * Serializes the objects information.
  14114. * @param currentSerializationObject defines the object to serialize in
  14115. * @returns the serialized object
  14116. */
  14117. serialize(currentSerializationObject?: any): any;
  14118. /**
  14119. * Returns a new TransformNode object parsed from the source provided.
  14120. * @param parsedTransformNode is the source.
  14121. * @param scene the scne the object belongs to
  14122. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14123. * @returns a new TransformNode object parsed from the source provided.
  14124. */
  14125. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14126. /**
  14127. * Get all child-transformNodes of this node
  14128. * @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
  14129. * @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
  14130. * @returns an array of TransformNode
  14131. */
  14132. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14133. /**
  14134. * Releases resources associated with this transform node.
  14135. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14136. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14137. */
  14138. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14139. /**
  14140. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14141. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14142. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14143. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14144. * @returns the current mesh
  14145. */
  14146. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14147. private _syncAbsoluteScalingAndRotation;
  14148. }
  14149. }
  14150. declare module BABYLON {
  14151. /**
  14152. * Class used to override all child animations of a given target
  14153. */
  14154. export class AnimationPropertiesOverride {
  14155. /**
  14156. * Gets or sets a value indicating if animation blending must be used
  14157. */
  14158. enableBlending: boolean;
  14159. /**
  14160. * Gets or sets the blending speed to use when enableBlending is true
  14161. */
  14162. blendingSpeed: number;
  14163. /**
  14164. * Gets or sets the default loop mode to use
  14165. */
  14166. loopMode: number;
  14167. }
  14168. }
  14169. declare module BABYLON {
  14170. /**
  14171. * Class used to store bone information
  14172. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14173. */
  14174. export class Bone extends Node {
  14175. /**
  14176. * defines the bone name
  14177. */
  14178. name: string;
  14179. private static _tmpVecs;
  14180. private static _tmpQuat;
  14181. private static _tmpMats;
  14182. /**
  14183. * Gets the list of child bones
  14184. */
  14185. children: Bone[];
  14186. /** Gets the animations associated with this bone */
  14187. animations: Animation[];
  14188. /**
  14189. * Gets or sets bone length
  14190. */
  14191. length: number;
  14192. /**
  14193. * @hidden Internal only
  14194. * Set this value to map this bone to a different index in the transform matrices
  14195. * Set this value to -1 to exclude the bone from the transform matrices
  14196. */
  14197. _index: Nullable<number>;
  14198. private _skeleton;
  14199. private _localMatrix;
  14200. private _restPose;
  14201. private _baseMatrix;
  14202. private _absoluteTransform;
  14203. private _invertedAbsoluteTransform;
  14204. private _parent;
  14205. private _scalingDeterminant;
  14206. private _worldTransform;
  14207. private _localScaling;
  14208. private _localRotation;
  14209. private _localPosition;
  14210. private _needToDecompose;
  14211. private _needToCompose;
  14212. /** @hidden */
  14213. _linkedTransformNode: Nullable<TransformNode>;
  14214. /** @hidden */
  14215. _waitingTransformNodeId: Nullable<string>;
  14216. /** @hidden */
  14217. get _matrix(): Matrix;
  14218. /** @hidden */
  14219. set _matrix(value: Matrix);
  14220. /**
  14221. * Create a new bone
  14222. * @param name defines the bone name
  14223. * @param skeleton defines the parent skeleton
  14224. * @param parentBone defines the parent (can be null if the bone is the root)
  14225. * @param localMatrix defines the local matrix
  14226. * @param restPose defines the rest pose matrix
  14227. * @param baseMatrix defines the base matrix
  14228. * @param index defines index of the bone in the hiearchy
  14229. */
  14230. constructor(
  14231. /**
  14232. * defines the bone name
  14233. */
  14234. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14235. /**
  14236. * Gets the current object class name.
  14237. * @return the class name
  14238. */
  14239. getClassName(): string;
  14240. /**
  14241. * Gets the parent skeleton
  14242. * @returns a skeleton
  14243. */
  14244. getSkeleton(): Skeleton;
  14245. /**
  14246. * Gets parent bone
  14247. * @returns a bone or null if the bone is the root of the bone hierarchy
  14248. */
  14249. getParent(): Nullable<Bone>;
  14250. /**
  14251. * Returns an array containing the root bones
  14252. * @returns an array containing the root bones
  14253. */
  14254. getChildren(): Array<Bone>;
  14255. /**
  14256. * Gets the node index in matrix array generated for rendering
  14257. * @returns the node index
  14258. */
  14259. getIndex(): number;
  14260. /**
  14261. * Sets the parent bone
  14262. * @param parent defines the parent (can be null if the bone is the root)
  14263. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14264. */
  14265. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14266. /**
  14267. * Gets the local matrix
  14268. * @returns a matrix
  14269. */
  14270. getLocalMatrix(): Matrix;
  14271. /**
  14272. * Gets the base matrix (initial matrix which remains unchanged)
  14273. * @returns a matrix
  14274. */
  14275. getBaseMatrix(): Matrix;
  14276. /**
  14277. * Gets the rest pose matrix
  14278. * @returns a matrix
  14279. */
  14280. getRestPose(): Matrix;
  14281. /**
  14282. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14283. */
  14284. getWorldMatrix(): Matrix;
  14285. /**
  14286. * Sets the local matrix to rest pose matrix
  14287. */
  14288. returnToRest(): void;
  14289. /**
  14290. * Gets the inverse of the absolute transform matrix.
  14291. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14292. * @returns a matrix
  14293. */
  14294. getInvertedAbsoluteTransform(): Matrix;
  14295. /**
  14296. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14297. * @returns a matrix
  14298. */
  14299. getAbsoluteTransform(): Matrix;
  14300. /**
  14301. * Links with the given transform node.
  14302. * The local matrix of this bone is copied from the transform node every frame.
  14303. * @param transformNode defines the transform node to link to
  14304. */
  14305. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14306. /**
  14307. * Gets the node used to drive the bone's transformation
  14308. * @returns a transform node or null
  14309. */
  14310. getTransformNode(): Nullable<TransformNode>;
  14311. /** Gets or sets current position (in local space) */
  14312. get position(): Vector3;
  14313. set position(newPosition: Vector3);
  14314. /** Gets or sets current rotation (in local space) */
  14315. get rotation(): Vector3;
  14316. set rotation(newRotation: Vector3);
  14317. /** Gets or sets current rotation quaternion (in local space) */
  14318. get rotationQuaternion(): Quaternion;
  14319. set rotationQuaternion(newRotation: Quaternion);
  14320. /** Gets or sets current scaling (in local space) */
  14321. get scaling(): Vector3;
  14322. set scaling(newScaling: Vector3);
  14323. /**
  14324. * Gets the animation properties override
  14325. */
  14326. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14327. private _decompose;
  14328. private _compose;
  14329. /**
  14330. * Update the base and local matrices
  14331. * @param matrix defines the new base or local matrix
  14332. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14333. * @param updateLocalMatrix defines if the local matrix should be updated
  14334. */
  14335. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14336. /** @hidden */
  14337. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14338. /**
  14339. * Flag the bone as dirty (Forcing it to update everything)
  14340. */
  14341. markAsDirty(): void;
  14342. /** @hidden */
  14343. _markAsDirtyAndCompose(): void;
  14344. private _markAsDirtyAndDecompose;
  14345. /**
  14346. * Translate the bone in local or world space
  14347. * @param vec The amount to translate the bone
  14348. * @param space The space that the translation is in
  14349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14350. */
  14351. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14352. /**
  14353. * Set the postion of the bone in local or world space
  14354. * @param position The position to set the bone
  14355. * @param space The space that the position is in
  14356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14357. */
  14358. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14359. /**
  14360. * Set the absolute position of the bone (world space)
  14361. * @param position The position to set the bone
  14362. * @param mesh The mesh that this bone is attached to
  14363. */
  14364. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14365. /**
  14366. * Scale the bone on the x, y and z axes (in local space)
  14367. * @param x The amount to scale the bone on the x axis
  14368. * @param y The amount to scale the bone on the y axis
  14369. * @param z The amount to scale the bone on the z axis
  14370. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14371. */
  14372. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14373. /**
  14374. * Set the bone scaling in local space
  14375. * @param scale defines the scaling vector
  14376. */
  14377. setScale(scale: Vector3): void;
  14378. /**
  14379. * Gets the current scaling in local space
  14380. * @returns the current scaling vector
  14381. */
  14382. getScale(): Vector3;
  14383. /**
  14384. * Gets the current scaling in local space and stores it in a target vector
  14385. * @param result defines the target vector
  14386. */
  14387. getScaleToRef(result: Vector3): void;
  14388. /**
  14389. * Set the yaw, pitch, and roll of the bone in local or world space
  14390. * @param yaw The rotation of the bone on the y axis
  14391. * @param pitch The rotation of the bone on the x axis
  14392. * @param roll The rotation of the bone on the z axis
  14393. * @param space The space that the axes of rotation are in
  14394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14395. */
  14396. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14397. /**
  14398. * Add a rotation to the bone on an axis in local or world space
  14399. * @param axis The axis to rotate the bone on
  14400. * @param amount The amount to rotate the bone
  14401. * @param space The space that the axis is in
  14402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14403. */
  14404. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14405. /**
  14406. * Set the rotation of the bone to a particular axis angle in local or world space
  14407. * @param axis The axis to rotate the bone on
  14408. * @param angle The angle that the bone should be rotated to
  14409. * @param space The space that the axis is in
  14410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14411. */
  14412. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14413. /**
  14414. * Set the euler rotation of the bone in local of world space
  14415. * @param rotation The euler rotation that the bone should be set to
  14416. * @param space The space that the rotation is in
  14417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14418. */
  14419. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14420. /**
  14421. * Set the quaternion rotation of the bone in local of world space
  14422. * @param quat The quaternion rotation that the bone should be set to
  14423. * @param space The space that the rotation is in
  14424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14425. */
  14426. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14427. /**
  14428. * Set the rotation matrix of the bone in local of world space
  14429. * @param rotMat The rotation matrix that the bone should be set to
  14430. * @param space The space that the rotation is in
  14431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14432. */
  14433. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14434. private _rotateWithMatrix;
  14435. private _getNegativeRotationToRef;
  14436. /**
  14437. * Get the position of the bone in local or world space
  14438. * @param space The space that the returned position is in
  14439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14440. * @returns The position of the bone
  14441. */
  14442. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14443. /**
  14444. * Copy the position of the bone to a vector3 in local or world space
  14445. * @param space The space that the returned position is in
  14446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14447. * @param result The vector3 to copy the position to
  14448. */
  14449. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14450. /**
  14451. * Get the absolute position of the bone (world space)
  14452. * @param mesh The mesh that this bone is attached to
  14453. * @returns The absolute position of the bone
  14454. */
  14455. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14456. /**
  14457. * Copy the absolute position of the bone (world space) to the result param
  14458. * @param mesh The mesh that this bone is attached to
  14459. * @param result The vector3 to copy the absolute position to
  14460. */
  14461. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14462. /**
  14463. * Compute the absolute transforms of this bone and its children
  14464. */
  14465. computeAbsoluteTransforms(): void;
  14466. /**
  14467. * Get the world direction from an axis that is in the local space of the bone
  14468. * @param localAxis The local direction that is used to compute the world direction
  14469. * @param mesh The mesh that this bone is attached to
  14470. * @returns The world direction
  14471. */
  14472. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14473. /**
  14474. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14475. * @param localAxis The local direction that is used to compute the world direction
  14476. * @param mesh The mesh that this bone is attached to
  14477. * @param result The vector3 that the world direction will be copied to
  14478. */
  14479. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14480. /**
  14481. * Get the euler rotation of the bone in local or world space
  14482. * @param space The space that the rotation should be in
  14483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14484. * @returns The euler rotation
  14485. */
  14486. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14487. /**
  14488. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14489. * @param space The space that the rotation should be in
  14490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14491. * @param result The vector3 that the rotation should be copied to
  14492. */
  14493. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14494. /**
  14495. * Get the quaternion rotation of the bone in either local or world space
  14496. * @param space The space that the rotation should be in
  14497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14498. * @returns The quaternion rotation
  14499. */
  14500. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14501. /**
  14502. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14503. * @param space The space that the rotation should be in
  14504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14505. * @param result The quaternion that the rotation should be copied to
  14506. */
  14507. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14508. /**
  14509. * Get the rotation matrix of the bone in local or world space
  14510. * @param space The space that the rotation should be in
  14511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14512. * @returns The rotation matrix
  14513. */
  14514. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14515. /**
  14516. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14517. * @param space The space that the rotation should be in
  14518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14519. * @param result The quaternion that the rotation should be copied to
  14520. */
  14521. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14522. /**
  14523. * Get the world position of a point that is in the local space of the bone
  14524. * @param position The local position
  14525. * @param mesh The mesh that this bone is attached to
  14526. * @returns The world position
  14527. */
  14528. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14529. /**
  14530. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14531. * @param position The local position
  14532. * @param mesh The mesh that this bone is attached to
  14533. * @param result The vector3 that the world position should be copied to
  14534. */
  14535. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14536. /**
  14537. * Get the local position of a point that is in world space
  14538. * @param position The world position
  14539. * @param mesh The mesh that this bone is attached to
  14540. * @returns The local position
  14541. */
  14542. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14543. /**
  14544. * Get the local position of a point that is in world space and copy it to the result param
  14545. * @param position The world position
  14546. * @param mesh The mesh that this bone is attached to
  14547. * @param result The vector3 that the local position should be copied to
  14548. */
  14549. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14550. }
  14551. }
  14552. declare module BABYLON {
  14553. /**
  14554. * Defines a runtime animation
  14555. */
  14556. export class RuntimeAnimation {
  14557. private _events;
  14558. /**
  14559. * The current frame of the runtime animation
  14560. */
  14561. private _currentFrame;
  14562. /**
  14563. * The animation used by the runtime animation
  14564. */
  14565. private _animation;
  14566. /**
  14567. * The target of the runtime animation
  14568. */
  14569. private _target;
  14570. /**
  14571. * The initiating animatable
  14572. */
  14573. private _host;
  14574. /**
  14575. * The original value of the runtime animation
  14576. */
  14577. private _originalValue;
  14578. /**
  14579. * The original blend value of the runtime animation
  14580. */
  14581. private _originalBlendValue;
  14582. /**
  14583. * The offsets cache of the runtime animation
  14584. */
  14585. private _offsetsCache;
  14586. /**
  14587. * The high limits cache of the runtime animation
  14588. */
  14589. private _highLimitsCache;
  14590. /**
  14591. * Specifies if the runtime animation has been stopped
  14592. */
  14593. private _stopped;
  14594. /**
  14595. * The blending factor of the runtime animation
  14596. */
  14597. private _blendingFactor;
  14598. /**
  14599. * The BabylonJS scene
  14600. */
  14601. private _scene;
  14602. /**
  14603. * The current value of the runtime animation
  14604. */
  14605. private _currentValue;
  14606. /** @hidden */
  14607. _animationState: _IAnimationState;
  14608. /**
  14609. * The active target of the runtime animation
  14610. */
  14611. private _activeTargets;
  14612. private _currentActiveTarget;
  14613. private _directTarget;
  14614. /**
  14615. * The target path of the runtime animation
  14616. */
  14617. private _targetPath;
  14618. /**
  14619. * The weight of the runtime animation
  14620. */
  14621. private _weight;
  14622. /**
  14623. * The ratio offset of the runtime animation
  14624. */
  14625. private _ratioOffset;
  14626. /**
  14627. * The previous delay of the runtime animation
  14628. */
  14629. private _previousDelay;
  14630. /**
  14631. * The previous ratio of the runtime animation
  14632. */
  14633. private _previousRatio;
  14634. private _enableBlending;
  14635. private _keys;
  14636. private _minFrame;
  14637. private _maxFrame;
  14638. private _minValue;
  14639. private _maxValue;
  14640. private _targetIsArray;
  14641. /**
  14642. * Gets the current frame of the runtime animation
  14643. */
  14644. get currentFrame(): number;
  14645. /**
  14646. * Gets the weight of the runtime animation
  14647. */
  14648. get weight(): number;
  14649. /**
  14650. * Gets the current value of the runtime animation
  14651. */
  14652. get currentValue(): any;
  14653. /**
  14654. * Gets the target path of the runtime animation
  14655. */
  14656. get targetPath(): string;
  14657. /**
  14658. * Gets the actual target of the runtime animation
  14659. */
  14660. get target(): any;
  14661. /**
  14662. * Gets the additive state of the runtime animation
  14663. */
  14664. get isAdditive(): boolean;
  14665. /** @hidden */
  14666. _onLoop: () => void;
  14667. /**
  14668. * Create a new RuntimeAnimation object
  14669. * @param target defines the target of the animation
  14670. * @param animation defines the source animation object
  14671. * @param scene defines the hosting scene
  14672. * @param host defines the initiating Animatable
  14673. */
  14674. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14675. private _preparePath;
  14676. /**
  14677. * Gets the animation from the runtime animation
  14678. */
  14679. get animation(): Animation;
  14680. /**
  14681. * Resets the runtime animation to the beginning
  14682. * @param restoreOriginal defines whether to restore the target property to the original value
  14683. */
  14684. reset(restoreOriginal?: boolean): void;
  14685. /**
  14686. * Specifies if the runtime animation is stopped
  14687. * @returns Boolean specifying if the runtime animation is stopped
  14688. */
  14689. isStopped(): boolean;
  14690. /**
  14691. * Disposes of the runtime animation
  14692. */
  14693. dispose(): void;
  14694. /**
  14695. * Apply the interpolated value to the target
  14696. * @param currentValue defines the value computed by the animation
  14697. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14698. */
  14699. setValue(currentValue: any, weight: number): void;
  14700. private _getOriginalValues;
  14701. private _setValue;
  14702. /**
  14703. * Gets the loop pmode of the runtime animation
  14704. * @returns Loop Mode
  14705. */
  14706. private _getCorrectLoopMode;
  14707. /**
  14708. * Move the current animation to a given frame
  14709. * @param frame defines the frame to move to
  14710. */
  14711. goToFrame(frame: number): void;
  14712. /**
  14713. * @hidden Internal use only
  14714. */
  14715. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14716. /**
  14717. * Execute the current animation
  14718. * @param delay defines the delay to add to the current frame
  14719. * @param from defines the lower bound of the animation range
  14720. * @param to defines the upper bound of the animation range
  14721. * @param loop defines if the current animation must loop
  14722. * @param speedRatio defines the current speed ratio
  14723. * @param weight defines the weight of the animation (default is -1 so no weight)
  14724. * @param onLoop optional callback called when animation loops
  14725. * @returns a boolean indicating if the animation is running
  14726. */
  14727. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14728. }
  14729. }
  14730. declare module BABYLON {
  14731. /**
  14732. * Class used to store an actual running animation
  14733. */
  14734. export class Animatable {
  14735. /** defines the target object */
  14736. target: any;
  14737. /** defines the starting frame number (default is 0) */
  14738. fromFrame: number;
  14739. /** defines the ending frame number (default is 100) */
  14740. toFrame: number;
  14741. /** defines if the animation must loop (default is false) */
  14742. loopAnimation: boolean;
  14743. /** defines a callback to call when animation ends if it is not looping */
  14744. onAnimationEnd?: (() => void) | null | undefined;
  14745. /** defines a callback to call when animation loops */
  14746. onAnimationLoop?: (() => void) | null | undefined;
  14747. /** defines whether the animation should be evaluated additively */
  14748. isAdditive: boolean;
  14749. private _localDelayOffset;
  14750. private _pausedDelay;
  14751. private _runtimeAnimations;
  14752. private _paused;
  14753. private _scene;
  14754. private _speedRatio;
  14755. private _weight;
  14756. private _syncRoot;
  14757. /**
  14758. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14759. * This will only apply for non looping animation (default is true)
  14760. */
  14761. disposeOnEnd: boolean;
  14762. /**
  14763. * Gets a boolean indicating if the animation has started
  14764. */
  14765. animationStarted: boolean;
  14766. /**
  14767. * Observer raised when the animation ends
  14768. */
  14769. onAnimationEndObservable: Observable<Animatable>;
  14770. /**
  14771. * Observer raised when the animation loops
  14772. */
  14773. onAnimationLoopObservable: Observable<Animatable>;
  14774. /**
  14775. * Gets the root Animatable used to synchronize and normalize animations
  14776. */
  14777. get syncRoot(): Nullable<Animatable>;
  14778. /**
  14779. * Gets the current frame of the first RuntimeAnimation
  14780. * Used to synchronize Animatables
  14781. */
  14782. get masterFrame(): number;
  14783. /**
  14784. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14785. */
  14786. get weight(): number;
  14787. set weight(value: number);
  14788. /**
  14789. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14790. */
  14791. get speedRatio(): number;
  14792. set speedRatio(value: number);
  14793. /**
  14794. * Creates a new Animatable
  14795. * @param scene defines the hosting scene
  14796. * @param target defines the target object
  14797. * @param fromFrame defines the starting frame number (default is 0)
  14798. * @param toFrame defines the ending frame number (default is 100)
  14799. * @param loopAnimation defines if the animation must loop (default is false)
  14800. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14801. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14802. * @param animations defines a group of animation to add to the new Animatable
  14803. * @param onAnimationLoop defines a callback to call when animation loops
  14804. * @param isAdditive defines whether the animation should be evaluated additively
  14805. */
  14806. constructor(scene: Scene,
  14807. /** defines the target object */
  14808. target: any,
  14809. /** defines the starting frame number (default is 0) */
  14810. fromFrame?: number,
  14811. /** defines the ending frame number (default is 100) */
  14812. toFrame?: number,
  14813. /** defines if the animation must loop (default is false) */
  14814. loopAnimation?: boolean, speedRatio?: number,
  14815. /** defines a callback to call when animation ends if it is not looping */
  14816. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14817. /** defines a callback to call when animation loops */
  14818. onAnimationLoop?: (() => void) | null | undefined,
  14819. /** defines whether the animation should be evaluated additively */
  14820. isAdditive?: boolean);
  14821. /**
  14822. * Synchronize and normalize current Animatable with a source Animatable
  14823. * This is useful when using animation weights and when animations are not of the same length
  14824. * @param root defines the root Animatable to synchronize with
  14825. * @returns the current Animatable
  14826. */
  14827. syncWith(root: Animatable): Animatable;
  14828. /**
  14829. * Gets the list of runtime animations
  14830. * @returns an array of RuntimeAnimation
  14831. */
  14832. getAnimations(): RuntimeAnimation[];
  14833. /**
  14834. * Adds more animations to the current animatable
  14835. * @param target defines the target of the animations
  14836. * @param animations defines the new animations to add
  14837. */
  14838. appendAnimations(target: any, animations: Animation[]): void;
  14839. /**
  14840. * Gets the source animation for a specific property
  14841. * @param property defines the propertyu to look for
  14842. * @returns null or the source animation for the given property
  14843. */
  14844. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14845. /**
  14846. * Gets the runtime animation for a specific property
  14847. * @param property defines the propertyu to look for
  14848. * @returns null or the runtime animation for the given property
  14849. */
  14850. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14851. /**
  14852. * Resets the animatable to its original state
  14853. */
  14854. reset(): void;
  14855. /**
  14856. * Allows the animatable to blend with current running animations
  14857. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14858. * @param blendingSpeed defines the blending speed to use
  14859. */
  14860. enableBlending(blendingSpeed: number): void;
  14861. /**
  14862. * Disable animation blending
  14863. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14864. */
  14865. disableBlending(): void;
  14866. /**
  14867. * Jump directly to a given frame
  14868. * @param frame defines the frame to jump to
  14869. */
  14870. goToFrame(frame: number): void;
  14871. /**
  14872. * Pause the animation
  14873. */
  14874. pause(): void;
  14875. /**
  14876. * Restart the animation
  14877. */
  14878. restart(): void;
  14879. private _raiseOnAnimationEnd;
  14880. /**
  14881. * Stop and delete the current animation
  14882. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14883. * @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)
  14884. */
  14885. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14886. /**
  14887. * Wait asynchronously for the animation to end
  14888. * @returns a promise which will be fullfilled when the animation ends
  14889. */
  14890. waitAsync(): Promise<Animatable>;
  14891. /** @hidden */
  14892. _animate(delay: number): boolean;
  14893. }
  14894. interface Scene {
  14895. /** @hidden */
  14896. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14897. /** @hidden */
  14898. _processLateAnimationBindingsForMatrices(holder: {
  14899. totalWeight: number;
  14900. totalAdditiveWeight: number;
  14901. animations: RuntimeAnimation[];
  14902. additiveAnimations: RuntimeAnimation[];
  14903. originalValue: Matrix;
  14904. }): any;
  14905. /** @hidden */
  14906. _processLateAnimationBindingsForQuaternions(holder: {
  14907. totalWeight: number;
  14908. totalAdditiveWeight: number;
  14909. animations: RuntimeAnimation[];
  14910. additiveAnimations: RuntimeAnimation[];
  14911. originalValue: Quaternion;
  14912. }, refQuaternion: Quaternion): Quaternion;
  14913. /** @hidden */
  14914. _processLateAnimationBindings(): void;
  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 weight defines the weight to apply to the animation (1.0 by default)
  14921. * @param loop defines if the animation loops
  14922. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14923. * @param onAnimationEnd defines the function to be executed when the animation ends
  14924. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14925. * @param targetMask defines if the target should be animated 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. 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;
  14931. /**
  14932. * Will start the animation sequence of a given target
  14933. * @param target defines the target
  14934. * @param from defines from which frame should animation start
  14935. * @param to defines until which frame should animation run.
  14936. * @param loop defines if the animation loops
  14937. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14938. * @param onAnimationEnd defines the function to be executed when the animation ends
  14939. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14940. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14941. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14942. * @param onAnimationLoop defines the callback to call when an animation loops
  14943. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14944. * @returns the animatable object created for this animation
  14945. */
  14946. 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;
  14947. /**
  14948. * Will start the animation sequence of a given target and its hierarchy
  14949. * @param target defines the target
  14950. * @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.
  14951. * @param from defines from which frame should animation start
  14952. * @param to defines until which frame should animation run.
  14953. * @param loop defines if the animation loops
  14954. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14955. * @param onAnimationEnd defines the function to be executed when the animation ends
  14956. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14957. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14958. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14959. * @param onAnimationLoop defines the callback to call when an animation loops
  14960. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14961. * @returns the list of created animatables
  14962. */
  14963. 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[];
  14964. /**
  14965. * Begin a new animation on a given node
  14966. * @param target defines the target where the animation will take place
  14967. * @param animations defines the list of animations to start
  14968. * @param from defines the initial value
  14969. * @param to defines the final value
  14970. * @param loop defines if you want animation to loop (off by default)
  14971. * @param speedRatio defines the speed ratio to apply to all animations
  14972. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14973. * @param onAnimationLoop defines the callback to call when an animation loops
  14974. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14975. * @returns the list of created animatables
  14976. */
  14977. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14978. /**
  14979. * Begin a new animation on a given node and its hierarchy
  14980. * @param target defines the root node where the animation will take place
  14981. * @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.
  14982. * @param animations defines the list of animations to start
  14983. * @param from defines the initial value
  14984. * @param to defines the final value
  14985. * @param loop defines if you want animation to loop (off by default)
  14986. * @param speedRatio defines the speed ratio to apply to all animations
  14987. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14988. * @param onAnimationLoop defines the callback to call when an animation loops
  14989. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14990. * @returns the list of animatables created for all nodes
  14991. */
  14992. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14993. /**
  14994. * Gets the animatable associated with a specific target
  14995. * @param target defines the target of the animatable
  14996. * @returns the required animatable if found
  14997. */
  14998. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14999. /**
  15000. * Gets all animatables associated with a given target
  15001. * @param target defines the target to look animatables for
  15002. * @returns an array of Animatables
  15003. */
  15004. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15005. /**
  15006. * Stops and removes all animations that have been applied to the scene
  15007. */
  15008. stopAllAnimations(): void;
  15009. /**
  15010. * Gets the current delta time used by animation engine
  15011. */
  15012. deltaTime: number;
  15013. }
  15014. interface Bone {
  15015. /**
  15016. * Copy an animation range from another bone
  15017. * @param source defines the source bone
  15018. * @param rangeName defines the range name to copy
  15019. * @param frameOffset defines the frame offset
  15020. * @param rescaleAsRequired defines if rescaling must be applied if required
  15021. * @param skelDimensionsRatio defines the scaling ratio
  15022. * @returns true if operation was successful
  15023. */
  15024. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15025. }
  15026. }
  15027. declare module BABYLON {
  15028. /**
  15029. * Class used to handle skinning animations
  15030. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15031. */
  15032. export class Skeleton implements IAnimatable {
  15033. /** defines the skeleton name */
  15034. name: string;
  15035. /** defines the skeleton Id */
  15036. id: string;
  15037. /**
  15038. * Defines the list of child bones
  15039. */
  15040. bones: Bone[];
  15041. /**
  15042. * Defines an estimate of the dimension of the skeleton at rest
  15043. */
  15044. dimensionsAtRest: Vector3;
  15045. /**
  15046. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15047. */
  15048. needInitialSkinMatrix: boolean;
  15049. /**
  15050. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15051. */
  15052. overrideMesh: Nullable<AbstractMesh>;
  15053. /**
  15054. * Gets the list of animations attached to this skeleton
  15055. */
  15056. animations: Array<Animation>;
  15057. private _scene;
  15058. private _isDirty;
  15059. private _transformMatrices;
  15060. private _transformMatrixTexture;
  15061. private _meshesWithPoseMatrix;
  15062. private _animatables;
  15063. private _identity;
  15064. private _synchronizedWithMesh;
  15065. private _ranges;
  15066. private _lastAbsoluteTransformsUpdateId;
  15067. private _canUseTextureForBones;
  15068. private _uniqueId;
  15069. /** @hidden */
  15070. _numBonesWithLinkedTransformNode: number;
  15071. /** @hidden */
  15072. _hasWaitingData: Nullable<boolean>;
  15073. /**
  15074. * Specifies if the skeleton should be serialized
  15075. */
  15076. doNotSerialize: boolean;
  15077. private _useTextureToStoreBoneMatrices;
  15078. /**
  15079. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15080. * Please note that this option is not available if the hardware does not support it
  15081. */
  15082. get useTextureToStoreBoneMatrices(): boolean;
  15083. set useTextureToStoreBoneMatrices(value: boolean);
  15084. private _animationPropertiesOverride;
  15085. /**
  15086. * Gets or sets the animation properties override
  15087. */
  15088. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15089. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15090. /**
  15091. * List of inspectable custom properties (used by the Inspector)
  15092. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15093. */
  15094. inspectableCustomProperties: IInspectable[];
  15095. /**
  15096. * An observable triggered before computing the skeleton's matrices
  15097. */
  15098. onBeforeComputeObservable: Observable<Skeleton>;
  15099. /**
  15100. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15101. */
  15102. get isUsingTextureForMatrices(): boolean;
  15103. /**
  15104. * Gets the unique ID of this skeleton
  15105. */
  15106. get uniqueId(): number;
  15107. /**
  15108. * Creates a new skeleton
  15109. * @param name defines the skeleton name
  15110. * @param id defines the skeleton Id
  15111. * @param scene defines the hosting scene
  15112. */
  15113. constructor(
  15114. /** defines the skeleton name */
  15115. name: string,
  15116. /** defines the skeleton Id */
  15117. id: string, scene: Scene);
  15118. /**
  15119. * Gets the current object class name.
  15120. * @return the class name
  15121. */
  15122. getClassName(): string;
  15123. /**
  15124. * Returns an array containing the root bones
  15125. * @returns an array containing the root bones
  15126. */
  15127. getChildren(): Array<Bone>;
  15128. /**
  15129. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15130. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15131. * @returns a Float32Array containing matrices data
  15132. */
  15133. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15134. /**
  15135. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15136. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15137. * @returns a raw texture containing the data
  15138. */
  15139. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15140. /**
  15141. * Gets the current hosting scene
  15142. * @returns a scene object
  15143. */
  15144. getScene(): Scene;
  15145. /**
  15146. * Gets a string representing the current skeleton data
  15147. * @param fullDetails defines a boolean indicating if we want a verbose version
  15148. * @returns a string representing the current skeleton data
  15149. */
  15150. toString(fullDetails?: boolean): string;
  15151. /**
  15152. * Get bone's index searching by name
  15153. * @param name defines bone's name to search for
  15154. * @return the indice of the bone. Returns -1 if not found
  15155. */
  15156. getBoneIndexByName(name: string): number;
  15157. /**
  15158. * Creater a new animation range
  15159. * @param name defines the name of the range
  15160. * @param from defines the start key
  15161. * @param to defines the end key
  15162. */
  15163. createAnimationRange(name: string, from: number, to: number): void;
  15164. /**
  15165. * Delete a specific animation range
  15166. * @param name defines the name of the range
  15167. * @param deleteFrames defines if frames must be removed as well
  15168. */
  15169. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15170. /**
  15171. * Gets a specific animation range
  15172. * @param name defines the name of the range to look for
  15173. * @returns the requested animation range or null if not found
  15174. */
  15175. getAnimationRange(name: string): Nullable<AnimationRange>;
  15176. /**
  15177. * Gets the list of all animation ranges defined on this skeleton
  15178. * @returns an array
  15179. */
  15180. getAnimationRanges(): Nullable<AnimationRange>[];
  15181. /**
  15182. * Copy animation range from a source skeleton.
  15183. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15184. * @param source defines the source skeleton
  15185. * @param name defines the name of the range to copy
  15186. * @param rescaleAsRequired defines if rescaling must be applied if required
  15187. * @returns true if operation was successful
  15188. */
  15189. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15190. /**
  15191. * Forces the skeleton to go to rest pose
  15192. */
  15193. returnToRest(): void;
  15194. private _getHighestAnimationFrame;
  15195. /**
  15196. * Begin a specific animation range
  15197. * @param name defines the name of the range to start
  15198. * @param loop defines if looping must be turned on (false by default)
  15199. * @param speedRatio defines the speed ratio to apply (1 by default)
  15200. * @param onAnimationEnd defines a callback which will be called when animation will end
  15201. * @returns a new animatable
  15202. */
  15203. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15204. /**
  15205. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15206. * @param skeleton defines the Skeleton containing the animation range to convert
  15207. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15208. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15209. * @returns the original skeleton
  15210. */
  15211. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15212. /** @hidden */
  15213. _markAsDirty(): void;
  15214. /** @hidden */
  15215. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15216. /** @hidden */
  15217. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15218. private _computeTransformMatrices;
  15219. /**
  15220. * Build all resources required to render a skeleton
  15221. */
  15222. prepare(): void;
  15223. /**
  15224. * Gets the list of animatables currently running for this skeleton
  15225. * @returns an array of animatables
  15226. */
  15227. getAnimatables(): IAnimatable[];
  15228. /**
  15229. * Clone the current skeleton
  15230. * @param name defines the name of the new skeleton
  15231. * @param id defines the id of the new skeleton
  15232. * @returns the new skeleton
  15233. */
  15234. clone(name: string, id?: string): Skeleton;
  15235. /**
  15236. * Enable animation blending for this skeleton
  15237. * @param blendingSpeed defines the blending speed to apply
  15238. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15239. */
  15240. enableBlending(blendingSpeed?: number): void;
  15241. /**
  15242. * Releases all resources associated with the current skeleton
  15243. */
  15244. dispose(): void;
  15245. /**
  15246. * Serialize the skeleton in a JSON object
  15247. * @returns a JSON object
  15248. */
  15249. serialize(): any;
  15250. /**
  15251. * Creates a new skeleton from serialized data
  15252. * @param parsedSkeleton defines the serialized data
  15253. * @param scene defines the hosting scene
  15254. * @returns a new skeleton
  15255. */
  15256. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15257. /**
  15258. * Compute all node absolute transforms
  15259. * @param forceUpdate defines if computation must be done even if cache is up to date
  15260. */
  15261. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15262. /**
  15263. * Gets the root pose matrix
  15264. * @returns a matrix
  15265. */
  15266. getPoseMatrix(): Nullable<Matrix>;
  15267. /**
  15268. * Sorts bones per internal index
  15269. */
  15270. sortBones(): void;
  15271. private _sortBones;
  15272. }
  15273. }
  15274. declare module BABYLON {
  15275. /**
  15276. * Creates an instance based on a source mesh.
  15277. */
  15278. export class InstancedMesh extends AbstractMesh {
  15279. private _sourceMesh;
  15280. private _currentLOD;
  15281. /** @hidden */
  15282. _indexInSourceMeshInstanceArray: number;
  15283. constructor(name: string, source: Mesh);
  15284. /**
  15285. * Returns the string "InstancedMesh".
  15286. */
  15287. getClassName(): string;
  15288. /** Gets the list of lights affecting that mesh */
  15289. get lightSources(): Light[];
  15290. _resyncLightSources(): void;
  15291. _resyncLightSource(light: Light): void;
  15292. _removeLightSource(light: Light, dispose: boolean): void;
  15293. /**
  15294. * If the source mesh receives shadows
  15295. */
  15296. get receiveShadows(): boolean;
  15297. /**
  15298. * The material of the source mesh
  15299. */
  15300. get material(): Nullable<Material>;
  15301. /**
  15302. * Visibility of the source mesh
  15303. */
  15304. get visibility(): number;
  15305. /**
  15306. * Skeleton of the source mesh
  15307. */
  15308. get skeleton(): Nullable<Skeleton>;
  15309. /**
  15310. * Rendering ground id of the source mesh
  15311. */
  15312. get renderingGroupId(): number;
  15313. set renderingGroupId(value: number);
  15314. /**
  15315. * Returns the total number of vertices (integer).
  15316. */
  15317. getTotalVertices(): number;
  15318. /**
  15319. * Returns a positive integer : the total number of indices in this mesh geometry.
  15320. * @returns the numner of indices or zero if the mesh has no geometry.
  15321. */
  15322. getTotalIndices(): number;
  15323. /**
  15324. * The source mesh of the instance
  15325. */
  15326. get sourceMesh(): Mesh;
  15327. /**
  15328. * Is this node ready to be used/rendered
  15329. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15330. * @return {boolean} is it ready
  15331. */
  15332. isReady(completeCheck?: boolean): boolean;
  15333. /**
  15334. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15335. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15336. * @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.
  15337. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15338. */
  15339. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15340. /**
  15341. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15342. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15343. * The `data` are either a numeric array either a Float32Array.
  15344. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15345. * 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).
  15346. * Note that a new underlying VertexBuffer object is created each call.
  15347. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15348. *
  15349. * Possible `kind` values :
  15350. * - VertexBuffer.PositionKind
  15351. * - VertexBuffer.UVKind
  15352. * - VertexBuffer.UV2Kind
  15353. * - VertexBuffer.UV3Kind
  15354. * - VertexBuffer.UV4Kind
  15355. * - VertexBuffer.UV5Kind
  15356. * - VertexBuffer.UV6Kind
  15357. * - VertexBuffer.ColorKind
  15358. * - VertexBuffer.MatricesIndicesKind
  15359. * - VertexBuffer.MatricesIndicesExtraKind
  15360. * - VertexBuffer.MatricesWeightsKind
  15361. * - VertexBuffer.MatricesWeightsExtraKind
  15362. *
  15363. * Returns the Mesh.
  15364. */
  15365. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15366. /**
  15367. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15368. * If the mesh has no geometry, it is simply returned as it is.
  15369. * The `data` are either a numeric array either a Float32Array.
  15370. * No new underlying VertexBuffer object is created.
  15371. * 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.
  15372. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15373. *
  15374. * Possible `kind` values :
  15375. * - VertexBuffer.PositionKind
  15376. * - VertexBuffer.UVKind
  15377. * - VertexBuffer.UV2Kind
  15378. * - VertexBuffer.UV3Kind
  15379. * - VertexBuffer.UV4Kind
  15380. * - VertexBuffer.UV5Kind
  15381. * - VertexBuffer.UV6Kind
  15382. * - VertexBuffer.ColorKind
  15383. * - VertexBuffer.MatricesIndicesKind
  15384. * - VertexBuffer.MatricesIndicesExtraKind
  15385. * - VertexBuffer.MatricesWeightsKind
  15386. * - VertexBuffer.MatricesWeightsExtraKind
  15387. *
  15388. * Returns the Mesh.
  15389. */
  15390. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15391. /**
  15392. * Sets the mesh indices.
  15393. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15394. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15395. * This method creates a new index buffer each call.
  15396. * Returns the Mesh.
  15397. */
  15398. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15399. /**
  15400. * Boolean : True if the mesh owns the requested kind of data.
  15401. */
  15402. isVerticesDataPresent(kind: string): boolean;
  15403. /**
  15404. * Returns an array of indices (IndicesArray).
  15405. */
  15406. getIndices(): Nullable<IndicesArray>;
  15407. get _positions(): Nullable<Vector3[]>;
  15408. /**
  15409. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15410. * This means the mesh underlying bounding box and sphere are recomputed.
  15411. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15412. * @returns the current mesh
  15413. */
  15414. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15415. /** @hidden */
  15416. _preActivate(): InstancedMesh;
  15417. /** @hidden */
  15418. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15419. /** @hidden */
  15420. _postActivate(): void;
  15421. getWorldMatrix(): Matrix;
  15422. get isAnInstance(): boolean;
  15423. /**
  15424. * Returns the current associated LOD AbstractMesh.
  15425. */
  15426. getLOD(camera: Camera): AbstractMesh;
  15427. /** @hidden */
  15428. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15429. /** @hidden */
  15430. _syncSubMeshes(): InstancedMesh;
  15431. /** @hidden */
  15432. _generatePointsArray(): boolean;
  15433. /**
  15434. * Creates a new InstancedMesh from the current mesh.
  15435. * - name (string) : the cloned mesh name
  15436. * - newParent (optional Node) : the optional Node to parent the clone to.
  15437. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15438. *
  15439. * Returns the clone.
  15440. */
  15441. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15442. /**
  15443. * Disposes the InstancedMesh.
  15444. * Returns nothing.
  15445. */
  15446. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15447. }
  15448. interface Mesh {
  15449. /**
  15450. * Register a custom buffer that will be instanced
  15451. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15452. * @param kind defines the buffer kind
  15453. * @param stride defines the stride in floats
  15454. */
  15455. registerInstancedBuffer(kind: string, stride: number): void;
  15456. /** @hidden */
  15457. _userInstancedBuffersStorage: {
  15458. data: {
  15459. [key: string]: Float32Array;
  15460. };
  15461. sizes: {
  15462. [key: string]: number;
  15463. };
  15464. vertexBuffers: {
  15465. [key: string]: Nullable<VertexBuffer>;
  15466. };
  15467. strides: {
  15468. [key: string]: number;
  15469. };
  15470. };
  15471. }
  15472. interface AbstractMesh {
  15473. /**
  15474. * Object used to store instanced buffers defined by user
  15475. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15476. */
  15477. instancedBuffers: {
  15478. [key: string]: any;
  15479. };
  15480. }
  15481. }
  15482. declare module BABYLON {
  15483. /**
  15484. * Defines the options associated with the creation of a shader material.
  15485. */
  15486. export interface IShaderMaterialOptions {
  15487. /**
  15488. * Does the material work in alpha blend mode
  15489. */
  15490. needAlphaBlending: boolean;
  15491. /**
  15492. * Does the material work in alpha test mode
  15493. */
  15494. needAlphaTesting: boolean;
  15495. /**
  15496. * The list of attribute names used in the shader
  15497. */
  15498. attributes: string[];
  15499. /**
  15500. * The list of unifrom names used in the shader
  15501. */
  15502. uniforms: string[];
  15503. /**
  15504. * The list of UBO names used in the shader
  15505. */
  15506. uniformBuffers: string[];
  15507. /**
  15508. * The list of sampler names used in the shader
  15509. */
  15510. samplers: string[];
  15511. /**
  15512. * The list of defines used in the shader
  15513. */
  15514. defines: string[];
  15515. }
  15516. /**
  15517. * 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.
  15518. *
  15519. * This returned material effects how the mesh will look based on the code in the shaders.
  15520. *
  15521. * @see http://doc.babylonjs.com/how_to/shader_material
  15522. */
  15523. export class ShaderMaterial extends Material {
  15524. private _shaderPath;
  15525. private _options;
  15526. private _textures;
  15527. private _textureArrays;
  15528. private _floats;
  15529. private _ints;
  15530. private _floatsArrays;
  15531. private _colors3;
  15532. private _colors3Arrays;
  15533. private _colors4;
  15534. private _colors4Arrays;
  15535. private _vectors2;
  15536. private _vectors3;
  15537. private _vectors4;
  15538. private _matrices;
  15539. private _matrixArrays;
  15540. private _matrices3x3;
  15541. private _matrices2x2;
  15542. private _vectors2Arrays;
  15543. private _vectors3Arrays;
  15544. private _vectors4Arrays;
  15545. private _cachedWorldViewMatrix;
  15546. private _cachedWorldViewProjectionMatrix;
  15547. private _renderId;
  15548. private _multiview;
  15549. private _cachedDefines;
  15550. /**
  15551. * Instantiate a new shader material.
  15552. * 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.
  15553. * This returned material effects how the mesh will look based on the code in the shaders.
  15554. * @see http://doc.babylonjs.com/how_to/shader_material
  15555. * @param name Define the name of the material in the scene
  15556. * @param scene Define the scene the material belongs to
  15557. * @param shaderPath Defines the route to the shader code in one of three ways:
  15558. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15559. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15560. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15561. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15562. * @param options Define the options used to create the shader
  15563. */
  15564. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15565. /**
  15566. * Gets the shader path used to define the shader code
  15567. * It can be modified to trigger a new compilation
  15568. */
  15569. get shaderPath(): any;
  15570. /**
  15571. * Sets the shader path used to define the shader code
  15572. * It can be modified to trigger a new compilation
  15573. */
  15574. set shaderPath(shaderPath: any);
  15575. /**
  15576. * Gets the options used to compile the shader.
  15577. * They can be modified to trigger a new compilation
  15578. */
  15579. get options(): IShaderMaterialOptions;
  15580. /**
  15581. * Gets the current class name of the material e.g. "ShaderMaterial"
  15582. * Mainly use in serialization.
  15583. * @returns the class name
  15584. */
  15585. getClassName(): string;
  15586. /**
  15587. * Specifies if the material will require alpha blending
  15588. * @returns a boolean specifying if alpha blending is needed
  15589. */
  15590. needAlphaBlending(): boolean;
  15591. /**
  15592. * Specifies if this material should be rendered in alpha test mode
  15593. * @returns a boolean specifying if an alpha test is needed.
  15594. */
  15595. needAlphaTesting(): boolean;
  15596. private _checkUniform;
  15597. /**
  15598. * Set a texture in the shader.
  15599. * @param name Define the name of the uniform samplers as defined in the shader
  15600. * @param texture Define the texture to bind to this sampler
  15601. * @return the material itself allowing "fluent" like uniform updates
  15602. */
  15603. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15604. /**
  15605. * Set a texture array in the shader.
  15606. * @param name Define the name of the uniform sampler array as defined in the shader
  15607. * @param textures Define the list of textures to bind to this sampler
  15608. * @return the material itself allowing "fluent" like uniform updates
  15609. */
  15610. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15611. /**
  15612. * Set a float in the shader.
  15613. * @param name Define the name of the uniform as defined in the shader
  15614. * @param value Define the value to give to the uniform
  15615. * @return the material itself allowing "fluent" like uniform updates
  15616. */
  15617. setFloat(name: string, value: number): ShaderMaterial;
  15618. /**
  15619. * Set a int in the shader.
  15620. * @param name Define the name of the uniform as defined in the shader
  15621. * @param value Define the value to give to the uniform
  15622. * @return the material itself allowing "fluent" like uniform updates
  15623. */
  15624. setInt(name: string, value: number): ShaderMaterial;
  15625. /**
  15626. * Set an array of floats in the shader.
  15627. * @param name Define the name of the uniform as defined in the shader
  15628. * @param value Define the value to give to the uniform
  15629. * @return the material itself allowing "fluent" like uniform updates
  15630. */
  15631. setFloats(name: string, value: number[]): ShaderMaterial;
  15632. /**
  15633. * Set a vec3 in the shader from a Color3.
  15634. * @param name Define the name of the uniform as defined in the shader
  15635. * @param value Define the value to give to the uniform
  15636. * @return the material itself allowing "fluent" like uniform updates
  15637. */
  15638. setColor3(name: string, value: Color3): ShaderMaterial;
  15639. /**
  15640. * Set a vec3 array in the shader from a Color3 array.
  15641. * @param name Define the name of the uniform as defined in the shader
  15642. * @param value Define the value to give to the uniform
  15643. * @return the material itself allowing "fluent" like uniform updates
  15644. */
  15645. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15646. /**
  15647. * Set a vec4 in the shader from a Color4.
  15648. * @param name Define the name of the uniform as defined in the shader
  15649. * @param value Define the value to give to the uniform
  15650. * @return the material itself allowing "fluent" like uniform updates
  15651. */
  15652. setColor4(name: string, value: Color4): ShaderMaterial;
  15653. /**
  15654. * Set a vec4 array in the shader from a Color4 array.
  15655. * @param name Define the name of the uniform as defined in the shader
  15656. * @param value Define the value to give to the uniform
  15657. * @return the material itself allowing "fluent" like uniform updates
  15658. */
  15659. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15660. /**
  15661. * Set a vec2 in the shader from a Vector2.
  15662. * @param name Define the name of the uniform as defined in the shader
  15663. * @param value Define the value to give to the uniform
  15664. * @return the material itself allowing "fluent" like uniform updates
  15665. */
  15666. setVector2(name: string, value: Vector2): ShaderMaterial;
  15667. /**
  15668. * Set a vec3 in the shader from a Vector3.
  15669. * @param name Define the name of the uniform as defined in the shader
  15670. * @param value Define the value to give to the uniform
  15671. * @return the material itself allowing "fluent" like uniform updates
  15672. */
  15673. setVector3(name: string, value: Vector3): ShaderMaterial;
  15674. /**
  15675. * Set a vec4 in the shader from a Vector4.
  15676. * @param name Define the name of the uniform as defined in the shader
  15677. * @param value Define the value to give to the uniform
  15678. * @return the material itself allowing "fluent" like uniform updates
  15679. */
  15680. setVector4(name: string, value: Vector4): ShaderMaterial;
  15681. /**
  15682. * Set a mat4 in the shader from a Matrix.
  15683. * @param name Define the name of the uniform as defined in the shader
  15684. * @param value Define the value to give to the uniform
  15685. * @return the material itself allowing "fluent" like uniform updates
  15686. */
  15687. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15688. /**
  15689. * Set a float32Array in the shader from a matrix array.
  15690. * @param name Define the name of the uniform as defined in the shader
  15691. * @param value Define the value to give to the uniform
  15692. * @return the material itself allowing "fluent" like uniform updates
  15693. */
  15694. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15695. /**
  15696. * Set a mat3 in the shader from a Float32Array.
  15697. * @param name Define the name of the uniform as defined in the shader
  15698. * @param value Define the value to give to the uniform
  15699. * @return the material itself allowing "fluent" like uniform updates
  15700. */
  15701. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15702. /**
  15703. * Set a mat2 in the shader from a Float32Array.
  15704. * @param name Define the name of the uniform as defined in the shader
  15705. * @param value Define the value to give to the uniform
  15706. * @return the material itself allowing "fluent" like uniform updates
  15707. */
  15708. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15709. /**
  15710. * Set a vec2 array in the shader from a number array.
  15711. * @param name Define the name of the uniform as defined in the shader
  15712. * @param value Define the value to give to the uniform
  15713. * @return the material itself allowing "fluent" like uniform updates
  15714. */
  15715. setArray2(name: string, value: number[]): ShaderMaterial;
  15716. /**
  15717. * Set a vec3 array in the shader from a number array.
  15718. * @param name Define the name of the uniform as defined in the shader
  15719. * @param value Define the value to give to the uniform
  15720. * @return the material itself allowing "fluent" like uniform updates
  15721. */
  15722. setArray3(name: string, value: number[]): ShaderMaterial;
  15723. /**
  15724. * Set a vec4 array in the shader from a number array.
  15725. * @param name Define the name of the uniform as defined in the shader
  15726. * @param value Define the value to give to the uniform
  15727. * @return the material itself allowing "fluent" like uniform updates
  15728. */
  15729. setArray4(name: string, value: number[]): ShaderMaterial;
  15730. private _checkCache;
  15731. /**
  15732. * Specifies that the submesh is ready to be used
  15733. * @param mesh defines the mesh to check
  15734. * @param subMesh defines which submesh to check
  15735. * @param useInstances specifies that instances should be used
  15736. * @returns a boolean indicating that the submesh is ready or not
  15737. */
  15738. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15739. /**
  15740. * Checks if the material is ready to render the requested mesh
  15741. * @param mesh Define the mesh to render
  15742. * @param useInstances Define whether or not the material is used with instances
  15743. * @returns true if ready, otherwise false
  15744. */
  15745. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15746. /**
  15747. * Binds the world matrix to the material
  15748. * @param world defines the world transformation matrix
  15749. * @param effectOverride - If provided, use this effect instead of internal effect
  15750. */
  15751. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15752. /**
  15753. * Binds the submesh to this material by preparing the effect and shader to draw
  15754. * @param world defines the world transformation matrix
  15755. * @param mesh defines the mesh containing the submesh
  15756. * @param subMesh defines the submesh to bind the material to
  15757. */
  15758. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15759. /**
  15760. * Binds the material to the mesh
  15761. * @param world defines the world transformation matrix
  15762. * @param mesh defines the mesh to bind the material to
  15763. * @param effectOverride - If provided, use this effect instead of internal effect
  15764. */
  15765. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15766. protected _afterBind(mesh?: Mesh): void;
  15767. /**
  15768. * Gets the active textures from the material
  15769. * @returns an array of textures
  15770. */
  15771. getActiveTextures(): BaseTexture[];
  15772. /**
  15773. * Specifies if the material uses a texture
  15774. * @param texture defines the texture to check against the material
  15775. * @returns a boolean specifying if the material uses the texture
  15776. */
  15777. hasTexture(texture: BaseTexture): boolean;
  15778. /**
  15779. * Makes a duplicate of the material, and gives it a new name
  15780. * @param name defines the new name for the duplicated material
  15781. * @returns the cloned material
  15782. */
  15783. clone(name: string): ShaderMaterial;
  15784. /**
  15785. * Disposes the material
  15786. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15787. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15788. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15789. */
  15790. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15791. /**
  15792. * Serializes this material in a JSON representation
  15793. * @returns the serialized material object
  15794. */
  15795. serialize(): any;
  15796. /**
  15797. * Creates a shader material from parsed shader material data
  15798. * @param source defines the JSON represnetation of the material
  15799. * @param scene defines the hosting scene
  15800. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15801. * @returns a new material
  15802. */
  15803. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15804. }
  15805. }
  15806. declare module BABYLON {
  15807. /** @hidden */
  15808. export var colorPixelShader: {
  15809. name: string;
  15810. shader: string;
  15811. };
  15812. }
  15813. declare module BABYLON {
  15814. /** @hidden */
  15815. export var colorVertexShader: {
  15816. name: string;
  15817. shader: string;
  15818. };
  15819. }
  15820. declare module BABYLON {
  15821. /**
  15822. * Line mesh
  15823. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15824. */
  15825. export class LinesMesh extends Mesh {
  15826. /**
  15827. * If vertex color should be applied to the mesh
  15828. */
  15829. readonly useVertexColor?: boolean | undefined;
  15830. /**
  15831. * If vertex alpha should be applied to the mesh
  15832. */
  15833. readonly useVertexAlpha?: boolean | undefined;
  15834. /**
  15835. * Color of the line (Default: White)
  15836. */
  15837. color: Color3;
  15838. /**
  15839. * Alpha of the line (Default: 1)
  15840. */
  15841. alpha: number;
  15842. /**
  15843. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15844. * This margin is expressed in world space coordinates, so its value may vary.
  15845. * Default value is 0.1
  15846. */
  15847. intersectionThreshold: number;
  15848. private _colorShader;
  15849. private color4;
  15850. /**
  15851. * Creates a new LinesMesh
  15852. * @param name defines the name
  15853. * @param scene defines the hosting scene
  15854. * @param parent defines the parent mesh if any
  15855. * @param source defines the optional source LinesMesh used to clone data from
  15856. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15857. * When false, achieved by calling a clone(), also passing False.
  15858. * This will make creation of children, recursive.
  15859. * @param useVertexColor defines if this LinesMesh supports vertex color
  15860. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15861. */
  15862. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15863. /**
  15864. * If vertex color should be applied to the mesh
  15865. */
  15866. useVertexColor?: boolean | undefined,
  15867. /**
  15868. * If vertex alpha should be applied to the mesh
  15869. */
  15870. useVertexAlpha?: boolean | undefined);
  15871. private _addClipPlaneDefine;
  15872. private _removeClipPlaneDefine;
  15873. isReady(): boolean;
  15874. /**
  15875. * Returns the string "LineMesh"
  15876. */
  15877. getClassName(): string;
  15878. /**
  15879. * @hidden
  15880. */
  15881. get material(): Material;
  15882. /**
  15883. * @hidden
  15884. */
  15885. set material(value: Material);
  15886. /**
  15887. * @hidden
  15888. */
  15889. get checkCollisions(): boolean;
  15890. /** @hidden */
  15891. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15892. /** @hidden */
  15893. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15894. /**
  15895. * Disposes of the line mesh
  15896. * @param doNotRecurse If children should be disposed
  15897. */
  15898. dispose(doNotRecurse?: boolean): void;
  15899. /**
  15900. * Returns a new LineMesh object cloned from the current one.
  15901. */
  15902. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15903. /**
  15904. * Creates a new InstancedLinesMesh object from the mesh model.
  15905. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15906. * @param name defines the name of the new instance
  15907. * @returns a new InstancedLinesMesh
  15908. */
  15909. createInstance(name: string): InstancedLinesMesh;
  15910. }
  15911. /**
  15912. * Creates an instance based on a source LinesMesh
  15913. */
  15914. export class InstancedLinesMesh extends InstancedMesh {
  15915. /**
  15916. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15917. * This margin is expressed in world space coordinates, so its value may vary.
  15918. * Initilized with the intersectionThreshold value of the source LinesMesh
  15919. */
  15920. intersectionThreshold: number;
  15921. constructor(name: string, source: LinesMesh);
  15922. /**
  15923. * Returns the string "InstancedLinesMesh".
  15924. */
  15925. getClassName(): string;
  15926. }
  15927. }
  15928. declare module BABYLON {
  15929. /** @hidden */
  15930. export var linePixelShader: {
  15931. name: string;
  15932. shader: string;
  15933. };
  15934. }
  15935. declare module BABYLON {
  15936. /** @hidden */
  15937. export var lineVertexShader: {
  15938. name: string;
  15939. shader: string;
  15940. };
  15941. }
  15942. declare module BABYLON {
  15943. interface AbstractMesh {
  15944. /**
  15945. * Gets the edgesRenderer associated with the mesh
  15946. */
  15947. edgesRenderer: Nullable<EdgesRenderer>;
  15948. }
  15949. interface LinesMesh {
  15950. /**
  15951. * Enables the edge rendering mode on the mesh.
  15952. * This mode makes the mesh edges visible
  15953. * @param epsilon defines the maximal distance between two angles to detect a face
  15954. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15955. * @returns the currentAbstractMesh
  15956. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15957. */
  15958. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15959. }
  15960. interface InstancedLinesMesh {
  15961. /**
  15962. * Enables the edge rendering mode on the mesh.
  15963. * This mode makes the mesh edges visible
  15964. * @param epsilon defines the maximal distance between two angles to detect a face
  15965. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15966. * @returns the current InstancedLinesMesh
  15967. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15968. */
  15969. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15970. }
  15971. /**
  15972. * Defines the minimum contract an Edges renderer should follow.
  15973. */
  15974. export interface IEdgesRenderer extends IDisposable {
  15975. /**
  15976. * Gets or sets a boolean indicating if the edgesRenderer is active
  15977. */
  15978. isEnabled: boolean;
  15979. /**
  15980. * Renders the edges of the attached mesh,
  15981. */
  15982. render(): void;
  15983. /**
  15984. * Checks wether or not the edges renderer is ready to render.
  15985. * @return true if ready, otherwise false.
  15986. */
  15987. isReady(): boolean;
  15988. }
  15989. /**
  15990. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15991. */
  15992. export class EdgesRenderer implements IEdgesRenderer {
  15993. /**
  15994. * Define the size of the edges with an orthographic camera
  15995. */
  15996. edgesWidthScalerForOrthographic: number;
  15997. /**
  15998. * Define the size of the edges with a perspective camera
  15999. */
  16000. edgesWidthScalerForPerspective: number;
  16001. protected _source: AbstractMesh;
  16002. protected _linesPositions: number[];
  16003. protected _linesNormals: number[];
  16004. protected _linesIndices: number[];
  16005. protected _epsilon: number;
  16006. protected _indicesCount: number;
  16007. protected _lineShader: ShaderMaterial;
  16008. protected _ib: DataBuffer;
  16009. protected _buffers: {
  16010. [key: string]: Nullable<VertexBuffer>;
  16011. };
  16012. protected _checkVerticesInsteadOfIndices: boolean;
  16013. private _meshRebuildObserver;
  16014. private _meshDisposeObserver;
  16015. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16016. isEnabled: boolean;
  16017. /**
  16018. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16019. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16020. * @param source Mesh used to create edges
  16021. * @param epsilon sum of angles in adjacency to check for edge
  16022. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16023. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16024. */
  16025. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16026. protected _prepareRessources(): void;
  16027. /** @hidden */
  16028. _rebuild(): void;
  16029. /**
  16030. * Releases the required resources for the edges renderer
  16031. */
  16032. dispose(): void;
  16033. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16034. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16035. /**
  16036. * Checks if the pair of p0 and p1 is en edge
  16037. * @param faceIndex
  16038. * @param edge
  16039. * @param faceNormals
  16040. * @param p0
  16041. * @param p1
  16042. * @private
  16043. */
  16044. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16045. /**
  16046. * push line into the position, normal and index buffer
  16047. * @protected
  16048. */
  16049. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16050. /**
  16051. * Generates lines edges from adjacencjes
  16052. * @private
  16053. */
  16054. _generateEdgesLines(): void;
  16055. /**
  16056. * Checks wether or not the edges renderer is ready to render.
  16057. * @return true if ready, otherwise false.
  16058. */
  16059. isReady(): boolean;
  16060. /**
  16061. * Renders the edges of the attached mesh,
  16062. */
  16063. render(): void;
  16064. }
  16065. /**
  16066. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16067. */
  16068. export class LineEdgesRenderer extends EdgesRenderer {
  16069. /**
  16070. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16071. * @param source LineMesh used to generate edges
  16072. * @param epsilon not important (specified angle for edge detection)
  16073. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16074. */
  16075. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16076. /**
  16077. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16078. */
  16079. _generateEdgesLines(): void;
  16080. }
  16081. }
  16082. declare module BABYLON {
  16083. /**
  16084. * This represents the object necessary to create a rendering group.
  16085. * This is exclusively used and created by the rendering manager.
  16086. * To modify the behavior, you use the available helpers in your scene or meshes.
  16087. * @hidden
  16088. */
  16089. export class RenderingGroup {
  16090. index: number;
  16091. private static _zeroVector;
  16092. private _scene;
  16093. private _opaqueSubMeshes;
  16094. private _transparentSubMeshes;
  16095. private _alphaTestSubMeshes;
  16096. private _depthOnlySubMeshes;
  16097. private _particleSystems;
  16098. private _spriteManagers;
  16099. private _opaqueSortCompareFn;
  16100. private _alphaTestSortCompareFn;
  16101. private _transparentSortCompareFn;
  16102. private _renderOpaque;
  16103. private _renderAlphaTest;
  16104. private _renderTransparent;
  16105. /** @hidden */
  16106. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16107. onBeforeTransparentRendering: () => void;
  16108. /**
  16109. * Set the opaque sort comparison function.
  16110. * If null the sub meshes will be render in the order they were created
  16111. */
  16112. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16113. /**
  16114. * Set the alpha test sort comparison function.
  16115. * If null the sub meshes will be render in the order they were created
  16116. */
  16117. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16118. /**
  16119. * Set the transparent sort comparison function.
  16120. * If null the sub meshes will be render in the order they were created
  16121. */
  16122. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16123. /**
  16124. * Creates a new rendering group.
  16125. * @param index The rendering group index
  16126. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16127. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16128. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16129. */
  16130. 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>);
  16131. /**
  16132. * Render all the sub meshes contained in the group.
  16133. * @param customRenderFunction Used to override the default render behaviour of the group.
  16134. * @returns true if rendered some submeshes.
  16135. */
  16136. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16137. /**
  16138. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16139. * @param subMeshes The submeshes to render
  16140. */
  16141. private renderOpaqueSorted;
  16142. /**
  16143. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16144. * @param subMeshes The submeshes to render
  16145. */
  16146. private renderAlphaTestSorted;
  16147. /**
  16148. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16149. * @param subMeshes The submeshes to render
  16150. */
  16151. private renderTransparentSorted;
  16152. /**
  16153. * Renders the submeshes in a specified order.
  16154. * @param subMeshes The submeshes to sort before render
  16155. * @param sortCompareFn The comparison function use to sort
  16156. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16157. * @param transparent Specifies to activate blending if true
  16158. */
  16159. private static renderSorted;
  16160. /**
  16161. * Renders the submeshes in the order they were dispatched (no sort applied).
  16162. * @param subMeshes The submeshes to render
  16163. */
  16164. private static renderUnsorted;
  16165. /**
  16166. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16167. * are rendered back to front if in the same alpha index.
  16168. *
  16169. * @param a The first submesh
  16170. * @param b The second submesh
  16171. * @returns The result of the comparison
  16172. */
  16173. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16174. /**
  16175. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16176. * are rendered back to front.
  16177. *
  16178. * @param a The first submesh
  16179. * @param b The second submesh
  16180. * @returns The result of the comparison
  16181. */
  16182. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16183. /**
  16184. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16185. * are rendered front to back (prevent overdraw).
  16186. *
  16187. * @param a The first submesh
  16188. * @param b The second submesh
  16189. * @returns The result of the comparison
  16190. */
  16191. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16192. /**
  16193. * Resets the different lists of submeshes to prepare a new frame.
  16194. */
  16195. prepare(): void;
  16196. dispose(): void;
  16197. /**
  16198. * Inserts the submesh in its correct queue depending on its material.
  16199. * @param subMesh The submesh to dispatch
  16200. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16201. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16202. */
  16203. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16204. dispatchSprites(spriteManager: ISpriteManager): void;
  16205. dispatchParticles(particleSystem: IParticleSystem): void;
  16206. private _renderParticles;
  16207. private _renderSprites;
  16208. }
  16209. }
  16210. declare module BABYLON {
  16211. /**
  16212. * Interface describing the different options available in the rendering manager
  16213. * regarding Auto Clear between groups.
  16214. */
  16215. export interface IRenderingManagerAutoClearSetup {
  16216. /**
  16217. * Defines whether or not autoclear is enable.
  16218. */
  16219. autoClear: boolean;
  16220. /**
  16221. * Defines whether or not to autoclear the depth buffer.
  16222. */
  16223. depth: boolean;
  16224. /**
  16225. * Defines whether or not to autoclear the stencil buffer.
  16226. */
  16227. stencil: boolean;
  16228. }
  16229. /**
  16230. * This class is used by the onRenderingGroupObservable
  16231. */
  16232. export class RenderingGroupInfo {
  16233. /**
  16234. * The Scene that being rendered
  16235. */
  16236. scene: Scene;
  16237. /**
  16238. * The camera currently used for the rendering pass
  16239. */
  16240. camera: Nullable<Camera>;
  16241. /**
  16242. * The ID of the renderingGroup being processed
  16243. */
  16244. renderingGroupId: number;
  16245. }
  16246. /**
  16247. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16248. * It is enable to manage the different groups as well as the different necessary sort functions.
  16249. * This should not be used directly aside of the few static configurations
  16250. */
  16251. export class RenderingManager {
  16252. /**
  16253. * The max id used for rendering groups (not included)
  16254. */
  16255. static MAX_RENDERINGGROUPS: number;
  16256. /**
  16257. * The min id used for rendering groups (included)
  16258. */
  16259. static MIN_RENDERINGGROUPS: number;
  16260. /**
  16261. * Used to globally prevent autoclearing scenes.
  16262. */
  16263. static AUTOCLEAR: boolean;
  16264. /**
  16265. * @hidden
  16266. */
  16267. _useSceneAutoClearSetup: boolean;
  16268. private _scene;
  16269. private _renderingGroups;
  16270. private _depthStencilBufferAlreadyCleaned;
  16271. private _autoClearDepthStencil;
  16272. private _customOpaqueSortCompareFn;
  16273. private _customAlphaTestSortCompareFn;
  16274. private _customTransparentSortCompareFn;
  16275. private _renderingGroupInfo;
  16276. /**
  16277. * Instantiates a new rendering group for a particular scene
  16278. * @param scene Defines the scene the groups belongs to
  16279. */
  16280. constructor(scene: Scene);
  16281. private _clearDepthStencilBuffer;
  16282. /**
  16283. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16284. * @hidden
  16285. */
  16286. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16287. /**
  16288. * Resets the different information of the group to prepare a new frame
  16289. * @hidden
  16290. */
  16291. reset(): void;
  16292. /**
  16293. * Dispose and release the group and its associated resources.
  16294. * @hidden
  16295. */
  16296. dispose(): void;
  16297. /**
  16298. * Clear the info related to rendering groups preventing retention points during dispose.
  16299. */
  16300. freeRenderingGroups(): void;
  16301. private _prepareRenderingGroup;
  16302. /**
  16303. * Add a sprite manager to the rendering manager in order to render it this frame.
  16304. * @param spriteManager Define the sprite manager to render
  16305. */
  16306. dispatchSprites(spriteManager: ISpriteManager): void;
  16307. /**
  16308. * Add a particle system to the rendering manager in order to render it this frame.
  16309. * @param particleSystem Define the particle system to render
  16310. */
  16311. dispatchParticles(particleSystem: IParticleSystem): void;
  16312. /**
  16313. * Add a submesh to the manager in order to render it this frame
  16314. * @param subMesh The submesh to dispatch
  16315. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16316. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16317. */
  16318. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16319. /**
  16320. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16321. * This allowed control for front to back rendering or reversly depending of the special needs.
  16322. *
  16323. * @param renderingGroupId The rendering group id corresponding to its index
  16324. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16325. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16326. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16327. */
  16328. 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;
  16329. /**
  16330. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16331. *
  16332. * @param renderingGroupId The rendering group id corresponding to its index
  16333. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16334. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16335. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16336. */
  16337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16338. /**
  16339. * Gets the current auto clear configuration for one rendering group of the rendering
  16340. * manager.
  16341. * @param index the rendering group index to get the information for
  16342. * @returns The auto clear setup for the requested rendering group
  16343. */
  16344. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16345. }
  16346. }
  16347. declare module BABYLON {
  16348. /**
  16349. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16350. */
  16351. export interface ICustomShaderOptions {
  16352. /**
  16353. * Gets or sets the custom shader name to use
  16354. */
  16355. shaderName: string;
  16356. /**
  16357. * The list of attribute names used in the shader
  16358. */
  16359. attributes?: string[];
  16360. /**
  16361. * The list of unifrom names used in the shader
  16362. */
  16363. uniforms?: string[];
  16364. /**
  16365. * The list of sampler names used in the shader
  16366. */
  16367. samplers?: string[];
  16368. /**
  16369. * The list of defines used in the shader
  16370. */
  16371. defines?: string[];
  16372. }
  16373. /**
  16374. * Interface to implement to create a shadow generator compatible with BJS.
  16375. */
  16376. export interface IShadowGenerator {
  16377. /**
  16378. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16379. * @returns The render target texture if present otherwise, null
  16380. */
  16381. getShadowMap(): Nullable<RenderTargetTexture>;
  16382. /**
  16383. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16384. * @param subMesh The submesh we want to render in the shadow map
  16385. * @param useInstances Defines wether will draw in the map using instances
  16386. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16387. * @returns true if ready otherwise, false
  16388. */
  16389. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16390. /**
  16391. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16392. * @param defines Defines of the material we want to update
  16393. * @param lightIndex Index of the light in the enabled light list of the material
  16394. */
  16395. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16396. /**
  16397. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16398. * defined in the generator but impacting the effect).
  16399. * It implies the unifroms available on the materials are the standard BJS ones.
  16400. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16401. * @param effect The effect we are binfing the information for
  16402. */
  16403. bindShadowLight(lightIndex: string, effect: Effect): void;
  16404. /**
  16405. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16406. * (eq to shadow prjection matrix * light transform matrix)
  16407. * @returns The transform matrix used to create the shadow map
  16408. */
  16409. getTransformMatrix(): Matrix;
  16410. /**
  16411. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16412. * Cube and 2D textures for instance.
  16413. */
  16414. recreateShadowMap(): void;
  16415. /**
  16416. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16417. * @param onCompiled Callback triggered at the and of the effects compilation
  16418. * @param options Sets of optional options forcing the compilation with different modes
  16419. */
  16420. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16421. useInstances: boolean;
  16422. }>): void;
  16423. /**
  16424. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16425. * @param options Sets of optional options forcing the compilation with different modes
  16426. * @returns A promise that resolves when the compilation completes
  16427. */
  16428. forceCompilationAsync(options?: Partial<{
  16429. useInstances: boolean;
  16430. }>): Promise<void>;
  16431. /**
  16432. * Serializes the shadow generator setup to a json object.
  16433. * @returns The serialized JSON object
  16434. */
  16435. serialize(): any;
  16436. /**
  16437. * Disposes the Shadow map and related Textures and effects.
  16438. */
  16439. dispose(): void;
  16440. }
  16441. /**
  16442. * Default implementation IShadowGenerator.
  16443. * This is the main object responsible of generating shadows in the framework.
  16444. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16445. */
  16446. export class ShadowGenerator implements IShadowGenerator {
  16447. /**
  16448. * Name of the shadow generator class
  16449. */
  16450. static CLASSNAME: string;
  16451. /**
  16452. * Shadow generator mode None: no filtering applied.
  16453. */
  16454. static readonly FILTER_NONE: number;
  16455. /**
  16456. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16458. */
  16459. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16460. /**
  16461. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16462. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16463. */
  16464. static readonly FILTER_POISSONSAMPLING: number;
  16465. /**
  16466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16468. */
  16469. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16470. /**
  16471. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16472. * edge artifacts on steep falloff.
  16473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16474. */
  16475. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16476. /**
  16477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16478. * edge artifacts on steep falloff.
  16479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16480. */
  16481. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16482. /**
  16483. * Shadow generator mode PCF: Percentage Closer Filtering
  16484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16485. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16486. */
  16487. static readonly FILTER_PCF: number;
  16488. /**
  16489. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16490. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16491. * Contact Hardening
  16492. */
  16493. static readonly FILTER_PCSS: number;
  16494. /**
  16495. * Reserved for PCF and PCSS
  16496. * Highest Quality.
  16497. *
  16498. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16499. *
  16500. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16501. */
  16502. static readonly QUALITY_HIGH: number;
  16503. /**
  16504. * Reserved for PCF and PCSS
  16505. * Good tradeoff for quality/perf cross devices
  16506. *
  16507. * Execute PCF on a 3*3 kernel.
  16508. *
  16509. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16510. */
  16511. static readonly QUALITY_MEDIUM: number;
  16512. /**
  16513. * Reserved for PCF and PCSS
  16514. * The lowest quality but the fastest.
  16515. *
  16516. * Execute PCF on a 1*1 kernel.
  16517. *
  16518. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16519. */
  16520. static readonly QUALITY_LOW: number;
  16521. /** Gets or sets the custom shader name to use */
  16522. customShaderOptions: ICustomShaderOptions;
  16523. /**
  16524. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16525. */
  16526. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16527. /**
  16528. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16529. */
  16530. onAfterShadowMapRenderObservable: Observable<Effect>;
  16531. /**
  16532. * Observable triggered before a mesh is rendered in the shadow map.
  16533. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16534. */
  16535. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16536. /**
  16537. * Observable triggered after a mesh is rendered in the shadow map.
  16538. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16539. */
  16540. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16541. protected _bias: number;
  16542. /**
  16543. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16544. */
  16545. get bias(): number;
  16546. /**
  16547. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16548. */
  16549. set bias(bias: number);
  16550. protected _normalBias: number;
  16551. /**
  16552. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16553. */
  16554. get normalBias(): number;
  16555. /**
  16556. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16557. */
  16558. set normalBias(normalBias: number);
  16559. protected _blurBoxOffset: number;
  16560. /**
  16561. * Gets the blur box offset: offset applied during the blur pass.
  16562. * Only useful if useKernelBlur = false
  16563. */
  16564. get blurBoxOffset(): number;
  16565. /**
  16566. * Sets the blur box offset: offset applied during the blur pass.
  16567. * Only useful if useKernelBlur = false
  16568. */
  16569. set blurBoxOffset(value: number);
  16570. protected _blurScale: number;
  16571. /**
  16572. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16573. * 2 means half of the size.
  16574. */
  16575. get blurScale(): number;
  16576. /**
  16577. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16578. * 2 means half of the size.
  16579. */
  16580. set blurScale(value: number);
  16581. protected _blurKernel: number;
  16582. /**
  16583. * Gets the blur kernel: kernel size of the blur pass.
  16584. * Only useful if useKernelBlur = true
  16585. */
  16586. get blurKernel(): number;
  16587. /**
  16588. * Sets the blur kernel: kernel size of the blur pass.
  16589. * Only useful if useKernelBlur = true
  16590. */
  16591. set blurKernel(value: number);
  16592. protected _useKernelBlur: boolean;
  16593. /**
  16594. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16595. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16596. */
  16597. get useKernelBlur(): boolean;
  16598. /**
  16599. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16600. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16601. */
  16602. set useKernelBlur(value: boolean);
  16603. protected _depthScale: number;
  16604. /**
  16605. * Gets the depth scale used in ESM mode.
  16606. */
  16607. get depthScale(): number;
  16608. /**
  16609. * Sets the depth scale used in ESM mode.
  16610. * This can override the scale stored on the light.
  16611. */
  16612. set depthScale(value: number);
  16613. protected _validateFilter(filter: number): number;
  16614. protected _filter: number;
  16615. /**
  16616. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16617. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16618. */
  16619. get filter(): number;
  16620. /**
  16621. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16622. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16623. */
  16624. set filter(value: number);
  16625. /**
  16626. * Gets if the current filter is set to Poisson Sampling.
  16627. */
  16628. get usePoissonSampling(): boolean;
  16629. /**
  16630. * Sets the current filter to Poisson Sampling.
  16631. */
  16632. set usePoissonSampling(value: boolean);
  16633. /**
  16634. * Gets if the current filter is set to ESM.
  16635. */
  16636. get useExponentialShadowMap(): boolean;
  16637. /**
  16638. * Sets the current filter is to ESM.
  16639. */
  16640. set useExponentialShadowMap(value: boolean);
  16641. /**
  16642. * Gets if the current filter is set to filtered ESM.
  16643. */
  16644. get useBlurExponentialShadowMap(): boolean;
  16645. /**
  16646. * Gets if the current filter is set to filtered ESM.
  16647. */
  16648. set useBlurExponentialShadowMap(value: boolean);
  16649. /**
  16650. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16651. * exponential to prevent steep falloff artifacts).
  16652. */
  16653. get useCloseExponentialShadowMap(): boolean;
  16654. /**
  16655. * Sets the current filter to "close ESM" (using the inverse of the
  16656. * exponential to prevent steep falloff artifacts).
  16657. */
  16658. set useCloseExponentialShadowMap(value: boolean);
  16659. /**
  16660. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16661. * exponential to prevent steep falloff artifacts).
  16662. */
  16663. get useBlurCloseExponentialShadowMap(): boolean;
  16664. /**
  16665. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16666. * exponential to prevent steep falloff artifacts).
  16667. */
  16668. set useBlurCloseExponentialShadowMap(value: boolean);
  16669. /**
  16670. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16671. */
  16672. get usePercentageCloserFiltering(): boolean;
  16673. /**
  16674. * Sets the current filter to "PCF" (percentage closer filtering).
  16675. */
  16676. set usePercentageCloserFiltering(value: boolean);
  16677. protected _filteringQuality: number;
  16678. /**
  16679. * Gets the PCF or PCSS Quality.
  16680. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16681. */
  16682. get filteringQuality(): number;
  16683. /**
  16684. * Sets the PCF or PCSS Quality.
  16685. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16686. */
  16687. set filteringQuality(filteringQuality: number);
  16688. /**
  16689. * Gets if the current filter is set to "PCSS" (contact hardening).
  16690. */
  16691. get useContactHardeningShadow(): boolean;
  16692. /**
  16693. * Sets the current filter to "PCSS" (contact hardening).
  16694. */
  16695. set useContactHardeningShadow(value: boolean);
  16696. protected _contactHardeningLightSizeUVRatio: number;
  16697. /**
  16698. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16699. * Using a ratio helps keeping shape stability independently of the map size.
  16700. *
  16701. * It does not account for the light projection as it was having too much
  16702. * instability during the light setup or during light position changes.
  16703. *
  16704. * Only valid if useContactHardeningShadow is true.
  16705. */
  16706. get contactHardeningLightSizeUVRatio(): number;
  16707. /**
  16708. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16709. * Using a ratio helps keeping shape stability independently of the map size.
  16710. *
  16711. * It does not account for the light projection as it was having too much
  16712. * instability during the light setup or during light position changes.
  16713. *
  16714. * Only valid if useContactHardeningShadow is true.
  16715. */
  16716. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16717. protected _darkness: number;
  16718. /** Gets or sets the actual darkness of a shadow */
  16719. get darkness(): number;
  16720. set darkness(value: number);
  16721. /**
  16722. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16723. * 0 means strongest and 1 would means no shadow.
  16724. * @returns the darkness.
  16725. */
  16726. getDarkness(): number;
  16727. /**
  16728. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16729. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16730. * @returns the shadow generator allowing fluent coding.
  16731. */
  16732. setDarkness(darkness: number): ShadowGenerator;
  16733. protected _transparencyShadow: boolean;
  16734. /** Gets or sets the ability to have transparent shadow */
  16735. get transparencyShadow(): boolean;
  16736. set transparencyShadow(value: boolean);
  16737. /**
  16738. * Sets the ability to have transparent shadow (boolean).
  16739. * @param transparent True if transparent else False
  16740. * @returns the shadow generator allowing fluent coding
  16741. */
  16742. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16743. /**
  16744. * Enables or disables shadows with varying strength based on the transparency
  16745. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  16746. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  16747. * mesh.visibility * alphaTexture.a
  16748. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  16749. */
  16750. enableSoftTransparentShadow: boolean;
  16751. protected _shadowMap: Nullable<RenderTargetTexture>;
  16752. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16753. /**
  16754. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16755. * @returns The render target texture if present otherwise, null
  16756. */
  16757. getShadowMap(): Nullable<RenderTargetTexture>;
  16758. /**
  16759. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16760. * @returns The render target texture if the shadow map is present otherwise, null
  16761. */
  16762. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16763. /**
  16764. * Gets the class name of that object
  16765. * @returns "ShadowGenerator"
  16766. */
  16767. getClassName(): string;
  16768. /**
  16769. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16770. * @param mesh Mesh to add
  16771. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16772. * @returns the Shadow Generator itself
  16773. */
  16774. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16775. /**
  16776. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16777. * @param mesh Mesh to remove
  16778. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16779. * @returns the Shadow Generator itself
  16780. */
  16781. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16782. /**
  16783. * Controls the extent to which the shadows fade out at the edge of the frustum
  16784. */
  16785. frustumEdgeFalloff: number;
  16786. protected _light: IShadowLight;
  16787. /**
  16788. * Returns the associated light object.
  16789. * @returns the light generating the shadow
  16790. */
  16791. getLight(): IShadowLight;
  16792. /**
  16793. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16794. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16795. * It might on the other hand introduce peter panning.
  16796. */
  16797. forceBackFacesOnly: boolean;
  16798. protected _scene: Scene;
  16799. protected _lightDirection: Vector3;
  16800. protected _effect: Effect;
  16801. protected _viewMatrix: Matrix;
  16802. protected _projectionMatrix: Matrix;
  16803. protected _transformMatrix: Matrix;
  16804. protected _cachedPosition: Vector3;
  16805. protected _cachedDirection: Vector3;
  16806. protected _cachedDefines: string;
  16807. protected _currentRenderID: number;
  16808. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16809. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16810. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16811. protected _blurPostProcesses: PostProcess[];
  16812. protected _mapSize: number;
  16813. protected _currentFaceIndex: number;
  16814. protected _currentFaceIndexCache: number;
  16815. protected _textureType: number;
  16816. protected _defaultTextureMatrix: Matrix;
  16817. protected _storedUniqueId: Nullable<number>;
  16818. /** @hidden */
  16819. static _SceneComponentInitialization: (scene: Scene) => void;
  16820. /**
  16821. * Creates a ShadowGenerator object.
  16822. * A ShadowGenerator is the required tool to use the shadows.
  16823. * Each light casting shadows needs to use its own ShadowGenerator.
  16824. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16825. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16826. * @param light The light object generating the shadows.
  16827. * @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.
  16828. */
  16829. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16830. protected _initializeGenerator(): void;
  16831. protected _createTargetRenderTexture(): void;
  16832. protected _initializeShadowMap(): void;
  16833. protected _initializeBlurRTTAndPostProcesses(): void;
  16834. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16835. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16836. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  16837. protected _applyFilterValues(): void;
  16838. /**
  16839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16840. * @param onCompiled Callback triggered at the and of the effects compilation
  16841. * @param options Sets of optional options forcing the compilation with different modes
  16842. */
  16843. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16844. useInstances: boolean;
  16845. }>): void;
  16846. /**
  16847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16848. * @param options Sets of optional options forcing the compilation with different modes
  16849. * @returns A promise that resolves when the compilation completes
  16850. */
  16851. forceCompilationAsync(options?: Partial<{
  16852. useInstances: boolean;
  16853. }>): Promise<void>;
  16854. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16855. private _prepareShadowDefines;
  16856. /**
  16857. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16858. * @param subMesh The submesh we want to render in the shadow map
  16859. * @param useInstances Defines wether will draw in the map using instances
  16860. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16861. * @returns true if ready otherwise, false
  16862. */
  16863. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16864. /**
  16865. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16866. * @param defines Defines of the material we want to update
  16867. * @param lightIndex Index of the light in the enabled light list of the material
  16868. */
  16869. prepareDefines(defines: any, lightIndex: number): void;
  16870. /**
  16871. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16872. * defined in the generator but impacting the effect).
  16873. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16874. * @param effect The effect we are binfing the information for
  16875. */
  16876. bindShadowLight(lightIndex: string, effect: Effect): void;
  16877. /**
  16878. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16879. * (eq to shadow prjection matrix * light transform matrix)
  16880. * @returns The transform matrix used to create the shadow map
  16881. */
  16882. getTransformMatrix(): Matrix;
  16883. /**
  16884. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16885. * Cube and 2D textures for instance.
  16886. */
  16887. recreateShadowMap(): void;
  16888. protected _disposeBlurPostProcesses(): void;
  16889. protected _disposeRTTandPostProcesses(): void;
  16890. /**
  16891. * Disposes the ShadowGenerator.
  16892. * Returns nothing.
  16893. */
  16894. dispose(): void;
  16895. /**
  16896. * Serializes the shadow generator setup to a json object.
  16897. * @returns The serialized JSON object
  16898. */
  16899. serialize(): any;
  16900. /**
  16901. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16902. * @param parsedShadowGenerator The JSON object to parse
  16903. * @param scene The scene to create the shadow map for
  16904. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16905. * @returns The parsed shadow generator
  16906. */
  16907. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16908. }
  16909. }
  16910. declare module BABYLON {
  16911. /**
  16912. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16913. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16914. * 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.
  16915. */
  16916. export abstract class Light extends Node {
  16917. /**
  16918. * Falloff Default: light is falling off following the material specification:
  16919. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16920. */
  16921. static readonly FALLOFF_DEFAULT: number;
  16922. /**
  16923. * Falloff Physical: light is falling off following the inverse squared distance law.
  16924. */
  16925. static readonly FALLOFF_PHYSICAL: number;
  16926. /**
  16927. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16928. * to enhance interoperability with other engines.
  16929. */
  16930. static readonly FALLOFF_GLTF: number;
  16931. /**
  16932. * Falloff Standard: light is falling off like in the standard material
  16933. * to enhance interoperability with other materials.
  16934. */
  16935. static readonly FALLOFF_STANDARD: number;
  16936. /**
  16937. * If every light affecting the material is in this lightmapMode,
  16938. * material.lightmapTexture adds or multiplies
  16939. * (depends on material.useLightmapAsShadowmap)
  16940. * after every other light calculations.
  16941. */
  16942. static readonly LIGHTMAP_DEFAULT: number;
  16943. /**
  16944. * material.lightmapTexture as only diffuse lighting from this light
  16945. * adds only specular lighting from this light
  16946. * adds dynamic shadows
  16947. */
  16948. static readonly LIGHTMAP_SPECULAR: number;
  16949. /**
  16950. * material.lightmapTexture as only lighting
  16951. * no light calculation from this light
  16952. * only adds dynamic shadows from this light
  16953. */
  16954. static readonly LIGHTMAP_SHADOWSONLY: number;
  16955. /**
  16956. * Each light type uses the default quantity according to its type:
  16957. * point/spot lights use luminous intensity
  16958. * directional lights use illuminance
  16959. */
  16960. static readonly INTENSITYMODE_AUTOMATIC: number;
  16961. /**
  16962. * lumen (lm)
  16963. */
  16964. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16965. /**
  16966. * candela (lm/sr)
  16967. */
  16968. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16969. /**
  16970. * lux (lm/m^2)
  16971. */
  16972. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16973. /**
  16974. * nit (cd/m^2)
  16975. */
  16976. static readonly INTENSITYMODE_LUMINANCE: number;
  16977. /**
  16978. * Light type const id of the point light.
  16979. */
  16980. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16981. /**
  16982. * Light type const id of the directional light.
  16983. */
  16984. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16985. /**
  16986. * Light type const id of the spot light.
  16987. */
  16988. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16989. /**
  16990. * Light type const id of the hemispheric light.
  16991. */
  16992. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16993. /**
  16994. * Diffuse gives the basic color to an object.
  16995. */
  16996. diffuse: Color3;
  16997. /**
  16998. * Specular produces a highlight color on an object.
  16999. * Note: This is note affecting PBR materials.
  17000. */
  17001. specular: Color3;
  17002. /**
  17003. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17004. * falling off base on range or angle.
  17005. * This can be set to any values in Light.FALLOFF_x.
  17006. *
  17007. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17008. * other types of materials.
  17009. */
  17010. falloffType: number;
  17011. /**
  17012. * Strength of the light.
  17013. * Note: By default it is define in the framework own unit.
  17014. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17015. */
  17016. intensity: number;
  17017. private _range;
  17018. protected _inverseSquaredRange: number;
  17019. /**
  17020. * Defines how far from the source the light is impacting in scene units.
  17021. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17022. */
  17023. get range(): number;
  17024. /**
  17025. * Defines how far from the source the light is impacting in scene units.
  17026. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17027. */
  17028. set range(value: number);
  17029. /**
  17030. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17031. * of light.
  17032. */
  17033. private _photometricScale;
  17034. private _intensityMode;
  17035. /**
  17036. * Gets the photometric scale used to interpret the intensity.
  17037. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17038. */
  17039. get intensityMode(): number;
  17040. /**
  17041. * Sets the photometric scale used to interpret the intensity.
  17042. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17043. */
  17044. set intensityMode(value: number);
  17045. private _radius;
  17046. /**
  17047. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17048. */
  17049. get radius(): number;
  17050. /**
  17051. * sets the light radius used by PBR Materials to simulate soft area lights.
  17052. */
  17053. set radius(value: number);
  17054. private _renderPriority;
  17055. /**
  17056. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17057. * exceeding the number allowed of the materials.
  17058. */
  17059. renderPriority: number;
  17060. private _shadowEnabled;
  17061. /**
  17062. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17063. * the current shadow generator.
  17064. */
  17065. get shadowEnabled(): boolean;
  17066. /**
  17067. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17068. * the current shadow generator.
  17069. */
  17070. set shadowEnabled(value: boolean);
  17071. private _includedOnlyMeshes;
  17072. /**
  17073. * Gets the only meshes impacted by this light.
  17074. */
  17075. get includedOnlyMeshes(): AbstractMesh[];
  17076. /**
  17077. * Sets the only meshes impacted by this light.
  17078. */
  17079. set includedOnlyMeshes(value: AbstractMesh[]);
  17080. private _excludedMeshes;
  17081. /**
  17082. * Gets the meshes not impacted by this light.
  17083. */
  17084. get excludedMeshes(): AbstractMesh[];
  17085. /**
  17086. * Sets the meshes not impacted by this light.
  17087. */
  17088. set excludedMeshes(value: AbstractMesh[]);
  17089. private _excludeWithLayerMask;
  17090. /**
  17091. * Gets the layer id use to find what meshes are not impacted by the light.
  17092. * Inactive if 0
  17093. */
  17094. get excludeWithLayerMask(): number;
  17095. /**
  17096. * Sets the layer id use to find what meshes are not impacted by the light.
  17097. * Inactive if 0
  17098. */
  17099. set excludeWithLayerMask(value: number);
  17100. private _includeOnlyWithLayerMask;
  17101. /**
  17102. * Gets the layer id use to find what meshes are impacted by the light.
  17103. * Inactive if 0
  17104. */
  17105. get includeOnlyWithLayerMask(): number;
  17106. /**
  17107. * Sets the layer id use to find what meshes are impacted by the light.
  17108. * Inactive if 0
  17109. */
  17110. set includeOnlyWithLayerMask(value: number);
  17111. private _lightmapMode;
  17112. /**
  17113. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17114. */
  17115. get lightmapMode(): number;
  17116. /**
  17117. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17118. */
  17119. set lightmapMode(value: number);
  17120. /**
  17121. * Shadow generator associted to the light.
  17122. * @hidden Internal use only.
  17123. */
  17124. _shadowGenerator: Nullable<IShadowGenerator>;
  17125. /**
  17126. * @hidden Internal use only.
  17127. */
  17128. _excludedMeshesIds: string[];
  17129. /**
  17130. * @hidden Internal use only.
  17131. */
  17132. _includedOnlyMeshesIds: string[];
  17133. /**
  17134. * The current light unifom buffer.
  17135. * @hidden Internal use only.
  17136. */
  17137. _uniformBuffer: UniformBuffer;
  17138. /** @hidden */
  17139. _renderId: number;
  17140. /**
  17141. * Creates a Light object in the scene.
  17142. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17143. * @param name The firendly name of the light
  17144. * @param scene The scene the light belongs too
  17145. */
  17146. constructor(name: string, scene: Scene);
  17147. protected abstract _buildUniformLayout(): void;
  17148. /**
  17149. * Sets the passed Effect "effect" with the Light information.
  17150. * @param effect The effect to update
  17151. * @param lightIndex The index of the light in the effect to update
  17152. * @returns The light
  17153. */
  17154. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17155. /**
  17156. * Sets the passed Effect "effect" with the Light textures.
  17157. * @param effect The effect to update
  17158. * @param lightIndex The index of the light in the effect to update
  17159. * @returns The light
  17160. */
  17161. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17162. /**
  17163. * Binds the lights information from the scene to the effect for the given mesh.
  17164. * @param lightIndex Light index
  17165. * @param scene The scene where the light belongs to
  17166. * @param effect The effect we are binding the data to
  17167. * @param useSpecular Defines if specular is supported
  17168. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17169. */
  17170. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17171. /**
  17172. * Sets the passed Effect "effect" with the Light information.
  17173. * @param effect The effect to update
  17174. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17175. * @returns The light
  17176. */
  17177. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17178. /**
  17179. * Returns the string "Light".
  17180. * @returns the class name
  17181. */
  17182. getClassName(): string;
  17183. /** @hidden */
  17184. readonly _isLight: boolean;
  17185. /**
  17186. * Converts the light information to a readable string for debug purpose.
  17187. * @param fullDetails Supports for multiple levels of logging within scene loading
  17188. * @returns the human readable light info
  17189. */
  17190. toString(fullDetails?: boolean): string;
  17191. /** @hidden */
  17192. protected _syncParentEnabledState(): void;
  17193. /**
  17194. * Set the enabled state of this node.
  17195. * @param value - the new enabled state
  17196. */
  17197. setEnabled(value: boolean): void;
  17198. /**
  17199. * Returns the Light associated shadow generator if any.
  17200. * @return the associated shadow generator.
  17201. */
  17202. getShadowGenerator(): Nullable<IShadowGenerator>;
  17203. /**
  17204. * Returns a Vector3, the absolute light position in the World.
  17205. * @returns the world space position of the light
  17206. */
  17207. getAbsolutePosition(): Vector3;
  17208. /**
  17209. * Specifies if the light will affect the passed mesh.
  17210. * @param mesh The mesh to test against the light
  17211. * @return true the mesh is affected otherwise, false.
  17212. */
  17213. canAffectMesh(mesh: AbstractMesh): boolean;
  17214. /**
  17215. * Sort function to order lights for rendering.
  17216. * @param a First Light object to compare to second.
  17217. * @param b Second Light object to compare first.
  17218. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17219. */
  17220. static CompareLightsPriority(a: Light, b: Light): number;
  17221. /**
  17222. * Releases resources associated with this node.
  17223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17225. */
  17226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17227. /**
  17228. * Returns the light type ID (integer).
  17229. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17230. */
  17231. getTypeID(): number;
  17232. /**
  17233. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17234. * @returns the scaled intensity in intensity mode unit
  17235. */
  17236. getScaledIntensity(): number;
  17237. /**
  17238. * Returns a new Light object, named "name", from the current one.
  17239. * @param name The name of the cloned light
  17240. * @returns the new created light
  17241. */
  17242. clone(name: string): Nullable<Light>;
  17243. /**
  17244. * Serializes the current light into a Serialization object.
  17245. * @returns the serialized object.
  17246. */
  17247. serialize(): any;
  17248. /**
  17249. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17250. * This new light is named "name" and added to the passed scene.
  17251. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17252. * @param name The friendly name of the light
  17253. * @param scene The scene the new light will belong to
  17254. * @returns the constructor function
  17255. */
  17256. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17257. /**
  17258. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17259. * @param parsedLight The JSON representation of the light
  17260. * @param scene The scene to create the parsed light in
  17261. * @returns the created light after parsing
  17262. */
  17263. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17264. private _hookArrayForExcluded;
  17265. private _hookArrayForIncludedOnly;
  17266. private _resyncMeshes;
  17267. /**
  17268. * Forces the meshes to update their light related information in their rendering used effects
  17269. * @hidden Internal Use Only
  17270. */
  17271. _markMeshesAsLightDirty(): void;
  17272. /**
  17273. * Recomputes the cached photometric scale if needed.
  17274. */
  17275. private _computePhotometricScale;
  17276. /**
  17277. * Returns the Photometric Scale according to the light type and intensity mode.
  17278. */
  17279. private _getPhotometricScale;
  17280. /**
  17281. * Reorder the light in the scene according to their defined priority.
  17282. * @hidden Internal Use Only
  17283. */
  17284. _reorderLightsInScene(): void;
  17285. /**
  17286. * Prepares the list of defines specific to the light type.
  17287. * @param defines the list of defines
  17288. * @param lightIndex defines the index of the light for the effect
  17289. */
  17290. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17291. }
  17292. }
  17293. declare module BABYLON {
  17294. /**
  17295. * Interface used to define Action
  17296. */
  17297. export interface IAction {
  17298. /**
  17299. * Trigger for the action
  17300. */
  17301. trigger: number;
  17302. /** Options of the trigger */
  17303. triggerOptions: any;
  17304. /**
  17305. * Gets the trigger parameters
  17306. * @returns the trigger parameters
  17307. */
  17308. getTriggerParameter(): any;
  17309. /**
  17310. * Internal only - executes current action event
  17311. * @hidden
  17312. */
  17313. _executeCurrent(evt?: ActionEvent): void;
  17314. /**
  17315. * Serialize placeholder for child classes
  17316. * @param parent of child
  17317. * @returns the serialized object
  17318. */
  17319. serialize(parent: any): any;
  17320. /**
  17321. * Internal only
  17322. * @hidden
  17323. */
  17324. _prepare(): void;
  17325. /**
  17326. * Internal only - manager for action
  17327. * @hidden
  17328. */
  17329. _actionManager: AbstractActionManager;
  17330. /**
  17331. * Adds action to chain of actions, may be a DoNothingAction
  17332. * @param action defines the next action to execute
  17333. * @returns The action passed in
  17334. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17335. */
  17336. then(action: IAction): IAction;
  17337. }
  17338. /**
  17339. * The action to be carried out following a trigger
  17340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17341. */
  17342. export class Action implements IAction {
  17343. /** the trigger, with or without parameters, for the action */
  17344. triggerOptions: any;
  17345. /**
  17346. * Trigger for the action
  17347. */
  17348. trigger: number;
  17349. /**
  17350. * Internal only - manager for action
  17351. * @hidden
  17352. */
  17353. _actionManager: ActionManager;
  17354. private _nextActiveAction;
  17355. private _child;
  17356. private _condition?;
  17357. private _triggerParameter;
  17358. /**
  17359. * An event triggered prior to action being executed.
  17360. */
  17361. onBeforeExecuteObservable: Observable<Action>;
  17362. /**
  17363. * Creates a new Action
  17364. * @param triggerOptions the trigger, with or without parameters, for the action
  17365. * @param condition an optional determinant of action
  17366. */
  17367. constructor(
  17368. /** the trigger, with or without parameters, for the action */
  17369. triggerOptions: any, condition?: Condition);
  17370. /**
  17371. * Internal only
  17372. * @hidden
  17373. */
  17374. _prepare(): void;
  17375. /**
  17376. * Gets the trigger parameters
  17377. * @returns the trigger parameters
  17378. */
  17379. getTriggerParameter(): any;
  17380. /**
  17381. * Internal only - executes current action event
  17382. * @hidden
  17383. */
  17384. _executeCurrent(evt?: ActionEvent): void;
  17385. /**
  17386. * Execute placeholder for child classes
  17387. * @param evt optional action event
  17388. */
  17389. execute(evt?: ActionEvent): void;
  17390. /**
  17391. * Skips to next active action
  17392. */
  17393. skipToNextActiveAction(): void;
  17394. /**
  17395. * Adds action to chain of actions, may be a DoNothingAction
  17396. * @param action defines the next action to execute
  17397. * @returns The action passed in
  17398. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17399. */
  17400. then(action: Action): Action;
  17401. /**
  17402. * Internal only
  17403. * @hidden
  17404. */
  17405. _getProperty(propertyPath: string): string;
  17406. /**
  17407. * Internal only
  17408. * @hidden
  17409. */
  17410. _getEffectiveTarget(target: any, propertyPath: string): any;
  17411. /**
  17412. * Serialize placeholder for child classes
  17413. * @param parent of child
  17414. * @returns the serialized object
  17415. */
  17416. serialize(parent: any): any;
  17417. /**
  17418. * Internal only called by serialize
  17419. * @hidden
  17420. */
  17421. protected _serialize(serializedAction: any, parent?: any): any;
  17422. /**
  17423. * Internal only
  17424. * @hidden
  17425. */
  17426. static _SerializeValueAsString: (value: any) => string;
  17427. /**
  17428. * Internal only
  17429. * @hidden
  17430. */
  17431. static _GetTargetProperty: (target: Node | Scene) => {
  17432. name: string;
  17433. targetType: string;
  17434. value: string;
  17435. };
  17436. }
  17437. }
  17438. declare module BABYLON {
  17439. /**
  17440. * A Condition applied to an Action
  17441. */
  17442. export class Condition {
  17443. /**
  17444. * Internal only - manager for action
  17445. * @hidden
  17446. */
  17447. _actionManager: ActionManager;
  17448. /**
  17449. * Internal only
  17450. * @hidden
  17451. */
  17452. _evaluationId: number;
  17453. /**
  17454. * Internal only
  17455. * @hidden
  17456. */
  17457. _currentResult: boolean;
  17458. /**
  17459. * Creates a new Condition
  17460. * @param actionManager the manager of the action the condition is applied to
  17461. */
  17462. constructor(actionManager: ActionManager);
  17463. /**
  17464. * Check if the current condition is valid
  17465. * @returns a boolean
  17466. */
  17467. isValid(): boolean;
  17468. /**
  17469. * Internal only
  17470. * @hidden
  17471. */
  17472. _getProperty(propertyPath: string): string;
  17473. /**
  17474. * Internal only
  17475. * @hidden
  17476. */
  17477. _getEffectiveTarget(target: any, propertyPath: string): any;
  17478. /**
  17479. * Serialize placeholder for child classes
  17480. * @returns the serialized object
  17481. */
  17482. serialize(): any;
  17483. /**
  17484. * Internal only
  17485. * @hidden
  17486. */
  17487. protected _serialize(serializedCondition: any): any;
  17488. }
  17489. /**
  17490. * Defines specific conditional operators as extensions of Condition
  17491. */
  17492. export class ValueCondition extends Condition {
  17493. /** path to specify the property of the target the conditional operator uses */
  17494. propertyPath: string;
  17495. /** the value compared by the conditional operator against the current value of the property */
  17496. value: any;
  17497. /** the conditional operator, default ValueCondition.IsEqual */
  17498. operator: number;
  17499. /**
  17500. * Internal only
  17501. * @hidden
  17502. */
  17503. private static _IsEqual;
  17504. /**
  17505. * Internal only
  17506. * @hidden
  17507. */
  17508. private static _IsDifferent;
  17509. /**
  17510. * Internal only
  17511. * @hidden
  17512. */
  17513. private static _IsGreater;
  17514. /**
  17515. * Internal only
  17516. * @hidden
  17517. */
  17518. private static _IsLesser;
  17519. /**
  17520. * returns the number for IsEqual
  17521. */
  17522. static get IsEqual(): number;
  17523. /**
  17524. * Returns the number for IsDifferent
  17525. */
  17526. static get IsDifferent(): number;
  17527. /**
  17528. * Returns the number for IsGreater
  17529. */
  17530. static get IsGreater(): number;
  17531. /**
  17532. * Returns the number for IsLesser
  17533. */
  17534. static get IsLesser(): number;
  17535. /**
  17536. * Internal only The action manager for the condition
  17537. * @hidden
  17538. */
  17539. _actionManager: ActionManager;
  17540. /**
  17541. * Internal only
  17542. * @hidden
  17543. */
  17544. private _target;
  17545. /**
  17546. * Internal only
  17547. * @hidden
  17548. */
  17549. private _effectiveTarget;
  17550. /**
  17551. * Internal only
  17552. * @hidden
  17553. */
  17554. private _property;
  17555. /**
  17556. * Creates a new ValueCondition
  17557. * @param actionManager manager for the action the condition applies to
  17558. * @param target for the action
  17559. * @param propertyPath path to specify the property of the target the conditional operator uses
  17560. * @param value the value compared by the conditional operator against the current value of the property
  17561. * @param operator the conditional operator, default ValueCondition.IsEqual
  17562. */
  17563. constructor(actionManager: ActionManager, target: any,
  17564. /** path to specify the property of the target the conditional operator uses */
  17565. propertyPath: string,
  17566. /** the value compared by the conditional operator against the current value of the property */
  17567. value: any,
  17568. /** the conditional operator, default ValueCondition.IsEqual */
  17569. operator?: number);
  17570. /**
  17571. * Compares the given value with the property value for the specified conditional operator
  17572. * @returns the result of the comparison
  17573. */
  17574. isValid(): boolean;
  17575. /**
  17576. * Serialize the ValueCondition into a JSON compatible object
  17577. * @returns serialization object
  17578. */
  17579. serialize(): any;
  17580. /**
  17581. * Gets the name of the conditional operator for the ValueCondition
  17582. * @param operator the conditional operator
  17583. * @returns the name
  17584. */
  17585. static GetOperatorName(operator: number): string;
  17586. }
  17587. /**
  17588. * Defines a predicate condition as an extension of Condition
  17589. */
  17590. export class PredicateCondition extends Condition {
  17591. /** defines the predicate function used to validate the condition */
  17592. predicate: () => boolean;
  17593. /**
  17594. * Internal only - manager for action
  17595. * @hidden
  17596. */
  17597. _actionManager: ActionManager;
  17598. /**
  17599. * Creates a new PredicateCondition
  17600. * @param actionManager manager for the action the condition applies to
  17601. * @param predicate defines the predicate function used to validate the condition
  17602. */
  17603. constructor(actionManager: ActionManager,
  17604. /** defines the predicate function used to validate the condition */
  17605. predicate: () => boolean);
  17606. /**
  17607. * @returns the validity of the predicate condition
  17608. */
  17609. isValid(): boolean;
  17610. }
  17611. /**
  17612. * Defines a state condition as an extension of Condition
  17613. */
  17614. export class StateCondition extends Condition {
  17615. /** Value to compare with target state */
  17616. value: string;
  17617. /**
  17618. * Internal only - manager for action
  17619. * @hidden
  17620. */
  17621. _actionManager: ActionManager;
  17622. /**
  17623. * Internal only
  17624. * @hidden
  17625. */
  17626. private _target;
  17627. /**
  17628. * Creates a new StateCondition
  17629. * @param actionManager manager for the action the condition applies to
  17630. * @param target of the condition
  17631. * @param value to compare with target state
  17632. */
  17633. constructor(actionManager: ActionManager, target: any,
  17634. /** Value to compare with target state */
  17635. value: string);
  17636. /**
  17637. * Gets a boolean indicating if the current condition is met
  17638. * @returns the validity of the state
  17639. */
  17640. isValid(): boolean;
  17641. /**
  17642. * Serialize the StateCondition into a JSON compatible object
  17643. * @returns serialization object
  17644. */
  17645. serialize(): any;
  17646. }
  17647. }
  17648. declare module BABYLON {
  17649. /**
  17650. * This defines an action responsible to toggle a boolean once triggered.
  17651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17652. */
  17653. export class SwitchBooleanAction extends Action {
  17654. /**
  17655. * The path to the boolean property in the target object
  17656. */
  17657. propertyPath: string;
  17658. private _target;
  17659. private _effectiveTarget;
  17660. private _property;
  17661. /**
  17662. * Instantiate the action
  17663. * @param triggerOptions defines the trigger options
  17664. * @param target defines the object containing the boolean
  17665. * @param propertyPath defines the path to the boolean property in the target object
  17666. * @param condition defines the trigger related conditions
  17667. */
  17668. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17669. /** @hidden */
  17670. _prepare(): void;
  17671. /**
  17672. * Execute the action toggle the boolean value.
  17673. */
  17674. execute(): void;
  17675. /**
  17676. * Serializes the actions and its related information.
  17677. * @param parent defines the object to serialize in
  17678. * @returns the serialized object
  17679. */
  17680. serialize(parent: any): any;
  17681. }
  17682. /**
  17683. * This defines an action responsible to set a the state field of the target
  17684. * to a desired value once triggered.
  17685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17686. */
  17687. export class SetStateAction extends Action {
  17688. /**
  17689. * The value to store in the state field.
  17690. */
  17691. value: string;
  17692. private _target;
  17693. /**
  17694. * Instantiate the action
  17695. * @param triggerOptions defines the trigger options
  17696. * @param target defines the object containing the state property
  17697. * @param value defines the value to store in the state field
  17698. * @param condition defines the trigger related conditions
  17699. */
  17700. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17701. /**
  17702. * Execute the action and store the value on the target state property.
  17703. */
  17704. execute(): void;
  17705. /**
  17706. * Serializes the actions and its related information.
  17707. * @param parent defines the object to serialize in
  17708. * @returns the serialized object
  17709. */
  17710. serialize(parent: any): any;
  17711. }
  17712. /**
  17713. * This defines an action responsible to set a property of the target
  17714. * to a desired value once triggered.
  17715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17716. */
  17717. export class SetValueAction extends Action {
  17718. /**
  17719. * The path of the property to set in the target.
  17720. */
  17721. propertyPath: string;
  17722. /**
  17723. * The value to set in the property
  17724. */
  17725. value: any;
  17726. private _target;
  17727. private _effectiveTarget;
  17728. private _property;
  17729. /**
  17730. * Instantiate the action
  17731. * @param triggerOptions defines the trigger options
  17732. * @param target defines the object containing the property
  17733. * @param propertyPath defines the path of the property to set in the target
  17734. * @param value defines the value to set in the property
  17735. * @param condition defines the trigger related conditions
  17736. */
  17737. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17738. /** @hidden */
  17739. _prepare(): void;
  17740. /**
  17741. * Execute the action and set the targetted property to the desired value.
  17742. */
  17743. execute(): void;
  17744. /**
  17745. * Serializes the actions and its related information.
  17746. * @param parent defines the object to serialize in
  17747. * @returns the serialized object
  17748. */
  17749. serialize(parent: any): any;
  17750. }
  17751. /**
  17752. * This defines an action responsible to increment the target value
  17753. * to a desired value once triggered.
  17754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17755. */
  17756. export class IncrementValueAction extends Action {
  17757. /**
  17758. * The path of the property to increment in the target.
  17759. */
  17760. propertyPath: string;
  17761. /**
  17762. * The value we should increment the property by.
  17763. */
  17764. value: any;
  17765. private _target;
  17766. private _effectiveTarget;
  17767. private _property;
  17768. /**
  17769. * Instantiate the action
  17770. * @param triggerOptions defines the trigger options
  17771. * @param target defines the object containing the property
  17772. * @param propertyPath defines the path of the property to increment in the target
  17773. * @param value defines the value value we should increment the property by
  17774. * @param condition defines the trigger related conditions
  17775. */
  17776. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17777. /** @hidden */
  17778. _prepare(): void;
  17779. /**
  17780. * Execute the action and increment the target of the value amount.
  17781. */
  17782. execute(): void;
  17783. /**
  17784. * Serializes the actions and its related information.
  17785. * @param parent defines the object to serialize in
  17786. * @returns the serialized object
  17787. */
  17788. serialize(parent: any): any;
  17789. }
  17790. /**
  17791. * This defines an action responsible to start an animation once triggered.
  17792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17793. */
  17794. export class PlayAnimationAction extends Action {
  17795. /**
  17796. * Where the animation should start (animation frame)
  17797. */
  17798. from: number;
  17799. /**
  17800. * Where the animation should stop (animation frame)
  17801. */
  17802. to: number;
  17803. /**
  17804. * Define if the animation should loop or stop after the first play.
  17805. */
  17806. loop?: boolean;
  17807. private _target;
  17808. /**
  17809. * Instantiate the action
  17810. * @param triggerOptions defines the trigger options
  17811. * @param target defines the target animation or animation name
  17812. * @param from defines from where the animation should start (animation frame)
  17813. * @param end defines where the animation should stop (animation frame)
  17814. * @param loop defines if the animation should loop or stop after the first play
  17815. * @param condition defines the trigger related conditions
  17816. */
  17817. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17818. /** @hidden */
  17819. _prepare(): void;
  17820. /**
  17821. * Execute the action and play 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 to stop an animation once triggered.
  17833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17834. */
  17835. export class StopAnimationAction extends Action {
  17836. private _target;
  17837. /**
  17838. * Instantiate the action
  17839. * @param triggerOptions defines the trigger options
  17840. * @param target defines the target animation or animation name
  17841. * @param condition defines the trigger related conditions
  17842. */
  17843. constructor(triggerOptions: any, target: any, condition?: Condition);
  17844. /** @hidden */
  17845. _prepare(): void;
  17846. /**
  17847. * Execute the action and stop the animation.
  17848. */
  17849. execute(): void;
  17850. /**
  17851. * Serializes the actions and its related information.
  17852. * @param parent defines the object to serialize in
  17853. * @returns the serialized object
  17854. */
  17855. serialize(parent: any): any;
  17856. }
  17857. /**
  17858. * This defines an action responsible that does nothing once triggered.
  17859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17860. */
  17861. export class DoNothingAction extends Action {
  17862. /**
  17863. * Instantiate the action
  17864. * @param triggerOptions defines the trigger options
  17865. * @param condition defines the trigger related conditions
  17866. */
  17867. constructor(triggerOptions?: any, condition?: Condition);
  17868. /**
  17869. * Execute the action and do nothing.
  17870. */
  17871. execute(): void;
  17872. /**
  17873. * Serializes the actions and its related information.
  17874. * @param parent defines the object to serialize in
  17875. * @returns the serialized object
  17876. */
  17877. serialize(parent: any): any;
  17878. }
  17879. /**
  17880. * This defines an action responsible to trigger several actions once triggered.
  17881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17882. */
  17883. export class CombineAction extends Action {
  17884. /**
  17885. * The list of aggregated animations to run.
  17886. */
  17887. children: Action[];
  17888. /**
  17889. * Instantiate the action
  17890. * @param triggerOptions defines the trigger options
  17891. * @param children defines the list of aggregated animations to run
  17892. * @param condition defines the trigger related conditions
  17893. */
  17894. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17895. /** @hidden */
  17896. _prepare(): void;
  17897. /**
  17898. * Execute the action and executes all the aggregated actions.
  17899. */
  17900. execute(evt: ActionEvent): void;
  17901. /**
  17902. * Serializes the actions and its related information.
  17903. * @param parent defines the object to serialize in
  17904. * @returns the serialized object
  17905. */
  17906. serialize(parent: any): any;
  17907. }
  17908. /**
  17909. * This defines an action responsible to run code (external event) once triggered.
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17911. */
  17912. export class ExecuteCodeAction extends Action {
  17913. /**
  17914. * The callback function to run.
  17915. */
  17916. func: (evt: ActionEvent) => void;
  17917. /**
  17918. * Instantiate the action
  17919. * @param triggerOptions defines the trigger options
  17920. * @param func defines the callback function to run
  17921. * @param condition defines the trigger related conditions
  17922. */
  17923. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17924. /**
  17925. * Execute the action and run the attached code.
  17926. */
  17927. execute(evt: ActionEvent): void;
  17928. }
  17929. /**
  17930. * This defines an action responsible to set the parent property of the target once triggered.
  17931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17932. */
  17933. export class SetParentAction extends Action {
  17934. private _parent;
  17935. private _target;
  17936. /**
  17937. * Instantiate the action
  17938. * @param triggerOptions defines the trigger options
  17939. * @param target defines the target containing the parent property
  17940. * @param parent defines from where the animation should start (animation frame)
  17941. * @param condition defines the trigger related conditions
  17942. */
  17943. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17944. /** @hidden */
  17945. _prepare(): void;
  17946. /**
  17947. * Execute the action and set the parent property.
  17948. */
  17949. execute(): void;
  17950. /**
  17951. * Serializes the actions and its related information.
  17952. * @param parent defines the object to serialize in
  17953. * @returns the serialized object
  17954. */
  17955. serialize(parent: any): any;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /**
  17960. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17961. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17963. */
  17964. export class ActionManager extends AbstractActionManager {
  17965. /**
  17966. * Nothing
  17967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17968. */
  17969. static readonly NothingTrigger: number;
  17970. /**
  17971. * On pick
  17972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17973. */
  17974. static readonly OnPickTrigger: number;
  17975. /**
  17976. * On left pick
  17977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17978. */
  17979. static readonly OnLeftPickTrigger: number;
  17980. /**
  17981. * On right pick
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17983. */
  17984. static readonly OnRightPickTrigger: number;
  17985. /**
  17986. * On center pick
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17988. */
  17989. static readonly OnCenterPickTrigger: number;
  17990. /**
  17991. * On pick down
  17992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17993. */
  17994. static readonly OnPickDownTrigger: number;
  17995. /**
  17996. * On double pick
  17997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17998. */
  17999. static readonly OnDoublePickTrigger: number;
  18000. /**
  18001. * On pick up
  18002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18003. */
  18004. static readonly OnPickUpTrigger: number;
  18005. /**
  18006. * On pick out.
  18007. * This trigger will only be raised if you also declared a OnPickDown
  18008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18009. */
  18010. static readonly OnPickOutTrigger: number;
  18011. /**
  18012. * On long press
  18013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18014. */
  18015. static readonly OnLongPressTrigger: number;
  18016. /**
  18017. * On pointer over
  18018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18019. */
  18020. static readonly OnPointerOverTrigger: number;
  18021. /**
  18022. * On pointer out
  18023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18024. */
  18025. static readonly OnPointerOutTrigger: number;
  18026. /**
  18027. * On every frame
  18028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18029. */
  18030. static readonly OnEveryFrameTrigger: number;
  18031. /**
  18032. * On intersection enter
  18033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18034. */
  18035. static readonly OnIntersectionEnterTrigger: number;
  18036. /**
  18037. * On intersection exit
  18038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18039. */
  18040. static readonly OnIntersectionExitTrigger: number;
  18041. /**
  18042. * On key down
  18043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18044. */
  18045. static readonly OnKeyDownTrigger: number;
  18046. /**
  18047. * On key up
  18048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18049. */
  18050. static readonly OnKeyUpTrigger: number;
  18051. private _scene;
  18052. /**
  18053. * Creates a new action manager
  18054. * @param scene defines the hosting scene
  18055. */
  18056. constructor(scene: Scene);
  18057. /**
  18058. * Releases all associated resources
  18059. */
  18060. dispose(): void;
  18061. /**
  18062. * Gets hosting scene
  18063. * @returns the hosting scene
  18064. */
  18065. getScene(): Scene;
  18066. /**
  18067. * Does this action manager handles actions of any of the given triggers
  18068. * @param triggers defines the triggers to be tested
  18069. * @return a boolean indicating whether one (or more) of the triggers is handled
  18070. */
  18071. hasSpecificTriggers(triggers: number[]): boolean;
  18072. /**
  18073. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18074. * speed.
  18075. * @param triggerA defines the trigger to be tested
  18076. * @param triggerB defines the trigger to be tested
  18077. * @return a boolean indicating whether one (or more) of the triggers is handled
  18078. */
  18079. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18080. /**
  18081. * Does this action manager handles actions of a given trigger
  18082. * @param trigger defines the trigger to be tested
  18083. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18084. * @return whether the trigger is handled
  18085. */
  18086. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18087. /**
  18088. * Does this action manager has pointer triggers
  18089. */
  18090. get hasPointerTriggers(): boolean;
  18091. /**
  18092. * Does this action manager has pick triggers
  18093. */
  18094. get hasPickTriggers(): boolean;
  18095. /**
  18096. * Registers an action to this action manager
  18097. * @param action defines the action to be registered
  18098. * @return the action amended (prepared) after registration
  18099. */
  18100. registerAction(action: IAction): Nullable<IAction>;
  18101. /**
  18102. * Unregisters an action to this action manager
  18103. * @param action defines the action to be unregistered
  18104. * @return a boolean indicating whether the action has been unregistered
  18105. */
  18106. unregisterAction(action: IAction): Boolean;
  18107. /**
  18108. * Process a specific trigger
  18109. * @param trigger defines the trigger to process
  18110. * @param evt defines the event details to be processed
  18111. */
  18112. processTrigger(trigger: number, evt?: IActionEvent): void;
  18113. /** @hidden */
  18114. _getEffectiveTarget(target: any, propertyPath: string): any;
  18115. /** @hidden */
  18116. _getProperty(propertyPath: string): string;
  18117. /**
  18118. * Serialize this manager to a JSON object
  18119. * @param name defines the property name to store this manager
  18120. * @returns a JSON representation of this manager
  18121. */
  18122. serialize(name: string): any;
  18123. /**
  18124. * Creates a new ActionManager from a JSON data
  18125. * @param parsedActions defines the JSON data to read from
  18126. * @param object defines the hosting mesh
  18127. * @param scene defines the hosting scene
  18128. */
  18129. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18130. /**
  18131. * Get a trigger name by index
  18132. * @param trigger defines the trigger index
  18133. * @returns a trigger name
  18134. */
  18135. static GetTriggerName(trigger: number): string;
  18136. }
  18137. }
  18138. declare module BABYLON {
  18139. /**
  18140. * Class used to represent a sprite
  18141. * @see http://doc.babylonjs.com/babylon101/sprites
  18142. */
  18143. export class Sprite {
  18144. /** defines the name */
  18145. name: string;
  18146. /** Gets or sets the current world position */
  18147. position: Vector3;
  18148. /** Gets or sets the main color */
  18149. color: Color4;
  18150. /** Gets or sets the width */
  18151. width: number;
  18152. /** Gets or sets the height */
  18153. height: number;
  18154. /** Gets or sets rotation angle */
  18155. angle: number;
  18156. /** Gets or sets the cell index in the sprite sheet */
  18157. cellIndex: number;
  18158. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18159. cellRef: string;
  18160. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18161. invertU: number;
  18162. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18163. invertV: number;
  18164. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18165. disposeWhenFinishedAnimating: boolean;
  18166. /** Gets the list of attached animations */
  18167. animations: Animation[];
  18168. /** Gets or sets a boolean indicating if the sprite can be picked */
  18169. isPickable: boolean;
  18170. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18171. useAlphaForPicking: boolean;
  18172. /** @hidden */
  18173. _xOffset: number;
  18174. /** @hidden */
  18175. _yOffset: number;
  18176. /** @hidden */
  18177. _xSize: number;
  18178. /** @hidden */
  18179. _ySize: number;
  18180. /**
  18181. * Gets or sets the associated action manager
  18182. */
  18183. actionManager: Nullable<ActionManager>;
  18184. /**
  18185. * An event triggered when the control has been disposed
  18186. */
  18187. onDisposeObservable: Observable<Sprite>;
  18188. private _animationStarted;
  18189. private _loopAnimation;
  18190. private _fromIndex;
  18191. private _toIndex;
  18192. private _delay;
  18193. private _direction;
  18194. private _manager;
  18195. private _time;
  18196. private _onAnimationEnd;
  18197. /**
  18198. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18199. */
  18200. isVisible: boolean;
  18201. /**
  18202. * Gets or sets the sprite size
  18203. */
  18204. get size(): number;
  18205. set size(value: number);
  18206. /**
  18207. * Creates a new Sprite
  18208. * @param name defines the name
  18209. * @param manager defines the manager
  18210. */
  18211. constructor(
  18212. /** defines the name */
  18213. name: string, manager: ISpriteManager);
  18214. /**
  18215. * Starts an animation
  18216. * @param from defines the initial key
  18217. * @param to defines the end key
  18218. * @param loop defines if the animation must loop
  18219. * @param delay defines the start delay (in ms)
  18220. * @param onAnimationEnd defines a callback to call when animation ends
  18221. */
  18222. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18223. /** Stops current animation (if any) */
  18224. stopAnimation(): void;
  18225. /** @hidden */
  18226. _animate(deltaTime: number): void;
  18227. /** Release associated resources */
  18228. dispose(): void;
  18229. }
  18230. }
  18231. declare module BABYLON {
  18232. /**
  18233. * Information about the result of picking within a scene
  18234. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18235. */
  18236. export class PickingInfo {
  18237. /** @hidden */
  18238. _pickingUnavailable: boolean;
  18239. /**
  18240. * If the pick collided with an object
  18241. */
  18242. hit: boolean;
  18243. /**
  18244. * Distance away where the pick collided
  18245. */
  18246. distance: number;
  18247. /**
  18248. * The location of pick collision
  18249. */
  18250. pickedPoint: Nullable<Vector3>;
  18251. /**
  18252. * The mesh corresponding the the pick collision
  18253. */
  18254. pickedMesh: Nullable<AbstractMesh>;
  18255. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18256. bu: number;
  18257. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18258. bv: number;
  18259. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18260. faceId: number;
  18261. /** Id of the the submesh that was picked */
  18262. subMeshId: number;
  18263. /** If a sprite was picked, this will be the sprite the pick collided with */
  18264. pickedSprite: Nullable<Sprite>;
  18265. /**
  18266. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18267. */
  18268. originMesh: Nullable<AbstractMesh>;
  18269. /**
  18270. * The ray that was used to perform the picking.
  18271. */
  18272. ray: Nullable<Ray>;
  18273. /**
  18274. * Gets the normal correspodning to the face the pick collided with
  18275. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18276. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18277. * @returns The normal correspodning to the face the pick collided with
  18278. */
  18279. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18280. /**
  18281. * Gets the texture coordinates of where the pick occured
  18282. * @returns the vector containing the coordnates of the texture
  18283. */
  18284. getTextureCoordinates(): Nullable<Vector2>;
  18285. }
  18286. }
  18287. declare module BABYLON {
  18288. /**
  18289. * Gather the list of pointer event types as constants.
  18290. */
  18291. export class PointerEventTypes {
  18292. /**
  18293. * 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.
  18294. */
  18295. static readonly POINTERDOWN: number;
  18296. /**
  18297. * The pointerup event is fired when a pointer is no longer active.
  18298. */
  18299. static readonly POINTERUP: number;
  18300. /**
  18301. * The pointermove event is fired when a pointer changes coordinates.
  18302. */
  18303. static readonly POINTERMOVE: number;
  18304. /**
  18305. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18306. */
  18307. static readonly POINTERWHEEL: number;
  18308. /**
  18309. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18310. */
  18311. static readonly POINTERPICK: number;
  18312. /**
  18313. * The pointertap event is fired when a the object has been touched and released without drag.
  18314. */
  18315. static readonly POINTERTAP: number;
  18316. /**
  18317. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18318. */
  18319. static readonly POINTERDOUBLETAP: number;
  18320. }
  18321. /**
  18322. * Base class of pointer info types.
  18323. */
  18324. export class PointerInfoBase {
  18325. /**
  18326. * Defines the type of event (PointerEventTypes)
  18327. */
  18328. type: number;
  18329. /**
  18330. * Defines the related dom event
  18331. */
  18332. event: PointerEvent | MouseWheelEvent;
  18333. /**
  18334. * Instantiates the base class of pointers info.
  18335. * @param type Defines the type of event (PointerEventTypes)
  18336. * @param event Defines the related dom event
  18337. */
  18338. constructor(
  18339. /**
  18340. * Defines the type of event (PointerEventTypes)
  18341. */
  18342. type: number,
  18343. /**
  18344. * Defines the related dom event
  18345. */
  18346. event: PointerEvent | MouseWheelEvent);
  18347. }
  18348. /**
  18349. * This class is used to store pointer related info for the onPrePointerObservable event.
  18350. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18351. */
  18352. export class PointerInfoPre extends PointerInfoBase {
  18353. /**
  18354. * Ray from a pointer if availible (eg. 6dof controller)
  18355. */
  18356. ray: Nullable<Ray>;
  18357. /**
  18358. * Defines the local position of the pointer on the canvas.
  18359. */
  18360. localPosition: Vector2;
  18361. /**
  18362. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18363. */
  18364. skipOnPointerObservable: boolean;
  18365. /**
  18366. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18367. * @param type Defines the type of event (PointerEventTypes)
  18368. * @param event Defines the related dom event
  18369. * @param localX Defines the local x coordinates of the pointer when the event occured
  18370. * @param localY Defines the local y coordinates of the pointer when the event occured
  18371. */
  18372. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18373. }
  18374. /**
  18375. * This type contains all the data related to a pointer event in Babylon.js.
  18376. * 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.
  18377. */
  18378. export class PointerInfo extends PointerInfoBase {
  18379. /**
  18380. * Defines the picking info associated to the info (if any)\
  18381. */
  18382. pickInfo: Nullable<PickingInfo>;
  18383. /**
  18384. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18385. * @param type Defines the type of event (PointerEventTypes)
  18386. * @param event Defines the related dom event
  18387. * @param pickInfo Defines the picking info associated to the info (if any)\
  18388. */
  18389. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18390. /**
  18391. * Defines the picking info associated to the info (if any)\
  18392. */
  18393. pickInfo: Nullable<PickingInfo>);
  18394. }
  18395. /**
  18396. * Data relating to a touch event on the screen.
  18397. */
  18398. export interface PointerTouch {
  18399. /**
  18400. * X coordinate of touch.
  18401. */
  18402. x: number;
  18403. /**
  18404. * Y coordinate of touch.
  18405. */
  18406. y: number;
  18407. /**
  18408. * Id of touch. Unique for each finger.
  18409. */
  18410. pointerId: number;
  18411. /**
  18412. * Event type passed from DOM.
  18413. */
  18414. type: any;
  18415. }
  18416. }
  18417. declare module BABYLON {
  18418. /**
  18419. * Manage the mouse inputs to control the movement of a free camera.
  18420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18421. */
  18422. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18423. /**
  18424. * Define if touch is enabled in the mouse input
  18425. */
  18426. touchEnabled: boolean;
  18427. /**
  18428. * Defines the camera the input is attached to.
  18429. */
  18430. camera: FreeCamera;
  18431. /**
  18432. * Defines the buttons associated with the input to handle camera move.
  18433. */
  18434. buttons: number[];
  18435. /**
  18436. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18437. */
  18438. angularSensibility: number;
  18439. private _pointerInput;
  18440. private _onMouseMove;
  18441. private _observer;
  18442. private previousPosition;
  18443. /**
  18444. * Observable for when a pointer move event occurs containing the move offset
  18445. */
  18446. onPointerMovedObservable: Observable<{
  18447. offsetX: number;
  18448. offsetY: number;
  18449. }>;
  18450. /**
  18451. * @hidden
  18452. * If the camera should be rotated automatically based on pointer movement
  18453. */
  18454. _allowCameraRotation: boolean;
  18455. /**
  18456. * Manage the mouse inputs to control the movement of a free camera.
  18457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18458. * @param touchEnabled Defines if touch is enabled or not
  18459. */
  18460. constructor(
  18461. /**
  18462. * Define if touch is enabled in the mouse input
  18463. */
  18464. touchEnabled?: boolean);
  18465. /**
  18466. * Attach the input controls to a specific dom element to get the input from.
  18467. * @param element Defines the element the controls should be listened from
  18468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18469. */
  18470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18471. /**
  18472. * Called on JS contextmenu event.
  18473. * Override this method to provide functionality.
  18474. */
  18475. protected onContextMenu(evt: PointerEvent): void;
  18476. /**
  18477. * Detach the current controls from the specified dom element.
  18478. * @param element Defines the element to stop listening the inputs from
  18479. */
  18480. detachControl(element: Nullable<HTMLElement>): void;
  18481. /**
  18482. * Gets the class name of the current intput.
  18483. * @returns the class name
  18484. */
  18485. getClassName(): string;
  18486. /**
  18487. * Get the friendly name associated with the input class.
  18488. * @returns the input friendly name
  18489. */
  18490. getSimpleName(): string;
  18491. }
  18492. }
  18493. declare module BABYLON {
  18494. /**
  18495. * Manage the touch inputs to control the movement of a free camera.
  18496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18497. */
  18498. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18499. /**
  18500. * Defines the camera the input is attached to.
  18501. */
  18502. camera: FreeCamera;
  18503. /**
  18504. * Defines the touch sensibility for rotation.
  18505. * The higher the faster.
  18506. */
  18507. touchAngularSensibility: number;
  18508. /**
  18509. * Defines the touch sensibility for move.
  18510. * The higher the faster.
  18511. */
  18512. touchMoveSensibility: number;
  18513. private _offsetX;
  18514. private _offsetY;
  18515. private _pointerPressed;
  18516. private _pointerInput;
  18517. private _observer;
  18518. private _onLostFocus;
  18519. /**
  18520. * Attach the input controls to a specific dom element to get the input from.
  18521. * @param element Defines the element the controls should be listened from
  18522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18523. */
  18524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18525. /**
  18526. * Detach the current controls from the specified dom element.
  18527. * @param element Defines the element to stop listening the inputs from
  18528. */
  18529. detachControl(element: Nullable<HTMLElement>): void;
  18530. /**
  18531. * Update the current camera state depending on the inputs that have been used this frame.
  18532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18533. */
  18534. checkInputs(): void;
  18535. /**
  18536. * Gets the class name of the current intput.
  18537. * @returns the class name
  18538. */
  18539. getClassName(): string;
  18540. /**
  18541. * Get the friendly name associated with the input class.
  18542. * @returns the input friendly name
  18543. */
  18544. getSimpleName(): string;
  18545. }
  18546. }
  18547. declare module BABYLON {
  18548. /**
  18549. * Default Inputs manager for the FreeCamera.
  18550. * It groups all the default supported inputs for ease of use.
  18551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18552. */
  18553. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18554. /**
  18555. * @hidden
  18556. */
  18557. _mouseInput: Nullable<FreeCameraMouseInput>;
  18558. /**
  18559. * Instantiates a new FreeCameraInputsManager.
  18560. * @param camera Defines the camera the inputs belong to
  18561. */
  18562. constructor(camera: FreeCamera);
  18563. /**
  18564. * Add keyboard input support to the input manager.
  18565. * @returns the current input manager
  18566. */
  18567. addKeyboard(): FreeCameraInputsManager;
  18568. /**
  18569. * Add mouse input support to the input manager.
  18570. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18571. * @returns the current input manager
  18572. */
  18573. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18574. /**
  18575. * Removes the mouse input support from the manager
  18576. * @returns the current input manager
  18577. */
  18578. removeMouse(): FreeCameraInputsManager;
  18579. /**
  18580. * Add touch input support to the input manager.
  18581. * @returns the current input manager
  18582. */
  18583. addTouch(): FreeCameraInputsManager;
  18584. /**
  18585. * Remove all attached input methods from a camera
  18586. */
  18587. clear(): void;
  18588. }
  18589. }
  18590. declare module BABYLON {
  18591. /**
  18592. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18593. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18594. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18595. */
  18596. export class FreeCamera extends TargetCamera {
  18597. /**
  18598. * Define the collision ellipsoid of the camera.
  18599. * This is helpful to simulate a camera body like the player body around the camera
  18600. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18601. */
  18602. ellipsoid: Vector3;
  18603. /**
  18604. * Define an offset for the position of the ellipsoid around the camera.
  18605. * This can be helpful to determine the center of the body near the gravity center of the body
  18606. * instead of its head.
  18607. */
  18608. ellipsoidOffset: Vector3;
  18609. /**
  18610. * Enable or disable collisions of the camera with the rest of the scene objects.
  18611. */
  18612. checkCollisions: boolean;
  18613. /**
  18614. * Enable or disable gravity on the camera.
  18615. */
  18616. applyGravity: boolean;
  18617. /**
  18618. * Define the input manager associated to the camera.
  18619. */
  18620. inputs: FreeCameraInputsManager;
  18621. /**
  18622. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18623. * Higher values reduce sensitivity.
  18624. */
  18625. get angularSensibility(): number;
  18626. /**
  18627. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18628. * Higher values reduce sensitivity.
  18629. */
  18630. set angularSensibility(value: number);
  18631. /**
  18632. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18633. */
  18634. get keysUp(): number[];
  18635. set keysUp(value: number[]);
  18636. /**
  18637. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18638. */
  18639. get keysUpward(): number[];
  18640. set keysUpward(value: number[]);
  18641. /**
  18642. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18643. */
  18644. get keysDown(): number[];
  18645. set keysDown(value: number[]);
  18646. /**
  18647. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18648. */
  18649. get keysDownward(): number[];
  18650. set keysDownward(value: number[]);
  18651. /**
  18652. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18653. */
  18654. get keysLeft(): number[];
  18655. set keysLeft(value: number[]);
  18656. /**
  18657. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18658. */
  18659. get keysRight(): number[];
  18660. set keysRight(value: number[]);
  18661. /**
  18662. * Event raised when the camera collide with a mesh in the scene.
  18663. */
  18664. onCollide: (collidedMesh: AbstractMesh) => void;
  18665. private _collider;
  18666. private _needMoveForGravity;
  18667. private _oldPosition;
  18668. private _diffPosition;
  18669. private _newPosition;
  18670. /** @hidden */
  18671. _localDirection: Vector3;
  18672. /** @hidden */
  18673. _transformedDirection: Vector3;
  18674. /**
  18675. * Instantiates a Free Camera.
  18676. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18677. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18678. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18679. * @param name Define the name of the camera in the scene
  18680. * @param position Define the start position of the camera in the scene
  18681. * @param scene Define the scene the camera belongs to
  18682. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18683. */
  18684. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18685. /**
  18686. * Attached controls to the current camera.
  18687. * @param element Defines the element the controls should be listened from
  18688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18689. */
  18690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18691. /**
  18692. * Detach the current controls from the camera.
  18693. * The camera will stop reacting to inputs.
  18694. * @param element Defines the element to stop listening the inputs from
  18695. */
  18696. detachControl(element: HTMLElement): void;
  18697. private _collisionMask;
  18698. /**
  18699. * Define a collision mask to limit the list of object the camera can collide with
  18700. */
  18701. get collisionMask(): number;
  18702. set collisionMask(mask: number);
  18703. /** @hidden */
  18704. _collideWithWorld(displacement: Vector3): void;
  18705. private _onCollisionPositionChange;
  18706. /** @hidden */
  18707. _checkInputs(): void;
  18708. /** @hidden */
  18709. _decideIfNeedsToMove(): boolean;
  18710. /** @hidden */
  18711. _updatePosition(): void;
  18712. /**
  18713. * Destroy the camera and release the current resources hold by it.
  18714. */
  18715. dispose(): void;
  18716. /**
  18717. * Gets the current object class name.
  18718. * @return the class name
  18719. */
  18720. getClassName(): string;
  18721. }
  18722. }
  18723. declare module BABYLON {
  18724. /**
  18725. * Represents a gamepad control stick position
  18726. */
  18727. export class StickValues {
  18728. /**
  18729. * The x component of the control stick
  18730. */
  18731. x: number;
  18732. /**
  18733. * The y component of the control stick
  18734. */
  18735. y: number;
  18736. /**
  18737. * Initializes the gamepad x and y control stick values
  18738. * @param x The x component of the gamepad control stick value
  18739. * @param y The y component of the gamepad control stick value
  18740. */
  18741. constructor(
  18742. /**
  18743. * The x component of the control stick
  18744. */
  18745. x: number,
  18746. /**
  18747. * The y component of the control stick
  18748. */
  18749. y: number);
  18750. }
  18751. /**
  18752. * An interface which manages callbacks for gamepad button changes
  18753. */
  18754. export interface GamepadButtonChanges {
  18755. /**
  18756. * Called when a gamepad has been changed
  18757. */
  18758. changed: boolean;
  18759. /**
  18760. * Called when a gamepad press event has been triggered
  18761. */
  18762. pressChanged: boolean;
  18763. /**
  18764. * Called when a touch event has been triggered
  18765. */
  18766. touchChanged: boolean;
  18767. /**
  18768. * Called when a value has changed
  18769. */
  18770. valueChanged: boolean;
  18771. }
  18772. /**
  18773. * Represents a gamepad
  18774. */
  18775. export class Gamepad {
  18776. /**
  18777. * The id of the gamepad
  18778. */
  18779. id: string;
  18780. /**
  18781. * The index of the gamepad
  18782. */
  18783. index: number;
  18784. /**
  18785. * The browser gamepad
  18786. */
  18787. browserGamepad: any;
  18788. /**
  18789. * Specifies what type of gamepad this represents
  18790. */
  18791. type: number;
  18792. private _leftStick;
  18793. private _rightStick;
  18794. /** @hidden */
  18795. _isConnected: boolean;
  18796. private _leftStickAxisX;
  18797. private _leftStickAxisY;
  18798. private _rightStickAxisX;
  18799. private _rightStickAxisY;
  18800. /**
  18801. * Triggered when the left control stick has been changed
  18802. */
  18803. private _onleftstickchanged;
  18804. /**
  18805. * Triggered when the right control stick has been changed
  18806. */
  18807. private _onrightstickchanged;
  18808. /**
  18809. * Represents a gamepad controller
  18810. */
  18811. static GAMEPAD: number;
  18812. /**
  18813. * Represents a generic controller
  18814. */
  18815. static GENERIC: number;
  18816. /**
  18817. * Represents an XBox controller
  18818. */
  18819. static XBOX: number;
  18820. /**
  18821. * Represents a pose-enabled controller
  18822. */
  18823. static POSE_ENABLED: number;
  18824. /**
  18825. * Represents an Dual Shock controller
  18826. */
  18827. static DUALSHOCK: number;
  18828. /**
  18829. * Specifies whether the left control stick should be Y-inverted
  18830. */
  18831. protected _invertLeftStickY: boolean;
  18832. /**
  18833. * Specifies if the gamepad has been connected
  18834. */
  18835. get isConnected(): boolean;
  18836. /**
  18837. * Initializes the gamepad
  18838. * @param id The id of the gamepad
  18839. * @param index The index of the gamepad
  18840. * @param browserGamepad The browser gamepad
  18841. * @param leftStickX The x component of the left joystick
  18842. * @param leftStickY The y component of the left joystick
  18843. * @param rightStickX The x component of the right joystick
  18844. * @param rightStickY The y component of the right joystick
  18845. */
  18846. constructor(
  18847. /**
  18848. * The id of the gamepad
  18849. */
  18850. id: string,
  18851. /**
  18852. * The index of the gamepad
  18853. */
  18854. index: number,
  18855. /**
  18856. * The browser gamepad
  18857. */
  18858. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18859. /**
  18860. * Callback triggered when the left joystick has changed
  18861. * @param callback
  18862. */
  18863. onleftstickchanged(callback: (values: StickValues) => void): void;
  18864. /**
  18865. * Callback triggered when the right joystick has changed
  18866. * @param callback
  18867. */
  18868. onrightstickchanged(callback: (values: StickValues) => void): void;
  18869. /**
  18870. * Gets the left joystick
  18871. */
  18872. get leftStick(): StickValues;
  18873. /**
  18874. * Sets the left joystick values
  18875. */
  18876. set leftStick(newValues: StickValues);
  18877. /**
  18878. * Gets the right joystick
  18879. */
  18880. get rightStick(): StickValues;
  18881. /**
  18882. * Sets the right joystick value
  18883. */
  18884. set rightStick(newValues: StickValues);
  18885. /**
  18886. * Updates the gamepad joystick positions
  18887. */
  18888. update(): void;
  18889. /**
  18890. * Disposes the gamepad
  18891. */
  18892. dispose(): void;
  18893. }
  18894. /**
  18895. * Represents a generic gamepad
  18896. */
  18897. export class GenericPad extends Gamepad {
  18898. private _buttons;
  18899. private _onbuttondown;
  18900. private _onbuttonup;
  18901. /**
  18902. * Observable triggered when a button has been pressed
  18903. */
  18904. onButtonDownObservable: Observable<number>;
  18905. /**
  18906. * Observable triggered when a button has been released
  18907. */
  18908. onButtonUpObservable: Observable<number>;
  18909. /**
  18910. * Callback triggered when a button has been pressed
  18911. * @param callback Called when a button has been pressed
  18912. */
  18913. onbuttondown(callback: (buttonPressed: number) => void): void;
  18914. /**
  18915. * Callback triggered when a button has been released
  18916. * @param callback Called when a button has been released
  18917. */
  18918. onbuttonup(callback: (buttonReleased: number) => void): void;
  18919. /**
  18920. * Initializes the generic gamepad
  18921. * @param id The id of the generic gamepad
  18922. * @param index The index of the generic gamepad
  18923. * @param browserGamepad The browser gamepad
  18924. */
  18925. constructor(id: string, index: number, browserGamepad: any);
  18926. private _setButtonValue;
  18927. /**
  18928. * Updates the generic gamepad
  18929. */
  18930. update(): void;
  18931. /**
  18932. * Disposes the generic gamepad
  18933. */
  18934. dispose(): void;
  18935. }
  18936. }
  18937. declare module BABYLON {
  18938. /**
  18939. * Defines the types of pose enabled controllers that are supported
  18940. */
  18941. export enum PoseEnabledControllerType {
  18942. /**
  18943. * HTC Vive
  18944. */
  18945. VIVE = 0,
  18946. /**
  18947. * Oculus Rift
  18948. */
  18949. OCULUS = 1,
  18950. /**
  18951. * Windows mixed reality
  18952. */
  18953. WINDOWS = 2,
  18954. /**
  18955. * Samsung gear VR
  18956. */
  18957. GEAR_VR = 3,
  18958. /**
  18959. * Google Daydream
  18960. */
  18961. DAYDREAM = 4,
  18962. /**
  18963. * Generic
  18964. */
  18965. GENERIC = 5
  18966. }
  18967. /**
  18968. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18969. */
  18970. export interface MutableGamepadButton {
  18971. /**
  18972. * Value of the button/trigger
  18973. */
  18974. value: number;
  18975. /**
  18976. * If the button/trigger is currently touched
  18977. */
  18978. touched: boolean;
  18979. /**
  18980. * If the button/trigger is currently pressed
  18981. */
  18982. pressed: boolean;
  18983. }
  18984. /**
  18985. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18986. * @hidden
  18987. */
  18988. export interface ExtendedGamepadButton extends GamepadButton {
  18989. /**
  18990. * If the button/trigger is currently pressed
  18991. */
  18992. readonly pressed: boolean;
  18993. /**
  18994. * If the button/trigger is currently touched
  18995. */
  18996. readonly touched: boolean;
  18997. /**
  18998. * Value of the button/trigger
  18999. */
  19000. readonly value: number;
  19001. }
  19002. /** @hidden */
  19003. export interface _GamePadFactory {
  19004. /**
  19005. * Returns whether or not the current gamepad can be created for this type of controller.
  19006. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19007. * @returns true if it can be created, otherwise false
  19008. */
  19009. canCreate(gamepadInfo: any): boolean;
  19010. /**
  19011. * Creates a new instance of the Gamepad.
  19012. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19013. * @returns the new gamepad instance
  19014. */
  19015. create(gamepadInfo: any): Gamepad;
  19016. }
  19017. /**
  19018. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19019. */
  19020. export class PoseEnabledControllerHelper {
  19021. /** @hidden */
  19022. static _ControllerFactories: _GamePadFactory[];
  19023. /** @hidden */
  19024. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19025. /**
  19026. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19027. * @param vrGamepad the gamepad to initialized
  19028. * @returns a vr controller of the type the gamepad identified as
  19029. */
  19030. static InitiateController(vrGamepad: any): Gamepad;
  19031. }
  19032. /**
  19033. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19034. */
  19035. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19036. /**
  19037. * If the controller is used in a webXR session
  19038. */
  19039. isXR: boolean;
  19040. private _deviceRoomPosition;
  19041. private _deviceRoomRotationQuaternion;
  19042. /**
  19043. * The device position in babylon space
  19044. */
  19045. devicePosition: Vector3;
  19046. /**
  19047. * The device rotation in babylon space
  19048. */
  19049. deviceRotationQuaternion: Quaternion;
  19050. /**
  19051. * The scale factor of the device in babylon space
  19052. */
  19053. deviceScaleFactor: number;
  19054. /**
  19055. * (Likely devicePosition should be used instead) The device position in its room space
  19056. */
  19057. position: Vector3;
  19058. /**
  19059. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19060. */
  19061. rotationQuaternion: Quaternion;
  19062. /**
  19063. * The type of controller (Eg. Windows mixed reality)
  19064. */
  19065. controllerType: PoseEnabledControllerType;
  19066. protected _calculatedPosition: Vector3;
  19067. private _calculatedRotation;
  19068. /**
  19069. * The raw pose from the device
  19070. */
  19071. rawPose: DevicePose;
  19072. private _trackPosition;
  19073. private _maxRotationDistFromHeadset;
  19074. private _draggedRoomRotation;
  19075. /**
  19076. * @hidden
  19077. */
  19078. _disableTrackPosition(fixedPosition: Vector3): void;
  19079. /**
  19080. * Internal, the mesh attached to the controller
  19081. * @hidden
  19082. */
  19083. _mesh: Nullable<AbstractMesh>;
  19084. private _poseControlledCamera;
  19085. private _leftHandSystemQuaternion;
  19086. /**
  19087. * Internal, matrix used to convert room space to babylon space
  19088. * @hidden
  19089. */
  19090. _deviceToWorld: Matrix;
  19091. /**
  19092. * Node to be used when casting a ray from the controller
  19093. * @hidden
  19094. */
  19095. _pointingPoseNode: Nullable<TransformNode>;
  19096. /**
  19097. * Name of the child mesh that can be used to cast a ray from the controller
  19098. */
  19099. static readonly POINTING_POSE: string;
  19100. /**
  19101. * Creates a new PoseEnabledController from a gamepad
  19102. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19103. */
  19104. constructor(browserGamepad: any);
  19105. private _workingMatrix;
  19106. /**
  19107. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19108. */
  19109. update(): void;
  19110. /**
  19111. * Updates only the pose device and mesh without doing any button event checking
  19112. */
  19113. protected _updatePoseAndMesh(): void;
  19114. /**
  19115. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19116. * @param poseData raw pose fromthe device
  19117. */
  19118. updateFromDevice(poseData: DevicePose): void;
  19119. /**
  19120. * @hidden
  19121. */
  19122. _meshAttachedObservable: Observable<AbstractMesh>;
  19123. /**
  19124. * Attaches a mesh to the controller
  19125. * @param mesh the mesh to be attached
  19126. */
  19127. attachToMesh(mesh: AbstractMesh): void;
  19128. /**
  19129. * Attaches the controllers mesh to a camera
  19130. * @param camera the camera the mesh should be attached to
  19131. */
  19132. attachToPoseControlledCamera(camera: TargetCamera): void;
  19133. /**
  19134. * Disposes of the controller
  19135. */
  19136. dispose(): void;
  19137. /**
  19138. * The mesh that is attached to the controller
  19139. */
  19140. get mesh(): Nullable<AbstractMesh>;
  19141. /**
  19142. * Gets the ray of the controller in the direction the controller is pointing
  19143. * @param length the length the resulting ray should be
  19144. * @returns a ray in the direction the controller is pointing
  19145. */
  19146. getForwardRay(length?: number): Ray;
  19147. }
  19148. }
  19149. declare module BABYLON {
  19150. /**
  19151. * Defines the WebVRController object that represents controllers tracked in 3D space
  19152. */
  19153. export abstract class WebVRController extends PoseEnabledController {
  19154. /**
  19155. * Internal, the default controller model for the controller
  19156. */
  19157. protected _defaultModel: Nullable<AbstractMesh>;
  19158. /**
  19159. * Fired when the trigger state has changed
  19160. */
  19161. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19162. /**
  19163. * Fired when the main button state has changed
  19164. */
  19165. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19166. /**
  19167. * Fired when the secondary button state has changed
  19168. */
  19169. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19170. /**
  19171. * Fired when the pad state has changed
  19172. */
  19173. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19174. /**
  19175. * Fired when controllers stick values have changed
  19176. */
  19177. onPadValuesChangedObservable: Observable<StickValues>;
  19178. /**
  19179. * Array of button availible on the controller
  19180. */
  19181. protected _buttons: Array<MutableGamepadButton>;
  19182. private _onButtonStateChange;
  19183. /**
  19184. * Fired when a controller button's state has changed
  19185. * @param callback the callback containing the button that was modified
  19186. */
  19187. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19188. /**
  19189. * X and Y axis corresponding to the controllers joystick
  19190. */
  19191. pad: StickValues;
  19192. /**
  19193. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19194. */
  19195. hand: string;
  19196. /**
  19197. * The default controller model for the controller
  19198. */
  19199. get defaultModel(): Nullable<AbstractMesh>;
  19200. /**
  19201. * Creates a new WebVRController from a gamepad
  19202. * @param vrGamepad the gamepad that the WebVRController should be created from
  19203. */
  19204. constructor(vrGamepad: any);
  19205. /**
  19206. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19207. */
  19208. update(): void;
  19209. /**
  19210. * Function to be called when a button is modified
  19211. */
  19212. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19213. /**
  19214. * Loads a mesh and attaches it to the controller
  19215. * @param scene the scene the mesh should be added to
  19216. * @param meshLoaded callback for when the mesh has been loaded
  19217. */
  19218. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19219. private _setButtonValue;
  19220. private _changes;
  19221. private _checkChanges;
  19222. /**
  19223. * Disposes of th webVRCOntroller
  19224. */
  19225. dispose(): void;
  19226. }
  19227. }
  19228. declare module BABYLON {
  19229. /**
  19230. * The HemisphericLight simulates the ambient environment light,
  19231. * so the passed direction is the light reflection direction, not the incoming direction.
  19232. */
  19233. export class HemisphericLight extends Light {
  19234. /**
  19235. * The groundColor is the light in the opposite direction to the one specified during creation.
  19236. * 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.
  19237. */
  19238. groundColor: Color3;
  19239. /**
  19240. * The light reflection direction, not the incoming direction.
  19241. */
  19242. direction: Vector3;
  19243. /**
  19244. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19245. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19246. * The HemisphericLight can't cast shadows.
  19247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19248. * @param name The friendly name of the light
  19249. * @param direction The direction of the light reflection
  19250. * @param scene The scene the light belongs to
  19251. */
  19252. constructor(name: string, direction: Vector3, scene: Scene);
  19253. protected _buildUniformLayout(): void;
  19254. /**
  19255. * Returns the string "HemisphericLight".
  19256. * @return The class name
  19257. */
  19258. getClassName(): string;
  19259. /**
  19260. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19261. * Returns the updated direction.
  19262. * @param target The target the direction should point to
  19263. * @return The computed direction
  19264. */
  19265. setDirectionToTarget(target: Vector3): Vector3;
  19266. /**
  19267. * Returns the shadow generator associated to the light.
  19268. * @returns Always null for hemispheric lights because it does not support shadows.
  19269. */
  19270. getShadowGenerator(): Nullable<IShadowGenerator>;
  19271. /**
  19272. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19273. * @param effect The effect to update
  19274. * @param lightIndex The index of the light in the effect to update
  19275. * @returns The hemispheric light
  19276. */
  19277. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19279. /**
  19280. * Computes the world matrix of the node
  19281. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19282. * @param useWasUpdatedFlag defines a reserved property
  19283. * @returns the world matrix
  19284. */
  19285. computeWorldMatrix(): Matrix;
  19286. /**
  19287. * Returns the integer 3.
  19288. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19289. */
  19290. getTypeID(): number;
  19291. /**
  19292. * Prepares the list of defines specific to the light type.
  19293. * @param defines the list of defines
  19294. * @param lightIndex defines the index of the light for the effect
  19295. */
  19296. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19297. }
  19298. }
  19299. declare module BABYLON {
  19300. /** @hidden */
  19301. export var vrMultiviewToSingleviewPixelShader: {
  19302. name: string;
  19303. shader: string;
  19304. };
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * Renders to multiple views with a single draw call
  19309. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19310. */
  19311. export class MultiviewRenderTarget extends RenderTargetTexture {
  19312. /**
  19313. * Creates a multiview render target
  19314. * @param scene scene used with the render target
  19315. * @param size the size of the render target (used for each view)
  19316. */
  19317. constructor(scene: Scene, size?: number | {
  19318. width: number;
  19319. height: number;
  19320. } | {
  19321. ratio: number;
  19322. });
  19323. /**
  19324. * @hidden
  19325. * @param faceIndex the face index, if its a cube texture
  19326. */
  19327. _bindFrameBuffer(faceIndex?: number): void;
  19328. /**
  19329. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19330. * @returns the view count
  19331. */
  19332. getViewCount(): number;
  19333. }
  19334. }
  19335. declare module BABYLON {
  19336. /**
  19337. * Represents a camera frustum
  19338. */
  19339. export class Frustum {
  19340. /**
  19341. * Gets the planes representing the frustum
  19342. * @param transform matrix to be applied to the returned planes
  19343. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19344. */
  19345. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19346. /**
  19347. * Gets the near frustum plane transformed by the transform matrix
  19348. * @param transform transformation matrix to be applied to the resulting frustum plane
  19349. * @param frustumPlane the resuling frustum plane
  19350. */
  19351. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19352. /**
  19353. * Gets the far frustum plane transformed by the transform matrix
  19354. * @param transform transformation matrix to be applied to the resulting frustum plane
  19355. * @param frustumPlane the resuling frustum plane
  19356. */
  19357. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19358. /**
  19359. * Gets the left frustum plane transformed by the transform matrix
  19360. * @param transform transformation matrix to be applied to the resulting frustum plane
  19361. * @param frustumPlane the resuling frustum plane
  19362. */
  19363. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19364. /**
  19365. * Gets the right frustum plane transformed by the transform matrix
  19366. * @param transform transformation matrix to be applied to the resulting frustum plane
  19367. * @param frustumPlane the resuling frustum plane
  19368. */
  19369. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19370. /**
  19371. * Gets the top frustum plane transformed by the transform matrix
  19372. * @param transform transformation matrix to be applied to the resulting frustum plane
  19373. * @param frustumPlane the resuling frustum plane
  19374. */
  19375. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19376. /**
  19377. * Gets the bottom frustum plane transformed by the transform matrix
  19378. * @param transform transformation matrix to be applied to the resulting frustum plane
  19379. * @param frustumPlane the resuling frustum plane
  19380. */
  19381. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19382. /**
  19383. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19384. * @param transform transformation matrix to be applied to the resulting frustum planes
  19385. * @param frustumPlanes the resuling frustum planes
  19386. */
  19387. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19388. }
  19389. }
  19390. declare module BABYLON {
  19391. interface Engine {
  19392. /**
  19393. * Creates a new multiview render target
  19394. * @param width defines the width of the texture
  19395. * @param height defines the height of the texture
  19396. * @returns the created multiview texture
  19397. */
  19398. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19399. /**
  19400. * Binds a multiview framebuffer to be drawn to
  19401. * @param multiviewTexture texture to bind
  19402. */
  19403. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19404. }
  19405. interface Camera {
  19406. /**
  19407. * @hidden
  19408. * 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)
  19409. */
  19410. _useMultiviewToSingleView: boolean;
  19411. /**
  19412. * @hidden
  19413. * 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)
  19414. */
  19415. _multiviewTexture: Nullable<RenderTargetTexture>;
  19416. /**
  19417. * @hidden
  19418. * ensures the multiview texture of the camera exists and has the specified width/height
  19419. * @param width height to set on the multiview texture
  19420. * @param height width to set on the multiview texture
  19421. */
  19422. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19423. }
  19424. interface Scene {
  19425. /** @hidden */
  19426. _transformMatrixR: Matrix;
  19427. /** @hidden */
  19428. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19429. /** @hidden */
  19430. _createMultiviewUbo(): void;
  19431. /** @hidden */
  19432. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19433. /** @hidden */
  19434. _renderMultiviewToSingleView(camera: Camera): void;
  19435. }
  19436. }
  19437. declare module BABYLON {
  19438. /**
  19439. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19440. * This will not be used for webXR as it supports displaying texture arrays directly
  19441. */
  19442. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19443. /**
  19444. * Initializes a VRMultiviewToSingleview
  19445. * @param name name of the post process
  19446. * @param camera camera to be applied to
  19447. * @param scaleFactor scaling factor to the size of the output texture
  19448. */
  19449. constructor(name: string, camera: Camera, scaleFactor: number);
  19450. }
  19451. }
  19452. declare module BABYLON {
  19453. /**
  19454. * Interface used to define additional presentation attributes
  19455. */
  19456. export interface IVRPresentationAttributes {
  19457. /**
  19458. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19459. */
  19460. highRefreshRate: boolean;
  19461. /**
  19462. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19463. */
  19464. foveationLevel: number;
  19465. }
  19466. interface Engine {
  19467. /** @hidden */
  19468. _vrDisplay: any;
  19469. /** @hidden */
  19470. _vrSupported: boolean;
  19471. /** @hidden */
  19472. _oldSize: Size;
  19473. /** @hidden */
  19474. _oldHardwareScaleFactor: number;
  19475. /** @hidden */
  19476. _vrExclusivePointerMode: boolean;
  19477. /** @hidden */
  19478. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19479. /** @hidden */
  19480. _onVRDisplayPointerRestricted: () => void;
  19481. /** @hidden */
  19482. _onVRDisplayPointerUnrestricted: () => void;
  19483. /** @hidden */
  19484. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19485. /** @hidden */
  19486. _onVrDisplayDisconnect: Nullable<() => void>;
  19487. /** @hidden */
  19488. _onVrDisplayPresentChange: Nullable<() => void>;
  19489. /**
  19490. * Observable signaled when VR display mode changes
  19491. */
  19492. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19493. /**
  19494. * Observable signaled when VR request present is complete
  19495. */
  19496. onVRRequestPresentComplete: Observable<boolean>;
  19497. /**
  19498. * Observable signaled when VR request present starts
  19499. */
  19500. onVRRequestPresentStart: Observable<Engine>;
  19501. /**
  19502. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19503. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19504. */
  19505. isInVRExclusivePointerMode: boolean;
  19506. /**
  19507. * Gets a boolean indicating if a webVR device was detected
  19508. * @returns true if a webVR device was detected
  19509. */
  19510. isVRDevicePresent(): boolean;
  19511. /**
  19512. * Gets the current webVR device
  19513. * @returns the current webVR device (or null)
  19514. */
  19515. getVRDevice(): any;
  19516. /**
  19517. * Initializes a webVR display and starts listening to display change events
  19518. * The onVRDisplayChangedObservable will be notified upon these changes
  19519. * @returns A promise containing a VRDisplay and if vr is supported
  19520. */
  19521. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19522. /** @hidden */
  19523. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19524. /**
  19525. * Gets or sets the presentation attributes used to configure VR rendering
  19526. */
  19527. vrPresentationAttributes?: IVRPresentationAttributes;
  19528. /**
  19529. * Call this function to switch to webVR mode
  19530. * Will do nothing if webVR is not supported or if there is no webVR device
  19531. * @param options the webvr options provided to the camera. mainly used for multiview
  19532. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19533. */
  19534. enableVR(options: WebVROptions): void;
  19535. /** @hidden */
  19536. _onVRFullScreenTriggered(): void;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. /**
  19541. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19542. * IMPORTANT!! The data is right-hand data.
  19543. * @export
  19544. * @interface DevicePose
  19545. */
  19546. export interface DevicePose {
  19547. /**
  19548. * The position of the device, values in array are [x,y,z].
  19549. */
  19550. readonly position: Nullable<Float32Array>;
  19551. /**
  19552. * The linearVelocity of the device, values in array are [x,y,z].
  19553. */
  19554. readonly linearVelocity: Nullable<Float32Array>;
  19555. /**
  19556. * The linearAcceleration of the device, values in array are [x,y,z].
  19557. */
  19558. readonly linearAcceleration: Nullable<Float32Array>;
  19559. /**
  19560. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19561. */
  19562. readonly orientation: Nullable<Float32Array>;
  19563. /**
  19564. * The angularVelocity of the device, values in array are [x,y,z].
  19565. */
  19566. readonly angularVelocity: Nullable<Float32Array>;
  19567. /**
  19568. * The angularAcceleration of the device, values in array are [x,y,z].
  19569. */
  19570. readonly angularAcceleration: Nullable<Float32Array>;
  19571. }
  19572. /**
  19573. * Interface representing a pose controlled object in Babylon.
  19574. * A pose controlled object has both regular pose values as well as pose values
  19575. * from an external device such as a VR head mounted display
  19576. */
  19577. export interface PoseControlled {
  19578. /**
  19579. * The position of the object in babylon space.
  19580. */
  19581. position: Vector3;
  19582. /**
  19583. * The rotation quaternion of the object in babylon space.
  19584. */
  19585. rotationQuaternion: Quaternion;
  19586. /**
  19587. * The position of the device in babylon space.
  19588. */
  19589. devicePosition?: Vector3;
  19590. /**
  19591. * The rotation quaternion of the device in babylon space.
  19592. */
  19593. deviceRotationQuaternion: Quaternion;
  19594. /**
  19595. * The raw pose coming from the device.
  19596. */
  19597. rawPose: Nullable<DevicePose>;
  19598. /**
  19599. * The scale of the device to be used when translating from device space to babylon space.
  19600. */
  19601. deviceScaleFactor: number;
  19602. /**
  19603. * Updates the poseControlled values based on the input device pose.
  19604. * @param poseData the pose data to update the object with
  19605. */
  19606. updateFromDevice(poseData: DevicePose): void;
  19607. }
  19608. /**
  19609. * Set of options to customize the webVRCamera
  19610. */
  19611. export interface WebVROptions {
  19612. /**
  19613. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19614. */
  19615. trackPosition?: boolean;
  19616. /**
  19617. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19618. */
  19619. positionScale?: number;
  19620. /**
  19621. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19622. */
  19623. displayName?: string;
  19624. /**
  19625. * Should the native controller meshes be initialized. (default: true)
  19626. */
  19627. controllerMeshes?: boolean;
  19628. /**
  19629. * Creating a default HemiLight only on controllers. (default: true)
  19630. */
  19631. defaultLightingOnControllers?: boolean;
  19632. /**
  19633. * If you don't want to use the default VR button of the helper. (default: false)
  19634. */
  19635. useCustomVRButton?: boolean;
  19636. /**
  19637. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19638. */
  19639. customVRButton?: HTMLButtonElement;
  19640. /**
  19641. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19642. */
  19643. rayLength?: number;
  19644. /**
  19645. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19646. */
  19647. defaultHeight?: number;
  19648. /**
  19649. * If multiview should be used if availible (default: false)
  19650. */
  19651. useMultiview?: boolean;
  19652. }
  19653. /**
  19654. * This represents a WebVR camera.
  19655. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19656. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19657. */
  19658. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19659. private webVROptions;
  19660. /**
  19661. * @hidden
  19662. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19663. */
  19664. _vrDevice: any;
  19665. /**
  19666. * The rawPose of the vrDevice.
  19667. */
  19668. rawPose: Nullable<DevicePose>;
  19669. private _onVREnabled;
  19670. private _specsVersion;
  19671. private _attached;
  19672. private _frameData;
  19673. protected _descendants: Array<Node>;
  19674. private _deviceRoomPosition;
  19675. /** @hidden */
  19676. _deviceRoomRotationQuaternion: Quaternion;
  19677. private _standingMatrix;
  19678. /**
  19679. * Represents device position in babylon space.
  19680. */
  19681. devicePosition: Vector3;
  19682. /**
  19683. * Represents device rotation in babylon space.
  19684. */
  19685. deviceRotationQuaternion: Quaternion;
  19686. /**
  19687. * The scale of the device to be used when translating from device space to babylon space.
  19688. */
  19689. deviceScaleFactor: number;
  19690. private _deviceToWorld;
  19691. private _worldToDevice;
  19692. /**
  19693. * References to the webVR controllers for the vrDevice.
  19694. */
  19695. controllers: Array<WebVRController>;
  19696. /**
  19697. * Emits an event when a controller is attached.
  19698. */
  19699. onControllersAttachedObservable: Observable<WebVRController[]>;
  19700. /**
  19701. * Emits an event when a controller's mesh has been loaded;
  19702. */
  19703. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19704. /**
  19705. * Emits an event when the HMD's pose has been updated.
  19706. */
  19707. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19708. private _poseSet;
  19709. /**
  19710. * If the rig cameras be used as parent instead of this camera.
  19711. */
  19712. rigParenting: boolean;
  19713. private _lightOnControllers;
  19714. private _defaultHeight?;
  19715. /**
  19716. * Instantiates a WebVRFreeCamera.
  19717. * @param name The name of the WebVRFreeCamera
  19718. * @param position The starting anchor position for the camera
  19719. * @param scene The scene the camera belongs to
  19720. * @param webVROptions a set of customizable options for the webVRCamera
  19721. */
  19722. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19723. /**
  19724. * Gets the device distance from the ground in meters.
  19725. * @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.
  19726. */
  19727. deviceDistanceToRoomGround(): number;
  19728. /**
  19729. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19730. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19731. */
  19732. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19733. /**
  19734. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19735. * @returns A promise with a boolean set to if the standing matrix is supported.
  19736. */
  19737. useStandingMatrixAsync(): Promise<boolean>;
  19738. /**
  19739. * Disposes the camera
  19740. */
  19741. dispose(): void;
  19742. /**
  19743. * Gets a vrController by name.
  19744. * @param name The name of the controller to retreive
  19745. * @returns the controller matching the name specified or null if not found
  19746. */
  19747. getControllerByName(name: string): Nullable<WebVRController>;
  19748. private _leftController;
  19749. /**
  19750. * The controller corresponding to the users left hand.
  19751. */
  19752. get leftController(): Nullable<WebVRController>;
  19753. private _rightController;
  19754. /**
  19755. * The controller corresponding to the users right hand.
  19756. */
  19757. get rightController(): Nullable<WebVRController>;
  19758. /**
  19759. * Casts a ray forward from the vrCamera's gaze.
  19760. * @param length Length of the ray (default: 100)
  19761. * @returns the ray corresponding to the gaze
  19762. */
  19763. getForwardRay(length?: number): Ray;
  19764. /**
  19765. * @hidden
  19766. * Updates the camera based on device's frame data
  19767. */
  19768. _checkInputs(): void;
  19769. /**
  19770. * Updates the poseControlled values based on the input device pose.
  19771. * @param poseData Pose coming from the device
  19772. */
  19773. updateFromDevice(poseData: DevicePose): void;
  19774. private _htmlElementAttached;
  19775. private _detachIfAttached;
  19776. /**
  19777. * WebVR's attach control will start broadcasting frames to the device.
  19778. * Note that in certain browsers (chrome for example) this function must be called
  19779. * within a user-interaction callback. Example:
  19780. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19781. *
  19782. * @param element html element to attach the vrDevice to
  19783. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19784. */
  19785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19786. /**
  19787. * Detaches the camera from the html element and disables VR
  19788. *
  19789. * @param element html element to detach from
  19790. */
  19791. detachControl(element: HTMLElement): void;
  19792. /**
  19793. * @returns the name of this class
  19794. */
  19795. getClassName(): string;
  19796. /**
  19797. * Calls resetPose on the vrDisplay
  19798. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19799. */
  19800. resetToCurrentRotation(): void;
  19801. /**
  19802. * @hidden
  19803. * Updates the rig cameras (left and right eye)
  19804. */
  19805. _updateRigCameras(): void;
  19806. private _workingVector;
  19807. private _oneVector;
  19808. private _workingMatrix;
  19809. private updateCacheCalled;
  19810. private _correctPositionIfNotTrackPosition;
  19811. /**
  19812. * @hidden
  19813. * Updates the cached values of the camera
  19814. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19815. */
  19816. _updateCache(ignoreParentClass?: boolean): void;
  19817. /**
  19818. * @hidden
  19819. * Get current device position in babylon world
  19820. */
  19821. _computeDevicePosition(): void;
  19822. /**
  19823. * Updates the current device position and rotation in the babylon world
  19824. */
  19825. update(): void;
  19826. /**
  19827. * @hidden
  19828. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19829. * @returns an identity matrix
  19830. */
  19831. _getViewMatrix(): Matrix;
  19832. private _tmpMatrix;
  19833. /**
  19834. * This function is called by the two RIG cameras.
  19835. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19836. * @hidden
  19837. */
  19838. _getWebVRViewMatrix(): Matrix;
  19839. /** @hidden */
  19840. _getWebVRProjectionMatrix(): Matrix;
  19841. private _onGamepadConnectedObserver;
  19842. private _onGamepadDisconnectedObserver;
  19843. private _updateCacheWhenTrackingDisabledObserver;
  19844. /**
  19845. * Initializes the controllers and their meshes
  19846. */
  19847. initControllers(): void;
  19848. }
  19849. }
  19850. declare module BABYLON {
  19851. /**
  19852. * Size options for a post process
  19853. */
  19854. export type PostProcessOptions = {
  19855. width: number;
  19856. height: number;
  19857. };
  19858. /**
  19859. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19860. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19861. */
  19862. export class PostProcess {
  19863. /** Name of the PostProcess. */
  19864. name: string;
  19865. /**
  19866. * Gets or sets the unique id of the post process
  19867. */
  19868. uniqueId: number;
  19869. /**
  19870. * Width of the texture to apply the post process on
  19871. */
  19872. width: number;
  19873. /**
  19874. * Height of the texture to apply the post process on
  19875. */
  19876. height: number;
  19877. /**
  19878. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19879. * @hidden
  19880. */
  19881. _outputTexture: Nullable<InternalTexture>;
  19882. /**
  19883. * Sampling mode used by the shader
  19884. * See https://doc.babylonjs.com/classes/3.1/texture
  19885. */
  19886. renderTargetSamplingMode: number;
  19887. /**
  19888. * Clear color to use when screen clearing
  19889. */
  19890. clearColor: Color4;
  19891. /**
  19892. * If the buffer needs to be cleared before applying the post process. (default: true)
  19893. * Should be set to false if shader will overwrite all previous pixels.
  19894. */
  19895. autoClear: boolean;
  19896. /**
  19897. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19898. */
  19899. alphaMode: number;
  19900. /**
  19901. * Sets the setAlphaBlendConstants of the babylon engine
  19902. */
  19903. alphaConstants: Color4;
  19904. /**
  19905. * Animations to be used for the post processing
  19906. */
  19907. animations: Animation[];
  19908. /**
  19909. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19910. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19911. */
  19912. enablePixelPerfectMode: boolean;
  19913. /**
  19914. * Force the postprocess to be applied without taking in account viewport
  19915. */
  19916. forceFullscreenViewport: boolean;
  19917. /**
  19918. * List of inspectable custom properties (used by the Inspector)
  19919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19920. */
  19921. inspectableCustomProperties: IInspectable[];
  19922. /**
  19923. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19924. *
  19925. * | Value | Type | Description |
  19926. * | ----- | ----------------------------------- | ----------- |
  19927. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19928. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19929. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19930. *
  19931. */
  19932. scaleMode: number;
  19933. /**
  19934. * Force textures to be a power of two (default: false)
  19935. */
  19936. alwaysForcePOT: boolean;
  19937. private _samples;
  19938. /**
  19939. * Number of sample textures (default: 1)
  19940. */
  19941. get samples(): number;
  19942. set samples(n: number);
  19943. /**
  19944. * Modify the scale of the post process to be the same as the viewport (default: false)
  19945. */
  19946. adaptScaleToCurrentViewport: boolean;
  19947. private _camera;
  19948. private _scene;
  19949. private _engine;
  19950. private _options;
  19951. private _reusable;
  19952. private _textureType;
  19953. private _textureFormat;
  19954. /**
  19955. * Smart array of input and output textures for the post process.
  19956. * @hidden
  19957. */
  19958. _textures: SmartArray<InternalTexture>;
  19959. /**
  19960. * The index in _textures that corresponds to the output texture.
  19961. * @hidden
  19962. */
  19963. _currentRenderTextureInd: number;
  19964. private _effect;
  19965. private _samplers;
  19966. private _fragmentUrl;
  19967. private _vertexUrl;
  19968. private _parameters;
  19969. private _scaleRatio;
  19970. protected _indexParameters: any;
  19971. private _shareOutputWithPostProcess;
  19972. private _texelSize;
  19973. private _forcedOutputTexture;
  19974. /**
  19975. * Returns the fragment url or shader name used in the post process.
  19976. * @returns the fragment url or name in the shader store.
  19977. */
  19978. getEffectName(): string;
  19979. /**
  19980. * An event triggered when the postprocess is activated.
  19981. */
  19982. onActivateObservable: Observable<Camera>;
  19983. private _onActivateObserver;
  19984. /**
  19985. * A function that is added to the onActivateObservable
  19986. */
  19987. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19988. /**
  19989. * An event triggered when the postprocess changes its size.
  19990. */
  19991. onSizeChangedObservable: Observable<PostProcess>;
  19992. private _onSizeChangedObserver;
  19993. /**
  19994. * A function that is added to the onSizeChangedObservable
  19995. */
  19996. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19997. /**
  19998. * An event triggered when the postprocess applies its effect.
  19999. */
  20000. onApplyObservable: Observable<Effect>;
  20001. private _onApplyObserver;
  20002. /**
  20003. * A function that is added to the onApplyObservable
  20004. */
  20005. set onApply(callback: (effect: Effect) => void);
  20006. /**
  20007. * An event triggered before rendering the postprocess
  20008. */
  20009. onBeforeRenderObservable: Observable<Effect>;
  20010. private _onBeforeRenderObserver;
  20011. /**
  20012. * A function that is added to the onBeforeRenderObservable
  20013. */
  20014. set onBeforeRender(callback: (effect: Effect) => void);
  20015. /**
  20016. * An event triggered after rendering the postprocess
  20017. */
  20018. onAfterRenderObservable: Observable<Effect>;
  20019. private _onAfterRenderObserver;
  20020. /**
  20021. * A function that is added to the onAfterRenderObservable
  20022. */
  20023. set onAfterRender(callback: (efect: Effect) => void);
  20024. /**
  20025. * 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
  20026. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20027. */
  20028. get inputTexture(): InternalTexture;
  20029. set inputTexture(value: InternalTexture);
  20030. /**
  20031. * Gets the camera which post process is applied to.
  20032. * @returns The camera the post process is applied to.
  20033. */
  20034. getCamera(): Camera;
  20035. /**
  20036. * Gets the texel size of the postprocess.
  20037. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20038. */
  20039. get texelSize(): Vector2;
  20040. /**
  20041. * Creates a new instance PostProcess
  20042. * @param name The name of the PostProcess.
  20043. * @param fragmentUrl The url of the fragment shader to be used.
  20044. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20045. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20046. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20047. * @param camera The camera to apply the render pass to.
  20048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20049. * @param engine The engine which the post process will be applied. (default: current engine)
  20050. * @param reusable If the post process can be reused on the same frame. (default: false)
  20051. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20052. * @param textureType Type of textures used when performing the post process. (default: 0)
  20053. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20054. * @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
  20055. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20056. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20057. */
  20058. constructor(
  20059. /** Name of the PostProcess. */
  20060. 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);
  20061. /**
  20062. * Gets a string idenfifying the name of the class
  20063. * @returns "PostProcess" string
  20064. */
  20065. getClassName(): string;
  20066. /**
  20067. * Gets the engine which this post process belongs to.
  20068. * @returns The engine the post process was enabled with.
  20069. */
  20070. getEngine(): Engine;
  20071. /**
  20072. * The effect that is created when initializing the post process.
  20073. * @returns The created effect corresponding the the postprocess.
  20074. */
  20075. getEffect(): Effect;
  20076. /**
  20077. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20078. * @param postProcess The post process to share the output with.
  20079. * @returns This post process.
  20080. */
  20081. shareOutputWith(postProcess: PostProcess): PostProcess;
  20082. /**
  20083. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20084. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20085. */
  20086. useOwnOutput(): void;
  20087. /**
  20088. * Updates the effect with the current post process compile time values and recompiles the shader.
  20089. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20090. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20091. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20092. * @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
  20093. * @param onCompiled Called when the shader has been compiled.
  20094. * @param onError Called if there is an error when compiling a shader.
  20095. */
  20096. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20097. /**
  20098. * The post process is reusable if it can be used multiple times within one frame.
  20099. * @returns If the post process is reusable
  20100. */
  20101. isReusable(): boolean;
  20102. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20103. markTextureDirty(): void;
  20104. /**
  20105. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20106. * 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.
  20107. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20108. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20109. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20110. * @returns The target texture that was bound to be written to.
  20111. */
  20112. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20113. /**
  20114. * If the post process is supported.
  20115. */
  20116. get isSupported(): boolean;
  20117. /**
  20118. * The aspect ratio of the output texture.
  20119. */
  20120. get aspectRatio(): number;
  20121. /**
  20122. * Get a value indicating if the post-process is ready to be used
  20123. * @returns true if the post-process is ready (shader is compiled)
  20124. */
  20125. isReady(): boolean;
  20126. /**
  20127. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20128. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20129. */
  20130. apply(): Nullable<Effect>;
  20131. private _disposeTextures;
  20132. /**
  20133. * Disposes the post process.
  20134. * @param camera The camera to dispose the post process on.
  20135. */
  20136. dispose(camera?: Camera): void;
  20137. }
  20138. }
  20139. declare module BABYLON {
  20140. /** @hidden */
  20141. export var kernelBlurVaryingDeclaration: {
  20142. name: string;
  20143. shader: string;
  20144. };
  20145. }
  20146. declare module BABYLON {
  20147. /** @hidden */
  20148. export var kernelBlurFragment: {
  20149. name: string;
  20150. shader: string;
  20151. };
  20152. }
  20153. declare module BABYLON {
  20154. /** @hidden */
  20155. export var kernelBlurFragment2: {
  20156. name: string;
  20157. shader: string;
  20158. };
  20159. }
  20160. declare module BABYLON {
  20161. /** @hidden */
  20162. export var kernelBlurPixelShader: {
  20163. name: string;
  20164. shader: string;
  20165. };
  20166. }
  20167. declare module BABYLON {
  20168. /** @hidden */
  20169. export var kernelBlurVertex: {
  20170. name: string;
  20171. shader: string;
  20172. };
  20173. }
  20174. declare module BABYLON {
  20175. /** @hidden */
  20176. export var kernelBlurVertexShader: {
  20177. name: string;
  20178. shader: string;
  20179. };
  20180. }
  20181. declare module BABYLON {
  20182. /**
  20183. * The Blur Post Process which blurs an image based on a kernel and direction.
  20184. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20185. */
  20186. export class BlurPostProcess extends PostProcess {
  20187. /** The direction in which to blur the image. */
  20188. direction: Vector2;
  20189. private blockCompilation;
  20190. protected _kernel: number;
  20191. protected _idealKernel: number;
  20192. protected _packedFloat: boolean;
  20193. private _staticDefines;
  20194. /**
  20195. * Sets the length in pixels of the blur sample region
  20196. */
  20197. set kernel(v: number);
  20198. /**
  20199. * Gets the length in pixels of the blur sample region
  20200. */
  20201. get kernel(): number;
  20202. /**
  20203. * Sets wether or not the blur needs to unpack/repack floats
  20204. */
  20205. set packedFloat(v: boolean);
  20206. /**
  20207. * Gets wether or not the blur is unpacking/repacking floats
  20208. */
  20209. get packedFloat(): boolean;
  20210. /**
  20211. * Creates a new instance BlurPostProcess
  20212. * @param name The name of the effect.
  20213. * @param direction The direction in which to blur the image.
  20214. * @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.
  20215. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20216. * @param camera The camera to apply the render pass to.
  20217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20218. * @param engine The engine which the post process will be applied. (default: current engine)
  20219. * @param reusable If the post process can be reused on the same frame. (default: false)
  20220. * @param textureType Type of textures used when performing the post process. (default: 0)
  20221. * @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)
  20222. */
  20223. constructor(name: string,
  20224. /** The direction in which to blur the image. */
  20225. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20226. /**
  20227. * Updates the effect with the current post process compile time values and recompiles the shader.
  20228. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20229. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20230. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20231. * @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
  20232. * @param onCompiled Called when the shader has been compiled.
  20233. * @param onError Called if there is an error when compiling a shader.
  20234. */
  20235. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20236. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20237. /**
  20238. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20239. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20240. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20241. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20242. * The gaps between physical kernels are compensated for in the weighting of the samples
  20243. * @param idealKernel Ideal blur kernel.
  20244. * @return Nearest best kernel.
  20245. */
  20246. protected _nearestBestKernel(idealKernel: number): number;
  20247. /**
  20248. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20249. * @param x The point on the Gaussian distribution to sample.
  20250. * @return the value of the Gaussian function at x.
  20251. */
  20252. protected _gaussianWeight(x: number): number;
  20253. /**
  20254. * Generates a string that can be used as a floating point number in GLSL.
  20255. * @param x Value to print.
  20256. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20257. * @return GLSL float string.
  20258. */
  20259. protected _glslFloat(x: number, decimalFigures?: number): string;
  20260. }
  20261. }
  20262. declare module BABYLON {
  20263. /**
  20264. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20265. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20266. * You can then easily use it as a reflectionTexture on a flat surface.
  20267. * In case the surface is not a plane, please consider relying on reflection probes.
  20268. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20269. */
  20270. export class MirrorTexture extends RenderTargetTexture {
  20271. private scene;
  20272. /**
  20273. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20274. * 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.
  20275. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20276. */
  20277. mirrorPlane: Plane;
  20278. /**
  20279. * Define the blur ratio used to blur the reflection if needed.
  20280. */
  20281. set blurRatio(value: number);
  20282. get blurRatio(): number;
  20283. /**
  20284. * Define the adaptive blur kernel used to blur the reflection if needed.
  20285. * This will autocompute the closest best match for the `blurKernel`
  20286. */
  20287. set adaptiveBlurKernel(value: number);
  20288. /**
  20289. * Define the blur kernel used to blur the reflection if needed.
  20290. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20291. */
  20292. set blurKernel(value: number);
  20293. /**
  20294. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20295. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20296. */
  20297. set blurKernelX(value: number);
  20298. get blurKernelX(): number;
  20299. /**
  20300. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20301. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20302. */
  20303. set blurKernelY(value: number);
  20304. get blurKernelY(): number;
  20305. private _autoComputeBlurKernel;
  20306. protected _onRatioRescale(): void;
  20307. private _updateGammaSpace;
  20308. private _imageProcessingConfigChangeObserver;
  20309. private _transformMatrix;
  20310. private _mirrorMatrix;
  20311. private _savedViewMatrix;
  20312. private _blurX;
  20313. private _blurY;
  20314. private _adaptiveBlurKernel;
  20315. private _blurKernelX;
  20316. private _blurKernelY;
  20317. private _blurRatio;
  20318. /**
  20319. * Instantiates a Mirror Texture.
  20320. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20321. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20322. * You can then easily use it as a reflectionTexture on a flat surface.
  20323. * In case the surface is not a plane, please consider relying on reflection probes.
  20324. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20325. * @param name
  20326. * @param size
  20327. * @param scene
  20328. * @param generateMipMaps
  20329. * @param type
  20330. * @param samplingMode
  20331. * @param generateDepthBuffer
  20332. */
  20333. constructor(name: string, size: number | {
  20334. width: number;
  20335. height: number;
  20336. } | {
  20337. ratio: number;
  20338. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20339. private _preparePostProcesses;
  20340. /**
  20341. * Clone the mirror texture.
  20342. * @returns the cloned texture
  20343. */
  20344. clone(): MirrorTexture;
  20345. /**
  20346. * Serialize the texture to a JSON representation you could use in Parse later on
  20347. * @returns the serialized JSON representation
  20348. */
  20349. serialize(): any;
  20350. /**
  20351. * Dispose the texture and release its associated resources.
  20352. */
  20353. dispose(): void;
  20354. }
  20355. }
  20356. declare module BABYLON {
  20357. /**
  20358. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20359. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20360. */
  20361. export class Texture extends BaseTexture {
  20362. /**
  20363. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20364. */
  20365. static SerializeBuffers: boolean;
  20366. /** @hidden */
  20367. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20368. /** @hidden */
  20369. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20370. /** @hidden */
  20371. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20372. /** nearest is mag = nearest and min = nearest and mip = linear */
  20373. static readonly NEAREST_SAMPLINGMODE: number;
  20374. /** nearest is mag = nearest and min = nearest and mip = linear */
  20375. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20376. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20377. static readonly BILINEAR_SAMPLINGMODE: number;
  20378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20379. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20380. /** Trilinear is mag = linear and min = linear and mip = linear */
  20381. static readonly TRILINEAR_SAMPLINGMODE: number;
  20382. /** Trilinear is mag = linear and min = linear and mip = linear */
  20383. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20384. /** mag = nearest and min = nearest and mip = nearest */
  20385. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20386. /** mag = nearest and min = linear and mip = nearest */
  20387. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20388. /** mag = nearest and min = linear and mip = linear */
  20389. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20390. /** mag = nearest and min = linear and mip = none */
  20391. static readonly NEAREST_LINEAR: number;
  20392. /** mag = nearest and min = nearest and mip = none */
  20393. static readonly NEAREST_NEAREST: number;
  20394. /** mag = linear and min = nearest and mip = nearest */
  20395. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20396. /** mag = linear and min = nearest and mip = linear */
  20397. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20398. /** mag = linear and min = linear and mip = none */
  20399. static readonly LINEAR_LINEAR: number;
  20400. /** mag = linear and min = nearest and mip = none */
  20401. static readonly LINEAR_NEAREST: number;
  20402. /** Explicit coordinates mode */
  20403. static readonly EXPLICIT_MODE: number;
  20404. /** Spherical coordinates mode */
  20405. static readonly SPHERICAL_MODE: number;
  20406. /** Planar coordinates mode */
  20407. static readonly PLANAR_MODE: number;
  20408. /** Cubic coordinates mode */
  20409. static readonly CUBIC_MODE: number;
  20410. /** Projection coordinates mode */
  20411. static readonly PROJECTION_MODE: number;
  20412. /** Inverse Cubic coordinates mode */
  20413. static readonly SKYBOX_MODE: number;
  20414. /** Inverse Cubic coordinates mode */
  20415. static readonly INVCUBIC_MODE: number;
  20416. /** Equirectangular coordinates mode */
  20417. static readonly EQUIRECTANGULAR_MODE: number;
  20418. /** Equirectangular Fixed coordinates mode */
  20419. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20420. /** Equirectangular Fixed Mirrored coordinates mode */
  20421. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20422. /** Texture is not repeating outside of 0..1 UVs */
  20423. static readonly CLAMP_ADDRESSMODE: number;
  20424. /** Texture is repeating outside of 0..1 UVs */
  20425. static readonly WRAP_ADDRESSMODE: number;
  20426. /** Texture is repeating and mirrored */
  20427. static readonly MIRROR_ADDRESSMODE: number;
  20428. /**
  20429. * 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
  20430. */
  20431. static UseSerializedUrlIfAny: boolean;
  20432. /**
  20433. * Define the url of the texture.
  20434. */
  20435. url: Nullable<string>;
  20436. /**
  20437. * Define an offset on the texture to offset the u coordinates of the UVs
  20438. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20439. */
  20440. uOffset: number;
  20441. /**
  20442. * Define an offset on the texture to offset the v coordinates of the UVs
  20443. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20444. */
  20445. vOffset: number;
  20446. /**
  20447. * Define an offset on the texture to scale the u coordinates of the UVs
  20448. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20449. */
  20450. uScale: number;
  20451. /**
  20452. * Define an offset on the texture to scale the v coordinates of the UVs
  20453. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20454. */
  20455. vScale: number;
  20456. /**
  20457. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20458. * @see http://doc.babylonjs.com/how_to/more_materials
  20459. */
  20460. uAng: number;
  20461. /**
  20462. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20463. * @see http://doc.babylonjs.com/how_to/more_materials
  20464. */
  20465. vAng: number;
  20466. /**
  20467. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20468. * @see http://doc.babylonjs.com/how_to/more_materials
  20469. */
  20470. wAng: number;
  20471. /**
  20472. * Defines the center of rotation (U)
  20473. */
  20474. uRotationCenter: number;
  20475. /**
  20476. * Defines the center of rotation (V)
  20477. */
  20478. vRotationCenter: number;
  20479. /**
  20480. * Defines the center of rotation (W)
  20481. */
  20482. wRotationCenter: number;
  20483. /**
  20484. * Are mip maps generated for this texture or not.
  20485. */
  20486. get noMipmap(): boolean;
  20487. /**
  20488. * List of inspectable custom properties (used by the Inspector)
  20489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20490. */
  20491. inspectableCustomProperties: Nullable<IInspectable[]>;
  20492. private _noMipmap;
  20493. /** @hidden */
  20494. _invertY: boolean;
  20495. private _rowGenerationMatrix;
  20496. private _cachedTextureMatrix;
  20497. private _projectionModeMatrix;
  20498. private _t0;
  20499. private _t1;
  20500. private _t2;
  20501. private _cachedUOffset;
  20502. private _cachedVOffset;
  20503. private _cachedUScale;
  20504. private _cachedVScale;
  20505. private _cachedUAng;
  20506. private _cachedVAng;
  20507. private _cachedWAng;
  20508. private _cachedProjectionMatrixId;
  20509. private _cachedCoordinatesMode;
  20510. /** @hidden */
  20511. protected _initialSamplingMode: number;
  20512. /** @hidden */
  20513. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20514. private _deleteBuffer;
  20515. protected _format: Nullable<number>;
  20516. private _delayedOnLoad;
  20517. private _delayedOnError;
  20518. private _mimeType?;
  20519. /**
  20520. * Observable triggered once the texture has been loaded.
  20521. */
  20522. onLoadObservable: Observable<Texture>;
  20523. protected _isBlocking: boolean;
  20524. /**
  20525. * Is the texture preventing material to render while loading.
  20526. * If false, a default texture will be used instead of the loading one during the preparation step.
  20527. */
  20528. set isBlocking(value: boolean);
  20529. get isBlocking(): boolean;
  20530. /**
  20531. * Get the current sampling mode associated with the texture.
  20532. */
  20533. get samplingMode(): number;
  20534. /**
  20535. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20536. */
  20537. get invertY(): boolean;
  20538. /**
  20539. * Instantiates a new texture.
  20540. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20541. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20542. * @param url defines the url of the picture to load as a texture
  20543. * @param scene defines the scene or engine the texture will belong to
  20544. * @param noMipmap defines if the texture will require mip maps or not
  20545. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20546. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20547. * @param onLoad defines a callback triggered when the texture has been loaded
  20548. * @param onError defines a callback triggered when an error occurred during the loading session
  20549. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20550. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20551. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20552. * @param mimeType defines an optional mime type information
  20553. */
  20554. 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);
  20555. /**
  20556. * Update the url (and optional buffer) of this texture if url was null during construction.
  20557. * @param url the url of the texture
  20558. * @param buffer the buffer of the texture (defaults to null)
  20559. * @param onLoad callback called when the texture is loaded (defaults to null)
  20560. */
  20561. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20562. /**
  20563. * Finish the loading sequence of a texture flagged as delayed load.
  20564. * @hidden
  20565. */
  20566. delayLoad(): void;
  20567. private _prepareRowForTextureGeneration;
  20568. /**
  20569. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20570. * @returns the transform matrix of the texture.
  20571. */
  20572. getTextureMatrix(uBase?: number): Matrix;
  20573. /**
  20574. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20575. * @returns The reflection texture transform
  20576. */
  20577. getReflectionTextureMatrix(): Matrix;
  20578. /**
  20579. * Clones the texture.
  20580. * @returns the cloned texture
  20581. */
  20582. clone(): Texture;
  20583. /**
  20584. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20585. * @returns The JSON representation of the texture
  20586. */
  20587. serialize(): any;
  20588. /**
  20589. * Get the current class name of the texture useful for serialization or dynamic coding.
  20590. * @returns "Texture"
  20591. */
  20592. getClassName(): string;
  20593. /**
  20594. * Dispose the texture and release its associated resources.
  20595. */
  20596. dispose(): void;
  20597. /**
  20598. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20599. * @param parsedTexture Define the JSON representation of the texture
  20600. * @param scene Define the scene the parsed texture should be instantiated in
  20601. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20602. * @returns The parsed texture if successful
  20603. */
  20604. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20605. /**
  20606. * Creates a texture from its base 64 representation.
  20607. * @param data Define the base64 payload without the data: prefix
  20608. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20609. * @param scene Define the scene the texture should belong to
  20610. * @param noMipmap Forces the texture to not create mip map information if true
  20611. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20612. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20613. * @param onLoad define a callback triggered when the texture has been loaded
  20614. * @param onError define a callback triggered when an error occurred during the loading session
  20615. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20616. * @returns the created texture
  20617. */
  20618. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20619. /**
  20620. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20621. * @param data Define the base64 payload without the data: prefix
  20622. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20623. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20624. * @param scene Define the scene the texture should belong to
  20625. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20626. * @param noMipmap Forces the texture to not create mip map information if true
  20627. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20628. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20629. * @param onLoad define a callback triggered when the texture has been loaded
  20630. * @param onError define a callback triggered when an error occurred during the loading session
  20631. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20632. * @returns the created texture
  20633. */
  20634. 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;
  20635. }
  20636. }
  20637. declare module BABYLON {
  20638. /**
  20639. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20640. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20641. */
  20642. export class PostProcessManager {
  20643. private _scene;
  20644. private _indexBuffer;
  20645. private _vertexBuffers;
  20646. /**
  20647. * Creates a new instance PostProcess
  20648. * @param scene The scene that the post process is associated with.
  20649. */
  20650. constructor(scene: Scene);
  20651. private _prepareBuffers;
  20652. private _buildIndexBuffer;
  20653. /**
  20654. * Rebuilds the vertex buffers of the manager.
  20655. * @hidden
  20656. */
  20657. _rebuild(): void;
  20658. /**
  20659. * Prepares a frame to be run through a post process.
  20660. * @param sourceTexture The input texture to the post procesess. (default: null)
  20661. * @param postProcesses An array of post processes to be run. (default: null)
  20662. * @returns True if the post processes were able to be run.
  20663. * @hidden
  20664. */
  20665. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20666. /**
  20667. * Manually render a set of post processes to a texture.
  20668. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  20669. * @param postProcesses An array of post processes to be run.
  20670. * @param targetTexture The target texture to render to.
  20671. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20672. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20673. * @param lodLevel defines which lod of the texture to render to
  20674. */
  20675. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20676. /**
  20677. * Finalize the result of the output of the postprocesses.
  20678. * @param doNotPresent If true the result will not be displayed to the screen.
  20679. * @param targetTexture The target texture to render to.
  20680. * @param faceIndex The index of the face to bind the target texture to.
  20681. * @param postProcesses The array of post processes to render.
  20682. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20683. * @hidden
  20684. */
  20685. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20686. /**
  20687. * Disposes of the post process manager.
  20688. */
  20689. dispose(): void;
  20690. }
  20691. }
  20692. declare module BABYLON {
  20693. /**
  20694. * This Helps creating a texture that will be created from a camera in your scene.
  20695. * It is basically a dynamic texture that could be used to create special effects for instance.
  20696. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20697. */
  20698. export class RenderTargetTexture extends Texture {
  20699. isCube: boolean;
  20700. /**
  20701. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20702. */
  20703. static readonly REFRESHRATE_RENDER_ONCE: number;
  20704. /**
  20705. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20706. */
  20707. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20708. /**
  20709. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20710. * the central point of your effect and can save a lot of performances.
  20711. */
  20712. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20713. /**
  20714. * Use this predicate to dynamically define the list of mesh you want to render.
  20715. * If set, the renderList property will be overwritten.
  20716. */
  20717. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20718. private _renderList;
  20719. /**
  20720. * Use this list to define the list of mesh you want to render.
  20721. */
  20722. get renderList(): Nullable<Array<AbstractMesh>>;
  20723. set renderList(value: Nullable<Array<AbstractMesh>>);
  20724. /**
  20725. * Use this function to overload the renderList array at rendering time.
  20726. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20727. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20728. * the cube (if the RTT is a cube, else layerOrFace=0).
  20729. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20730. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20731. * hold dummy elements!
  20732. */
  20733. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20734. private _hookArray;
  20735. /**
  20736. * Define if particles should be rendered in your texture.
  20737. */
  20738. renderParticles: boolean;
  20739. /**
  20740. * Define if sprites should be rendered in your texture.
  20741. */
  20742. renderSprites: boolean;
  20743. /**
  20744. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20745. */
  20746. coordinatesMode: number;
  20747. /**
  20748. * Define the camera used to render the texture.
  20749. */
  20750. activeCamera: Nullable<Camera>;
  20751. /**
  20752. * Override the mesh isReady function with your own one.
  20753. */
  20754. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20755. /**
  20756. * Override the render function of the texture with your own one.
  20757. */
  20758. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20759. /**
  20760. * Define if camera post processes should be use while rendering the texture.
  20761. */
  20762. useCameraPostProcesses: boolean;
  20763. /**
  20764. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20765. */
  20766. ignoreCameraViewport: boolean;
  20767. private _postProcessManager;
  20768. private _postProcesses;
  20769. private _resizeObserver;
  20770. /**
  20771. * An event triggered when the texture is unbind.
  20772. */
  20773. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20774. /**
  20775. * An event triggered when the texture is unbind.
  20776. */
  20777. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20778. private _onAfterUnbindObserver;
  20779. /**
  20780. * Set a after unbind callback in the texture.
  20781. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20782. */
  20783. set onAfterUnbind(callback: () => void);
  20784. /**
  20785. * An event triggered before rendering the texture
  20786. */
  20787. onBeforeRenderObservable: Observable<number>;
  20788. private _onBeforeRenderObserver;
  20789. /**
  20790. * Set a before render callback in the texture.
  20791. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20792. */
  20793. set onBeforeRender(callback: (faceIndex: number) => void);
  20794. /**
  20795. * An event triggered after rendering the texture
  20796. */
  20797. onAfterRenderObservable: Observable<number>;
  20798. private _onAfterRenderObserver;
  20799. /**
  20800. * Set a after render callback in the texture.
  20801. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20802. */
  20803. set onAfterRender(callback: (faceIndex: number) => void);
  20804. /**
  20805. * An event triggered after the texture clear
  20806. */
  20807. onClearObservable: Observable<Engine>;
  20808. private _onClearObserver;
  20809. /**
  20810. * Set a clear callback in the texture.
  20811. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20812. */
  20813. set onClear(callback: (Engine: Engine) => void);
  20814. /**
  20815. * An event triggered when the texture is resized.
  20816. */
  20817. onResizeObservable: Observable<RenderTargetTexture>;
  20818. /**
  20819. * Define the clear color of the Render Target if it should be different from the scene.
  20820. */
  20821. clearColor: Color4;
  20822. protected _size: number | {
  20823. width: number;
  20824. height: number;
  20825. layers?: number;
  20826. };
  20827. protected _initialSizeParameter: number | {
  20828. width: number;
  20829. height: number;
  20830. } | {
  20831. ratio: number;
  20832. };
  20833. protected _sizeRatio: Nullable<number>;
  20834. /** @hidden */
  20835. _generateMipMaps: boolean;
  20836. protected _renderingManager: RenderingManager;
  20837. /** @hidden */
  20838. _waitingRenderList: string[];
  20839. protected _doNotChangeAspectRatio: boolean;
  20840. protected _currentRefreshId: number;
  20841. protected _refreshRate: number;
  20842. protected _textureMatrix: Matrix;
  20843. protected _samples: number;
  20844. protected _renderTargetOptions: RenderTargetCreationOptions;
  20845. /**
  20846. * Gets render target creation options that were used.
  20847. */
  20848. get renderTargetOptions(): RenderTargetCreationOptions;
  20849. protected _engine: Engine;
  20850. protected _onRatioRescale(): void;
  20851. /**
  20852. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20853. * It must define where the camera used to render the texture is set
  20854. */
  20855. boundingBoxPosition: Vector3;
  20856. private _boundingBoxSize;
  20857. /**
  20858. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20859. * When defined, the cubemap will switch to local mode
  20860. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20861. * @example https://www.babylonjs-playground.com/#RNASML
  20862. */
  20863. set boundingBoxSize(value: Vector3);
  20864. get boundingBoxSize(): Vector3;
  20865. /**
  20866. * In case the RTT has been created with a depth texture, get the associated
  20867. * depth texture.
  20868. * Otherwise, return null.
  20869. */
  20870. get depthStencilTexture(): Nullable<InternalTexture>;
  20871. /**
  20872. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20873. * or used a shadow, depth texture...
  20874. * @param name The friendly name of the texture
  20875. * @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)
  20876. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20877. * @param generateMipMaps True if mip maps need to be generated after render.
  20878. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20879. * @param type The type of the buffer in the RTT (int, half float, float...)
  20880. * @param isCube True if a cube texture needs to be created
  20881. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20882. * @param generateDepthBuffer True to generate a depth buffer
  20883. * @param generateStencilBuffer True to generate a stencil buffer
  20884. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20885. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20886. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20887. */
  20888. constructor(name: string, size: number | {
  20889. width: number;
  20890. height: number;
  20891. layers?: number;
  20892. } | {
  20893. ratio: number;
  20894. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20895. /**
  20896. * Creates a depth stencil texture.
  20897. * This is only available in WebGL 2 or with the depth texture extension available.
  20898. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20899. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20900. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20901. */
  20902. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20903. private _processSizeParameter;
  20904. /**
  20905. * Define the number of samples to use in case of MSAA.
  20906. * It defaults to one meaning no MSAA has been enabled.
  20907. */
  20908. get samples(): number;
  20909. set samples(value: number);
  20910. /**
  20911. * Resets the refresh counter of the texture and start bak from scratch.
  20912. * Could be useful to regenerate the texture if it is setup to render only once.
  20913. */
  20914. resetRefreshCounter(): void;
  20915. /**
  20916. * Define the refresh rate of the texture or the rendering frequency.
  20917. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20918. */
  20919. get refreshRate(): number;
  20920. set refreshRate(value: number);
  20921. /**
  20922. * Adds a post process to the render target rendering passes.
  20923. * @param postProcess define the post process to add
  20924. */
  20925. addPostProcess(postProcess: PostProcess): void;
  20926. /**
  20927. * Clear all the post processes attached to the render target
  20928. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20929. */
  20930. clearPostProcesses(dispose?: boolean): void;
  20931. /**
  20932. * Remove one of the post process from the list of attached post processes to the texture
  20933. * @param postProcess define the post process to remove from the list
  20934. */
  20935. removePostProcess(postProcess: PostProcess): void;
  20936. /** @hidden */
  20937. _shouldRender(): boolean;
  20938. /**
  20939. * Gets the actual render size of the texture.
  20940. * @returns the width of the render size
  20941. */
  20942. getRenderSize(): number;
  20943. /**
  20944. * Gets the actual render width of the texture.
  20945. * @returns the width of the render size
  20946. */
  20947. getRenderWidth(): number;
  20948. /**
  20949. * Gets the actual render height of the texture.
  20950. * @returns the height of the render size
  20951. */
  20952. getRenderHeight(): number;
  20953. /**
  20954. * Gets the actual number of layers of the texture.
  20955. * @returns the number of layers
  20956. */
  20957. getRenderLayers(): number;
  20958. /**
  20959. * Get if the texture can be rescaled or not.
  20960. */
  20961. get canRescale(): boolean;
  20962. /**
  20963. * Resize the texture using a ratio.
  20964. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20965. */
  20966. scale(ratio: number): void;
  20967. /**
  20968. * Get the texture reflection matrix used to rotate/transform the reflection.
  20969. * @returns the reflection matrix
  20970. */
  20971. getReflectionTextureMatrix(): Matrix;
  20972. /**
  20973. * Resize the texture to a new desired size.
  20974. * Be carrefull as it will recreate all the data in the new texture.
  20975. * @param size Define the new size. It can be:
  20976. * - a number for squared texture,
  20977. * - an object containing { width: number, height: number }
  20978. * - or an object containing a ratio { ratio: number }
  20979. */
  20980. resize(size: number | {
  20981. width: number;
  20982. height: number;
  20983. } | {
  20984. ratio: number;
  20985. }): void;
  20986. private _defaultRenderListPrepared;
  20987. /**
  20988. * Renders all the objects from the render list into the texture.
  20989. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20990. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20991. */
  20992. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20993. private _bestReflectionRenderTargetDimension;
  20994. private _prepareRenderingManager;
  20995. /**
  20996. * @hidden
  20997. * @param faceIndex face index to bind to if this is a cubetexture
  20998. * @param layer defines the index of the texture to bind in the array
  20999. */
  21000. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21001. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21002. private renderToTarget;
  21003. /**
  21004. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21005. * This allowed control for front to back rendering or reversly depending of the special needs.
  21006. *
  21007. * @param renderingGroupId The rendering group id corresponding to its index
  21008. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21009. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21010. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21011. */
  21012. 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;
  21013. /**
  21014. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21015. *
  21016. * @param renderingGroupId The rendering group id corresponding to its index
  21017. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21018. */
  21019. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21020. /**
  21021. * Clones the texture.
  21022. * @returns the cloned texture
  21023. */
  21024. clone(): RenderTargetTexture;
  21025. /**
  21026. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21027. * @returns The JSON representation of the texture
  21028. */
  21029. serialize(): any;
  21030. /**
  21031. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21032. */
  21033. disposeFramebufferObjects(): void;
  21034. /**
  21035. * Dispose the texture and release its associated resources.
  21036. */
  21037. dispose(): void;
  21038. /** @hidden */
  21039. _rebuild(): void;
  21040. /**
  21041. * Clear the info related to rendering groups preventing retention point in material dispose.
  21042. */
  21043. freeRenderingGroups(): void;
  21044. /**
  21045. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21046. * @returns the view count
  21047. */
  21048. getViewCount(): number;
  21049. }
  21050. }
  21051. declare module BABYLON {
  21052. /**
  21053. * Class used to manipulate GUIDs
  21054. */
  21055. export class GUID {
  21056. /**
  21057. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21058. * Be aware Math.random() could cause collisions, but:
  21059. * "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"
  21060. * @returns a pseudo random id
  21061. */
  21062. static RandomId(): string;
  21063. }
  21064. }
  21065. declare module BABYLON {
  21066. /**
  21067. * Options to be used when creating a shadow depth material
  21068. */
  21069. export interface IIOptionShadowDepthMaterial {
  21070. /** Variables in the vertex shader code that need to have their names remapped.
  21071. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21072. * "var_name" should be either: worldPos or vNormalW
  21073. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21074. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21075. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21076. */
  21077. remappedVariables?: string[];
  21078. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21079. standalone?: boolean;
  21080. }
  21081. /**
  21082. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21083. */
  21084. export class ShadowDepthWrapper {
  21085. private _scene;
  21086. private _options?;
  21087. private _baseMaterial;
  21088. private _onEffectCreatedObserver;
  21089. private _subMeshToEffect;
  21090. private _subMeshToDepthEffect;
  21091. private _meshes;
  21092. /** @hidden */
  21093. _matriceNames: any;
  21094. /** Gets the standalone status of the wrapper */
  21095. get standalone(): boolean;
  21096. /** Gets the base material the wrapper is built upon */
  21097. get baseMaterial(): Material;
  21098. /**
  21099. * Instantiate a new shadow depth wrapper.
  21100. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21101. * generate the shadow depth map. For more information, please refer to the documentation:
  21102. * https://doc.babylonjs.com/babylon101/shadows
  21103. * @param baseMaterial Material to wrap
  21104. * @param scene Define the scene the material belongs to
  21105. * @param options Options used to create the wrapper
  21106. */
  21107. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21108. /**
  21109. * Gets the effect to use to generate the depth map
  21110. * @param subMesh subMesh to get the effect for
  21111. * @param shadowGenerator shadow generator to get the effect for
  21112. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21113. */
  21114. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21115. /**
  21116. * Specifies that the submesh is ready to be used for depth rendering
  21117. * @param subMesh submesh to check
  21118. * @param defines the list of defines to take into account when checking the effect
  21119. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21120. * @param useInstances specifies that instances should be used
  21121. * @returns a boolean indicating that the submesh is ready or not
  21122. */
  21123. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21124. /**
  21125. * Disposes the resources
  21126. */
  21127. dispose(): void;
  21128. private _makeEffect;
  21129. }
  21130. }
  21131. declare module BABYLON {
  21132. /**
  21133. * Options for compiling materials.
  21134. */
  21135. export interface IMaterialCompilationOptions {
  21136. /**
  21137. * Defines whether clip planes are enabled.
  21138. */
  21139. clipPlane: boolean;
  21140. /**
  21141. * Defines whether instances are enabled.
  21142. */
  21143. useInstances: boolean;
  21144. }
  21145. /**
  21146. * Base class for the main features of a material in Babylon.js
  21147. */
  21148. export class Material implements IAnimatable {
  21149. /**
  21150. * Returns the triangle fill mode
  21151. */
  21152. static readonly TriangleFillMode: number;
  21153. /**
  21154. * Returns the wireframe mode
  21155. */
  21156. static readonly WireFrameFillMode: number;
  21157. /**
  21158. * Returns the point fill mode
  21159. */
  21160. static readonly PointFillMode: number;
  21161. /**
  21162. * Returns the point list draw mode
  21163. */
  21164. static readonly PointListDrawMode: number;
  21165. /**
  21166. * Returns the line list draw mode
  21167. */
  21168. static readonly LineListDrawMode: number;
  21169. /**
  21170. * Returns the line loop draw mode
  21171. */
  21172. static readonly LineLoopDrawMode: number;
  21173. /**
  21174. * Returns the line strip draw mode
  21175. */
  21176. static readonly LineStripDrawMode: number;
  21177. /**
  21178. * Returns the triangle strip draw mode
  21179. */
  21180. static readonly TriangleStripDrawMode: number;
  21181. /**
  21182. * Returns the triangle fan draw mode
  21183. */
  21184. static readonly TriangleFanDrawMode: number;
  21185. /**
  21186. * Stores the clock-wise side orientation
  21187. */
  21188. static readonly ClockWiseSideOrientation: number;
  21189. /**
  21190. * Stores the counter clock-wise side orientation
  21191. */
  21192. static readonly CounterClockWiseSideOrientation: number;
  21193. /**
  21194. * The dirty texture flag value
  21195. */
  21196. static readonly TextureDirtyFlag: number;
  21197. /**
  21198. * The dirty light flag value
  21199. */
  21200. static readonly LightDirtyFlag: number;
  21201. /**
  21202. * The dirty fresnel flag value
  21203. */
  21204. static readonly FresnelDirtyFlag: number;
  21205. /**
  21206. * The dirty attribute flag value
  21207. */
  21208. static readonly AttributesDirtyFlag: number;
  21209. /**
  21210. * The dirty misc flag value
  21211. */
  21212. static readonly MiscDirtyFlag: number;
  21213. /**
  21214. * The all dirty flag value
  21215. */
  21216. static readonly AllDirtyFlag: number;
  21217. /**
  21218. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21219. */
  21220. static readonly MATERIAL_OPAQUE: number;
  21221. /**
  21222. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21223. */
  21224. static readonly MATERIAL_ALPHATEST: number;
  21225. /**
  21226. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21227. */
  21228. static readonly MATERIAL_ALPHABLEND: number;
  21229. /**
  21230. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21231. * They are also discarded below the alpha cutoff threshold to improve performances.
  21232. */
  21233. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21234. /**
  21235. * Custom callback helping to override the default shader used in the material.
  21236. */
  21237. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21238. /**
  21239. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21240. */
  21241. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21242. /**
  21243. * The ID of the material
  21244. */
  21245. id: string;
  21246. /**
  21247. * Gets or sets the unique id of the material
  21248. */
  21249. uniqueId: number;
  21250. /**
  21251. * The name of the material
  21252. */
  21253. name: string;
  21254. /**
  21255. * Gets or sets user defined metadata
  21256. */
  21257. metadata: any;
  21258. /**
  21259. * For internal use only. Please do not use.
  21260. */
  21261. reservedDataStore: any;
  21262. /**
  21263. * Specifies if the ready state should be checked on each call
  21264. */
  21265. checkReadyOnEveryCall: boolean;
  21266. /**
  21267. * Specifies if the ready state should be checked once
  21268. */
  21269. checkReadyOnlyOnce: boolean;
  21270. /**
  21271. * The state of the material
  21272. */
  21273. state: string;
  21274. /**
  21275. * The alpha value of the material
  21276. */
  21277. protected _alpha: number;
  21278. /**
  21279. * List of inspectable custom properties (used by the Inspector)
  21280. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21281. */
  21282. inspectableCustomProperties: IInspectable[];
  21283. /**
  21284. * Sets the alpha value of the material
  21285. */
  21286. set alpha(value: number);
  21287. /**
  21288. * Gets the alpha value of the material
  21289. */
  21290. get alpha(): number;
  21291. /**
  21292. * Specifies if back face culling is enabled
  21293. */
  21294. protected _backFaceCulling: boolean;
  21295. /**
  21296. * Sets the back-face culling state
  21297. */
  21298. set backFaceCulling(value: boolean);
  21299. /**
  21300. * Gets the back-face culling state
  21301. */
  21302. get backFaceCulling(): boolean;
  21303. /**
  21304. * Stores the value for side orientation
  21305. */
  21306. sideOrientation: number;
  21307. /**
  21308. * Callback triggered when the material is compiled
  21309. */
  21310. onCompiled: Nullable<(effect: Effect) => void>;
  21311. /**
  21312. * Callback triggered when an error occurs
  21313. */
  21314. onError: Nullable<(effect: Effect, errors: string) => void>;
  21315. /**
  21316. * Callback triggered to get the render target textures
  21317. */
  21318. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21319. /**
  21320. * Gets a boolean indicating that current material needs to register RTT
  21321. */
  21322. get hasRenderTargetTextures(): boolean;
  21323. /**
  21324. * Specifies if the material should be serialized
  21325. */
  21326. doNotSerialize: boolean;
  21327. /**
  21328. * @hidden
  21329. */
  21330. _storeEffectOnSubMeshes: boolean;
  21331. /**
  21332. * Stores the animations for the material
  21333. */
  21334. animations: Nullable<Array<Animation>>;
  21335. /**
  21336. * An event triggered when the material is disposed
  21337. */
  21338. onDisposeObservable: Observable<Material>;
  21339. /**
  21340. * An observer which watches for dispose events
  21341. */
  21342. private _onDisposeObserver;
  21343. private _onUnBindObservable;
  21344. /**
  21345. * Called during a dispose event
  21346. */
  21347. set onDispose(callback: () => void);
  21348. private _onBindObservable;
  21349. /**
  21350. * An event triggered when the material is bound
  21351. */
  21352. get onBindObservable(): Observable<AbstractMesh>;
  21353. /**
  21354. * An observer which watches for bind events
  21355. */
  21356. private _onBindObserver;
  21357. /**
  21358. * Called during a bind event
  21359. */
  21360. set onBind(callback: (Mesh: AbstractMesh) => void);
  21361. /**
  21362. * An event triggered when the material is unbound
  21363. */
  21364. get onUnBindObservable(): Observable<Material>;
  21365. protected _onEffectCreatedObservable: Nullable<Observable<{
  21366. effect: Effect;
  21367. subMesh: Nullable<SubMesh>;
  21368. }>>;
  21369. /**
  21370. * An event triggered when the effect is (re)created
  21371. */
  21372. get onEffectCreatedObservable(): Observable<{
  21373. effect: Effect;
  21374. subMesh: Nullable<SubMesh>;
  21375. }>;
  21376. /**
  21377. * Stores the value of the alpha mode
  21378. */
  21379. private _alphaMode;
  21380. /**
  21381. * Sets the value of the alpha mode.
  21382. *
  21383. * | Value | Type | Description |
  21384. * | --- | --- | --- |
  21385. * | 0 | ALPHA_DISABLE | |
  21386. * | 1 | ALPHA_ADD | |
  21387. * | 2 | ALPHA_COMBINE | |
  21388. * | 3 | ALPHA_SUBTRACT | |
  21389. * | 4 | ALPHA_MULTIPLY | |
  21390. * | 5 | ALPHA_MAXIMIZED | |
  21391. * | 6 | ALPHA_ONEONE | |
  21392. * | 7 | ALPHA_PREMULTIPLIED | |
  21393. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21394. * | 9 | ALPHA_INTERPOLATE | |
  21395. * | 10 | ALPHA_SCREENMODE | |
  21396. *
  21397. */
  21398. set alphaMode(value: number);
  21399. /**
  21400. * Gets the value of the alpha mode
  21401. */
  21402. get alphaMode(): number;
  21403. /**
  21404. * Stores the state of the need depth pre-pass value
  21405. */
  21406. private _needDepthPrePass;
  21407. /**
  21408. * Sets the need depth pre-pass value
  21409. */
  21410. set needDepthPrePass(value: boolean);
  21411. /**
  21412. * Gets the depth pre-pass value
  21413. */
  21414. get needDepthPrePass(): boolean;
  21415. /**
  21416. * Specifies if depth writing should be disabled
  21417. */
  21418. disableDepthWrite: boolean;
  21419. /**
  21420. * Specifies if color writing should be disabled
  21421. */
  21422. disableColorWrite: boolean;
  21423. /**
  21424. * Specifies if depth writing should be forced
  21425. */
  21426. forceDepthWrite: boolean;
  21427. /**
  21428. * Specifies the depth function that should be used. 0 means the default engine function
  21429. */
  21430. depthFunction: number;
  21431. /**
  21432. * Specifies if there should be a separate pass for culling
  21433. */
  21434. separateCullingPass: boolean;
  21435. /**
  21436. * Stores the state specifing if fog should be enabled
  21437. */
  21438. private _fogEnabled;
  21439. /**
  21440. * Sets the state for enabling fog
  21441. */
  21442. set fogEnabled(value: boolean);
  21443. /**
  21444. * Gets the value of the fog enabled state
  21445. */
  21446. get fogEnabled(): boolean;
  21447. /**
  21448. * Stores the size of points
  21449. */
  21450. pointSize: number;
  21451. /**
  21452. * Stores the z offset value
  21453. */
  21454. zOffset: number;
  21455. get wireframe(): boolean;
  21456. /**
  21457. * Sets the state of wireframe mode
  21458. */
  21459. set wireframe(value: boolean);
  21460. /**
  21461. * Gets the value specifying if point clouds are enabled
  21462. */
  21463. get pointsCloud(): boolean;
  21464. /**
  21465. * Sets the state of point cloud mode
  21466. */
  21467. set pointsCloud(value: boolean);
  21468. /**
  21469. * Gets the material fill mode
  21470. */
  21471. get fillMode(): number;
  21472. /**
  21473. * Sets the material fill mode
  21474. */
  21475. set fillMode(value: number);
  21476. /**
  21477. * @hidden
  21478. * Stores the effects for the material
  21479. */
  21480. _effect: Nullable<Effect>;
  21481. /**
  21482. * Specifies if uniform buffers should be used
  21483. */
  21484. private _useUBO;
  21485. /**
  21486. * Stores a reference to the scene
  21487. */
  21488. private _scene;
  21489. /**
  21490. * Stores the fill mode state
  21491. */
  21492. private _fillMode;
  21493. /**
  21494. * Specifies if the depth write state should be cached
  21495. */
  21496. private _cachedDepthWriteState;
  21497. /**
  21498. * Specifies if the color write state should be cached
  21499. */
  21500. private _cachedColorWriteState;
  21501. /**
  21502. * Specifies if the depth function state should be cached
  21503. */
  21504. private _cachedDepthFunctionState;
  21505. /**
  21506. * Stores the uniform buffer
  21507. */
  21508. protected _uniformBuffer: UniformBuffer;
  21509. /** @hidden */
  21510. _indexInSceneMaterialArray: number;
  21511. /** @hidden */
  21512. meshMap: Nullable<{
  21513. [id: string]: AbstractMesh | undefined;
  21514. }>;
  21515. /**
  21516. * Creates a material instance
  21517. * @param name defines the name of the material
  21518. * @param scene defines the scene to reference
  21519. * @param doNotAdd specifies if the material should be added to the scene
  21520. */
  21521. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21522. /**
  21523. * Returns a string representation of the current material
  21524. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21525. * @returns a string with material information
  21526. */
  21527. toString(fullDetails?: boolean): string;
  21528. /**
  21529. * Gets the class name of the material
  21530. * @returns a string with the class name of the material
  21531. */
  21532. getClassName(): string;
  21533. /**
  21534. * Specifies if updates for the material been locked
  21535. */
  21536. get isFrozen(): boolean;
  21537. /**
  21538. * Locks updates for the material
  21539. */
  21540. freeze(): void;
  21541. /**
  21542. * Unlocks updates for the material
  21543. */
  21544. unfreeze(): void;
  21545. /**
  21546. * Specifies if the material is ready to be used
  21547. * @param mesh defines the mesh to check
  21548. * @param useInstances specifies if instances should be used
  21549. * @returns a boolean indicating if the material is ready to be used
  21550. */
  21551. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21552. /**
  21553. * Specifies that the submesh is ready to be used
  21554. * @param mesh defines the mesh to check
  21555. * @param subMesh defines which submesh to check
  21556. * @param useInstances specifies that instances should be used
  21557. * @returns a boolean indicating that the submesh is ready or not
  21558. */
  21559. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21560. /**
  21561. * Returns the material effect
  21562. * @returns the effect associated with the material
  21563. */
  21564. getEffect(): Nullable<Effect>;
  21565. /**
  21566. * Returns the current scene
  21567. * @returns a Scene
  21568. */
  21569. getScene(): Scene;
  21570. /**
  21571. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21572. */
  21573. protected _forceAlphaTest: boolean;
  21574. /**
  21575. * The transparency mode of the material.
  21576. */
  21577. protected _transparencyMode: Nullable<number>;
  21578. /**
  21579. * Gets the current transparency mode.
  21580. */
  21581. get transparencyMode(): Nullable<number>;
  21582. /**
  21583. * Sets the transparency mode of the material.
  21584. *
  21585. * | Value | Type | Description |
  21586. * | ----- | ----------------------------------- | ----------- |
  21587. * | 0 | OPAQUE | |
  21588. * | 1 | ALPHATEST | |
  21589. * | 2 | ALPHABLEND | |
  21590. * | 3 | ALPHATESTANDBLEND | |
  21591. *
  21592. */
  21593. set transparencyMode(value: Nullable<number>);
  21594. /**
  21595. * Returns true if alpha blending should be disabled.
  21596. */
  21597. protected get _disableAlphaBlending(): boolean;
  21598. /**
  21599. * Specifies whether or not this material should be rendered in alpha blend mode.
  21600. * @returns a boolean specifying if alpha blending is needed
  21601. */
  21602. needAlphaBlending(): boolean;
  21603. /**
  21604. * Specifies if the mesh will require alpha blending
  21605. * @param mesh defines the mesh to check
  21606. * @returns a boolean specifying if alpha blending is needed for the mesh
  21607. */
  21608. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21609. /**
  21610. * Specifies whether or not this material should be rendered in alpha test mode.
  21611. * @returns a boolean specifying if an alpha test is needed.
  21612. */
  21613. needAlphaTesting(): boolean;
  21614. /**
  21615. * Specifies if material alpha testing should be turned on for the mesh
  21616. * @param mesh defines the mesh to check
  21617. */
  21618. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21619. /**
  21620. * Gets the texture used for the alpha test
  21621. * @returns the texture to use for alpha testing
  21622. */
  21623. getAlphaTestTexture(): Nullable<BaseTexture>;
  21624. /**
  21625. * Marks the material to indicate that it needs to be re-calculated
  21626. */
  21627. markDirty(): void;
  21628. /** @hidden */
  21629. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21630. /**
  21631. * Binds the material to the mesh
  21632. * @param world defines the world transformation matrix
  21633. * @param mesh defines the mesh to bind the material to
  21634. */
  21635. bind(world: Matrix, mesh?: Mesh): void;
  21636. /**
  21637. * Binds the submesh to the material
  21638. * @param world defines the world transformation matrix
  21639. * @param mesh defines the mesh containing the submesh
  21640. * @param subMesh defines the submesh to bind the material to
  21641. */
  21642. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21643. /**
  21644. * Binds the world matrix to the material
  21645. * @param world defines the world transformation matrix
  21646. */
  21647. bindOnlyWorldMatrix(world: Matrix): void;
  21648. /**
  21649. * Binds the scene's uniform buffer to the effect.
  21650. * @param effect defines the effect to bind to the scene uniform buffer
  21651. * @param sceneUbo defines the uniform buffer storing scene data
  21652. */
  21653. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21654. /**
  21655. * Binds the view matrix to the effect
  21656. * @param effect defines the effect to bind the view matrix to
  21657. */
  21658. bindView(effect: Effect): void;
  21659. /**
  21660. * Binds the view projection matrix to the effect
  21661. * @param effect defines the effect to bind the view projection matrix to
  21662. */
  21663. bindViewProjection(effect: Effect): void;
  21664. /**
  21665. * Processes to execute after binding the material to a mesh
  21666. * @param mesh defines the rendered mesh
  21667. */
  21668. protected _afterBind(mesh?: Mesh): void;
  21669. /**
  21670. * Unbinds the material from the mesh
  21671. */
  21672. unbind(): void;
  21673. /**
  21674. * Gets the active textures from the material
  21675. * @returns an array of textures
  21676. */
  21677. getActiveTextures(): BaseTexture[];
  21678. /**
  21679. * Specifies if the material uses a texture
  21680. * @param texture defines the texture to check against the material
  21681. * @returns a boolean specifying if the material uses the texture
  21682. */
  21683. hasTexture(texture: BaseTexture): boolean;
  21684. /**
  21685. * Makes a duplicate of the material, and gives it a new name
  21686. * @param name defines the new name for the duplicated material
  21687. * @returns the cloned material
  21688. */
  21689. clone(name: string): Nullable<Material>;
  21690. /**
  21691. * Gets the meshes bound to the material
  21692. * @returns an array of meshes bound to the material
  21693. */
  21694. getBindedMeshes(): AbstractMesh[];
  21695. /**
  21696. * Force shader compilation
  21697. * @param mesh defines the mesh associated with this material
  21698. * @param onCompiled defines a function to execute once the material is compiled
  21699. * @param options defines the options to configure the compilation
  21700. * @param onError defines a function to execute if the material fails compiling
  21701. */
  21702. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21703. /**
  21704. * Force shader compilation
  21705. * @param mesh defines the mesh that will use this material
  21706. * @param options defines additional options for compiling the shaders
  21707. * @returns a promise that resolves when the compilation completes
  21708. */
  21709. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21710. private static readonly _AllDirtyCallBack;
  21711. private static readonly _ImageProcessingDirtyCallBack;
  21712. private static readonly _TextureDirtyCallBack;
  21713. private static readonly _FresnelDirtyCallBack;
  21714. private static readonly _MiscDirtyCallBack;
  21715. private static readonly _LightsDirtyCallBack;
  21716. private static readonly _AttributeDirtyCallBack;
  21717. private static _FresnelAndMiscDirtyCallBack;
  21718. private static _TextureAndMiscDirtyCallBack;
  21719. private static readonly _DirtyCallbackArray;
  21720. private static readonly _RunDirtyCallBacks;
  21721. /**
  21722. * Marks a define in the material to indicate that it needs to be re-computed
  21723. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21724. */
  21725. markAsDirty(flag: number): void;
  21726. /**
  21727. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21728. * @param func defines a function which checks material defines against the submeshes
  21729. */
  21730. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21731. /**
  21732. * Indicates that we need to re-calculated for all submeshes
  21733. */
  21734. protected _markAllSubMeshesAsAllDirty(): void;
  21735. /**
  21736. * Indicates that image processing needs to be re-calculated for all submeshes
  21737. */
  21738. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21739. /**
  21740. * Indicates that textures need to be re-calculated for all submeshes
  21741. */
  21742. protected _markAllSubMeshesAsTexturesDirty(): void;
  21743. /**
  21744. * Indicates that fresnel needs to be re-calculated for all submeshes
  21745. */
  21746. protected _markAllSubMeshesAsFresnelDirty(): void;
  21747. /**
  21748. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21749. */
  21750. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21751. /**
  21752. * Indicates that lights need to be re-calculated for all submeshes
  21753. */
  21754. protected _markAllSubMeshesAsLightsDirty(): void;
  21755. /**
  21756. * Indicates that attributes need to be re-calculated for all submeshes
  21757. */
  21758. protected _markAllSubMeshesAsAttributesDirty(): void;
  21759. /**
  21760. * Indicates that misc needs to be re-calculated for all submeshes
  21761. */
  21762. protected _markAllSubMeshesAsMiscDirty(): void;
  21763. /**
  21764. * Indicates that textures and misc need to be re-calculated for all submeshes
  21765. */
  21766. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21767. /**
  21768. * Disposes the material
  21769. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21770. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21771. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21772. */
  21773. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21774. /** @hidden */
  21775. private releaseVertexArrayObject;
  21776. /**
  21777. * Serializes this material
  21778. * @returns the serialized material object
  21779. */
  21780. serialize(): any;
  21781. /**
  21782. * Creates a material from parsed material data
  21783. * @param parsedMaterial defines parsed material data
  21784. * @param scene defines the hosting scene
  21785. * @param rootUrl defines the root URL to use to load textures
  21786. * @returns a new material
  21787. */
  21788. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21789. }
  21790. }
  21791. declare module BABYLON {
  21792. /**
  21793. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21794. * separate meshes. This can be use to improve performances.
  21795. * @see http://doc.babylonjs.com/how_to/multi_materials
  21796. */
  21797. export class MultiMaterial extends Material {
  21798. private _subMaterials;
  21799. /**
  21800. * Gets or Sets the list of Materials used within the multi material.
  21801. * They need to be ordered according to the submeshes order in the associated mesh
  21802. */
  21803. get subMaterials(): Nullable<Material>[];
  21804. set subMaterials(value: Nullable<Material>[]);
  21805. /**
  21806. * Function used to align with Node.getChildren()
  21807. * @returns the list of Materials used within the multi material
  21808. */
  21809. getChildren(): Nullable<Material>[];
  21810. /**
  21811. * Instantiates a new Multi Material
  21812. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21813. * separate meshes. This can be use to improve performances.
  21814. * @see http://doc.babylonjs.com/how_to/multi_materials
  21815. * @param name Define the name in the scene
  21816. * @param scene Define the scene the material belongs to
  21817. */
  21818. constructor(name: string, scene: Scene);
  21819. private _hookArray;
  21820. /**
  21821. * Get one of the submaterial by its index in the submaterials array
  21822. * @param index The index to look the sub material at
  21823. * @returns The Material if the index has been defined
  21824. */
  21825. getSubMaterial(index: number): Nullable<Material>;
  21826. /**
  21827. * Get the list of active textures for the whole sub materials list.
  21828. * @returns All the textures that will be used during the rendering
  21829. */
  21830. getActiveTextures(): BaseTexture[];
  21831. /**
  21832. * Gets the current class name of the material e.g. "MultiMaterial"
  21833. * Mainly use in serialization.
  21834. * @returns the class name
  21835. */
  21836. getClassName(): string;
  21837. /**
  21838. * Checks if the material is ready to render the requested sub mesh
  21839. * @param mesh Define the mesh the submesh belongs to
  21840. * @param subMesh Define the sub mesh to look readyness for
  21841. * @param useInstances Define whether or not the material is used with instances
  21842. * @returns true if ready, otherwise false
  21843. */
  21844. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21845. /**
  21846. * Clones the current material and its related sub materials
  21847. * @param name Define the name of the newly cloned material
  21848. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21849. * @returns the cloned material
  21850. */
  21851. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21852. /**
  21853. * Serializes the materials into a JSON representation.
  21854. * @returns the JSON representation
  21855. */
  21856. serialize(): any;
  21857. /**
  21858. * Dispose the material and release its associated resources
  21859. * @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)
  21860. * @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)
  21861. * @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)
  21862. */
  21863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21864. /**
  21865. * Creates a MultiMaterial from parsed MultiMaterial data.
  21866. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21867. * @param scene defines the hosting scene
  21868. * @returns a new MultiMaterial
  21869. */
  21870. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21871. }
  21872. }
  21873. declare module BABYLON {
  21874. /**
  21875. * Base class for submeshes
  21876. */
  21877. export class BaseSubMesh {
  21878. /** @hidden */
  21879. _materialDefines: Nullable<MaterialDefines>;
  21880. /** @hidden */
  21881. _materialEffect: Nullable<Effect>;
  21882. /** @hidden */
  21883. _effectOverride: Nullable<Effect>;
  21884. /**
  21885. * Gets material defines used by the effect associated to the sub mesh
  21886. */
  21887. get materialDefines(): Nullable<MaterialDefines>;
  21888. /**
  21889. * Sets material defines used by the effect associated to the sub mesh
  21890. */
  21891. set materialDefines(defines: Nullable<MaterialDefines>);
  21892. /**
  21893. * Gets associated effect
  21894. */
  21895. get effect(): Nullable<Effect>;
  21896. /**
  21897. * Sets associated effect (effect used to render this submesh)
  21898. * @param effect defines the effect to associate with
  21899. * @param defines defines the set of defines used to compile this effect
  21900. */
  21901. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21902. }
  21903. /**
  21904. * Defines a subdivision inside a mesh
  21905. */
  21906. export class SubMesh extends BaseSubMesh implements ICullable {
  21907. /** the material index to use */
  21908. materialIndex: number;
  21909. /** vertex index start */
  21910. verticesStart: number;
  21911. /** vertices count */
  21912. verticesCount: number;
  21913. /** index start */
  21914. indexStart: number;
  21915. /** indices count */
  21916. indexCount: number;
  21917. /** @hidden */
  21918. _linesIndexCount: number;
  21919. private _mesh;
  21920. private _renderingMesh;
  21921. private _boundingInfo;
  21922. private _linesIndexBuffer;
  21923. /** @hidden */
  21924. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21925. /** @hidden */
  21926. _trianglePlanes: Plane[];
  21927. /** @hidden */
  21928. _lastColliderTransformMatrix: Nullable<Matrix>;
  21929. /** @hidden */
  21930. _renderId: number;
  21931. /** @hidden */
  21932. _alphaIndex: number;
  21933. /** @hidden */
  21934. _distanceToCamera: number;
  21935. /** @hidden */
  21936. _id: number;
  21937. private _currentMaterial;
  21938. /**
  21939. * Add a new submesh to a mesh
  21940. * @param materialIndex defines the material index to use
  21941. * @param verticesStart defines vertex index start
  21942. * @param verticesCount defines vertices count
  21943. * @param indexStart defines index start
  21944. * @param indexCount defines indices count
  21945. * @param mesh defines the parent mesh
  21946. * @param renderingMesh defines an optional rendering mesh
  21947. * @param createBoundingBox defines if bounding box should be created for this submesh
  21948. * @returns the new submesh
  21949. */
  21950. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21951. /**
  21952. * Creates a new submesh
  21953. * @param materialIndex defines the material index to use
  21954. * @param verticesStart defines vertex index start
  21955. * @param verticesCount defines vertices count
  21956. * @param indexStart defines index start
  21957. * @param indexCount defines indices count
  21958. * @param mesh defines the parent mesh
  21959. * @param renderingMesh defines an optional rendering mesh
  21960. * @param createBoundingBox defines if bounding box should be created for this submesh
  21961. */
  21962. constructor(
  21963. /** the material index to use */
  21964. materialIndex: number,
  21965. /** vertex index start */
  21966. verticesStart: number,
  21967. /** vertices count */
  21968. verticesCount: number,
  21969. /** index start */
  21970. indexStart: number,
  21971. /** indices count */
  21972. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21973. /**
  21974. * Returns true if this submesh covers the entire parent mesh
  21975. * @ignorenaming
  21976. */
  21977. get IsGlobal(): boolean;
  21978. /**
  21979. * Returns the submesh BoudingInfo object
  21980. * @returns current bounding info (or mesh's one if the submesh is global)
  21981. */
  21982. getBoundingInfo(): BoundingInfo;
  21983. /**
  21984. * Sets the submesh BoundingInfo
  21985. * @param boundingInfo defines the new bounding info to use
  21986. * @returns the SubMesh
  21987. */
  21988. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21989. /**
  21990. * Returns the mesh of the current submesh
  21991. * @return the parent mesh
  21992. */
  21993. getMesh(): AbstractMesh;
  21994. /**
  21995. * Returns the rendering mesh of the submesh
  21996. * @returns the rendering mesh (could be different from parent mesh)
  21997. */
  21998. getRenderingMesh(): Mesh;
  21999. /**
  22000. * Returns the submesh material
  22001. * @returns null or the current material
  22002. */
  22003. getMaterial(): Nullable<Material>;
  22004. /**
  22005. * Sets a new updated BoundingInfo object to the submesh
  22006. * @param data defines an optional position array to use to determine the bounding info
  22007. * @returns the SubMesh
  22008. */
  22009. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22010. /** @hidden */
  22011. _checkCollision(collider: Collider): boolean;
  22012. /**
  22013. * Updates the submesh BoundingInfo
  22014. * @param world defines the world matrix to use to update the bounding info
  22015. * @returns the submesh
  22016. */
  22017. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22018. /**
  22019. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22020. * @param frustumPlanes defines the frustum planes
  22021. * @returns true if the submesh is intersecting with the frustum
  22022. */
  22023. isInFrustum(frustumPlanes: Plane[]): boolean;
  22024. /**
  22025. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22026. * @param frustumPlanes defines the frustum planes
  22027. * @returns true if the submesh is inside the frustum
  22028. */
  22029. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22030. /**
  22031. * Renders the submesh
  22032. * @param enableAlphaMode defines if alpha needs to be used
  22033. * @returns the submesh
  22034. */
  22035. render(enableAlphaMode: boolean): SubMesh;
  22036. /**
  22037. * @hidden
  22038. */
  22039. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22040. /**
  22041. * Checks if the submesh intersects with a ray
  22042. * @param ray defines the ray to test
  22043. * @returns true is the passed ray intersects the submesh bounding box
  22044. */
  22045. canIntersects(ray: Ray): boolean;
  22046. /**
  22047. * Intersects current submesh with a ray
  22048. * @param ray defines the ray to test
  22049. * @param positions defines mesh's positions array
  22050. * @param indices defines mesh's indices array
  22051. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22053. * @returns intersection info or null if no intersection
  22054. */
  22055. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22056. /** @hidden */
  22057. private _intersectLines;
  22058. /** @hidden */
  22059. private _intersectUnIndexedLines;
  22060. /** @hidden */
  22061. private _intersectTriangles;
  22062. /** @hidden */
  22063. private _intersectUnIndexedTriangles;
  22064. /** @hidden */
  22065. _rebuild(): void;
  22066. /**
  22067. * Creates a new submesh from the passed mesh
  22068. * @param newMesh defines the new hosting mesh
  22069. * @param newRenderingMesh defines an optional rendering mesh
  22070. * @returns the new submesh
  22071. */
  22072. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22073. /**
  22074. * Release associated resources
  22075. */
  22076. dispose(): void;
  22077. /**
  22078. * Gets the class name
  22079. * @returns the string "SubMesh".
  22080. */
  22081. getClassName(): string;
  22082. /**
  22083. * Creates a new submesh from indices data
  22084. * @param materialIndex the index of the main mesh material
  22085. * @param startIndex the index where to start the copy in the mesh indices array
  22086. * @param indexCount the number of indices to copy then from the startIndex
  22087. * @param mesh the main mesh to create the submesh from
  22088. * @param renderingMesh the optional rendering mesh
  22089. * @returns a new submesh
  22090. */
  22091. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22092. }
  22093. }
  22094. declare module BABYLON {
  22095. /**
  22096. * Class used to represent data loading progression
  22097. */
  22098. export class SceneLoaderFlags {
  22099. private static _ForceFullSceneLoadingForIncremental;
  22100. private static _ShowLoadingScreen;
  22101. private static _CleanBoneMatrixWeights;
  22102. private static _loggingLevel;
  22103. /**
  22104. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22105. */
  22106. static get ForceFullSceneLoadingForIncremental(): boolean;
  22107. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22108. /**
  22109. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22110. */
  22111. static get ShowLoadingScreen(): boolean;
  22112. static set ShowLoadingScreen(value: boolean);
  22113. /**
  22114. * Defines the current logging level (while loading the scene)
  22115. * @ignorenaming
  22116. */
  22117. static get loggingLevel(): number;
  22118. static set loggingLevel(value: number);
  22119. /**
  22120. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22121. */
  22122. static get CleanBoneMatrixWeights(): boolean;
  22123. static set CleanBoneMatrixWeights(value: boolean);
  22124. }
  22125. }
  22126. declare module BABYLON {
  22127. /**
  22128. * Class used to store geometry data (vertex buffers + index buffer)
  22129. */
  22130. export class Geometry implements IGetSetVerticesData {
  22131. /**
  22132. * Gets or sets the ID of the geometry
  22133. */
  22134. id: string;
  22135. /**
  22136. * Gets or sets the unique ID of the geometry
  22137. */
  22138. uniqueId: number;
  22139. /**
  22140. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22141. */
  22142. delayLoadState: number;
  22143. /**
  22144. * Gets the file containing the data to load when running in delay load state
  22145. */
  22146. delayLoadingFile: Nullable<string>;
  22147. /**
  22148. * Callback called when the geometry is updated
  22149. */
  22150. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22151. private _scene;
  22152. private _engine;
  22153. private _meshes;
  22154. private _totalVertices;
  22155. /** @hidden */
  22156. _indices: IndicesArray;
  22157. /** @hidden */
  22158. _vertexBuffers: {
  22159. [key: string]: VertexBuffer;
  22160. };
  22161. private _isDisposed;
  22162. private _extend;
  22163. private _boundingBias;
  22164. /** @hidden */
  22165. _delayInfo: Array<string>;
  22166. private _indexBuffer;
  22167. private _indexBufferIsUpdatable;
  22168. /** @hidden */
  22169. _boundingInfo: Nullable<BoundingInfo>;
  22170. /** @hidden */
  22171. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22172. /** @hidden */
  22173. _softwareSkinningFrameId: number;
  22174. private _vertexArrayObjects;
  22175. private _updatable;
  22176. /** @hidden */
  22177. _positions: Nullable<Vector3[]>;
  22178. /**
  22179. * 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
  22180. */
  22181. get boundingBias(): Vector2;
  22182. /**
  22183. * 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
  22184. */
  22185. set boundingBias(value: Vector2);
  22186. /**
  22187. * Static function used to attach a new empty geometry to a mesh
  22188. * @param mesh defines the mesh to attach the geometry to
  22189. * @returns the new Geometry
  22190. */
  22191. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22192. /** Get the list of meshes using this geometry */
  22193. get meshes(): Mesh[];
  22194. /**
  22195. * Creates a new geometry
  22196. * @param id defines the unique ID
  22197. * @param scene defines the hosting scene
  22198. * @param vertexData defines the VertexData used to get geometry data
  22199. * @param updatable defines if geometry must be updatable (false by default)
  22200. * @param mesh defines the mesh that will be associated with the geometry
  22201. */
  22202. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22203. /**
  22204. * Gets the current extend of the geometry
  22205. */
  22206. get extend(): {
  22207. minimum: Vector3;
  22208. maximum: Vector3;
  22209. };
  22210. /**
  22211. * Gets the hosting scene
  22212. * @returns the hosting Scene
  22213. */
  22214. getScene(): Scene;
  22215. /**
  22216. * Gets the hosting engine
  22217. * @returns the hosting Engine
  22218. */
  22219. getEngine(): Engine;
  22220. /**
  22221. * Defines if the geometry is ready to use
  22222. * @returns true if the geometry is ready to be used
  22223. */
  22224. isReady(): boolean;
  22225. /**
  22226. * Gets a value indicating that the geometry should not be serialized
  22227. */
  22228. get doNotSerialize(): boolean;
  22229. /** @hidden */
  22230. _rebuild(): void;
  22231. /**
  22232. * Affects all geometry data in one call
  22233. * @param vertexData defines the geometry data
  22234. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22235. */
  22236. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22237. /**
  22238. * Set specific vertex data
  22239. * @param kind defines the data kind (Position, normal, etc...)
  22240. * @param data defines the vertex data to use
  22241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22243. */
  22244. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22245. /**
  22246. * Removes a specific vertex data
  22247. * @param kind defines the data kind (Position, normal, etc...)
  22248. */
  22249. removeVerticesData(kind: string): void;
  22250. /**
  22251. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22252. * @param buffer defines the vertex buffer to use
  22253. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22254. */
  22255. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22256. /**
  22257. * Update a specific vertex buffer
  22258. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22259. * It will do nothing if the buffer is not updatable
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. * @param data defines the data to use
  22262. * @param offset defines the offset in the target buffer where to store the data
  22263. * @param useBytes set to true if the offset is in bytes
  22264. */
  22265. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22266. /**
  22267. * Update a specific vertex buffer
  22268. * This function will create a new buffer if the current one is not updatable
  22269. * @param kind defines the data kind (Position, normal, etc...)
  22270. * @param data defines the data to use
  22271. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22272. */
  22273. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22274. private _updateBoundingInfo;
  22275. /** @hidden */
  22276. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22277. /**
  22278. * Gets total number of vertices
  22279. * @returns the total number of vertices
  22280. */
  22281. getTotalVertices(): number;
  22282. /**
  22283. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22284. * @param kind defines the data kind (Position, normal, etc...)
  22285. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22286. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22287. * @returns a float array containing vertex data
  22288. */
  22289. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22290. /**
  22291. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22292. * @param kind defines the data kind (Position, normal, etc...)
  22293. * @returns true if the vertex buffer with the specified kind is updatable
  22294. */
  22295. isVertexBufferUpdatable(kind: string): boolean;
  22296. /**
  22297. * Gets a specific vertex buffer
  22298. * @param kind defines the data kind (Position, normal, etc...)
  22299. * @returns a VertexBuffer
  22300. */
  22301. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22302. /**
  22303. * Returns all vertex buffers
  22304. * @return an object holding all vertex buffers indexed by kind
  22305. */
  22306. getVertexBuffers(): Nullable<{
  22307. [key: string]: VertexBuffer;
  22308. }>;
  22309. /**
  22310. * Gets a boolean indicating if specific vertex buffer is present
  22311. * @param kind defines the data kind (Position, normal, etc...)
  22312. * @returns true if data is present
  22313. */
  22314. isVerticesDataPresent(kind: string): boolean;
  22315. /**
  22316. * Gets a list of all attached data kinds (Position, normal, etc...)
  22317. * @returns a list of string containing all kinds
  22318. */
  22319. getVerticesDataKinds(): string[];
  22320. /**
  22321. * Update index buffer
  22322. * @param indices defines the indices to store in the index buffer
  22323. * @param offset defines the offset in the target buffer where to store the data
  22324. * @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)
  22325. */
  22326. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22327. /**
  22328. * Creates a new index buffer
  22329. * @param indices defines the indices to store in the index buffer
  22330. * @param totalVertices defines the total number of vertices (could be null)
  22331. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22332. */
  22333. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22334. /**
  22335. * Return the total number of indices
  22336. * @returns the total number of indices
  22337. */
  22338. getTotalIndices(): number;
  22339. /**
  22340. * Gets the index buffer array
  22341. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22342. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22343. * @returns the index buffer array
  22344. */
  22345. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22346. /**
  22347. * Gets the index buffer
  22348. * @return the index buffer
  22349. */
  22350. getIndexBuffer(): Nullable<DataBuffer>;
  22351. /** @hidden */
  22352. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22353. /**
  22354. * Release the associated resources for a specific mesh
  22355. * @param mesh defines the source mesh
  22356. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22357. */
  22358. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22359. /**
  22360. * Apply current geometry to a given mesh
  22361. * @param mesh defines the mesh to apply geometry to
  22362. */
  22363. applyToMesh(mesh: Mesh): void;
  22364. private _updateExtend;
  22365. private _applyToMesh;
  22366. private notifyUpdate;
  22367. /**
  22368. * Load the geometry if it was flagged as delay loaded
  22369. * @param scene defines the hosting scene
  22370. * @param onLoaded defines a callback called when the geometry is loaded
  22371. */
  22372. load(scene: Scene, onLoaded?: () => void): void;
  22373. private _queueLoad;
  22374. /**
  22375. * Invert the geometry to move from a right handed system to a left handed one.
  22376. */
  22377. toLeftHanded(): void;
  22378. /** @hidden */
  22379. _resetPointsArrayCache(): void;
  22380. /** @hidden */
  22381. _generatePointsArray(): boolean;
  22382. /**
  22383. * Gets a value indicating if the geometry is disposed
  22384. * @returns true if the geometry was disposed
  22385. */
  22386. isDisposed(): boolean;
  22387. private _disposeVertexArrayObjects;
  22388. /**
  22389. * Free all associated resources
  22390. */
  22391. dispose(): void;
  22392. /**
  22393. * Clone the current geometry into a new geometry
  22394. * @param id defines the unique ID of the new geometry
  22395. * @returns a new geometry object
  22396. */
  22397. copy(id: string): Geometry;
  22398. /**
  22399. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22400. * @return a JSON representation of the current geometry data (without the vertices data)
  22401. */
  22402. serialize(): any;
  22403. private toNumberArray;
  22404. /**
  22405. * Serialize all vertices data into a JSON oject
  22406. * @returns a JSON representation of the current geometry data
  22407. */
  22408. serializeVerticeData(): any;
  22409. /**
  22410. * Extracts a clone of a mesh geometry
  22411. * @param mesh defines the source mesh
  22412. * @param id defines the unique ID of the new geometry object
  22413. * @returns the new geometry object
  22414. */
  22415. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22416. /**
  22417. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22418. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22419. * Be aware Math.random() could cause collisions, but:
  22420. * "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"
  22421. * @returns a string containing a new GUID
  22422. */
  22423. static RandomId(): string;
  22424. /** @hidden */
  22425. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22426. private static _CleanMatricesWeights;
  22427. /**
  22428. * Create a new geometry from persisted data (Using .babylon file format)
  22429. * @param parsedVertexData defines the persisted data
  22430. * @param scene defines the hosting scene
  22431. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22432. * @returns the new geometry object
  22433. */
  22434. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22435. }
  22436. }
  22437. declare module BABYLON {
  22438. /**
  22439. * Define an interface for all classes that will get and set the data on vertices
  22440. */
  22441. export interface IGetSetVerticesData {
  22442. /**
  22443. * Gets a boolean indicating if specific vertex data is present
  22444. * @param kind defines the vertex data kind to use
  22445. * @returns true is data kind is present
  22446. */
  22447. isVerticesDataPresent(kind: string): boolean;
  22448. /**
  22449. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22450. * @param kind defines the data kind (Position, normal, etc...)
  22451. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22452. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22453. * @returns a float array containing vertex data
  22454. */
  22455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22456. /**
  22457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22458. * @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.
  22459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22460. * @returns the indices array or an empty array if the mesh has no geometry
  22461. */
  22462. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22463. /**
  22464. * Set specific vertex data
  22465. * @param kind defines the data kind (Position, normal, etc...)
  22466. * @param data defines the vertex data to use
  22467. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22468. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22469. */
  22470. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22471. /**
  22472. * Update a specific associated vertex buffer
  22473. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22474. * - VertexBuffer.PositionKind
  22475. * - VertexBuffer.UVKind
  22476. * - VertexBuffer.UV2Kind
  22477. * - VertexBuffer.UV3Kind
  22478. * - VertexBuffer.UV4Kind
  22479. * - VertexBuffer.UV5Kind
  22480. * - VertexBuffer.UV6Kind
  22481. * - VertexBuffer.ColorKind
  22482. * - VertexBuffer.MatricesIndicesKind
  22483. * - VertexBuffer.MatricesIndicesExtraKind
  22484. * - VertexBuffer.MatricesWeightsKind
  22485. * - VertexBuffer.MatricesWeightsExtraKind
  22486. * @param data defines the data source
  22487. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22488. * @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)
  22489. */
  22490. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22491. /**
  22492. * Creates a new index buffer
  22493. * @param indices defines the indices to store in the index buffer
  22494. * @param totalVertices defines the total number of vertices (could be null)
  22495. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22496. */
  22497. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22498. }
  22499. /**
  22500. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22501. */
  22502. export class VertexData {
  22503. /**
  22504. * Mesh side orientation : usually the external or front surface
  22505. */
  22506. static readonly FRONTSIDE: number;
  22507. /**
  22508. * Mesh side orientation : usually the internal or back surface
  22509. */
  22510. static readonly BACKSIDE: number;
  22511. /**
  22512. * Mesh side orientation : both internal and external or front and back surfaces
  22513. */
  22514. static readonly DOUBLESIDE: number;
  22515. /**
  22516. * Mesh side orientation : by default, `FRONTSIDE`
  22517. */
  22518. static readonly DEFAULTSIDE: number;
  22519. /**
  22520. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22521. */
  22522. positions: Nullable<FloatArray>;
  22523. /**
  22524. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22525. */
  22526. normals: Nullable<FloatArray>;
  22527. /**
  22528. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22529. */
  22530. tangents: Nullable<FloatArray>;
  22531. /**
  22532. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22533. */
  22534. uvs: Nullable<FloatArray>;
  22535. /**
  22536. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22537. */
  22538. uvs2: Nullable<FloatArray>;
  22539. /**
  22540. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22541. */
  22542. uvs3: Nullable<FloatArray>;
  22543. /**
  22544. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22545. */
  22546. uvs4: Nullable<FloatArray>;
  22547. /**
  22548. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22549. */
  22550. uvs5: Nullable<FloatArray>;
  22551. /**
  22552. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22553. */
  22554. uvs6: Nullable<FloatArray>;
  22555. /**
  22556. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22557. */
  22558. colors: Nullable<FloatArray>;
  22559. /**
  22560. * 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).
  22561. */
  22562. matricesIndices: Nullable<FloatArray>;
  22563. /**
  22564. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22565. */
  22566. matricesWeights: Nullable<FloatArray>;
  22567. /**
  22568. * An array extending the number of possible indices
  22569. */
  22570. matricesIndicesExtra: Nullable<FloatArray>;
  22571. /**
  22572. * An array extending the number of possible weights when the number of indices is extended
  22573. */
  22574. matricesWeightsExtra: Nullable<FloatArray>;
  22575. /**
  22576. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22577. */
  22578. indices: Nullable<IndicesArray>;
  22579. /**
  22580. * Uses the passed data array to set the set the values for the specified kind of data
  22581. * @param data a linear array of floating numbers
  22582. * @param kind the type of data that is being set, eg positions, colors etc
  22583. */
  22584. set(data: FloatArray, kind: string): void;
  22585. /**
  22586. * Associates the vertexData to the passed Mesh.
  22587. * Sets it as updatable or not (default `false`)
  22588. * @param mesh the mesh the vertexData is applied to
  22589. * @param updatable when used and having the value true allows new data to update the vertexData
  22590. * @returns the VertexData
  22591. */
  22592. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22593. /**
  22594. * Associates the vertexData to the passed Geometry.
  22595. * Sets it as updatable or not (default `false`)
  22596. * @param geometry the geometry the vertexData is applied to
  22597. * @param updatable when used and having the value true allows new data to update the vertexData
  22598. * @returns VertexData
  22599. */
  22600. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22601. /**
  22602. * Updates the associated mesh
  22603. * @param mesh the mesh to be updated
  22604. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22605. * @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
  22606. * @returns VertexData
  22607. */
  22608. updateMesh(mesh: Mesh): VertexData;
  22609. /**
  22610. * Updates the associated geometry
  22611. * @param geometry the geometry to be updated
  22612. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22613. * @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
  22614. * @returns VertexData.
  22615. */
  22616. updateGeometry(geometry: Geometry): VertexData;
  22617. private _applyTo;
  22618. private _update;
  22619. /**
  22620. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22621. * @param matrix the transforming matrix
  22622. * @returns the VertexData
  22623. */
  22624. transform(matrix: Matrix): VertexData;
  22625. /**
  22626. * Merges the passed VertexData into the current one
  22627. * @param other the VertexData to be merged into the current one
  22628. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22629. * @returns the modified VertexData
  22630. */
  22631. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22632. private _mergeElement;
  22633. private _validate;
  22634. /**
  22635. * Serializes the VertexData
  22636. * @returns a serialized object
  22637. */
  22638. serialize(): any;
  22639. /**
  22640. * Extracts the vertexData from a mesh
  22641. * @param mesh the mesh from which to extract the VertexData
  22642. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22643. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22644. * @returns the object VertexData associated to the passed mesh
  22645. */
  22646. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22647. /**
  22648. * Extracts the vertexData from the geometry
  22649. * @param geometry the geometry from which to extract the VertexData
  22650. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22651. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22652. * @returns the object VertexData associated to the passed mesh
  22653. */
  22654. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22655. private static _ExtractFrom;
  22656. /**
  22657. * Creates the VertexData for a Ribbon
  22658. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22659. * * pathArray array of paths, each of which an array of successive Vector3
  22660. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22661. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22662. * * 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
  22663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22664. * * 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)
  22665. * * 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)
  22666. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22667. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22668. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22669. * @returns the VertexData of the ribbon
  22670. */
  22671. static CreateRibbon(options: {
  22672. pathArray: Vector3[][];
  22673. closeArray?: boolean;
  22674. closePath?: boolean;
  22675. offset?: number;
  22676. sideOrientation?: number;
  22677. frontUVs?: Vector4;
  22678. backUVs?: Vector4;
  22679. invertUV?: boolean;
  22680. uvs?: Vector2[];
  22681. colors?: Color4[];
  22682. }): VertexData;
  22683. /**
  22684. * Creates the VertexData for a box
  22685. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22686. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22687. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22688. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22689. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22690. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22691. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22693. * * 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)
  22694. * * 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)
  22695. * @returns the VertexData of the box
  22696. */
  22697. static CreateBox(options: {
  22698. size?: number;
  22699. width?: number;
  22700. height?: number;
  22701. depth?: number;
  22702. faceUV?: Vector4[];
  22703. faceColors?: Color4[];
  22704. sideOrientation?: number;
  22705. frontUVs?: Vector4;
  22706. backUVs?: Vector4;
  22707. }): VertexData;
  22708. /**
  22709. * Creates the VertexData for a tiled box
  22710. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22711. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22712. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22713. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22715. * @returns the VertexData of the box
  22716. */
  22717. static CreateTiledBox(options: {
  22718. pattern?: number;
  22719. width?: number;
  22720. height?: number;
  22721. depth?: number;
  22722. tileSize?: number;
  22723. tileWidth?: number;
  22724. tileHeight?: number;
  22725. alignHorizontal?: number;
  22726. alignVertical?: number;
  22727. faceUV?: Vector4[];
  22728. faceColors?: Color4[];
  22729. sideOrientation?: number;
  22730. }): VertexData;
  22731. /**
  22732. * Creates the VertexData for a tiled plane
  22733. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22734. * * pattern a limited pattern arrangement depending on the number
  22735. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22736. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22737. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22739. * * 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)
  22740. * * 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)
  22741. * @returns the VertexData of the tiled plane
  22742. */
  22743. static CreateTiledPlane(options: {
  22744. pattern?: number;
  22745. tileSize?: number;
  22746. tileWidth?: number;
  22747. tileHeight?: number;
  22748. size?: number;
  22749. width?: number;
  22750. height?: number;
  22751. alignHorizontal?: number;
  22752. alignVertical?: number;
  22753. sideOrientation?: number;
  22754. frontUVs?: Vector4;
  22755. backUVs?: Vector4;
  22756. }): VertexData;
  22757. /**
  22758. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22759. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22760. * * segments sets the number of horizontal strips optional, default 32
  22761. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22762. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22763. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22764. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22765. * * 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
  22766. * * 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
  22767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22768. * * 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)
  22769. * * 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)
  22770. * @returns the VertexData of the ellipsoid
  22771. */
  22772. static CreateSphere(options: {
  22773. segments?: number;
  22774. diameter?: number;
  22775. diameterX?: number;
  22776. diameterY?: number;
  22777. diameterZ?: number;
  22778. arc?: number;
  22779. slice?: number;
  22780. sideOrientation?: number;
  22781. frontUVs?: Vector4;
  22782. backUVs?: Vector4;
  22783. }): VertexData;
  22784. /**
  22785. * Creates the VertexData for a cylinder, cone or prism
  22786. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22787. * * height sets the height (y direction) of the cylinder, optional, default 2
  22788. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22789. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22790. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22791. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22792. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22793. * * 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
  22794. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22795. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22796. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22797. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22799. * * 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)
  22800. * * 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)
  22801. * @returns the VertexData of the cylinder, cone or prism
  22802. */
  22803. static CreateCylinder(options: {
  22804. height?: number;
  22805. diameterTop?: number;
  22806. diameterBottom?: number;
  22807. diameter?: number;
  22808. tessellation?: number;
  22809. subdivisions?: number;
  22810. arc?: number;
  22811. faceColors?: Color4[];
  22812. faceUV?: Vector4[];
  22813. hasRings?: boolean;
  22814. enclose?: boolean;
  22815. sideOrientation?: number;
  22816. frontUVs?: Vector4;
  22817. backUVs?: Vector4;
  22818. }): VertexData;
  22819. /**
  22820. * Creates the VertexData for a torus
  22821. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22822. * * diameter the diameter of the torus, optional default 1
  22823. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22824. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22826. * * 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)
  22827. * * 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)
  22828. * @returns the VertexData of the torus
  22829. */
  22830. static CreateTorus(options: {
  22831. diameter?: number;
  22832. thickness?: number;
  22833. tessellation?: number;
  22834. sideOrientation?: number;
  22835. frontUVs?: Vector4;
  22836. backUVs?: Vector4;
  22837. }): VertexData;
  22838. /**
  22839. * Creates the VertexData of the LineSystem
  22840. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22841. * - lines an array of lines, each line being an array of successive Vector3
  22842. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22843. * @returns the VertexData of the LineSystem
  22844. */
  22845. static CreateLineSystem(options: {
  22846. lines: Vector3[][];
  22847. colors?: Nullable<Color4[][]>;
  22848. }): VertexData;
  22849. /**
  22850. * Create the VertexData for a DashedLines
  22851. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22852. * - points an array successive Vector3
  22853. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22854. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22855. * - dashNb the intended total number of dashes, optional, default 200
  22856. * @returns the VertexData for the DashedLines
  22857. */
  22858. static CreateDashedLines(options: {
  22859. points: Vector3[];
  22860. dashSize?: number;
  22861. gapSize?: number;
  22862. dashNb?: number;
  22863. }): VertexData;
  22864. /**
  22865. * Creates the VertexData for a Ground
  22866. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22867. * - width the width (x direction) of the ground, optional, default 1
  22868. * - height the height (z direction) of the ground, optional, default 1
  22869. * - subdivisions the number of subdivisions per side, optional, default 1
  22870. * @returns the VertexData of the Ground
  22871. */
  22872. static CreateGround(options: {
  22873. width?: number;
  22874. height?: number;
  22875. subdivisions?: number;
  22876. subdivisionsX?: number;
  22877. subdivisionsY?: number;
  22878. }): VertexData;
  22879. /**
  22880. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22881. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22882. * * xmin the ground minimum X coordinate, optional, default -1
  22883. * * zmin the ground minimum Z coordinate, optional, default -1
  22884. * * xmax the ground maximum X coordinate, optional, default 1
  22885. * * zmax the ground maximum Z coordinate, optional, default 1
  22886. * * 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}
  22887. * * 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}
  22888. * @returns the VertexData of the TiledGround
  22889. */
  22890. static CreateTiledGround(options: {
  22891. xmin: number;
  22892. zmin: number;
  22893. xmax: number;
  22894. zmax: number;
  22895. subdivisions?: {
  22896. w: number;
  22897. h: number;
  22898. };
  22899. precision?: {
  22900. w: number;
  22901. h: number;
  22902. };
  22903. }): VertexData;
  22904. /**
  22905. * Creates the VertexData of the Ground designed from a heightmap
  22906. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22907. * * width the width (x direction) of the ground
  22908. * * height the height (z direction) of the ground
  22909. * * subdivisions the number of subdivisions per side
  22910. * * minHeight the minimum altitude on the ground, optional, default 0
  22911. * * maxHeight the maximum altitude on the ground, optional default 1
  22912. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22913. * * buffer the array holding the image color data
  22914. * * bufferWidth the width of image
  22915. * * bufferHeight the height of image
  22916. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22917. * @returns the VertexData of the Ground designed from a heightmap
  22918. */
  22919. static CreateGroundFromHeightMap(options: {
  22920. width: number;
  22921. height: number;
  22922. subdivisions: number;
  22923. minHeight: number;
  22924. maxHeight: number;
  22925. colorFilter: Color3;
  22926. buffer: Uint8Array;
  22927. bufferWidth: number;
  22928. bufferHeight: number;
  22929. alphaFilter: number;
  22930. }): VertexData;
  22931. /**
  22932. * Creates the VertexData for a Plane
  22933. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22934. * * size sets the width and height of the plane to the value of size, optional default 1
  22935. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22936. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22938. * * 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)
  22939. * * 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)
  22940. * @returns the VertexData of the box
  22941. */
  22942. static CreatePlane(options: {
  22943. size?: number;
  22944. width?: number;
  22945. height?: number;
  22946. sideOrientation?: number;
  22947. frontUVs?: Vector4;
  22948. backUVs?: Vector4;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData of the Disc or regular Polygon
  22952. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22953. * * radius the radius of the disc, optional default 0.5
  22954. * * tessellation the number of polygon sides, optional, default 64
  22955. * * 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
  22956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22957. * * 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)
  22958. * * 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)
  22959. * @returns the VertexData of the box
  22960. */
  22961. static CreateDisc(options: {
  22962. radius?: number;
  22963. tessellation?: number;
  22964. arc?: number;
  22965. sideOrientation?: number;
  22966. frontUVs?: Vector4;
  22967. backUVs?: Vector4;
  22968. }): VertexData;
  22969. /**
  22970. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22971. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22972. * @param polygon a mesh built from polygonTriangulation.build()
  22973. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22974. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22975. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22976. * @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)
  22977. * @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)
  22978. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  22979. * @returns the VertexData of the Polygon
  22980. */
  22981. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  22982. /**
  22983. * Creates the VertexData of the IcoSphere
  22984. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22985. * * radius the radius of the IcoSphere, optional default 1
  22986. * * radiusX allows stretching in the x direction, optional, default radius
  22987. * * radiusY allows stretching in the y direction, optional, default radius
  22988. * * radiusZ allows stretching in the z direction, optional, default radius
  22989. * * flat when true creates a flat shaded mesh, optional, default true
  22990. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22992. * * 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)
  22993. * * 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)
  22994. * @returns the VertexData of the IcoSphere
  22995. */
  22996. static CreateIcoSphere(options: {
  22997. radius?: number;
  22998. radiusX?: number;
  22999. radiusY?: number;
  23000. radiusZ?: number;
  23001. flat?: boolean;
  23002. subdivisions?: number;
  23003. sideOrientation?: number;
  23004. frontUVs?: Vector4;
  23005. backUVs?: Vector4;
  23006. }): VertexData;
  23007. /**
  23008. * Creates the VertexData for a Polyhedron
  23009. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23010. * * type provided types are:
  23011. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23012. * * 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)
  23013. * * size the size of the IcoSphere, optional default 1
  23014. * * sizeX allows stretching in the x direction, optional, default size
  23015. * * sizeY allows stretching in the y direction, optional, default size
  23016. * * sizeZ allows stretching in the z direction, optional, default size
  23017. * * 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
  23018. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23019. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23020. * * flat when true creates a flat shaded mesh, optional, default true
  23021. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23023. * * 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)
  23024. * * 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)
  23025. * @returns the VertexData of the Polyhedron
  23026. */
  23027. static CreatePolyhedron(options: {
  23028. type?: number;
  23029. size?: number;
  23030. sizeX?: number;
  23031. sizeY?: number;
  23032. sizeZ?: number;
  23033. custom?: any;
  23034. faceUV?: Vector4[];
  23035. faceColors?: Color4[];
  23036. flat?: boolean;
  23037. sideOrientation?: number;
  23038. frontUVs?: Vector4;
  23039. backUVs?: Vector4;
  23040. }): VertexData;
  23041. /**
  23042. * Creates the VertexData for a TorusKnot
  23043. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23044. * * radius the radius of the torus knot, optional, default 2
  23045. * * tube the thickness of the tube, optional, default 0.5
  23046. * * radialSegments the number of sides on each tube segments, optional, default 32
  23047. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23048. * * p the number of windings around the z axis, optional, default 2
  23049. * * q the number of windings around the x axis, optional, default 3
  23050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23051. * * 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)
  23052. * * 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)
  23053. * @returns the VertexData of the Torus Knot
  23054. */
  23055. static CreateTorusKnot(options: {
  23056. radius?: number;
  23057. tube?: number;
  23058. radialSegments?: number;
  23059. tubularSegments?: number;
  23060. p?: number;
  23061. q?: number;
  23062. sideOrientation?: number;
  23063. frontUVs?: Vector4;
  23064. backUVs?: Vector4;
  23065. }): VertexData;
  23066. /**
  23067. * Compute normals for given positions and indices
  23068. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23069. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23070. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23071. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23072. * * facetNormals : optional array of facet normals (vector3)
  23073. * * facetPositions : optional array of facet positions (vector3)
  23074. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23075. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23076. * * bInfo : optional bounding info, required for facetPartitioning computation
  23077. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23078. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23079. * * useRightHandedSystem: optional boolean to for right handed system computation
  23080. * * depthSort : optional boolean to enable the facet depth sort computation
  23081. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23082. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23083. */
  23084. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23085. facetNormals?: any;
  23086. facetPositions?: any;
  23087. facetPartitioning?: any;
  23088. ratio?: number;
  23089. bInfo?: any;
  23090. bbSize?: Vector3;
  23091. subDiv?: any;
  23092. useRightHandedSystem?: boolean;
  23093. depthSort?: boolean;
  23094. distanceTo?: Vector3;
  23095. depthSortedFacets?: any;
  23096. }): void;
  23097. /** @hidden */
  23098. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23099. /**
  23100. * Applies VertexData created from the imported parameters to the geometry
  23101. * @param parsedVertexData the parsed data from an imported file
  23102. * @param geometry the geometry to apply the VertexData to
  23103. */
  23104. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23105. }
  23106. }
  23107. declare module BABYLON {
  23108. /**
  23109. * Defines a target to use with MorphTargetManager
  23110. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23111. */
  23112. export class MorphTarget implements IAnimatable {
  23113. /** defines the name of the target */
  23114. name: string;
  23115. /**
  23116. * Gets or sets the list of animations
  23117. */
  23118. animations: Animation[];
  23119. private _scene;
  23120. private _positions;
  23121. private _normals;
  23122. private _tangents;
  23123. private _uvs;
  23124. private _influence;
  23125. private _uniqueId;
  23126. /**
  23127. * Observable raised when the influence changes
  23128. */
  23129. onInfluenceChanged: Observable<boolean>;
  23130. /** @hidden */
  23131. _onDataLayoutChanged: Observable<void>;
  23132. /**
  23133. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23134. */
  23135. get influence(): number;
  23136. set influence(influence: number);
  23137. /**
  23138. * Gets or sets the id of the morph Target
  23139. */
  23140. id: string;
  23141. private _animationPropertiesOverride;
  23142. /**
  23143. * Gets or sets the animation properties override
  23144. */
  23145. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23146. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23147. /**
  23148. * Creates a new MorphTarget
  23149. * @param name defines the name of the target
  23150. * @param influence defines the influence to use
  23151. * @param scene defines the scene the morphtarget belongs to
  23152. */
  23153. constructor(
  23154. /** defines the name of the target */
  23155. name: string, influence?: number, scene?: Nullable<Scene>);
  23156. /**
  23157. * Gets the unique ID of this manager
  23158. */
  23159. get uniqueId(): number;
  23160. /**
  23161. * Gets a boolean defining if the target contains position data
  23162. */
  23163. get hasPositions(): boolean;
  23164. /**
  23165. * Gets a boolean defining if the target contains normal data
  23166. */
  23167. get hasNormals(): boolean;
  23168. /**
  23169. * Gets a boolean defining if the target contains tangent data
  23170. */
  23171. get hasTangents(): boolean;
  23172. /**
  23173. * Gets a boolean defining if the target contains texture coordinates data
  23174. */
  23175. get hasUVs(): boolean;
  23176. /**
  23177. * Affects position data to this target
  23178. * @param data defines the position data to use
  23179. */
  23180. setPositions(data: Nullable<FloatArray>): void;
  23181. /**
  23182. * Gets the position data stored in this target
  23183. * @returns a FloatArray containing the position data (or null if not present)
  23184. */
  23185. getPositions(): Nullable<FloatArray>;
  23186. /**
  23187. * Affects normal data to this target
  23188. * @param data defines the normal data to use
  23189. */
  23190. setNormals(data: Nullable<FloatArray>): void;
  23191. /**
  23192. * Gets the normal data stored in this target
  23193. * @returns a FloatArray containing the normal data (or null if not present)
  23194. */
  23195. getNormals(): Nullable<FloatArray>;
  23196. /**
  23197. * Affects tangent data to this target
  23198. * @param data defines the tangent data to use
  23199. */
  23200. setTangents(data: Nullable<FloatArray>): void;
  23201. /**
  23202. * Gets the tangent data stored in this target
  23203. * @returns a FloatArray containing the tangent data (or null if not present)
  23204. */
  23205. getTangents(): Nullable<FloatArray>;
  23206. /**
  23207. * Affects texture coordinates data to this target
  23208. * @param data defines the texture coordinates data to use
  23209. */
  23210. setUVs(data: Nullable<FloatArray>): void;
  23211. /**
  23212. * Gets the texture coordinates data stored in this target
  23213. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23214. */
  23215. getUVs(): Nullable<FloatArray>;
  23216. /**
  23217. * Clone the current target
  23218. * @returns a new MorphTarget
  23219. */
  23220. clone(): MorphTarget;
  23221. /**
  23222. * Serializes the current target into a Serialization object
  23223. * @returns the serialized object
  23224. */
  23225. serialize(): any;
  23226. /**
  23227. * Returns the string "MorphTarget"
  23228. * @returns "MorphTarget"
  23229. */
  23230. getClassName(): string;
  23231. /**
  23232. * Creates a new target from serialized data
  23233. * @param serializationObject defines the serialized data to use
  23234. * @returns a new MorphTarget
  23235. */
  23236. static Parse(serializationObject: any): MorphTarget;
  23237. /**
  23238. * Creates a MorphTarget from mesh data
  23239. * @param mesh defines the source mesh
  23240. * @param name defines the name to use for the new target
  23241. * @param influence defines the influence to attach to the target
  23242. * @returns a new MorphTarget
  23243. */
  23244. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23245. }
  23246. }
  23247. declare module BABYLON {
  23248. /**
  23249. * This class is used to deform meshes using morphing between different targets
  23250. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23251. */
  23252. export class MorphTargetManager {
  23253. private _targets;
  23254. private _targetInfluenceChangedObservers;
  23255. private _targetDataLayoutChangedObservers;
  23256. private _activeTargets;
  23257. private _scene;
  23258. private _influences;
  23259. private _supportsNormals;
  23260. private _supportsTangents;
  23261. private _supportsUVs;
  23262. private _vertexCount;
  23263. private _uniqueId;
  23264. private _tempInfluences;
  23265. /**
  23266. * Gets or sets a boolean indicating if normals must be morphed
  23267. */
  23268. enableNormalMorphing: boolean;
  23269. /**
  23270. * Gets or sets a boolean indicating if tangents must be morphed
  23271. */
  23272. enableTangentMorphing: boolean;
  23273. /**
  23274. * Gets or sets a boolean indicating if UV must be morphed
  23275. */
  23276. enableUVMorphing: boolean;
  23277. /**
  23278. * Creates a new MorphTargetManager
  23279. * @param scene defines the current scene
  23280. */
  23281. constructor(scene?: Nullable<Scene>);
  23282. /**
  23283. * Gets the unique ID of this manager
  23284. */
  23285. get uniqueId(): number;
  23286. /**
  23287. * Gets the number of vertices handled by this manager
  23288. */
  23289. get vertexCount(): number;
  23290. /**
  23291. * Gets a boolean indicating if this manager supports morphing of normals
  23292. */
  23293. get supportsNormals(): boolean;
  23294. /**
  23295. * Gets a boolean indicating if this manager supports morphing of tangents
  23296. */
  23297. get supportsTangents(): boolean;
  23298. /**
  23299. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23300. */
  23301. get supportsUVs(): boolean;
  23302. /**
  23303. * Gets the number of targets stored in this manager
  23304. */
  23305. get numTargets(): number;
  23306. /**
  23307. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23308. */
  23309. get numInfluencers(): number;
  23310. /**
  23311. * Gets the list of influences (one per target)
  23312. */
  23313. get influences(): Float32Array;
  23314. /**
  23315. * Gets the active target at specified index. An active target is a target with an influence > 0
  23316. * @param index defines the index to check
  23317. * @returns the requested target
  23318. */
  23319. getActiveTarget(index: number): MorphTarget;
  23320. /**
  23321. * Gets the target at specified index
  23322. * @param index defines the index to check
  23323. * @returns the requested target
  23324. */
  23325. getTarget(index: number): MorphTarget;
  23326. /**
  23327. * Add a new target to this manager
  23328. * @param target defines the target to add
  23329. */
  23330. addTarget(target: MorphTarget): void;
  23331. /**
  23332. * Removes a target from the manager
  23333. * @param target defines the target to remove
  23334. */
  23335. removeTarget(target: MorphTarget): void;
  23336. /**
  23337. * Clone the current manager
  23338. * @returns a new MorphTargetManager
  23339. */
  23340. clone(): MorphTargetManager;
  23341. /**
  23342. * Serializes the current manager into a Serialization object
  23343. * @returns the serialized object
  23344. */
  23345. serialize(): any;
  23346. private _syncActiveTargets;
  23347. /**
  23348. * Syncrhonize the targets with all the meshes using this morph target manager
  23349. */
  23350. synchronize(): void;
  23351. /**
  23352. * Creates a new MorphTargetManager from serialized data
  23353. * @param serializationObject defines the serialized data
  23354. * @param scene defines the hosting scene
  23355. * @returns the new MorphTargetManager
  23356. */
  23357. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23358. }
  23359. }
  23360. declare module BABYLON {
  23361. /**
  23362. * Class used to represent a specific level of detail of a mesh
  23363. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23364. */
  23365. export class MeshLODLevel {
  23366. /** Defines the distance where this level should start being displayed */
  23367. distance: number;
  23368. /** Defines the mesh to use to render this level */
  23369. mesh: Nullable<Mesh>;
  23370. /**
  23371. * Creates a new LOD level
  23372. * @param distance defines the distance where this level should star being displayed
  23373. * @param mesh defines the mesh to use to render this level
  23374. */
  23375. constructor(
  23376. /** Defines the distance where this level should start being displayed */
  23377. distance: number,
  23378. /** Defines the mesh to use to render this level */
  23379. mesh: Nullable<Mesh>);
  23380. }
  23381. }
  23382. declare module BABYLON {
  23383. /**
  23384. * Mesh representing the gorund
  23385. */
  23386. export class GroundMesh extends Mesh {
  23387. /** If octree should be generated */
  23388. generateOctree: boolean;
  23389. private _heightQuads;
  23390. /** @hidden */
  23391. _subdivisionsX: number;
  23392. /** @hidden */
  23393. _subdivisionsY: number;
  23394. /** @hidden */
  23395. _width: number;
  23396. /** @hidden */
  23397. _height: number;
  23398. /** @hidden */
  23399. _minX: number;
  23400. /** @hidden */
  23401. _maxX: number;
  23402. /** @hidden */
  23403. _minZ: number;
  23404. /** @hidden */
  23405. _maxZ: number;
  23406. constructor(name: string, scene: Scene);
  23407. /**
  23408. * "GroundMesh"
  23409. * @returns "GroundMesh"
  23410. */
  23411. getClassName(): string;
  23412. /**
  23413. * The minimum of x and y subdivisions
  23414. */
  23415. get subdivisions(): number;
  23416. /**
  23417. * X subdivisions
  23418. */
  23419. get subdivisionsX(): number;
  23420. /**
  23421. * Y subdivisions
  23422. */
  23423. get subdivisionsY(): number;
  23424. /**
  23425. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23426. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23427. * @param chunksCount the number of subdivisions for x and y
  23428. * @param octreeBlocksSize (Default: 32)
  23429. */
  23430. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23431. /**
  23432. * Returns a height (y) value in the Worl system :
  23433. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23434. * @param x x coordinate
  23435. * @param z z coordinate
  23436. * @returns the ground y position if (x, z) are outside the ground surface.
  23437. */
  23438. getHeightAtCoordinates(x: number, z: number): number;
  23439. /**
  23440. * Returns a normalized vector (Vector3) orthogonal to the ground
  23441. * at the ground coordinates (x, z) expressed in the World system.
  23442. * @param x x coordinate
  23443. * @param z z coordinate
  23444. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23445. */
  23446. getNormalAtCoordinates(x: number, z: number): Vector3;
  23447. /**
  23448. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23449. * at the ground coordinates (x, z) expressed in the World system.
  23450. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23451. * @param x x coordinate
  23452. * @param z z coordinate
  23453. * @param ref vector to store the result
  23454. * @returns the GroundMesh.
  23455. */
  23456. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23457. /**
  23458. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23459. * if the ground has been updated.
  23460. * This can be used in the render loop.
  23461. * @returns the GroundMesh.
  23462. */
  23463. updateCoordinateHeights(): GroundMesh;
  23464. private _getFacetAt;
  23465. private _initHeightQuads;
  23466. private _computeHeightQuads;
  23467. /**
  23468. * Serializes this ground mesh
  23469. * @param serializationObject object to write serialization to
  23470. */
  23471. serialize(serializationObject: any): void;
  23472. /**
  23473. * Parses a serialized ground mesh
  23474. * @param parsedMesh the serialized mesh
  23475. * @param scene the scene to create the ground mesh in
  23476. * @returns the created ground mesh
  23477. */
  23478. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23479. }
  23480. }
  23481. declare module BABYLON {
  23482. /**
  23483. * Interface for Physics-Joint data
  23484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23485. */
  23486. export interface PhysicsJointData {
  23487. /**
  23488. * The main pivot of the joint
  23489. */
  23490. mainPivot?: Vector3;
  23491. /**
  23492. * The connected pivot of the joint
  23493. */
  23494. connectedPivot?: Vector3;
  23495. /**
  23496. * The main axis of the joint
  23497. */
  23498. mainAxis?: Vector3;
  23499. /**
  23500. * The connected axis of the joint
  23501. */
  23502. connectedAxis?: Vector3;
  23503. /**
  23504. * The collision of the joint
  23505. */
  23506. collision?: boolean;
  23507. /**
  23508. * Native Oimo/Cannon/Energy data
  23509. */
  23510. nativeParams?: any;
  23511. }
  23512. /**
  23513. * This is a holder class for the physics joint created by the physics plugin
  23514. * It holds a set of functions to control the underlying joint
  23515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23516. */
  23517. export class PhysicsJoint {
  23518. /**
  23519. * The type of the physics joint
  23520. */
  23521. type: number;
  23522. /**
  23523. * The data for the physics joint
  23524. */
  23525. jointData: PhysicsJointData;
  23526. private _physicsJoint;
  23527. protected _physicsPlugin: IPhysicsEnginePlugin;
  23528. /**
  23529. * Initializes the physics joint
  23530. * @param type The type of the physics joint
  23531. * @param jointData The data for the physics joint
  23532. */
  23533. constructor(
  23534. /**
  23535. * The type of the physics joint
  23536. */
  23537. type: number,
  23538. /**
  23539. * The data for the physics joint
  23540. */
  23541. jointData: PhysicsJointData);
  23542. /**
  23543. * Gets the physics joint
  23544. */
  23545. get physicsJoint(): any;
  23546. /**
  23547. * Sets the physics joint
  23548. */
  23549. set physicsJoint(newJoint: any);
  23550. /**
  23551. * Sets the physics plugin
  23552. */
  23553. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23554. /**
  23555. * Execute a function that is physics-plugin specific.
  23556. * @param {Function} func the function that will be executed.
  23557. * It accepts two parameters: the physics world and the physics joint
  23558. */
  23559. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23560. /**
  23561. * Distance-Joint type
  23562. */
  23563. static DistanceJoint: number;
  23564. /**
  23565. * Hinge-Joint type
  23566. */
  23567. static HingeJoint: number;
  23568. /**
  23569. * Ball-and-Socket joint type
  23570. */
  23571. static BallAndSocketJoint: number;
  23572. /**
  23573. * Wheel-Joint type
  23574. */
  23575. static WheelJoint: number;
  23576. /**
  23577. * Slider-Joint type
  23578. */
  23579. static SliderJoint: number;
  23580. /**
  23581. * Prismatic-Joint type
  23582. */
  23583. static PrismaticJoint: number;
  23584. /**
  23585. * Universal-Joint type
  23586. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23587. */
  23588. static UniversalJoint: number;
  23589. /**
  23590. * Hinge-Joint 2 type
  23591. */
  23592. static Hinge2Joint: number;
  23593. /**
  23594. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23595. */
  23596. static PointToPointJoint: number;
  23597. /**
  23598. * Spring-Joint type
  23599. */
  23600. static SpringJoint: number;
  23601. /**
  23602. * Lock-Joint type
  23603. */
  23604. static LockJoint: number;
  23605. }
  23606. /**
  23607. * A class representing a physics distance joint
  23608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23609. */
  23610. export class DistanceJoint extends PhysicsJoint {
  23611. /**
  23612. *
  23613. * @param jointData The data for the Distance-Joint
  23614. */
  23615. constructor(jointData: DistanceJointData);
  23616. /**
  23617. * Update the predefined distance.
  23618. * @param maxDistance The maximum preferred distance
  23619. * @param minDistance The minimum preferred distance
  23620. */
  23621. updateDistance(maxDistance: number, minDistance?: number): void;
  23622. }
  23623. /**
  23624. * Represents a Motor-Enabled Joint
  23625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23626. */
  23627. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23628. /**
  23629. * Initializes the Motor-Enabled Joint
  23630. * @param type The type of the joint
  23631. * @param jointData The physica joint data for the joint
  23632. */
  23633. constructor(type: number, jointData: PhysicsJointData);
  23634. /**
  23635. * Set the motor values.
  23636. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23637. * @param force the force to apply
  23638. * @param maxForce max force for this motor.
  23639. */
  23640. setMotor(force?: number, maxForce?: number): void;
  23641. /**
  23642. * Set the motor's limits.
  23643. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23644. * @param upperLimit The upper limit of the motor
  23645. * @param lowerLimit The lower limit of the motor
  23646. */
  23647. setLimit(upperLimit: number, lowerLimit?: number): void;
  23648. }
  23649. /**
  23650. * This class represents a single physics Hinge-Joint
  23651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23652. */
  23653. export class HingeJoint extends MotorEnabledJoint {
  23654. /**
  23655. * Initializes the Hinge-Joint
  23656. * @param jointData The joint data for the Hinge-Joint
  23657. */
  23658. constructor(jointData: PhysicsJointData);
  23659. /**
  23660. * Set the motor values.
  23661. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23662. * @param {number} force the force to apply
  23663. * @param {number} maxForce max force for this motor.
  23664. */
  23665. setMotor(force?: number, maxForce?: number): void;
  23666. /**
  23667. * Set the motor's limits.
  23668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23669. * @param upperLimit The upper limit of the motor
  23670. * @param lowerLimit The lower limit of the motor
  23671. */
  23672. setLimit(upperLimit: number, lowerLimit?: number): void;
  23673. }
  23674. /**
  23675. * This class represents a dual hinge physics joint (same as wheel joint)
  23676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23677. */
  23678. export class Hinge2Joint extends MotorEnabledJoint {
  23679. /**
  23680. * Initializes the Hinge2-Joint
  23681. * @param jointData The joint data for the Hinge2-Joint
  23682. */
  23683. constructor(jointData: PhysicsJointData);
  23684. /**
  23685. * Set the motor values.
  23686. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23687. * @param {number} targetSpeed the speed the motor is to reach
  23688. * @param {number} maxForce max force for this motor.
  23689. * @param {motorIndex} the motor's index, 0 or 1.
  23690. */
  23691. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23692. /**
  23693. * Set the motor limits.
  23694. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23695. * @param {number} upperLimit the upper limit
  23696. * @param {number} lowerLimit lower limit
  23697. * @param {motorIndex} the motor's index, 0 or 1.
  23698. */
  23699. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23700. }
  23701. /**
  23702. * Interface for a motor enabled joint
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export interface IMotorEnabledJoint {
  23706. /**
  23707. * Physics joint
  23708. */
  23709. physicsJoint: any;
  23710. /**
  23711. * Sets the motor of the motor-enabled joint
  23712. * @param force The force of the motor
  23713. * @param maxForce The maximum force of the motor
  23714. * @param motorIndex The index of the motor
  23715. */
  23716. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23717. /**
  23718. * Sets the limit of the motor
  23719. * @param upperLimit The upper limit of the motor
  23720. * @param lowerLimit The lower limit of the motor
  23721. * @param motorIndex The index of the motor
  23722. */
  23723. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23724. }
  23725. /**
  23726. * Joint data for a Distance-Joint
  23727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23728. */
  23729. export interface DistanceJointData extends PhysicsJointData {
  23730. /**
  23731. * Max distance the 2 joint objects can be apart
  23732. */
  23733. maxDistance: number;
  23734. }
  23735. /**
  23736. * Joint data from a spring joint
  23737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23738. */
  23739. export interface SpringJointData extends PhysicsJointData {
  23740. /**
  23741. * Length of the spring
  23742. */
  23743. length: number;
  23744. /**
  23745. * Stiffness of the spring
  23746. */
  23747. stiffness: number;
  23748. /**
  23749. * Damping of the spring
  23750. */
  23751. damping: number;
  23752. /** this callback will be called when applying the force to the impostors. */
  23753. forceApplicationCallback: () => void;
  23754. }
  23755. }
  23756. declare module BABYLON {
  23757. /**
  23758. * Holds the data for the raycast result
  23759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23760. */
  23761. export class PhysicsRaycastResult {
  23762. private _hasHit;
  23763. private _hitDistance;
  23764. private _hitNormalWorld;
  23765. private _hitPointWorld;
  23766. private _rayFromWorld;
  23767. private _rayToWorld;
  23768. /**
  23769. * Gets if there was a hit
  23770. */
  23771. get hasHit(): boolean;
  23772. /**
  23773. * Gets the distance from the hit
  23774. */
  23775. get hitDistance(): number;
  23776. /**
  23777. * Gets the hit normal/direction in the world
  23778. */
  23779. get hitNormalWorld(): Vector3;
  23780. /**
  23781. * Gets the hit point in the world
  23782. */
  23783. get hitPointWorld(): Vector3;
  23784. /**
  23785. * Gets the ray "start point" of the ray in the world
  23786. */
  23787. get rayFromWorld(): Vector3;
  23788. /**
  23789. * Gets the ray "end point" of the ray in the world
  23790. */
  23791. get rayToWorld(): Vector3;
  23792. /**
  23793. * Sets the hit data (normal & point in world space)
  23794. * @param hitNormalWorld defines the normal in world space
  23795. * @param hitPointWorld defines the point in world space
  23796. */
  23797. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23798. /**
  23799. * Sets the distance from the start point to the hit point
  23800. * @param distance
  23801. */
  23802. setHitDistance(distance: number): void;
  23803. /**
  23804. * Calculates the distance manually
  23805. */
  23806. calculateHitDistance(): void;
  23807. /**
  23808. * Resets all the values to default
  23809. * @param from The from point on world space
  23810. * @param to The to point on world space
  23811. */
  23812. reset(from?: Vector3, to?: Vector3): void;
  23813. }
  23814. /**
  23815. * Interface for the size containing width and height
  23816. */
  23817. interface IXYZ {
  23818. /**
  23819. * X
  23820. */
  23821. x: number;
  23822. /**
  23823. * Y
  23824. */
  23825. y: number;
  23826. /**
  23827. * Z
  23828. */
  23829. z: number;
  23830. }
  23831. }
  23832. declare module BABYLON {
  23833. /**
  23834. * Interface used to describe a physics joint
  23835. */
  23836. export interface PhysicsImpostorJoint {
  23837. /** Defines the main impostor to which the joint is linked */
  23838. mainImpostor: PhysicsImpostor;
  23839. /** Defines the impostor that is connected to the main impostor using this joint */
  23840. connectedImpostor: PhysicsImpostor;
  23841. /** Defines the joint itself */
  23842. joint: PhysicsJoint;
  23843. }
  23844. /** @hidden */
  23845. export interface IPhysicsEnginePlugin {
  23846. world: any;
  23847. name: string;
  23848. setGravity(gravity: Vector3): void;
  23849. setTimeStep(timeStep: number): void;
  23850. getTimeStep(): number;
  23851. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23852. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23853. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23854. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23855. removePhysicsBody(impostor: PhysicsImpostor): void;
  23856. generateJoint(joint: PhysicsImpostorJoint): void;
  23857. removeJoint(joint: PhysicsImpostorJoint): void;
  23858. isSupported(): boolean;
  23859. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23860. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23861. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23862. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23863. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23866. getBodyMass(impostor: PhysicsImpostor): number;
  23867. getBodyFriction(impostor: PhysicsImpostor): number;
  23868. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23869. getBodyRestitution(impostor: PhysicsImpostor): number;
  23870. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23871. getBodyPressure?(impostor: PhysicsImpostor): number;
  23872. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23873. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23874. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23875. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23876. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23877. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23878. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23879. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23880. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23881. sleepBody(impostor: PhysicsImpostor): void;
  23882. wakeUpBody(impostor: PhysicsImpostor): void;
  23883. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23884. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23885. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23886. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23887. getRadius(impostor: PhysicsImpostor): number;
  23888. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23889. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23890. dispose(): void;
  23891. }
  23892. /**
  23893. * Interface used to define a physics engine
  23894. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23895. */
  23896. export interface IPhysicsEngine {
  23897. /**
  23898. * Gets the gravity vector used by the simulation
  23899. */
  23900. gravity: Vector3;
  23901. /**
  23902. * Sets the gravity vector used by the simulation
  23903. * @param gravity defines the gravity vector to use
  23904. */
  23905. setGravity(gravity: Vector3): void;
  23906. /**
  23907. * Set the time step of the physics engine.
  23908. * Default is 1/60.
  23909. * To slow it down, enter 1/600 for example.
  23910. * To speed it up, 1/30
  23911. * @param newTimeStep the new timestep to apply to this world.
  23912. */
  23913. setTimeStep(newTimeStep: number): void;
  23914. /**
  23915. * Get the time step of the physics engine.
  23916. * @returns the current time step
  23917. */
  23918. getTimeStep(): number;
  23919. /**
  23920. * Set the sub time step of the physics engine.
  23921. * Default is 0 meaning there is no sub steps
  23922. * To increase physics resolution precision, set a small value (like 1 ms)
  23923. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23924. */
  23925. setSubTimeStep(subTimeStep: number): void;
  23926. /**
  23927. * Get the sub time step of the physics engine.
  23928. * @returns the current sub time step
  23929. */
  23930. getSubTimeStep(): number;
  23931. /**
  23932. * Release all resources
  23933. */
  23934. dispose(): void;
  23935. /**
  23936. * Gets the name of the current physics plugin
  23937. * @returns the name of the plugin
  23938. */
  23939. getPhysicsPluginName(): string;
  23940. /**
  23941. * Adding a new impostor for the impostor tracking.
  23942. * This will be done by the impostor itself.
  23943. * @param impostor the impostor to add
  23944. */
  23945. addImpostor(impostor: PhysicsImpostor): void;
  23946. /**
  23947. * Remove an impostor from the engine.
  23948. * This impostor and its mesh will not longer be updated by the physics engine.
  23949. * @param impostor the impostor to remove
  23950. */
  23951. removeImpostor(impostor: PhysicsImpostor): void;
  23952. /**
  23953. * Add a joint to the physics engine
  23954. * @param mainImpostor defines the main impostor to which the joint is added.
  23955. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23956. * @param joint defines the joint that will connect both impostors.
  23957. */
  23958. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23959. /**
  23960. * Removes a joint from the simulation
  23961. * @param mainImpostor defines the impostor used with the joint
  23962. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23963. * @param joint defines the joint to remove
  23964. */
  23965. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23966. /**
  23967. * Gets the current plugin used to run the simulation
  23968. * @returns current plugin
  23969. */
  23970. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23971. /**
  23972. * Gets the list of physic impostors
  23973. * @returns an array of PhysicsImpostor
  23974. */
  23975. getImpostors(): Array<PhysicsImpostor>;
  23976. /**
  23977. * Gets the impostor for a physics enabled object
  23978. * @param object defines the object impersonated by the impostor
  23979. * @returns the PhysicsImpostor or null if not found
  23980. */
  23981. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23982. /**
  23983. * Gets the impostor for a physics body object
  23984. * @param body defines physics body used by the impostor
  23985. * @returns the PhysicsImpostor or null if not found
  23986. */
  23987. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23988. /**
  23989. * Does a raycast in the physics world
  23990. * @param from when should the ray start?
  23991. * @param to when should the ray end?
  23992. * @returns PhysicsRaycastResult
  23993. */
  23994. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23995. /**
  23996. * Called by the scene. No need to call it.
  23997. * @param delta defines the timespam between frames
  23998. */
  23999. _step(delta: number): void;
  24000. }
  24001. }
  24002. declare module BABYLON {
  24003. /**
  24004. * The interface for the physics imposter parameters
  24005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24006. */
  24007. export interface PhysicsImpostorParameters {
  24008. /**
  24009. * The mass of the physics imposter
  24010. */
  24011. mass: number;
  24012. /**
  24013. * The friction of the physics imposter
  24014. */
  24015. friction?: number;
  24016. /**
  24017. * The coefficient of restitution of the physics imposter
  24018. */
  24019. restitution?: number;
  24020. /**
  24021. * The native options of the physics imposter
  24022. */
  24023. nativeOptions?: any;
  24024. /**
  24025. * Specifies if the parent should be ignored
  24026. */
  24027. ignoreParent?: boolean;
  24028. /**
  24029. * Specifies if bi-directional transformations should be disabled
  24030. */
  24031. disableBidirectionalTransformation?: boolean;
  24032. /**
  24033. * The pressure inside the physics imposter, soft object only
  24034. */
  24035. pressure?: number;
  24036. /**
  24037. * The stiffness the physics imposter, soft object only
  24038. */
  24039. stiffness?: number;
  24040. /**
  24041. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24042. */
  24043. velocityIterations?: number;
  24044. /**
  24045. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24046. */
  24047. positionIterations?: number;
  24048. /**
  24049. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24050. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24051. * Add to fix multiple points
  24052. */
  24053. fixedPoints?: number;
  24054. /**
  24055. * The collision margin around a soft object
  24056. */
  24057. margin?: number;
  24058. /**
  24059. * The collision margin around a soft object
  24060. */
  24061. damping?: number;
  24062. /**
  24063. * The path for a rope based on an extrusion
  24064. */
  24065. path?: any;
  24066. /**
  24067. * The shape of an extrusion used for a rope based on an extrusion
  24068. */
  24069. shape?: any;
  24070. }
  24071. /**
  24072. * Interface for a physics-enabled object
  24073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24074. */
  24075. export interface IPhysicsEnabledObject {
  24076. /**
  24077. * The position of the physics-enabled object
  24078. */
  24079. position: Vector3;
  24080. /**
  24081. * The rotation of the physics-enabled object
  24082. */
  24083. rotationQuaternion: Nullable<Quaternion>;
  24084. /**
  24085. * The scale of the physics-enabled object
  24086. */
  24087. scaling: Vector3;
  24088. /**
  24089. * The rotation of the physics-enabled object
  24090. */
  24091. rotation?: Vector3;
  24092. /**
  24093. * The parent of the physics-enabled object
  24094. */
  24095. parent?: any;
  24096. /**
  24097. * The bounding info of the physics-enabled object
  24098. * @returns The bounding info of the physics-enabled object
  24099. */
  24100. getBoundingInfo(): BoundingInfo;
  24101. /**
  24102. * Computes the world matrix
  24103. * @param force Specifies if the world matrix should be computed by force
  24104. * @returns A world matrix
  24105. */
  24106. computeWorldMatrix(force: boolean): Matrix;
  24107. /**
  24108. * Gets the world matrix
  24109. * @returns A world matrix
  24110. */
  24111. getWorldMatrix?(): Matrix;
  24112. /**
  24113. * Gets the child meshes
  24114. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24115. * @returns An array of abstract meshes
  24116. */
  24117. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24118. /**
  24119. * Gets the vertex data
  24120. * @param kind The type of vertex data
  24121. * @returns A nullable array of numbers, or a float32 array
  24122. */
  24123. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24124. /**
  24125. * Gets the indices from the mesh
  24126. * @returns A nullable array of index arrays
  24127. */
  24128. getIndices?(): Nullable<IndicesArray>;
  24129. /**
  24130. * Gets the scene from the mesh
  24131. * @returns the indices array or null
  24132. */
  24133. getScene?(): Scene;
  24134. /**
  24135. * Gets the absolute position from the mesh
  24136. * @returns the absolute position
  24137. */
  24138. getAbsolutePosition(): Vector3;
  24139. /**
  24140. * Gets the absolute pivot point from the mesh
  24141. * @returns the absolute pivot point
  24142. */
  24143. getAbsolutePivotPoint(): Vector3;
  24144. /**
  24145. * Rotates the mesh
  24146. * @param axis The axis of rotation
  24147. * @param amount The amount of rotation
  24148. * @param space The space of the rotation
  24149. * @returns The rotation transform node
  24150. */
  24151. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24152. /**
  24153. * Translates the mesh
  24154. * @param axis The axis of translation
  24155. * @param distance The distance of translation
  24156. * @param space The space of the translation
  24157. * @returns The transform node
  24158. */
  24159. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24160. /**
  24161. * Sets the absolute position of the mesh
  24162. * @param absolutePosition The absolute position of the mesh
  24163. * @returns The transform node
  24164. */
  24165. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24166. /**
  24167. * Gets the class name of the mesh
  24168. * @returns The class name
  24169. */
  24170. getClassName(): string;
  24171. }
  24172. /**
  24173. * Represents a physics imposter
  24174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24175. */
  24176. export class PhysicsImpostor {
  24177. /**
  24178. * The physics-enabled object used as the physics imposter
  24179. */
  24180. object: IPhysicsEnabledObject;
  24181. /**
  24182. * The type of the physics imposter
  24183. */
  24184. type: number;
  24185. private _options;
  24186. private _scene?;
  24187. /**
  24188. * The default object size of the imposter
  24189. */
  24190. static DEFAULT_OBJECT_SIZE: Vector3;
  24191. /**
  24192. * The identity quaternion of the imposter
  24193. */
  24194. static IDENTITY_QUATERNION: Quaternion;
  24195. /** @hidden */
  24196. _pluginData: any;
  24197. private _physicsEngine;
  24198. private _physicsBody;
  24199. private _bodyUpdateRequired;
  24200. private _onBeforePhysicsStepCallbacks;
  24201. private _onAfterPhysicsStepCallbacks;
  24202. /** @hidden */
  24203. _onPhysicsCollideCallbacks: Array<{
  24204. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24205. otherImpostors: Array<PhysicsImpostor>;
  24206. }>;
  24207. private _deltaPosition;
  24208. private _deltaRotation;
  24209. private _deltaRotationConjugated;
  24210. /** @hidden */
  24211. _isFromLine: boolean;
  24212. private _parent;
  24213. private _isDisposed;
  24214. private static _tmpVecs;
  24215. private static _tmpQuat;
  24216. /**
  24217. * Specifies if the physics imposter is disposed
  24218. */
  24219. get isDisposed(): boolean;
  24220. /**
  24221. * Gets the mass of the physics imposter
  24222. */
  24223. get mass(): number;
  24224. set mass(value: number);
  24225. /**
  24226. * Gets the coefficient of friction
  24227. */
  24228. get friction(): number;
  24229. /**
  24230. * Sets the coefficient of friction
  24231. */
  24232. set friction(value: number);
  24233. /**
  24234. * Gets the coefficient of restitution
  24235. */
  24236. get restitution(): number;
  24237. /**
  24238. * Sets the coefficient of restitution
  24239. */
  24240. set restitution(value: number);
  24241. /**
  24242. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24243. */
  24244. get pressure(): number;
  24245. /**
  24246. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24247. */
  24248. set pressure(value: number);
  24249. /**
  24250. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24251. */
  24252. get stiffness(): number;
  24253. /**
  24254. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24255. */
  24256. set stiffness(value: number);
  24257. /**
  24258. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24259. */
  24260. get velocityIterations(): number;
  24261. /**
  24262. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24263. */
  24264. set velocityIterations(value: number);
  24265. /**
  24266. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24267. */
  24268. get positionIterations(): number;
  24269. /**
  24270. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24271. */
  24272. set positionIterations(value: number);
  24273. /**
  24274. * The unique id of the physics imposter
  24275. * set by the physics engine when adding this impostor to the array
  24276. */
  24277. uniqueId: number;
  24278. /**
  24279. * @hidden
  24280. */
  24281. soft: boolean;
  24282. /**
  24283. * @hidden
  24284. */
  24285. segments: number;
  24286. private _joints;
  24287. /**
  24288. * Initializes the physics imposter
  24289. * @param object The physics-enabled object used as the physics imposter
  24290. * @param type The type of the physics imposter
  24291. * @param _options The options for the physics imposter
  24292. * @param _scene The Babylon scene
  24293. */
  24294. constructor(
  24295. /**
  24296. * The physics-enabled object used as the physics imposter
  24297. */
  24298. object: IPhysicsEnabledObject,
  24299. /**
  24300. * The type of the physics imposter
  24301. */
  24302. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24303. /**
  24304. * This function will completly initialize this impostor.
  24305. * It will create a new body - but only if this mesh has no parent.
  24306. * If it has, this impostor will not be used other than to define the impostor
  24307. * of the child mesh.
  24308. * @hidden
  24309. */
  24310. _init(): void;
  24311. private _getPhysicsParent;
  24312. /**
  24313. * Should a new body be generated.
  24314. * @returns boolean specifying if body initialization is required
  24315. */
  24316. isBodyInitRequired(): boolean;
  24317. /**
  24318. * Sets the updated scaling
  24319. * @param updated Specifies if the scaling is updated
  24320. */
  24321. setScalingUpdated(): void;
  24322. /**
  24323. * Force a regeneration of this or the parent's impostor's body.
  24324. * Use under cautious - This will remove all joints already implemented.
  24325. */
  24326. forceUpdate(): void;
  24327. /**
  24328. * Gets the body that holds this impostor. Either its own, or its parent.
  24329. */
  24330. get physicsBody(): any;
  24331. /**
  24332. * Get the parent of the physics imposter
  24333. * @returns Physics imposter or null
  24334. */
  24335. get parent(): Nullable<PhysicsImpostor>;
  24336. /**
  24337. * Sets the parent of the physics imposter
  24338. */
  24339. set parent(value: Nullable<PhysicsImpostor>);
  24340. /**
  24341. * Set the physics body. Used mainly by the physics engine/plugin
  24342. */
  24343. set physicsBody(physicsBody: any);
  24344. /**
  24345. * Resets the update flags
  24346. */
  24347. resetUpdateFlags(): void;
  24348. /**
  24349. * Gets the object extend size
  24350. * @returns the object extend size
  24351. */
  24352. getObjectExtendSize(): Vector3;
  24353. /**
  24354. * Gets the object center
  24355. * @returns The object center
  24356. */
  24357. getObjectCenter(): Vector3;
  24358. /**
  24359. * Get a specific parameter from the options parameters
  24360. * @param paramName The object parameter name
  24361. * @returns The object parameter
  24362. */
  24363. getParam(paramName: string): any;
  24364. /**
  24365. * Sets a specific parameter in the options given to the physics plugin
  24366. * @param paramName The parameter name
  24367. * @param value The value of the parameter
  24368. */
  24369. setParam(paramName: string, value: number): void;
  24370. /**
  24371. * Specifically change the body's mass option. Won't recreate the physics body object
  24372. * @param mass The mass of the physics imposter
  24373. */
  24374. setMass(mass: number): void;
  24375. /**
  24376. * Gets the linear velocity
  24377. * @returns linear velocity or null
  24378. */
  24379. getLinearVelocity(): Nullable<Vector3>;
  24380. /**
  24381. * Sets the linear velocity
  24382. * @param velocity linear velocity or null
  24383. */
  24384. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24385. /**
  24386. * Gets the angular velocity
  24387. * @returns angular velocity or null
  24388. */
  24389. getAngularVelocity(): Nullable<Vector3>;
  24390. /**
  24391. * Sets the angular velocity
  24392. * @param velocity The velocity or null
  24393. */
  24394. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24395. /**
  24396. * Execute a function with the physics plugin native code
  24397. * Provide a function the will have two variables - the world object and the physics body object
  24398. * @param func The function to execute with the physics plugin native code
  24399. */
  24400. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24401. /**
  24402. * Register a function that will be executed before the physics world is stepping forward
  24403. * @param func The function to execute before the physics world is stepped forward
  24404. */
  24405. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24406. /**
  24407. * Unregister a function that will be executed before the physics world is stepping forward
  24408. * @param func The function to execute before the physics world is stepped forward
  24409. */
  24410. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24411. /**
  24412. * Register a function that will be executed after the physics step
  24413. * @param func The function to execute after physics step
  24414. */
  24415. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24416. /**
  24417. * Unregisters a function that will be executed after the physics step
  24418. * @param func The function to execute after physics step
  24419. */
  24420. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24421. /**
  24422. * register a function that will be executed when this impostor collides against a different body
  24423. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24424. * @param func Callback that is executed on collision
  24425. */
  24426. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24427. /**
  24428. * Unregisters the physics imposter on contact
  24429. * @param collideAgainst The physics object to collide against
  24430. * @param func Callback to execute on collision
  24431. */
  24432. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24433. private _tmpQuat;
  24434. private _tmpQuat2;
  24435. /**
  24436. * Get the parent rotation
  24437. * @returns The parent rotation
  24438. */
  24439. getParentsRotation(): Quaternion;
  24440. /**
  24441. * this function is executed by the physics engine.
  24442. */
  24443. beforeStep: () => void;
  24444. /**
  24445. * this function is executed by the physics engine
  24446. */
  24447. afterStep: () => void;
  24448. /**
  24449. * Legacy collision detection event support
  24450. */
  24451. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24452. /**
  24453. * event and body object due to cannon's event-based architecture.
  24454. */
  24455. onCollide: (e: {
  24456. body: any;
  24457. }) => void;
  24458. /**
  24459. * Apply a force
  24460. * @param force The force to apply
  24461. * @param contactPoint The contact point for the force
  24462. * @returns The physics imposter
  24463. */
  24464. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24465. /**
  24466. * Apply an impulse
  24467. * @param force The impulse force
  24468. * @param contactPoint The contact point for the impulse force
  24469. * @returns The physics imposter
  24470. */
  24471. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24472. /**
  24473. * A help function to create a joint
  24474. * @param otherImpostor A physics imposter used to create a joint
  24475. * @param jointType The type of joint
  24476. * @param jointData The data for the joint
  24477. * @returns The physics imposter
  24478. */
  24479. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24480. /**
  24481. * Add a joint to this impostor with a different impostor
  24482. * @param otherImpostor A physics imposter used to add a joint
  24483. * @param joint The joint to add
  24484. * @returns The physics imposter
  24485. */
  24486. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24487. /**
  24488. * Add an anchor to a cloth impostor
  24489. * @param otherImpostor rigid impostor to anchor to
  24490. * @param width ratio across width from 0 to 1
  24491. * @param height ratio up height from 0 to 1
  24492. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24493. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24494. * @returns impostor the soft imposter
  24495. */
  24496. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24497. /**
  24498. * Add a hook to a rope impostor
  24499. * @param otherImpostor rigid impostor to anchor to
  24500. * @param length ratio across rope from 0 to 1
  24501. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24502. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24503. * @returns impostor the rope imposter
  24504. */
  24505. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24506. /**
  24507. * Will keep this body still, in a sleep mode.
  24508. * @returns the physics imposter
  24509. */
  24510. sleep(): PhysicsImpostor;
  24511. /**
  24512. * Wake the body up.
  24513. * @returns The physics imposter
  24514. */
  24515. wakeUp(): PhysicsImpostor;
  24516. /**
  24517. * Clones the physics imposter
  24518. * @param newObject The physics imposter clones to this physics-enabled object
  24519. * @returns A nullable physics imposter
  24520. */
  24521. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24522. /**
  24523. * Disposes the physics imposter
  24524. */
  24525. dispose(): void;
  24526. /**
  24527. * Sets the delta position
  24528. * @param position The delta position amount
  24529. */
  24530. setDeltaPosition(position: Vector3): void;
  24531. /**
  24532. * Sets the delta rotation
  24533. * @param rotation The delta rotation amount
  24534. */
  24535. setDeltaRotation(rotation: Quaternion): void;
  24536. /**
  24537. * Gets the box size of the physics imposter and stores the result in the input parameter
  24538. * @param result Stores the box size
  24539. * @returns The physics imposter
  24540. */
  24541. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24542. /**
  24543. * Gets the radius of the physics imposter
  24544. * @returns Radius of the physics imposter
  24545. */
  24546. getRadius(): number;
  24547. /**
  24548. * Sync a bone with this impostor
  24549. * @param bone The bone to sync to the impostor.
  24550. * @param boneMesh The mesh that the bone is influencing.
  24551. * @param jointPivot The pivot of the joint / bone in local space.
  24552. * @param distToJoint Optional distance from the impostor to the joint.
  24553. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24554. */
  24555. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24556. /**
  24557. * Sync impostor to a bone
  24558. * @param bone The bone that the impostor will be synced to.
  24559. * @param boneMesh The mesh that the bone is influencing.
  24560. * @param jointPivot The pivot of the joint / bone in local space.
  24561. * @param distToJoint Optional distance from the impostor to the joint.
  24562. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24563. * @param boneAxis Optional vector3 axis the bone is aligned with
  24564. */
  24565. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24566. /**
  24567. * No-Imposter type
  24568. */
  24569. static NoImpostor: number;
  24570. /**
  24571. * Sphere-Imposter type
  24572. */
  24573. static SphereImpostor: number;
  24574. /**
  24575. * Box-Imposter type
  24576. */
  24577. static BoxImpostor: number;
  24578. /**
  24579. * Plane-Imposter type
  24580. */
  24581. static PlaneImpostor: number;
  24582. /**
  24583. * Mesh-imposter type
  24584. */
  24585. static MeshImpostor: number;
  24586. /**
  24587. * Capsule-Impostor type (Ammo.js plugin only)
  24588. */
  24589. static CapsuleImpostor: number;
  24590. /**
  24591. * Cylinder-Imposter type
  24592. */
  24593. static CylinderImpostor: number;
  24594. /**
  24595. * Particle-Imposter type
  24596. */
  24597. static ParticleImpostor: number;
  24598. /**
  24599. * Heightmap-Imposter type
  24600. */
  24601. static HeightmapImpostor: number;
  24602. /**
  24603. * ConvexHull-Impostor type (Ammo.js plugin only)
  24604. */
  24605. static ConvexHullImpostor: number;
  24606. /**
  24607. * Custom-Imposter type (Ammo.js plugin only)
  24608. */
  24609. static CustomImpostor: number;
  24610. /**
  24611. * Rope-Imposter type
  24612. */
  24613. static RopeImpostor: number;
  24614. /**
  24615. * Cloth-Imposter type
  24616. */
  24617. static ClothImpostor: number;
  24618. /**
  24619. * Softbody-Imposter type
  24620. */
  24621. static SoftbodyImpostor: number;
  24622. }
  24623. }
  24624. declare module BABYLON {
  24625. /**
  24626. * @hidden
  24627. **/
  24628. export class _CreationDataStorage {
  24629. closePath?: boolean;
  24630. closeArray?: boolean;
  24631. idx: number[];
  24632. dashSize: number;
  24633. gapSize: number;
  24634. path3D: Path3D;
  24635. pathArray: Vector3[][];
  24636. arc: number;
  24637. radius: number;
  24638. cap: number;
  24639. tessellation: number;
  24640. }
  24641. /**
  24642. * @hidden
  24643. **/
  24644. class _InstanceDataStorage {
  24645. visibleInstances: any;
  24646. batchCache: _InstancesBatch;
  24647. instancesBufferSize: number;
  24648. instancesBuffer: Nullable<Buffer>;
  24649. instancesData: Float32Array;
  24650. overridenInstanceCount: number;
  24651. isFrozen: boolean;
  24652. previousBatch: Nullable<_InstancesBatch>;
  24653. hardwareInstancedRendering: boolean;
  24654. sideOrientation: number;
  24655. manualUpdate: boolean;
  24656. }
  24657. /**
  24658. * @hidden
  24659. **/
  24660. export class _InstancesBatch {
  24661. mustReturn: boolean;
  24662. visibleInstances: Nullable<InstancedMesh[]>[];
  24663. renderSelf: boolean[];
  24664. hardwareInstancedRendering: boolean[];
  24665. }
  24666. /**
  24667. * Class used to represent renderable models
  24668. */
  24669. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24670. /**
  24671. * Mesh side orientation : usually the external or front surface
  24672. */
  24673. static readonly FRONTSIDE: number;
  24674. /**
  24675. * Mesh side orientation : usually the internal or back surface
  24676. */
  24677. static readonly BACKSIDE: number;
  24678. /**
  24679. * Mesh side orientation : both internal and external or front and back surfaces
  24680. */
  24681. static readonly DOUBLESIDE: number;
  24682. /**
  24683. * Mesh side orientation : by default, `FRONTSIDE`
  24684. */
  24685. static readonly DEFAULTSIDE: number;
  24686. /**
  24687. * Mesh cap setting : no cap
  24688. */
  24689. static readonly NO_CAP: number;
  24690. /**
  24691. * Mesh cap setting : one cap at the beginning of the mesh
  24692. */
  24693. static readonly CAP_START: number;
  24694. /**
  24695. * Mesh cap setting : one cap at the end of the mesh
  24696. */
  24697. static readonly CAP_END: number;
  24698. /**
  24699. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24700. */
  24701. static readonly CAP_ALL: number;
  24702. /**
  24703. * Mesh pattern setting : no flip or rotate
  24704. */
  24705. static readonly NO_FLIP: number;
  24706. /**
  24707. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24708. */
  24709. static readonly FLIP_TILE: number;
  24710. /**
  24711. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24712. */
  24713. static readonly ROTATE_TILE: number;
  24714. /**
  24715. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24716. */
  24717. static readonly FLIP_ROW: number;
  24718. /**
  24719. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24720. */
  24721. static readonly ROTATE_ROW: number;
  24722. /**
  24723. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24724. */
  24725. static readonly FLIP_N_ROTATE_TILE: number;
  24726. /**
  24727. * Mesh pattern setting : rotate pattern and rotate
  24728. */
  24729. static readonly FLIP_N_ROTATE_ROW: number;
  24730. /**
  24731. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24732. */
  24733. static readonly CENTER: number;
  24734. /**
  24735. * Mesh tile positioning : part tiles on left
  24736. */
  24737. static readonly LEFT: number;
  24738. /**
  24739. * Mesh tile positioning : part tiles on right
  24740. */
  24741. static readonly RIGHT: number;
  24742. /**
  24743. * Mesh tile positioning : part tiles on top
  24744. */
  24745. static readonly TOP: number;
  24746. /**
  24747. * Mesh tile positioning : part tiles on bottom
  24748. */
  24749. static readonly BOTTOM: number;
  24750. /**
  24751. * Gets the default side orientation.
  24752. * @param orientation the orientation to value to attempt to get
  24753. * @returns the default orientation
  24754. * @hidden
  24755. */
  24756. static _GetDefaultSideOrientation(orientation?: number): number;
  24757. private _internalMeshDataInfo;
  24758. /**
  24759. * An event triggered before rendering the mesh
  24760. */
  24761. get onBeforeRenderObservable(): Observable<Mesh>;
  24762. /**
  24763. * An event triggered before binding the mesh
  24764. */
  24765. get onBeforeBindObservable(): Observable<Mesh>;
  24766. /**
  24767. * An event triggered after rendering the mesh
  24768. */
  24769. get onAfterRenderObservable(): Observable<Mesh>;
  24770. /**
  24771. * An event triggered before drawing the mesh
  24772. */
  24773. get onBeforeDrawObservable(): Observable<Mesh>;
  24774. private _onBeforeDrawObserver;
  24775. /**
  24776. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24777. */
  24778. set onBeforeDraw(callback: () => void);
  24779. get hasInstances(): boolean;
  24780. /**
  24781. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24782. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24783. */
  24784. delayLoadState: number;
  24785. /**
  24786. * Gets the list of instances created from this mesh
  24787. * it is not supposed to be modified manually.
  24788. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24790. */
  24791. instances: InstancedMesh[];
  24792. /**
  24793. * Gets the file containing delay loading data for this mesh
  24794. */
  24795. delayLoadingFile: string;
  24796. /** @hidden */
  24797. _binaryInfo: any;
  24798. /**
  24799. * User defined function used to change how LOD level selection is done
  24800. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24801. */
  24802. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24803. /**
  24804. * Gets or sets the morph target manager
  24805. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24806. */
  24807. get morphTargetManager(): Nullable<MorphTargetManager>;
  24808. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24809. /** @hidden */
  24810. _creationDataStorage: Nullable<_CreationDataStorage>;
  24811. /** @hidden */
  24812. _geometry: Nullable<Geometry>;
  24813. /** @hidden */
  24814. _delayInfo: Array<string>;
  24815. /** @hidden */
  24816. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24817. /** @hidden */
  24818. _instanceDataStorage: _InstanceDataStorage;
  24819. private _effectiveMaterial;
  24820. /** @hidden */
  24821. _shouldGenerateFlatShading: boolean;
  24822. /** @hidden */
  24823. _originalBuilderSideOrientation: number;
  24824. /**
  24825. * Use this property to change the original side orientation defined at construction time
  24826. */
  24827. overrideMaterialSideOrientation: Nullable<number>;
  24828. /**
  24829. * Gets the source mesh (the one used to clone this one from)
  24830. */
  24831. get source(): Nullable<Mesh>;
  24832. /**
  24833. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24834. */
  24835. get isUnIndexed(): boolean;
  24836. set isUnIndexed(value: boolean);
  24837. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24838. get worldMatrixInstancedBuffer(): Float32Array;
  24839. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24840. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24841. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24842. /**
  24843. * @constructor
  24844. * @param name The value used by scene.getMeshByName() to do a lookup.
  24845. * @param scene The scene to add this mesh to.
  24846. * @param parent The parent of this mesh, if it has one
  24847. * @param source An optional Mesh from which geometry is shared, cloned.
  24848. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24849. * When false, achieved by calling a clone(), also passing False.
  24850. * This will make creation of children, recursive.
  24851. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24852. */
  24853. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24854. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24855. doNotInstantiate: boolean;
  24856. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24857. /**
  24858. * Gets the class name
  24859. * @returns the string "Mesh".
  24860. */
  24861. getClassName(): string;
  24862. /** @hidden */
  24863. get _isMesh(): boolean;
  24864. /**
  24865. * Returns a description of this mesh
  24866. * @param fullDetails define if full details about this mesh must be used
  24867. * @returns a descriptive string representing this mesh
  24868. */
  24869. toString(fullDetails?: boolean): string;
  24870. /** @hidden */
  24871. _unBindEffect(): void;
  24872. /**
  24873. * Gets a boolean indicating if this mesh has LOD
  24874. */
  24875. get hasLODLevels(): boolean;
  24876. /**
  24877. * Gets the list of MeshLODLevel associated with the current mesh
  24878. * @returns an array of MeshLODLevel
  24879. */
  24880. getLODLevels(): MeshLODLevel[];
  24881. private _sortLODLevels;
  24882. /**
  24883. * Add a mesh as LOD level triggered at the given distance.
  24884. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24885. * @param distance The distance from the center of the object to show this level
  24886. * @param mesh The mesh to be added as LOD level (can be null)
  24887. * @return This mesh (for chaining)
  24888. */
  24889. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24890. /**
  24891. * Returns the LOD level mesh at the passed distance or null if not found.
  24892. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24893. * @param distance The distance from the center of the object to show this level
  24894. * @returns a Mesh or `null`
  24895. */
  24896. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24897. /**
  24898. * Remove a mesh from the LOD array
  24899. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24900. * @param mesh defines the mesh to be removed
  24901. * @return This mesh (for chaining)
  24902. */
  24903. removeLODLevel(mesh: Mesh): Mesh;
  24904. /**
  24905. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24906. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24907. * @param camera defines the camera to use to compute distance
  24908. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24909. * @return This mesh (for chaining)
  24910. */
  24911. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24912. /**
  24913. * Gets the mesh internal Geometry object
  24914. */
  24915. get geometry(): Nullable<Geometry>;
  24916. /**
  24917. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24918. * @returns the total number of vertices
  24919. */
  24920. getTotalVertices(): number;
  24921. /**
  24922. * Returns the content of an associated vertex buffer
  24923. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24924. * - VertexBuffer.PositionKind
  24925. * - VertexBuffer.UVKind
  24926. * - VertexBuffer.UV2Kind
  24927. * - VertexBuffer.UV3Kind
  24928. * - VertexBuffer.UV4Kind
  24929. * - VertexBuffer.UV5Kind
  24930. * - VertexBuffer.UV6Kind
  24931. * - VertexBuffer.ColorKind
  24932. * - VertexBuffer.MatricesIndicesKind
  24933. * - VertexBuffer.MatricesIndicesExtraKind
  24934. * - VertexBuffer.MatricesWeightsKind
  24935. * - VertexBuffer.MatricesWeightsExtraKind
  24936. * @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
  24937. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24938. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24939. */
  24940. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24941. /**
  24942. * Returns the mesh VertexBuffer object from the requested `kind`
  24943. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24944. * - VertexBuffer.PositionKind
  24945. * - VertexBuffer.NormalKind
  24946. * - VertexBuffer.UVKind
  24947. * - VertexBuffer.UV2Kind
  24948. * - VertexBuffer.UV3Kind
  24949. * - VertexBuffer.UV4Kind
  24950. * - VertexBuffer.UV5Kind
  24951. * - VertexBuffer.UV6Kind
  24952. * - VertexBuffer.ColorKind
  24953. * - VertexBuffer.MatricesIndicesKind
  24954. * - VertexBuffer.MatricesIndicesExtraKind
  24955. * - VertexBuffer.MatricesWeightsKind
  24956. * - VertexBuffer.MatricesWeightsExtraKind
  24957. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24958. */
  24959. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24960. /**
  24961. * Tests if a specific vertex buffer is associated with this mesh
  24962. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24963. * - VertexBuffer.PositionKind
  24964. * - VertexBuffer.NormalKind
  24965. * - VertexBuffer.UVKind
  24966. * - VertexBuffer.UV2Kind
  24967. * - VertexBuffer.UV3Kind
  24968. * - VertexBuffer.UV4Kind
  24969. * - VertexBuffer.UV5Kind
  24970. * - VertexBuffer.UV6Kind
  24971. * - VertexBuffer.ColorKind
  24972. * - VertexBuffer.MatricesIndicesKind
  24973. * - VertexBuffer.MatricesIndicesExtraKind
  24974. * - VertexBuffer.MatricesWeightsKind
  24975. * - VertexBuffer.MatricesWeightsExtraKind
  24976. * @returns a boolean
  24977. */
  24978. isVerticesDataPresent(kind: string): boolean;
  24979. /**
  24980. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24981. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24982. * - VertexBuffer.PositionKind
  24983. * - VertexBuffer.UVKind
  24984. * - VertexBuffer.UV2Kind
  24985. * - VertexBuffer.UV3Kind
  24986. * - VertexBuffer.UV4Kind
  24987. * - VertexBuffer.UV5Kind
  24988. * - VertexBuffer.UV6Kind
  24989. * - VertexBuffer.ColorKind
  24990. * - VertexBuffer.MatricesIndicesKind
  24991. * - VertexBuffer.MatricesIndicesExtraKind
  24992. * - VertexBuffer.MatricesWeightsKind
  24993. * - VertexBuffer.MatricesWeightsExtraKind
  24994. * @returns a boolean
  24995. */
  24996. isVertexBufferUpdatable(kind: string): boolean;
  24997. /**
  24998. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24999. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25000. * - VertexBuffer.PositionKind
  25001. * - VertexBuffer.NormalKind
  25002. * - VertexBuffer.UVKind
  25003. * - VertexBuffer.UV2Kind
  25004. * - VertexBuffer.UV3Kind
  25005. * - VertexBuffer.UV4Kind
  25006. * - VertexBuffer.UV5Kind
  25007. * - VertexBuffer.UV6Kind
  25008. * - VertexBuffer.ColorKind
  25009. * - VertexBuffer.MatricesIndicesKind
  25010. * - VertexBuffer.MatricesIndicesExtraKind
  25011. * - VertexBuffer.MatricesWeightsKind
  25012. * - VertexBuffer.MatricesWeightsExtraKind
  25013. * @returns an array of strings
  25014. */
  25015. getVerticesDataKinds(): string[];
  25016. /**
  25017. * Returns a positive integer : the total number of indices in this mesh geometry.
  25018. * @returns the numner of indices or zero if the mesh has no geometry.
  25019. */
  25020. getTotalIndices(): number;
  25021. /**
  25022. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25023. * @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.
  25024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25025. * @returns the indices array or an empty array if the mesh has no geometry
  25026. */
  25027. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25028. get isBlocked(): boolean;
  25029. /**
  25030. * Determine if the current mesh is ready to be rendered
  25031. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25032. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25033. * @returns true if all associated assets are ready (material, textures, shaders)
  25034. */
  25035. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25036. /**
  25037. * 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.
  25038. */
  25039. get areNormalsFrozen(): boolean;
  25040. /**
  25041. * 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.
  25042. * @returns the current mesh
  25043. */
  25044. freezeNormals(): Mesh;
  25045. /**
  25046. * 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
  25047. * @returns the current mesh
  25048. */
  25049. unfreezeNormals(): Mesh;
  25050. /**
  25051. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25052. */
  25053. set overridenInstanceCount(count: number);
  25054. /** @hidden */
  25055. _preActivate(): Mesh;
  25056. /** @hidden */
  25057. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25058. /** @hidden */
  25059. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25060. /**
  25061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25062. * This means the mesh underlying bounding box and sphere are recomputed.
  25063. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25064. * @returns the current mesh
  25065. */
  25066. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25067. /** @hidden */
  25068. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25069. /**
  25070. * This function will subdivide the mesh into multiple submeshes
  25071. * @param count defines the expected number of submeshes
  25072. */
  25073. subdivide(count: number): void;
  25074. /**
  25075. * Copy a FloatArray into a specific associated vertex buffer
  25076. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25077. * - VertexBuffer.PositionKind
  25078. * - VertexBuffer.UVKind
  25079. * - VertexBuffer.UV2Kind
  25080. * - VertexBuffer.UV3Kind
  25081. * - VertexBuffer.UV4Kind
  25082. * - VertexBuffer.UV5Kind
  25083. * - VertexBuffer.UV6Kind
  25084. * - VertexBuffer.ColorKind
  25085. * - VertexBuffer.MatricesIndicesKind
  25086. * - VertexBuffer.MatricesIndicesExtraKind
  25087. * - VertexBuffer.MatricesWeightsKind
  25088. * - VertexBuffer.MatricesWeightsExtraKind
  25089. * @param data defines the data source
  25090. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25091. * @param stride defines the data stride size (can be null)
  25092. * @returns the current mesh
  25093. */
  25094. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25095. /**
  25096. * Delete a vertex buffer associated with this mesh
  25097. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25098. * - VertexBuffer.PositionKind
  25099. * - VertexBuffer.UVKind
  25100. * - VertexBuffer.UV2Kind
  25101. * - VertexBuffer.UV3Kind
  25102. * - VertexBuffer.UV4Kind
  25103. * - VertexBuffer.UV5Kind
  25104. * - VertexBuffer.UV6Kind
  25105. * - VertexBuffer.ColorKind
  25106. * - VertexBuffer.MatricesIndicesKind
  25107. * - VertexBuffer.MatricesIndicesExtraKind
  25108. * - VertexBuffer.MatricesWeightsKind
  25109. * - VertexBuffer.MatricesWeightsExtraKind
  25110. */
  25111. removeVerticesData(kind: string): void;
  25112. /**
  25113. * Flags an associated vertex buffer as updatable
  25114. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25115. * - VertexBuffer.PositionKind
  25116. * - VertexBuffer.UVKind
  25117. * - VertexBuffer.UV2Kind
  25118. * - VertexBuffer.UV3Kind
  25119. * - VertexBuffer.UV4Kind
  25120. * - VertexBuffer.UV5Kind
  25121. * - VertexBuffer.UV6Kind
  25122. * - VertexBuffer.ColorKind
  25123. * - VertexBuffer.MatricesIndicesKind
  25124. * - VertexBuffer.MatricesIndicesExtraKind
  25125. * - VertexBuffer.MatricesWeightsKind
  25126. * - VertexBuffer.MatricesWeightsExtraKind
  25127. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25128. */
  25129. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25130. /**
  25131. * Sets the mesh global Vertex Buffer
  25132. * @param buffer defines the buffer to use
  25133. * @returns the current mesh
  25134. */
  25135. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25136. /**
  25137. * Update a specific associated vertex buffer
  25138. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25139. * - VertexBuffer.PositionKind
  25140. * - VertexBuffer.UVKind
  25141. * - VertexBuffer.UV2Kind
  25142. * - VertexBuffer.UV3Kind
  25143. * - VertexBuffer.UV4Kind
  25144. * - VertexBuffer.UV5Kind
  25145. * - VertexBuffer.UV6Kind
  25146. * - VertexBuffer.ColorKind
  25147. * - VertexBuffer.MatricesIndicesKind
  25148. * - VertexBuffer.MatricesIndicesExtraKind
  25149. * - VertexBuffer.MatricesWeightsKind
  25150. * - VertexBuffer.MatricesWeightsExtraKind
  25151. * @param data defines the data source
  25152. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25153. * @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)
  25154. * @returns the current mesh
  25155. */
  25156. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25157. /**
  25158. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25159. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25160. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25161. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25162. * @returns the current mesh
  25163. */
  25164. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25165. /**
  25166. * Creates a un-shared specific occurence of the geometry for the mesh.
  25167. * @returns the current mesh
  25168. */
  25169. makeGeometryUnique(): Mesh;
  25170. /**
  25171. * Set the index buffer of this mesh
  25172. * @param indices defines the source data
  25173. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25174. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25175. * @returns the current mesh
  25176. */
  25177. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25178. /**
  25179. * Update the current index buffer
  25180. * @param indices defines the source data
  25181. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25182. * @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)
  25183. * @returns the current mesh
  25184. */
  25185. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25186. /**
  25187. * Invert the geometry to move from a right handed system to a left handed one.
  25188. * @returns the current mesh
  25189. */
  25190. toLeftHanded(): Mesh;
  25191. /** @hidden */
  25192. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25193. /** @hidden */
  25194. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25195. /**
  25196. * Registers for this mesh a javascript function called just before the rendering process
  25197. * @param func defines the function to call before rendering this mesh
  25198. * @returns the current mesh
  25199. */
  25200. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25201. /**
  25202. * Disposes a previously registered javascript function called before the rendering
  25203. * @param func defines the function to remove
  25204. * @returns the current mesh
  25205. */
  25206. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25207. /**
  25208. * Registers for this mesh a javascript function called just after the rendering is complete
  25209. * @param func defines the function to call after rendering this mesh
  25210. * @returns the current mesh
  25211. */
  25212. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25213. /**
  25214. * Disposes a previously registered javascript function called after the rendering.
  25215. * @param func defines the function to remove
  25216. * @returns the current mesh
  25217. */
  25218. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25219. /** @hidden */
  25220. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25221. /** @hidden */
  25222. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25223. /** @hidden */
  25224. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25225. /** @hidden */
  25226. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25227. /** @hidden */
  25228. _rebuild(): void;
  25229. /** @hidden */
  25230. _freeze(): void;
  25231. /** @hidden */
  25232. _unFreeze(): void;
  25233. /**
  25234. * 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
  25235. * @param subMesh defines the subMesh to render
  25236. * @param enableAlphaMode defines if alpha mode can be changed
  25237. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25238. * @returns the current mesh
  25239. */
  25240. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25241. private _onBeforeDraw;
  25242. /**
  25243. * Renormalize the mesh and patch it up if there are no weights
  25244. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25245. * However in the case of zero weights then we set just a single influence to 1.
  25246. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25247. */
  25248. cleanMatrixWeights(): void;
  25249. private normalizeSkinFourWeights;
  25250. private normalizeSkinWeightsAndExtra;
  25251. /**
  25252. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25253. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25254. * the user know there was an issue with importing the mesh
  25255. * @returns a validation object with skinned, valid and report string
  25256. */
  25257. validateSkinning(): {
  25258. skinned: boolean;
  25259. valid: boolean;
  25260. report: string;
  25261. };
  25262. /** @hidden */
  25263. _checkDelayState(): Mesh;
  25264. private _queueLoad;
  25265. /**
  25266. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25267. * A mesh is in the frustum if its bounding box intersects the frustum
  25268. * @param frustumPlanes defines the frustum to test
  25269. * @returns true if the mesh is in the frustum planes
  25270. */
  25271. isInFrustum(frustumPlanes: Plane[]): boolean;
  25272. /**
  25273. * Sets the mesh material by the material or multiMaterial `id` property
  25274. * @param id is a string identifying the material or the multiMaterial
  25275. * @returns the current mesh
  25276. */
  25277. setMaterialByID(id: string): Mesh;
  25278. /**
  25279. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25280. * @returns an array of IAnimatable
  25281. */
  25282. getAnimatables(): IAnimatable[];
  25283. /**
  25284. * Modifies the mesh geometry according to the passed transformation matrix.
  25285. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25286. * The mesh normals are modified using the same transformation.
  25287. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25288. * @param transform defines the transform matrix to use
  25289. * @see http://doc.babylonjs.com/resources/baking_transformations
  25290. * @returns the current mesh
  25291. */
  25292. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25293. /**
  25294. * Modifies the mesh geometry according to its own current World Matrix.
  25295. * The mesh World Matrix is then reset.
  25296. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25297. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25298. * @see http://doc.babylonjs.com/resources/baking_transformations
  25299. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25300. * @returns the current mesh
  25301. */
  25302. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25303. /** @hidden */
  25304. get _positions(): Nullable<Vector3[]>;
  25305. /** @hidden */
  25306. _resetPointsArrayCache(): Mesh;
  25307. /** @hidden */
  25308. _generatePointsArray(): boolean;
  25309. /**
  25310. * Returns a new Mesh object generated from the current mesh properties.
  25311. * This method must not get confused with createInstance()
  25312. * @param name is a string, the name given to the new mesh
  25313. * @param newParent can be any Node object (default `null`)
  25314. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25315. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25316. * @returns a new mesh
  25317. */
  25318. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25319. /**
  25320. * Releases resources associated with this mesh.
  25321. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25322. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25323. */
  25324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25325. /** @hidden */
  25326. _disposeInstanceSpecificData(): void;
  25327. /**
  25328. * Modifies the mesh geometry according to a displacement map.
  25329. * 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.
  25330. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25331. * @param url is a string, the URL from the image file is to be downloaded.
  25332. * @param minHeight is the lower limit of the displacement.
  25333. * @param maxHeight is the upper limit of the displacement.
  25334. * @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.
  25335. * @param uvOffset is an optional vector2 used to offset UV.
  25336. * @param uvScale is an optional vector2 used to scale UV.
  25337. * @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.
  25338. * @returns the Mesh.
  25339. */
  25340. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25341. /**
  25342. * Modifies the mesh geometry according to a displacementMap buffer.
  25343. * 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.
  25344. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25345. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25346. * @param heightMapWidth is the width of the buffer image.
  25347. * @param heightMapHeight is the height of the buffer image.
  25348. * @param minHeight is the lower limit of the displacement.
  25349. * @param maxHeight is the upper limit of the displacement.
  25350. * @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.
  25351. * @param uvOffset is an optional vector2 used to offset UV.
  25352. * @param uvScale is an optional vector2 used to scale UV.
  25353. * @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.
  25354. * @returns the Mesh.
  25355. */
  25356. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25357. /**
  25358. * Modify the mesh to get a flat shading rendering.
  25359. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25360. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25361. * @returns current mesh
  25362. */
  25363. convertToFlatShadedMesh(): Mesh;
  25364. /**
  25365. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25366. * In other words, more vertices, no more indices and a single bigger VBO.
  25367. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25368. * @returns current mesh
  25369. */
  25370. convertToUnIndexedMesh(): Mesh;
  25371. /**
  25372. * Inverses facet orientations.
  25373. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25374. * @param flipNormals will also inverts the normals
  25375. * @returns current mesh
  25376. */
  25377. flipFaces(flipNormals?: boolean): Mesh;
  25378. /**
  25379. * Increase the number of facets and hence vertices in a mesh
  25380. * Vertex normals are interpolated from existing vertex normals
  25381. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25382. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25383. */
  25384. increaseVertices(numberPerEdge: number): void;
  25385. /**
  25386. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25387. * This will undo any application of covertToFlatShadedMesh
  25388. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25389. */
  25390. forceSharedVertices(): void;
  25391. /** @hidden */
  25392. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25393. /** @hidden */
  25394. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25395. /**
  25396. * Creates a new InstancedMesh object from the mesh model.
  25397. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25398. * @param name defines the name of the new instance
  25399. * @returns a new InstancedMesh
  25400. */
  25401. createInstance(name: string): InstancedMesh;
  25402. /**
  25403. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25404. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25405. * @returns the current mesh
  25406. */
  25407. synchronizeInstances(): Mesh;
  25408. /**
  25409. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25410. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25411. * This should be used together with the simplification to avoid disappearing triangles.
  25412. * @param successCallback an optional success callback to be called after the optimization finished.
  25413. * @returns the current mesh
  25414. */
  25415. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25416. /**
  25417. * Serialize current mesh
  25418. * @param serializationObject defines the object which will receive the serialization data
  25419. */
  25420. serialize(serializationObject: any): void;
  25421. /** @hidden */
  25422. _syncGeometryWithMorphTargetManager(): void;
  25423. /** @hidden */
  25424. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25425. /**
  25426. * Returns a new Mesh object parsed from the source provided.
  25427. * @param parsedMesh is the source
  25428. * @param scene defines the hosting scene
  25429. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25430. * @returns a new Mesh
  25431. */
  25432. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25433. /**
  25434. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25435. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25436. * @param name defines the name of the mesh to create
  25437. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25438. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25439. * @param closePath creates a seam between the first and the last points of each path of the path array
  25440. * @param offset is taken in account only if the `pathArray` is containing a single path
  25441. * @param scene defines the hosting scene
  25442. * @param updatable defines if the mesh must be flagged as updatable
  25443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25444. * @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)
  25445. * @returns a new Mesh
  25446. */
  25447. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25448. /**
  25449. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25450. * @param name defines the name of the mesh to create
  25451. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25452. * @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
  25453. * @param scene defines the hosting scene
  25454. * @param updatable defines if the mesh must be flagged as updatable
  25455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25456. * @returns a new Mesh
  25457. */
  25458. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25459. /**
  25460. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25461. * @param name defines the name of the mesh to create
  25462. * @param size sets the size (float) of each box side (default 1)
  25463. * @param scene defines the hosting scene
  25464. * @param updatable defines if the mesh must be flagged as updatable
  25465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25466. * @returns a new Mesh
  25467. */
  25468. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25469. /**
  25470. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25471. * @param name defines the name of the mesh to create
  25472. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25473. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25474. * @param scene defines the hosting scene
  25475. * @param updatable defines if the mesh must be flagged as updatable
  25476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25477. * @returns a new Mesh
  25478. */
  25479. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25480. /**
  25481. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25482. * @param name defines the name of the mesh to create
  25483. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25484. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25485. * @param scene defines the hosting scene
  25486. * @returns a new Mesh
  25487. */
  25488. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25489. /**
  25490. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  25493. * @param diameterTop set the top cap diameter (floats, default 1)
  25494. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25495. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25496. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25497. * @param scene defines the hosting scene
  25498. * @param updatable defines if the mesh must be flagged as updatable
  25499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25500. * @returns a new Mesh
  25501. */
  25502. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25503. /**
  25504. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25505. * @param name defines the name of the mesh to create
  25506. * @param diameter sets the diameter size (float) of the torus (default 1)
  25507. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25508. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25512. * @returns a new Mesh
  25513. */
  25514. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25515. /**
  25516. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25517. * @param name defines the name of the mesh to create
  25518. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25519. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25520. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25521. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25522. * @param p the number of windings on X axis (positive integers, default 2)
  25523. * @param q the number of windings on Y axis (positive integers, default 3)
  25524. * @param scene defines the hosting scene
  25525. * @param updatable defines if the mesh must be flagged as updatable
  25526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25527. * @returns a new Mesh
  25528. */
  25529. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25530. /**
  25531. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25532. * @param name defines the name of the mesh to create
  25533. * @param points is an array successive Vector3
  25534. * @param scene defines the hosting scene
  25535. * @param updatable defines if the mesh must be flagged as updatable
  25536. * @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).
  25537. * @returns a new Mesh
  25538. */
  25539. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25540. /**
  25541. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25542. * @param name defines the name of the mesh to create
  25543. * @param points is an array successive Vector3
  25544. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25545. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25546. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25547. * @param scene defines the hosting scene
  25548. * @param updatable defines if the mesh must be flagged as updatable
  25549. * @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)
  25550. * @returns a new Mesh
  25551. */
  25552. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25553. /**
  25554. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25555. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25556. * 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.
  25557. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25558. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25559. * Remember you can only change the shape positions, not their number when updating a polygon.
  25560. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25561. * @param name defines the name of the mesh to create
  25562. * @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
  25563. * @param scene defines the hosting scene
  25564. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25565. * @param updatable defines if the mesh must be flagged as updatable
  25566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25567. * @param earcutInjection can be used to inject your own earcut reference
  25568. * @returns a new Mesh
  25569. */
  25570. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25571. /**
  25572. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25573. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25574. * @param name defines the name of the mesh to create
  25575. * @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
  25576. * @param depth defines the height of extrusion
  25577. * @param scene defines the hosting scene
  25578. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25579. * @param updatable defines if the mesh must be flagged as updatable
  25580. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25581. * @param earcutInjection can be used to inject your own earcut reference
  25582. * @returns a new Mesh
  25583. */
  25584. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25585. /**
  25586. * Creates an extruded shape mesh.
  25587. * 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
  25588. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25589. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25590. * @param name defines the name of the mesh to create
  25591. * @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
  25592. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25593. * @param scale is the value to scale the shape
  25594. * @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
  25595. * @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
  25596. * @param scene defines the hosting scene
  25597. * @param updatable defines if the mesh must be flagged as updatable
  25598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25599. * @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)
  25600. * @returns a new Mesh
  25601. */
  25602. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25603. /**
  25604. * Creates an custom extruded shape mesh.
  25605. * The custom extrusion is a parametric shape.
  25606. * It has no predefined shape. Its final shape will depend on the input parameters.
  25607. * Please consider using the same method from the MeshBuilder class instead
  25608. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25609. * @param name defines the name of the mesh to create
  25610. * @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
  25611. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25612. * @param scaleFunction is a custom Javascript function called on each path point
  25613. * @param rotationFunction is a custom Javascript function called on each path point
  25614. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25615. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25616. * @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
  25617. * @param scene defines the hosting scene
  25618. * @param updatable defines if the mesh must be flagged as updatable
  25619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25620. * @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)
  25621. * @returns a new Mesh
  25622. */
  25623. 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;
  25624. /**
  25625. * Creates lathe mesh.
  25626. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25627. * Please consider using the same method from the MeshBuilder class instead
  25628. * @param name defines the name of the mesh to create
  25629. * @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
  25630. * @param radius is the radius value of the lathe
  25631. * @param tessellation is the side number of the lathe.
  25632. * @param scene defines the hosting scene
  25633. * @param updatable defines if the mesh must be flagged as updatable
  25634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25635. * @returns a new Mesh
  25636. */
  25637. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25638. /**
  25639. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25640. * @param name defines the name of the mesh to create
  25641. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25642. * @param scene defines the hosting scene
  25643. * @param updatable defines if the mesh must be flagged as updatable
  25644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25645. * @returns a new Mesh
  25646. */
  25647. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25648. /**
  25649. * Creates a ground mesh.
  25650. * Please consider using the same method from the MeshBuilder class instead
  25651. * @param name defines the name of the mesh to create
  25652. * @param width set the width of the ground
  25653. * @param height set the height of the ground
  25654. * @param subdivisions sets the number of subdivisions per side
  25655. * @param scene defines the hosting scene
  25656. * @param updatable defines if the mesh must be flagged as updatable
  25657. * @returns a new Mesh
  25658. */
  25659. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25660. /**
  25661. * Creates a tiled ground mesh.
  25662. * Please consider using the same method from the MeshBuilder class instead
  25663. * @param name defines the name of the mesh to create
  25664. * @param xmin set the ground minimum X coordinate
  25665. * @param zmin set the ground minimum Y coordinate
  25666. * @param xmax set the ground maximum X coordinate
  25667. * @param zmax set the ground maximum Z coordinate
  25668. * @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
  25669. * @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
  25670. * @param scene defines the hosting scene
  25671. * @param updatable defines if the mesh must be flagged as updatable
  25672. * @returns a new Mesh
  25673. */
  25674. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25675. w: number;
  25676. h: number;
  25677. }, precision: {
  25678. w: number;
  25679. h: number;
  25680. }, scene: Scene, updatable?: boolean): Mesh;
  25681. /**
  25682. * Creates a ground mesh from a height map.
  25683. * Please consider using the same method from the MeshBuilder class instead
  25684. * @see http://doc.babylonjs.com/babylon101/height_map
  25685. * @param name defines the name of the mesh to create
  25686. * @param url sets the URL of the height map image resource
  25687. * @param width set the ground width size
  25688. * @param height set the ground height size
  25689. * @param subdivisions sets the number of subdivision per side
  25690. * @param minHeight is the minimum altitude on the ground
  25691. * @param maxHeight is the maximum altitude on the ground
  25692. * @param scene defines the hosting scene
  25693. * @param updatable defines if the mesh must be flagged as updatable
  25694. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25695. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25696. * @returns a new Mesh
  25697. */
  25698. 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;
  25699. /**
  25700. * Creates a tube mesh.
  25701. * The tube is a parametric shape.
  25702. * It has no predefined shape. Its final shape will depend on the input parameters.
  25703. * Please consider using the same method from the MeshBuilder class instead
  25704. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25705. * @param name defines the name of the mesh to create
  25706. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25707. * @param radius sets the tube radius size
  25708. * @param tessellation is the number of sides on the tubular surface
  25709. * @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
  25710. * @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
  25711. * @param scene defines the hosting scene
  25712. * @param updatable defines if the mesh must be flagged as updatable
  25713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25714. * @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)
  25715. * @returns a new Mesh
  25716. */
  25717. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25718. (i: number, distance: number): number;
  25719. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25720. /**
  25721. * Creates a polyhedron mesh.
  25722. * Please consider using the same method from the MeshBuilder class instead.
  25723. * * 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
  25724. * * The parameter `size` (positive float, default 1) sets the polygon size
  25725. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25726. * * 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`
  25727. * * 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
  25728. * * 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)`)
  25729. * * 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
  25730. * * 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
  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 to create
  25735. * @param options defines the options used to create the mesh
  25736. * @param scene defines the hosting scene
  25737. * @returns a new Mesh
  25738. */
  25739. static CreatePolyhedron(name: string, options: {
  25740. type?: number;
  25741. size?: number;
  25742. sizeX?: number;
  25743. sizeY?: number;
  25744. sizeZ?: number;
  25745. custom?: any;
  25746. faceUV?: Vector4[];
  25747. faceColors?: Color4[];
  25748. updatable?: boolean;
  25749. sideOrientation?: number;
  25750. }, scene: Scene): Mesh;
  25751. /**
  25752. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25753. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25754. * * 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`)
  25755. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25756. * * 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
  25757. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25758. * * 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
  25759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25760. * @param name defines the name of the mesh
  25761. * @param options defines the options used to create the mesh
  25762. * @param scene defines the hosting scene
  25763. * @returns a new Mesh
  25764. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25765. */
  25766. static CreateIcoSphere(name: string, options: {
  25767. radius?: number;
  25768. flat?: boolean;
  25769. subdivisions?: number;
  25770. sideOrientation?: number;
  25771. updatable?: boolean;
  25772. }, scene: Scene): Mesh;
  25773. /**
  25774. * Creates a decal mesh.
  25775. * Please consider using the same method from the MeshBuilder class instead.
  25776. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25777. * @param name defines the name of the mesh
  25778. * @param sourceMesh defines the mesh receiving the decal
  25779. * @param position sets the position of the decal in world coordinates
  25780. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25781. * @param size sets the decal scaling
  25782. * @param angle sets the angle to rotate the decal
  25783. * @returns a new Mesh
  25784. */
  25785. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25786. /**
  25787. * Prepare internal position array for software CPU skinning
  25788. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25789. */
  25790. setPositionsForCPUSkinning(): Float32Array;
  25791. /**
  25792. * Prepare internal normal array for software CPU skinning
  25793. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25794. */
  25795. setNormalsForCPUSkinning(): Float32Array;
  25796. /**
  25797. * Updates the vertex buffer by applying transformation from the bones
  25798. * @param skeleton defines the skeleton to apply to current mesh
  25799. * @returns the current mesh
  25800. */
  25801. applySkeleton(skeleton: Skeleton): Mesh;
  25802. /**
  25803. * 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
  25804. * @param meshes defines the list of meshes to scan
  25805. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25806. */
  25807. static MinMax(meshes: AbstractMesh[]): {
  25808. min: Vector3;
  25809. max: Vector3;
  25810. };
  25811. /**
  25812. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25813. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25814. * @returns a vector3
  25815. */
  25816. static Center(meshesOrMinMaxVector: {
  25817. min: Vector3;
  25818. max: Vector3;
  25819. } | AbstractMesh[]): Vector3;
  25820. /**
  25821. * Merge the array of meshes into a single mesh for performance reasons.
  25822. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25823. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25824. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25825. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25826. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25827. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25828. * @returns a new mesh
  25829. */
  25830. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25831. /** @hidden */
  25832. addInstance(instance: InstancedMesh): void;
  25833. /** @hidden */
  25834. removeInstance(instance: InstancedMesh): void;
  25835. }
  25836. }
  25837. declare module BABYLON {
  25838. /**
  25839. * This is the base class of all the camera used in the application.
  25840. * @see http://doc.babylonjs.com/features/cameras
  25841. */
  25842. export class Camera extends Node {
  25843. /** @hidden */
  25844. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25845. /**
  25846. * This is the default projection mode used by the cameras.
  25847. * It helps recreating a feeling of perspective and better appreciate depth.
  25848. * This is the best way to simulate real life cameras.
  25849. */
  25850. static readonly PERSPECTIVE_CAMERA: number;
  25851. /**
  25852. * This helps creating camera with an orthographic mode.
  25853. * 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.
  25854. */
  25855. static readonly ORTHOGRAPHIC_CAMERA: number;
  25856. /**
  25857. * This is the default FOV mode for perspective cameras.
  25858. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25859. */
  25860. static readonly FOVMODE_VERTICAL_FIXED: number;
  25861. /**
  25862. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25863. */
  25864. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25865. /**
  25866. * This specifies ther is no need for a camera rig.
  25867. * Basically only one eye is rendered corresponding to the camera.
  25868. */
  25869. static readonly RIG_MODE_NONE: number;
  25870. /**
  25871. * Simulates a camera Rig with one blue eye and one red eye.
  25872. * This can be use with 3d blue and red glasses.
  25873. */
  25874. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25875. /**
  25876. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25877. */
  25878. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25879. /**
  25880. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25881. */
  25882. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25883. /**
  25884. * Defines that both eyes of the camera will be rendered over under each other.
  25885. */
  25886. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25887. /**
  25888. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25889. */
  25890. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25891. /**
  25892. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25893. */
  25894. static readonly RIG_MODE_VR: number;
  25895. /**
  25896. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25897. */
  25898. static readonly RIG_MODE_WEBVR: number;
  25899. /**
  25900. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25901. */
  25902. static readonly RIG_MODE_CUSTOM: number;
  25903. /**
  25904. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25905. */
  25906. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25907. /**
  25908. * Define the input manager associated with the camera.
  25909. */
  25910. inputs: CameraInputsManager<Camera>;
  25911. /** @hidden */
  25912. _position: Vector3;
  25913. /**
  25914. * Define the current local position of the camera in the scene
  25915. */
  25916. get position(): Vector3;
  25917. set position(newPosition: Vector3);
  25918. /**
  25919. * The vector the camera should consider as up.
  25920. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25921. */
  25922. upVector: Vector3;
  25923. /**
  25924. * Define the current limit on the left side for an orthographic camera
  25925. * In scene unit
  25926. */
  25927. orthoLeft: Nullable<number>;
  25928. /**
  25929. * Define the current limit on the right side for an orthographic camera
  25930. * In scene unit
  25931. */
  25932. orthoRight: Nullable<number>;
  25933. /**
  25934. * Define the current limit on the bottom side for an orthographic camera
  25935. * In scene unit
  25936. */
  25937. orthoBottom: Nullable<number>;
  25938. /**
  25939. * Define the current limit on the top side for an orthographic camera
  25940. * In scene unit
  25941. */
  25942. orthoTop: Nullable<number>;
  25943. /**
  25944. * Field Of View is set in Radians. (default is 0.8)
  25945. */
  25946. fov: number;
  25947. /**
  25948. * Define the minimum distance the camera can see from.
  25949. * This is important to note that the depth buffer are not infinite and the closer it starts
  25950. * the more your scene might encounter depth fighting issue.
  25951. */
  25952. minZ: number;
  25953. /**
  25954. * Define the maximum distance the camera can see to.
  25955. * This is important to note that the depth buffer are not infinite and the further it end
  25956. * the more your scene might encounter depth fighting issue.
  25957. */
  25958. maxZ: number;
  25959. /**
  25960. * Define the default inertia of the camera.
  25961. * This helps giving a smooth feeling to the camera movement.
  25962. */
  25963. inertia: number;
  25964. /**
  25965. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25966. */
  25967. mode: number;
  25968. /**
  25969. * Define whether the camera is intermediate.
  25970. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25971. */
  25972. isIntermediate: boolean;
  25973. /**
  25974. * Define the viewport of the camera.
  25975. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25976. */
  25977. viewport: Viewport;
  25978. /**
  25979. * Restricts the camera to viewing objects with the same layerMask.
  25980. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25981. */
  25982. layerMask: number;
  25983. /**
  25984. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25985. */
  25986. fovMode: number;
  25987. /**
  25988. * Rig mode of the camera.
  25989. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25990. * This is normally controlled byt the camera themselves as internal use.
  25991. */
  25992. cameraRigMode: number;
  25993. /**
  25994. * Defines the distance between both "eyes" in case of a RIG
  25995. */
  25996. interaxialDistance: number;
  25997. /**
  25998. * Defines if stereoscopic rendering is done side by side or over under.
  25999. */
  26000. isStereoscopicSideBySide: boolean;
  26001. /**
  26002. * 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
  26003. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26004. * else in the scene. (Eg. security camera)
  26005. *
  26006. * 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)
  26007. */
  26008. customRenderTargets: RenderTargetTexture[];
  26009. /**
  26010. * When set, the camera will render to this render target instead of the default canvas
  26011. *
  26012. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26013. */
  26014. outputRenderTarget: Nullable<RenderTargetTexture>;
  26015. /**
  26016. * Observable triggered when the camera view matrix has changed.
  26017. */
  26018. onViewMatrixChangedObservable: Observable<Camera>;
  26019. /**
  26020. * Observable triggered when the camera Projection matrix has changed.
  26021. */
  26022. onProjectionMatrixChangedObservable: Observable<Camera>;
  26023. /**
  26024. * Observable triggered when the inputs have been processed.
  26025. */
  26026. onAfterCheckInputsObservable: Observable<Camera>;
  26027. /**
  26028. * Observable triggered when reset has been called and applied to the camera.
  26029. */
  26030. onRestoreStateObservable: Observable<Camera>;
  26031. /**
  26032. * Is this camera a part of a rig system?
  26033. */
  26034. isRigCamera: boolean;
  26035. /**
  26036. * If isRigCamera set to true this will be set with the parent camera.
  26037. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26038. */
  26039. rigParent?: Camera;
  26040. /** @hidden */
  26041. _cameraRigParams: any;
  26042. /** @hidden */
  26043. _rigCameras: Camera[];
  26044. /** @hidden */
  26045. _rigPostProcess: Nullable<PostProcess>;
  26046. protected _webvrViewMatrix: Matrix;
  26047. /** @hidden */
  26048. _skipRendering: boolean;
  26049. /** @hidden */
  26050. _projectionMatrix: Matrix;
  26051. /** @hidden */
  26052. _postProcesses: Nullable<PostProcess>[];
  26053. /** @hidden */
  26054. _activeMeshes: SmartArray<AbstractMesh>;
  26055. protected _globalPosition: Vector3;
  26056. /** @hidden */
  26057. _computedViewMatrix: Matrix;
  26058. private _doNotComputeProjectionMatrix;
  26059. private _transformMatrix;
  26060. private _frustumPlanes;
  26061. private _refreshFrustumPlanes;
  26062. private _storedFov;
  26063. private _stateStored;
  26064. /**
  26065. * Instantiates a new camera object.
  26066. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26067. * @see http://doc.babylonjs.com/features/cameras
  26068. * @param name Defines the name of the camera in the scene
  26069. * @param position Defines the position of the camera
  26070. * @param scene Defines the scene the camera belongs too
  26071. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26072. */
  26073. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26074. /**
  26075. * Store current camera state (fov, position, etc..)
  26076. * @returns the camera
  26077. */
  26078. storeState(): Camera;
  26079. /**
  26080. * Restores the camera state values if it has been stored. You must call storeState() first
  26081. */
  26082. protected _restoreStateValues(): boolean;
  26083. /**
  26084. * Restored camera state. You must call storeState() first.
  26085. * @returns true if restored and false otherwise
  26086. */
  26087. restoreState(): boolean;
  26088. /**
  26089. * Gets the class name of the camera.
  26090. * @returns the class name
  26091. */
  26092. getClassName(): string;
  26093. /** @hidden */
  26094. readonly _isCamera: boolean;
  26095. /**
  26096. * Gets a string representation of the camera useful for debug purpose.
  26097. * @param fullDetails Defines that a more verboe level of logging is required
  26098. * @returns the string representation
  26099. */
  26100. toString(fullDetails?: boolean): string;
  26101. /**
  26102. * Gets the current world space position of the camera.
  26103. */
  26104. get globalPosition(): Vector3;
  26105. /**
  26106. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26107. * @returns the active meshe list
  26108. */
  26109. getActiveMeshes(): SmartArray<AbstractMesh>;
  26110. /**
  26111. * Check whether a mesh is part of the current active mesh list of the camera
  26112. * @param mesh Defines the mesh to check
  26113. * @returns true if active, false otherwise
  26114. */
  26115. isActiveMesh(mesh: Mesh): boolean;
  26116. /**
  26117. * Is this camera ready to be used/rendered
  26118. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26119. * @return true if the camera is ready
  26120. */
  26121. isReady(completeCheck?: boolean): boolean;
  26122. /** @hidden */
  26123. _initCache(): void;
  26124. /** @hidden */
  26125. _updateCache(ignoreParentClass?: boolean): void;
  26126. /** @hidden */
  26127. _isSynchronized(): boolean;
  26128. /** @hidden */
  26129. _isSynchronizedViewMatrix(): boolean;
  26130. /** @hidden */
  26131. _isSynchronizedProjectionMatrix(): boolean;
  26132. /**
  26133. * Attach the input controls to a specific dom element to get the input from.
  26134. * @param element Defines the element the controls should be listened from
  26135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26136. */
  26137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26138. /**
  26139. * Detach the current controls from the specified dom element.
  26140. * @param element Defines the element to stop listening the inputs from
  26141. */
  26142. detachControl(element: HTMLElement): void;
  26143. /**
  26144. * Update the camera state according to the different inputs gathered during the frame.
  26145. */
  26146. update(): void;
  26147. /** @hidden */
  26148. _checkInputs(): void;
  26149. /** @hidden */
  26150. get rigCameras(): Camera[];
  26151. /**
  26152. * Gets the post process used by the rig cameras
  26153. */
  26154. get rigPostProcess(): Nullable<PostProcess>;
  26155. /**
  26156. * Internal, gets the first post proces.
  26157. * @returns the first post process to be run on this camera.
  26158. */
  26159. _getFirstPostProcess(): Nullable<PostProcess>;
  26160. private _cascadePostProcessesToRigCams;
  26161. /**
  26162. * Attach a post process to the camera.
  26163. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26164. * @param postProcess The post process to attach to the camera
  26165. * @param insertAt The position of the post process in case several of them are in use in the scene
  26166. * @returns the position the post process has been inserted at
  26167. */
  26168. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26169. /**
  26170. * Detach a post process to the camera.
  26171. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26172. * @param postProcess The post process to detach from the camera
  26173. */
  26174. detachPostProcess(postProcess: PostProcess): void;
  26175. /**
  26176. * Gets the current world matrix of the camera
  26177. */
  26178. getWorldMatrix(): Matrix;
  26179. /** @hidden */
  26180. _getViewMatrix(): Matrix;
  26181. /**
  26182. * Gets the current view matrix of the camera.
  26183. * @param force forces the camera to recompute the matrix without looking at the cached state
  26184. * @returns the view matrix
  26185. */
  26186. getViewMatrix(force?: boolean): Matrix;
  26187. /**
  26188. * Freeze the projection matrix.
  26189. * It will prevent the cache check of the camera projection compute and can speed up perf
  26190. * if no parameter of the camera are meant to change
  26191. * @param projection Defines manually a projection if necessary
  26192. */
  26193. freezeProjectionMatrix(projection?: Matrix): void;
  26194. /**
  26195. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26196. */
  26197. unfreezeProjectionMatrix(): void;
  26198. /**
  26199. * Gets the current projection matrix of the camera.
  26200. * @param force forces the camera to recompute the matrix without looking at the cached state
  26201. * @returns the projection matrix
  26202. */
  26203. getProjectionMatrix(force?: boolean): Matrix;
  26204. /**
  26205. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26206. * @returns a Matrix
  26207. */
  26208. getTransformationMatrix(): Matrix;
  26209. private _updateFrustumPlanes;
  26210. /**
  26211. * Checks if a cullable object (mesh...) is in the camera frustum
  26212. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26213. * @param target The object to check
  26214. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26215. * @returns true if the object is in frustum otherwise false
  26216. */
  26217. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26218. /**
  26219. * Checks if a cullable object (mesh...) is in the camera frustum
  26220. * Unlike isInFrustum this cheks the full bounding box
  26221. * @param target The object to check
  26222. * @returns true if the object is in frustum otherwise false
  26223. */
  26224. isCompletelyInFrustum(target: ICullable): boolean;
  26225. /**
  26226. * Gets a ray in the forward direction from the camera.
  26227. * @param length Defines the length of the ray to create
  26228. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26229. * @param origin Defines the start point of the ray which defaults to the camera position
  26230. * @returns the forward ray
  26231. */
  26232. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26233. /**
  26234. * Releases resources associated with this node.
  26235. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26236. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26237. */
  26238. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26239. /** @hidden */
  26240. _isLeftCamera: boolean;
  26241. /**
  26242. * Gets the left camera of a rig setup in case of Rigged Camera
  26243. */
  26244. get isLeftCamera(): boolean;
  26245. /** @hidden */
  26246. _isRightCamera: boolean;
  26247. /**
  26248. * Gets the right camera of a rig setup in case of Rigged Camera
  26249. */
  26250. get isRightCamera(): boolean;
  26251. /**
  26252. * Gets the left camera of a rig setup in case of Rigged Camera
  26253. */
  26254. get leftCamera(): Nullable<FreeCamera>;
  26255. /**
  26256. * Gets the right camera of a rig setup in case of Rigged Camera
  26257. */
  26258. get rightCamera(): Nullable<FreeCamera>;
  26259. /**
  26260. * Gets the left camera target of a rig setup in case of Rigged Camera
  26261. * @returns the target position
  26262. */
  26263. getLeftTarget(): Nullable<Vector3>;
  26264. /**
  26265. * Gets the right camera target of a rig setup in case of Rigged Camera
  26266. * @returns the target position
  26267. */
  26268. getRightTarget(): Nullable<Vector3>;
  26269. /**
  26270. * @hidden
  26271. */
  26272. setCameraRigMode(mode: number, rigParams: any): void;
  26273. /** @hidden */
  26274. static _setStereoscopicRigMode(camera: Camera): void;
  26275. /** @hidden */
  26276. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26277. /** @hidden */
  26278. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26279. /** @hidden */
  26280. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26281. /** @hidden */
  26282. _getVRProjectionMatrix(): Matrix;
  26283. protected _updateCameraRotationMatrix(): void;
  26284. protected _updateWebVRCameraRotationMatrix(): void;
  26285. /**
  26286. * This function MUST be overwritten by the different WebVR cameras available.
  26287. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26288. * @hidden
  26289. */
  26290. _getWebVRProjectionMatrix(): Matrix;
  26291. /**
  26292. * This function MUST be overwritten by the different WebVR cameras available.
  26293. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26294. * @hidden
  26295. */
  26296. _getWebVRViewMatrix(): Matrix;
  26297. /** @hidden */
  26298. setCameraRigParameter(name: string, value: any): void;
  26299. /**
  26300. * needs to be overridden by children so sub has required properties to be copied
  26301. * @hidden
  26302. */
  26303. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26304. /**
  26305. * May need to be overridden by children
  26306. * @hidden
  26307. */
  26308. _updateRigCameras(): void;
  26309. /** @hidden */
  26310. _setupInputs(): void;
  26311. /**
  26312. * Serialiaze the camera setup to a json represention
  26313. * @returns the JSON representation
  26314. */
  26315. serialize(): any;
  26316. /**
  26317. * Clones the current camera.
  26318. * @param name The cloned camera name
  26319. * @returns the cloned camera
  26320. */
  26321. clone(name: string): Camera;
  26322. /**
  26323. * Gets the direction of the camera relative to a given local axis.
  26324. * @param localAxis Defines the reference axis to provide a relative direction.
  26325. * @return the direction
  26326. */
  26327. getDirection(localAxis: Vector3): Vector3;
  26328. /**
  26329. * Returns the current camera absolute rotation
  26330. */
  26331. get absoluteRotation(): Quaternion;
  26332. /**
  26333. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26334. * @param localAxis Defines the reference axis to provide a relative direction.
  26335. * @param result Defines the vector to store the result in
  26336. */
  26337. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26338. /**
  26339. * Gets a camera constructor for a given camera type
  26340. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26341. * @param name The name of the camera the result will be able to instantiate
  26342. * @param scene The scene the result will construct the camera in
  26343. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26344. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26345. * @returns a factory method to construc the camera
  26346. */
  26347. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26348. /**
  26349. * Compute the world matrix of the camera.
  26350. * @returns the camera world matrix
  26351. */
  26352. computeWorldMatrix(): Matrix;
  26353. /**
  26354. * Parse a JSON and creates the camera from the parsed information
  26355. * @param parsedCamera The JSON to parse
  26356. * @param scene The scene to instantiate the camera in
  26357. * @returns the newly constructed camera
  26358. */
  26359. static Parse(parsedCamera: any, scene: Scene): Camera;
  26360. }
  26361. }
  26362. declare module BABYLON {
  26363. /**
  26364. * Class containing static functions to help procedurally build meshes
  26365. */
  26366. export class DiscBuilder {
  26367. /**
  26368. * Creates a plane polygonal mesh. By default, this is a disc
  26369. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26370. * * 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
  26371. * * 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
  26372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26373. * * 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
  26374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26375. * @param name defines the name of the mesh
  26376. * @param options defines the options used to create the mesh
  26377. * @param scene defines the hosting scene
  26378. * @returns the plane polygonal mesh
  26379. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26380. */
  26381. static CreateDisc(name: string, options: {
  26382. radius?: number;
  26383. tessellation?: number;
  26384. arc?: number;
  26385. updatable?: boolean;
  26386. sideOrientation?: number;
  26387. frontUVs?: Vector4;
  26388. backUVs?: Vector4;
  26389. }, scene?: Nullable<Scene>): Mesh;
  26390. }
  26391. }
  26392. declare module BABYLON {
  26393. /**
  26394. * Options to be used when creating a FresnelParameters.
  26395. */
  26396. export type IFresnelParametersCreationOptions = {
  26397. /**
  26398. * Define the color used on edges (grazing angle)
  26399. */
  26400. leftColor?: Color3;
  26401. /**
  26402. * Define the color used on center
  26403. */
  26404. rightColor?: Color3;
  26405. /**
  26406. * Define bias applied to computed fresnel term
  26407. */
  26408. bias?: number;
  26409. /**
  26410. * Defined the power exponent applied to fresnel term
  26411. */
  26412. power?: number;
  26413. /**
  26414. * Define if the fresnel effect is enable or not.
  26415. */
  26416. isEnabled?: boolean;
  26417. };
  26418. /**
  26419. * Serialized format for FresnelParameters.
  26420. */
  26421. export type IFresnelParametersSerialized = {
  26422. /**
  26423. * Define the color used on edges (grazing angle) [as an array]
  26424. */
  26425. leftColor: number[];
  26426. /**
  26427. * Define the color used on center [as an array]
  26428. */
  26429. rightColor: number[];
  26430. /**
  26431. * Define bias applied to computed fresnel term
  26432. */
  26433. bias: number;
  26434. /**
  26435. * Defined the power exponent applied to fresnel term
  26436. */
  26437. power?: number;
  26438. /**
  26439. * Define if the fresnel effect is enable or not.
  26440. */
  26441. isEnabled: boolean;
  26442. };
  26443. /**
  26444. * This represents all the required information to add a fresnel effect on a material:
  26445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26446. */
  26447. export class FresnelParameters {
  26448. private _isEnabled;
  26449. /**
  26450. * Define if the fresnel effect is enable or not.
  26451. */
  26452. get isEnabled(): boolean;
  26453. set isEnabled(value: boolean);
  26454. /**
  26455. * Define the color used on edges (grazing angle)
  26456. */
  26457. leftColor: Color3;
  26458. /**
  26459. * Define the color used on center
  26460. */
  26461. rightColor: Color3;
  26462. /**
  26463. * Define bias applied to computed fresnel term
  26464. */
  26465. bias: number;
  26466. /**
  26467. * Defined the power exponent applied to fresnel term
  26468. */
  26469. power: number;
  26470. /**
  26471. * Creates a new FresnelParameters object.
  26472. *
  26473. * @param options provide your own settings to optionally to override defaults
  26474. */
  26475. constructor(options?: IFresnelParametersCreationOptions);
  26476. /**
  26477. * Clones the current fresnel and its valuues
  26478. * @returns a clone fresnel configuration
  26479. */
  26480. clone(): FresnelParameters;
  26481. /**
  26482. * Determines equality between FresnelParameters objects
  26483. * @param otherFresnelParameters defines the second operand
  26484. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26485. */
  26486. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26487. /**
  26488. * Serializes the current fresnel parameters to a JSON representation.
  26489. * @return the JSON serialization
  26490. */
  26491. serialize(): IFresnelParametersSerialized;
  26492. /**
  26493. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26494. * @param parsedFresnelParameters Define the JSON representation
  26495. * @returns the parsed parameters
  26496. */
  26497. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26498. }
  26499. }
  26500. declare module BABYLON {
  26501. /**
  26502. * Base class of materials working in push mode in babylon JS
  26503. * @hidden
  26504. */
  26505. export class PushMaterial extends Material {
  26506. protected _activeEffect: Effect;
  26507. protected _normalMatrix: Matrix;
  26508. /**
  26509. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26510. * This means that the material can keep using a previous shader while a new one is being compiled.
  26511. * This is mostly used when shader parallel compilation is supported (true by default)
  26512. */
  26513. allowShaderHotSwapping: boolean;
  26514. constructor(name: string, scene: Scene);
  26515. getEffect(): Effect;
  26516. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26517. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26518. /**
  26519. * Binds the given world matrix to the active effect
  26520. *
  26521. * @param world the matrix to bind
  26522. */
  26523. bindOnlyWorldMatrix(world: Matrix): void;
  26524. /**
  26525. * Binds the given normal matrix to the active effect
  26526. *
  26527. * @param normalMatrix the matrix to bind
  26528. */
  26529. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26530. bind(world: Matrix, mesh?: Mesh): void;
  26531. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26532. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26533. }
  26534. }
  26535. declare module BABYLON {
  26536. /**
  26537. * This groups all the flags used to control the materials channel.
  26538. */
  26539. export class MaterialFlags {
  26540. private static _DiffuseTextureEnabled;
  26541. /**
  26542. * Are diffuse textures enabled in the application.
  26543. */
  26544. static get DiffuseTextureEnabled(): boolean;
  26545. static set DiffuseTextureEnabled(value: boolean);
  26546. private static _AmbientTextureEnabled;
  26547. /**
  26548. * Are ambient textures enabled in the application.
  26549. */
  26550. static get AmbientTextureEnabled(): boolean;
  26551. static set AmbientTextureEnabled(value: boolean);
  26552. private static _OpacityTextureEnabled;
  26553. /**
  26554. * Are opacity textures enabled in the application.
  26555. */
  26556. static get OpacityTextureEnabled(): boolean;
  26557. static set OpacityTextureEnabled(value: boolean);
  26558. private static _ReflectionTextureEnabled;
  26559. /**
  26560. * Are reflection textures enabled in the application.
  26561. */
  26562. static get ReflectionTextureEnabled(): boolean;
  26563. static set ReflectionTextureEnabled(value: boolean);
  26564. private static _EmissiveTextureEnabled;
  26565. /**
  26566. * Are emissive textures enabled in the application.
  26567. */
  26568. static get EmissiveTextureEnabled(): boolean;
  26569. static set EmissiveTextureEnabled(value: boolean);
  26570. private static _SpecularTextureEnabled;
  26571. /**
  26572. * Are specular textures enabled in the application.
  26573. */
  26574. static get SpecularTextureEnabled(): boolean;
  26575. static set SpecularTextureEnabled(value: boolean);
  26576. private static _BumpTextureEnabled;
  26577. /**
  26578. * Are bump textures enabled in the application.
  26579. */
  26580. static get BumpTextureEnabled(): boolean;
  26581. static set BumpTextureEnabled(value: boolean);
  26582. private static _LightmapTextureEnabled;
  26583. /**
  26584. * Are lightmap textures enabled in the application.
  26585. */
  26586. static get LightmapTextureEnabled(): boolean;
  26587. static set LightmapTextureEnabled(value: boolean);
  26588. private static _RefractionTextureEnabled;
  26589. /**
  26590. * Are refraction textures enabled in the application.
  26591. */
  26592. static get RefractionTextureEnabled(): boolean;
  26593. static set RefractionTextureEnabled(value: boolean);
  26594. private static _ColorGradingTextureEnabled;
  26595. /**
  26596. * Are color grading textures enabled in the application.
  26597. */
  26598. static get ColorGradingTextureEnabled(): boolean;
  26599. static set ColorGradingTextureEnabled(value: boolean);
  26600. private static _FresnelEnabled;
  26601. /**
  26602. * Are fresnels enabled in the application.
  26603. */
  26604. static get FresnelEnabled(): boolean;
  26605. static set FresnelEnabled(value: boolean);
  26606. private static _ClearCoatTextureEnabled;
  26607. /**
  26608. * Are clear coat textures enabled in the application.
  26609. */
  26610. static get ClearCoatTextureEnabled(): boolean;
  26611. static set ClearCoatTextureEnabled(value: boolean);
  26612. private static _ClearCoatBumpTextureEnabled;
  26613. /**
  26614. * Are clear coat bump textures enabled in the application.
  26615. */
  26616. static get ClearCoatBumpTextureEnabled(): boolean;
  26617. static set ClearCoatBumpTextureEnabled(value: boolean);
  26618. private static _ClearCoatTintTextureEnabled;
  26619. /**
  26620. * Are clear coat tint textures enabled in the application.
  26621. */
  26622. static get ClearCoatTintTextureEnabled(): boolean;
  26623. static set ClearCoatTintTextureEnabled(value: boolean);
  26624. private static _SheenTextureEnabled;
  26625. /**
  26626. * Are sheen textures enabled in the application.
  26627. */
  26628. static get SheenTextureEnabled(): boolean;
  26629. static set SheenTextureEnabled(value: boolean);
  26630. private static _AnisotropicTextureEnabled;
  26631. /**
  26632. * Are anisotropic textures enabled in the application.
  26633. */
  26634. static get AnisotropicTextureEnabled(): boolean;
  26635. static set AnisotropicTextureEnabled(value: boolean);
  26636. private static _ThicknessTextureEnabled;
  26637. /**
  26638. * Are thickness textures enabled in the application.
  26639. */
  26640. static get ThicknessTextureEnabled(): boolean;
  26641. static set ThicknessTextureEnabled(value: boolean);
  26642. }
  26643. }
  26644. declare module BABYLON {
  26645. /** @hidden */
  26646. export var defaultFragmentDeclaration: {
  26647. name: string;
  26648. shader: string;
  26649. };
  26650. }
  26651. declare module BABYLON {
  26652. /** @hidden */
  26653. export var defaultUboDeclaration: {
  26654. name: string;
  26655. shader: string;
  26656. };
  26657. }
  26658. declare module BABYLON {
  26659. /** @hidden */
  26660. export var lightFragmentDeclaration: {
  26661. name: string;
  26662. shader: string;
  26663. };
  26664. }
  26665. declare module BABYLON {
  26666. /** @hidden */
  26667. export var lightUboDeclaration: {
  26668. name: string;
  26669. shader: string;
  26670. };
  26671. }
  26672. declare module BABYLON {
  26673. /** @hidden */
  26674. export var lightsFragmentFunctions: {
  26675. name: string;
  26676. shader: string;
  26677. };
  26678. }
  26679. declare module BABYLON {
  26680. /** @hidden */
  26681. export var shadowsFragmentFunctions: {
  26682. name: string;
  26683. shader: string;
  26684. };
  26685. }
  26686. declare module BABYLON {
  26687. /** @hidden */
  26688. export var fresnelFunction: {
  26689. name: string;
  26690. shader: string;
  26691. };
  26692. }
  26693. declare module BABYLON {
  26694. /** @hidden */
  26695. export var reflectionFunction: {
  26696. name: string;
  26697. shader: string;
  26698. };
  26699. }
  26700. declare module BABYLON {
  26701. /** @hidden */
  26702. export var bumpFragmentMainFunctions: {
  26703. name: string;
  26704. shader: string;
  26705. };
  26706. }
  26707. declare module BABYLON {
  26708. /** @hidden */
  26709. export var bumpFragmentFunctions: {
  26710. name: string;
  26711. shader: string;
  26712. };
  26713. }
  26714. declare module BABYLON {
  26715. /** @hidden */
  26716. export var logDepthDeclaration: {
  26717. name: string;
  26718. shader: string;
  26719. };
  26720. }
  26721. declare module BABYLON {
  26722. /** @hidden */
  26723. export var bumpFragment: {
  26724. name: string;
  26725. shader: string;
  26726. };
  26727. }
  26728. declare module BABYLON {
  26729. /** @hidden */
  26730. export var depthPrePass: {
  26731. name: string;
  26732. shader: string;
  26733. };
  26734. }
  26735. declare module BABYLON {
  26736. /** @hidden */
  26737. export var lightFragment: {
  26738. name: string;
  26739. shader: string;
  26740. };
  26741. }
  26742. declare module BABYLON {
  26743. /** @hidden */
  26744. export var logDepthFragment: {
  26745. name: string;
  26746. shader: string;
  26747. };
  26748. }
  26749. declare module BABYLON {
  26750. /** @hidden */
  26751. export var defaultPixelShader: {
  26752. name: string;
  26753. shader: string;
  26754. };
  26755. }
  26756. declare module BABYLON {
  26757. /** @hidden */
  26758. export var defaultVertexDeclaration: {
  26759. name: string;
  26760. shader: string;
  26761. };
  26762. }
  26763. declare module BABYLON {
  26764. /** @hidden */
  26765. export var bumpVertexDeclaration: {
  26766. name: string;
  26767. shader: string;
  26768. };
  26769. }
  26770. declare module BABYLON {
  26771. /** @hidden */
  26772. export var bumpVertex: {
  26773. name: string;
  26774. shader: string;
  26775. };
  26776. }
  26777. declare module BABYLON {
  26778. /** @hidden */
  26779. export var fogVertex: {
  26780. name: string;
  26781. shader: string;
  26782. };
  26783. }
  26784. declare module BABYLON {
  26785. /** @hidden */
  26786. export var shadowsVertex: {
  26787. name: string;
  26788. shader: string;
  26789. };
  26790. }
  26791. declare module BABYLON {
  26792. /** @hidden */
  26793. export var pointCloudVertex: {
  26794. name: string;
  26795. shader: string;
  26796. };
  26797. }
  26798. declare module BABYLON {
  26799. /** @hidden */
  26800. export var logDepthVertex: {
  26801. name: string;
  26802. shader: string;
  26803. };
  26804. }
  26805. declare module BABYLON {
  26806. /** @hidden */
  26807. export var defaultVertexShader: {
  26808. name: string;
  26809. shader: string;
  26810. };
  26811. }
  26812. declare module BABYLON {
  26813. /** @hidden */
  26814. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26815. MAINUV1: boolean;
  26816. MAINUV2: boolean;
  26817. DIFFUSE: boolean;
  26818. DIFFUSEDIRECTUV: number;
  26819. AMBIENT: boolean;
  26820. AMBIENTDIRECTUV: number;
  26821. OPACITY: boolean;
  26822. OPACITYDIRECTUV: number;
  26823. OPACITYRGB: boolean;
  26824. REFLECTION: boolean;
  26825. EMISSIVE: boolean;
  26826. EMISSIVEDIRECTUV: number;
  26827. SPECULAR: boolean;
  26828. SPECULARDIRECTUV: number;
  26829. BUMP: boolean;
  26830. BUMPDIRECTUV: number;
  26831. PARALLAX: boolean;
  26832. PARALLAXOCCLUSION: boolean;
  26833. SPECULAROVERALPHA: boolean;
  26834. CLIPPLANE: boolean;
  26835. CLIPPLANE2: boolean;
  26836. CLIPPLANE3: boolean;
  26837. CLIPPLANE4: boolean;
  26838. CLIPPLANE5: boolean;
  26839. CLIPPLANE6: boolean;
  26840. ALPHATEST: boolean;
  26841. DEPTHPREPASS: boolean;
  26842. ALPHAFROMDIFFUSE: boolean;
  26843. POINTSIZE: boolean;
  26844. FOG: boolean;
  26845. SPECULARTERM: boolean;
  26846. DIFFUSEFRESNEL: boolean;
  26847. OPACITYFRESNEL: boolean;
  26848. REFLECTIONFRESNEL: boolean;
  26849. REFRACTIONFRESNEL: boolean;
  26850. EMISSIVEFRESNEL: boolean;
  26851. FRESNEL: boolean;
  26852. NORMAL: boolean;
  26853. UV1: boolean;
  26854. UV2: boolean;
  26855. VERTEXCOLOR: boolean;
  26856. VERTEXALPHA: boolean;
  26857. NUM_BONE_INFLUENCERS: number;
  26858. BonesPerMesh: number;
  26859. BONETEXTURE: boolean;
  26860. INSTANCES: boolean;
  26861. GLOSSINESS: boolean;
  26862. ROUGHNESS: boolean;
  26863. EMISSIVEASILLUMINATION: boolean;
  26864. LINKEMISSIVEWITHDIFFUSE: boolean;
  26865. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26866. LIGHTMAP: boolean;
  26867. LIGHTMAPDIRECTUV: number;
  26868. OBJECTSPACE_NORMALMAP: boolean;
  26869. USELIGHTMAPASSHADOWMAP: boolean;
  26870. REFLECTIONMAP_3D: boolean;
  26871. REFLECTIONMAP_SPHERICAL: boolean;
  26872. REFLECTIONMAP_PLANAR: boolean;
  26873. REFLECTIONMAP_CUBIC: boolean;
  26874. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26875. REFLECTIONMAP_PROJECTION: boolean;
  26876. REFLECTIONMAP_SKYBOX: boolean;
  26877. REFLECTIONMAP_EXPLICIT: boolean;
  26878. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26879. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26880. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26881. INVERTCUBICMAP: boolean;
  26882. LOGARITHMICDEPTH: boolean;
  26883. REFRACTION: boolean;
  26884. REFRACTIONMAP_3D: boolean;
  26885. REFLECTIONOVERALPHA: boolean;
  26886. TWOSIDEDLIGHTING: boolean;
  26887. SHADOWFLOAT: boolean;
  26888. MORPHTARGETS: boolean;
  26889. MORPHTARGETS_NORMAL: boolean;
  26890. MORPHTARGETS_TANGENT: boolean;
  26891. MORPHTARGETS_UV: boolean;
  26892. NUM_MORPH_INFLUENCERS: number;
  26893. NONUNIFORMSCALING: boolean;
  26894. PREMULTIPLYALPHA: boolean;
  26895. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26896. ALPHABLEND: boolean;
  26897. IMAGEPROCESSING: boolean;
  26898. VIGNETTE: boolean;
  26899. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26900. VIGNETTEBLENDMODEOPAQUE: boolean;
  26901. TONEMAPPING: boolean;
  26902. TONEMAPPING_ACES: boolean;
  26903. CONTRAST: boolean;
  26904. COLORCURVES: boolean;
  26905. COLORGRADING: boolean;
  26906. COLORGRADING3D: boolean;
  26907. SAMPLER3DGREENDEPTH: boolean;
  26908. SAMPLER3DBGRMAP: boolean;
  26909. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26910. MULTIVIEW: boolean;
  26911. /**
  26912. * If the reflection texture on this material is in linear color space
  26913. * @hidden
  26914. */
  26915. IS_REFLECTION_LINEAR: boolean;
  26916. /**
  26917. * If the refraction texture on this material is in linear color space
  26918. * @hidden
  26919. */
  26920. IS_REFRACTION_LINEAR: boolean;
  26921. EXPOSURE: boolean;
  26922. constructor();
  26923. setReflectionMode(modeToEnable: string): void;
  26924. }
  26925. /**
  26926. * This is the default material used in Babylon. It is the best trade off between quality
  26927. * and performances.
  26928. * @see http://doc.babylonjs.com/babylon101/materials
  26929. */
  26930. export class StandardMaterial extends PushMaterial {
  26931. private _diffuseTexture;
  26932. /**
  26933. * The basic texture of the material as viewed under a light.
  26934. */
  26935. diffuseTexture: Nullable<BaseTexture>;
  26936. private _ambientTexture;
  26937. /**
  26938. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26939. */
  26940. ambientTexture: Nullable<BaseTexture>;
  26941. private _opacityTexture;
  26942. /**
  26943. * Define the transparency of the material from a texture.
  26944. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26945. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26946. */
  26947. opacityTexture: Nullable<BaseTexture>;
  26948. private _reflectionTexture;
  26949. /**
  26950. * Define the texture used to display the reflection.
  26951. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26952. */
  26953. reflectionTexture: Nullable<BaseTexture>;
  26954. private _emissiveTexture;
  26955. /**
  26956. * Define texture of the material as if self lit.
  26957. * This will be mixed in the final result even in the absence of light.
  26958. */
  26959. emissiveTexture: Nullable<BaseTexture>;
  26960. private _specularTexture;
  26961. /**
  26962. * Define how the color and intensity of the highlight given by the light in the material.
  26963. */
  26964. specularTexture: Nullable<BaseTexture>;
  26965. private _bumpTexture;
  26966. /**
  26967. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26968. * 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.
  26969. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26970. */
  26971. bumpTexture: Nullable<BaseTexture>;
  26972. private _lightmapTexture;
  26973. /**
  26974. * Complex lighting can be computationally expensive to compute at runtime.
  26975. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26976. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26977. */
  26978. lightmapTexture: Nullable<BaseTexture>;
  26979. private _refractionTexture;
  26980. /**
  26981. * Define the texture used to display the refraction.
  26982. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26983. */
  26984. refractionTexture: Nullable<BaseTexture>;
  26985. /**
  26986. * The color of the material lit by the environmental background lighting.
  26987. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26988. */
  26989. ambientColor: Color3;
  26990. /**
  26991. * The basic color of the material as viewed under a light.
  26992. */
  26993. diffuseColor: Color3;
  26994. /**
  26995. * Define how the color and intensity of the highlight given by the light in the material.
  26996. */
  26997. specularColor: Color3;
  26998. /**
  26999. * Define the color of the material as if self lit.
  27000. * This will be mixed in the final result even in the absence of light.
  27001. */
  27002. emissiveColor: Color3;
  27003. /**
  27004. * Defines how sharp are the highlights in the material.
  27005. * The bigger the value the sharper giving a more glossy feeling to the result.
  27006. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27007. */
  27008. specularPower: number;
  27009. private _useAlphaFromDiffuseTexture;
  27010. /**
  27011. * Does the transparency come from the diffuse texture alpha channel.
  27012. */
  27013. useAlphaFromDiffuseTexture: boolean;
  27014. private _useEmissiveAsIllumination;
  27015. /**
  27016. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27017. */
  27018. useEmissiveAsIllumination: boolean;
  27019. private _linkEmissiveWithDiffuse;
  27020. /**
  27021. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27022. * the emissive level when the final color is close to one.
  27023. */
  27024. linkEmissiveWithDiffuse: boolean;
  27025. private _useSpecularOverAlpha;
  27026. /**
  27027. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27028. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27029. */
  27030. useSpecularOverAlpha: boolean;
  27031. private _useReflectionOverAlpha;
  27032. /**
  27033. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27034. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27035. */
  27036. useReflectionOverAlpha: boolean;
  27037. private _disableLighting;
  27038. /**
  27039. * Does lights from the scene impacts this material.
  27040. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27041. */
  27042. disableLighting: boolean;
  27043. private _useObjectSpaceNormalMap;
  27044. /**
  27045. * Allows using an object space normal map (instead of tangent space).
  27046. */
  27047. useObjectSpaceNormalMap: boolean;
  27048. private _useParallax;
  27049. /**
  27050. * Is parallax enabled or not.
  27051. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27052. */
  27053. useParallax: boolean;
  27054. private _useParallaxOcclusion;
  27055. /**
  27056. * Is parallax occlusion enabled or not.
  27057. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27058. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27059. */
  27060. useParallaxOcclusion: boolean;
  27061. /**
  27062. * 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.
  27063. */
  27064. parallaxScaleBias: number;
  27065. private _roughness;
  27066. /**
  27067. * Helps to define how blurry the reflections should appears in the material.
  27068. */
  27069. roughness: number;
  27070. /**
  27071. * In case of refraction, define the value of the index of refraction.
  27072. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27073. */
  27074. indexOfRefraction: number;
  27075. /**
  27076. * Invert the refraction texture alongside the y axis.
  27077. * It can be useful with procedural textures or probe for instance.
  27078. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27079. */
  27080. invertRefractionY: boolean;
  27081. /**
  27082. * Defines the alpha limits in alpha test mode.
  27083. */
  27084. alphaCutOff: number;
  27085. private _useLightmapAsShadowmap;
  27086. /**
  27087. * In case of light mapping, define whether the map contains light or shadow informations.
  27088. */
  27089. useLightmapAsShadowmap: boolean;
  27090. private _diffuseFresnelParameters;
  27091. /**
  27092. * Define the diffuse fresnel parameters of the material.
  27093. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27094. */
  27095. diffuseFresnelParameters: FresnelParameters;
  27096. private _opacityFresnelParameters;
  27097. /**
  27098. * Define the opacity fresnel parameters of the material.
  27099. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27100. */
  27101. opacityFresnelParameters: FresnelParameters;
  27102. private _reflectionFresnelParameters;
  27103. /**
  27104. * Define the reflection fresnel parameters of the material.
  27105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27106. */
  27107. reflectionFresnelParameters: FresnelParameters;
  27108. private _refractionFresnelParameters;
  27109. /**
  27110. * Define the refraction fresnel parameters of the material.
  27111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27112. */
  27113. refractionFresnelParameters: FresnelParameters;
  27114. private _emissiveFresnelParameters;
  27115. /**
  27116. * Define the emissive fresnel parameters of the material.
  27117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27118. */
  27119. emissiveFresnelParameters: FresnelParameters;
  27120. private _useReflectionFresnelFromSpecular;
  27121. /**
  27122. * If true automatically deducts the fresnels values from the material specularity.
  27123. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27124. */
  27125. useReflectionFresnelFromSpecular: boolean;
  27126. private _useGlossinessFromSpecularMapAlpha;
  27127. /**
  27128. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27129. */
  27130. useGlossinessFromSpecularMapAlpha: boolean;
  27131. private _maxSimultaneousLights;
  27132. /**
  27133. * Defines the maximum number of lights that can be used in the material
  27134. */
  27135. maxSimultaneousLights: number;
  27136. private _invertNormalMapX;
  27137. /**
  27138. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27139. */
  27140. invertNormalMapX: boolean;
  27141. private _invertNormalMapY;
  27142. /**
  27143. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27144. */
  27145. invertNormalMapY: boolean;
  27146. private _twoSidedLighting;
  27147. /**
  27148. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27149. */
  27150. twoSidedLighting: boolean;
  27151. /**
  27152. * Default configuration related to image processing available in the standard Material.
  27153. */
  27154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27155. /**
  27156. * Gets the image processing configuration used either in this material.
  27157. */
  27158. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27159. /**
  27160. * Sets the Default image processing configuration used either in the this material.
  27161. *
  27162. * If sets to null, the scene one is in use.
  27163. */
  27164. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27165. /**
  27166. * Keep track of the image processing observer to allow dispose and replace.
  27167. */
  27168. private _imageProcessingObserver;
  27169. /**
  27170. * Attaches a new image processing configuration to the Standard Material.
  27171. * @param configuration
  27172. */
  27173. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27174. /**
  27175. * Gets wether the color curves effect is enabled.
  27176. */
  27177. get cameraColorCurvesEnabled(): boolean;
  27178. /**
  27179. * Sets wether the color curves effect is enabled.
  27180. */
  27181. set cameraColorCurvesEnabled(value: boolean);
  27182. /**
  27183. * Gets wether the color grading effect is enabled.
  27184. */
  27185. get cameraColorGradingEnabled(): boolean;
  27186. /**
  27187. * Gets wether the color grading effect is enabled.
  27188. */
  27189. set cameraColorGradingEnabled(value: boolean);
  27190. /**
  27191. * Gets wether tonemapping is enabled or not.
  27192. */
  27193. get cameraToneMappingEnabled(): boolean;
  27194. /**
  27195. * Sets wether tonemapping is enabled or not
  27196. */
  27197. set cameraToneMappingEnabled(value: boolean);
  27198. /**
  27199. * The camera exposure used on this material.
  27200. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27201. * This corresponds to a photographic exposure.
  27202. */
  27203. get cameraExposure(): number;
  27204. /**
  27205. * The camera exposure used on this material.
  27206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27207. * This corresponds to a photographic exposure.
  27208. */
  27209. set cameraExposure(value: number);
  27210. /**
  27211. * Gets The camera contrast used on this material.
  27212. */
  27213. get cameraContrast(): number;
  27214. /**
  27215. * Sets The camera contrast used on this material.
  27216. */
  27217. set cameraContrast(value: number);
  27218. /**
  27219. * Gets the Color Grading 2D Lookup Texture.
  27220. */
  27221. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27222. /**
  27223. * Sets the Color Grading 2D Lookup Texture.
  27224. */
  27225. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27226. /**
  27227. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27228. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27229. * 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;
  27230. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27231. */
  27232. get cameraColorCurves(): Nullable<ColorCurves>;
  27233. /**
  27234. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27235. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27236. * 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;
  27237. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27238. */
  27239. set cameraColorCurves(value: Nullable<ColorCurves>);
  27240. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27241. protected _worldViewProjectionMatrix: Matrix;
  27242. protected _globalAmbientColor: Color3;
  27243. protected _useLogarithmicDepth: boolean;
  27244. protected _rebuildInParallel: boolean;
  27245. /**
  27246. * Instantiates a new standard material.
  27247. * This is the default material used in Babylon. It is the best trade off between quality
  27248. * and performances.
  27249. * @see http://doc.babylonjs.com/babylon101/materials
  27250. * @param name Define the name of the material in the scene
  27251. * @param scene Define the scene the material belong to
  27252. */
  27253. constructor(name: string, scene: Scene);
  27254. /**
  27255. * Gets a boolean indicating that current material needs to register RTT
  27256. */
  27257. get hasRenderTargetTextures(): boolean;
  27258. /**
  27259. * Gets the current class name of the material e.g. "StandardMaterial"
  27260. * Mainly use in serialization.
  27261. * @returns the class name
  27262. */
  27263. getClassName(): string;
  27264. /**
  27265. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27266. * You can try switching to logarithmic depth.
  27267. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27268. */
  27269. get useLogarithmicDepth(): boolean;
  27270. set useLogarithmicDepth(value: boolean);
  27271. /**
  27272. * Specifies if the material will require alpha blending
  27273. * @returns a boolean specifying if alpha blending is needed
  27274. */
  27275. needAlphaBlending(): boolean;
  27276. /**
  27277. * Specifies if this material should be rendered in alpha test mode
  27278. * @returns a boolean specifying if an alpha test is needed.
  27279. */
  27280. needAlphaTesting(): boolean;
  27281. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27282. /**
  27283. * Get the texture used for alpha test purpose.
  27284. * @returns the diffuse texture in case of the standard material.
  27285. */
  27286. getAlphaTestTexture(): Nullable<BaseTexture>;
  27287. /**
  27288. * Get if the submesh is ready to be used and all its information available.
  27289. * Child classes can use it to update shaders
  27290. * @param mesh defines the mesh to check
  27291. * @param subMesh defines which submesh to check
  27292. * @param useInstances specifies that instances should be used
  27293. * @returns a boolean indicating that the submesh is ready or not
  27294. */
  27295. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27296. /**
  27297. * Builds the material UBO layouts.
  27298. * Used internally during the effect preparation.
  27299. */
  27300. buildUniformLayout(): void;
  27301. /**
  27302. * Unbinds the material from the mesh
  27303. */
  27304. unbind(): void;
  27305. /**
  27306. * Binds the submesh to this material by preparing the effect and shader to draw
  27307. * @param world defines the world transformation matrix
  27308. * @param mesh defines the mesh containing the submesh
  27309. * @param subMesh defines the submesh to bind the material to
  27310. */
  27311. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27312. /**
  27313. * Get the list of animatables in the material.
  27314. * @returns the list of animatables object used in the material
  27315. */
  27316. getAnimatables(): IAnimatable[];
  27317. /**
  27318. * Gets the active textures from the material
  27319. * @returns an array of textures
  27320. */
  27321. getActiveTextures(): BaseTexture[];
  27322. /**
  27323. * Specifies if the material uses a texture
  27324. * @param texture defines the texture to check against the material
  27325. * @returns a boolean specifying if the material uses the texture
  27326. */
  27327. hasTexture(texture: BaseTexture): boolean;
  27328. /**
  27329. * Disposes the material
  27330. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27331. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27332. */
  27333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27334. /**
  27335. * Makes a duplicate of the material, and gives it a new name
  27336. * @param name defines the new name for the duplicated material
  27337. * @returns the cloned material
  27338. */
  27339. clone(name: string): StandardMaterial;
  27340. /**
  27341. * Serializes this material in a JSON representation
  27342. * @returns the serialized material object
  27343. */
  27344. serialize(): any;
  27345. /**
  27346. * Creates a standard material from parsed material data
  27347. * @param source defines the JSON representation of the material
  27348. * @param scene defines the hosting scene
  27349. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27350. * @returns a new standard material
  27351. */
  27352. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27353. /**
  27354. * Are diffuse textures enabled in the application.
  27355. */
  27356. static get DiffuseTextureEnabled(): boolean;
  27357. static set DiffuseTextureEnabled(value: boolean);
  27358. /**
  27359. * Are ambient textures enabled in the application.
  27360. */
  27361. static get AmbientTextureEnabled(): boolean;
  27362. static set AmbientTextureEnabled(value: boolean);
  27363. /**
  27364. * Are opacity textures enabled in the application.
  27365. */
  27366. static get OpacityTextureEnabled(): boolean;
  27367. static set OpacityTextureEnabled(value: boolean);
  27368. /**
  27369. * Are reflection textures enabled in the application.
  27370. */
  27371. static get ReflectionTextureEnabled(): boolean;
  27372. static set ReflectionTextureEnabled(value: boolean);
  27373. /**
  27374. * Are emissive textures enabled in the application.
  27375. */
  27376. static get EmissiveTextureEnabled(): boolean;
  27377. static set EmissiveTextureEnabled(value: boolean);
  27378. /**
  27379. * Are specular textures enabled in the application.
  27380. */
  27381. static get SpecularTextureEnabled(): boolean;
  27382. static set SpecularTextureEnabled(value: boolean);
  27383. /**
  27384. * Are bump textures enabled in the application.
  27385. */
  27386. static get BumpTextureEnabled(): boolean;
  27387. static set BumpTextureEnabled(value: boolean);
  27388. /**
  27389. * Are lightmap textures enabled in the application.
  27390. */
  27391. static get LightmapTextureEnabled(): boolean;
  27392. static set LightmapTextureEnabled(value: boolean);
  27393. /**
  27394. * Are refraction textures enabled in the application.
  27395. */
  27396. static get RefractionTextureEnabled(): boolean;
  27397. static set RefractionTextureEnabled(value: boolean);
  27398. /**
  27399. * Are color grading textures enabled in the application.
  27400. */
  27401. static get ColorGradingTextureEnabled(): boolean;
  27402. static set ColorGradingTextureEnabled(value: boolean);
  27403. /**
  27404. * Are fresnels enabled in the application.
  27405. */
  27406. static get FresnelEnabled(): boolean;
  27407. static set FresnelEnabled(value: boolean);
  27408. }
  27409. }
  27410. declare module BABYLON {
  27411. /**
  27412. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27413. *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.
  27414. * The SPS is also a particle system. It provides some methods to manage the particles.
  27415. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27416. *
  27417. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27418. */
  27419. export class SolidParticleSystem implements IDisposable {
  27420. /**
  27421. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27422. * Example : var p = SPS.particles[i];
  27423. */
  27424. particles: SolidParticle[];
  27425. /**
  27426. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27427. */
  27428. nbParticles: number;
  27429. /**
  27430. * If the particles must ever face the camera (default false). Useful for planar particles.
  27431. */
  27432. billboard: boolean;
  27433. /**
  27434. * Recompute normals when adding a shape
  27435. */
  27436. recomputeNormals: boolean;
  27437. /**
  27438. * This a counter ofr your own usage. It's not set by any SPS functions.
  27439. */
  27440. counter: number;
  27441. /**
  27442. * The SPS name. This name is also given to the underlying mesh.
  27443. */
  27444. name: string;
  27445. /**
  27446. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27447. */
  27448. mesh: Mesh;
  27449. /**
  27450. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27451. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27452. */
  27453. vars: any;
  27454. /**
  27455. * This array is populated when the SPS is set as 'pickable'.
  27456. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27457. * Each element of this array is an object `{idx: int, faceId: int}`.
  27458. * `idx` is the picked particle index in the `SPS.particles` array
  27459. * `faceId` is the picked face index counted within this particle.
  27460. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27461. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27462. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27463. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27464. */
  27465. pickedParticles: {
  27466. idx: number;
  27467. faceId: number;
  27468. }[];
  27469. /**
  27470. * This array is populated when the SPS is set as 'pickable'
  27471. * Each key of this array is a submesh index.
  27472. * Each element of this array is a second array defined like this :
  27473. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27474. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27475. * `idx` is the picked particle index in the `SPS.particles` array
  27476. * `faceId` is the picked face index counted within this particle.
  27477. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27478. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27479. */
  27480. pickedBySubMesh: {
  27481. idx: number;
  27482. faceId: number;
  27483. }[][];
  27484. /**
  27485. * This array is populated when `enableDepthSort` is set to true.
  27486. * Each element of this array is an instance of the class DepthSortedParticle.
  27487. */
  27488. depthSortedParticles: DepthSortedParticle[];
  27489. /**
  27490. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27491. * @hidden
  27492. */
  27493. _bSphereOnly: boolean;
  27494. /**
  27495. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27496. * @hidden
  27497. */
  27498. _bSphereRadiusFactor: number;
  27499. private _scene;
  27500. private _positions;
  27501. private _indices;
  27502. private _normals;
  27503. private _colors;
  27504. private _uvs;
  27505. private _indices32;
  27506. private _positions32;
  27507. private _normals32;
  27508. private _fixedNormal32;
  27509. private _colors32;
  27510. private _uvs32;
  27511. private _index;
  27512. private _updatable;
  27513. private _pickable;
  27514. private _isVisibilityBoxLocked;
  27515. private _alwaysVisible;
  27516. private _depthSort;
  27517. private _expandable;
  27518. private _shapeCounter;
  27519. private _copy;
  27520. private _color;
  27521. private _computeParticleColor;
  27522. private _computeParticleTexture;
  27523. private _computeParticleRotation;
  27524. private _computeParticleVertex;
  27525. private _computeBoundingBox;
  27526. private _depthSortParticles;
  27527. private _camera;
  27528. private _mustUnrotateFixedNormals;
  27529. private _particlesIntersect;
  27530. private _needs32Bits;
  27531. private _isNotBuilt;
  27532. private _lastParticleId;
  27533. private _idxOfId;
  27534. private _multimaterialEnabled;
  27535. private _useModelMaterial;
  27536. private _indicesByMaterial;
  27537. private _materialIndexes;
  27538. private _depthSortFunction;
  27539. private _materialSortFunction;
  27540. private _materials;
  27541. private _multimaterial;
  27542. private _materialIndexesById;
  27543. private _defaultMaterial;
  27544. private _autoUpdateSubMeshes;
  27545. private _tmpVertex;
  27546. /**
  27547. * Creates a SPS (Solid Particle System) object.
  27548. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27549. * @param scene (Scene) is the scene in which the SPS is added.
  27550. * @param options defines the options of the sps e.g.
  27551. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27552. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27553. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27554. * * 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.
  27555. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27556. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27557. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27558. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27559. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27560. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27561. */
  27562. constructor(name: string, scene: Scene, options?: {
  27563. updatable?: boolean;
  27564. isPickable?: boolean;
  27565. enableDepthSort?: boolean;
  27566. particleIntersection?: boolean;
  27567. boundingSphereOnly?: boolean;
  27568. bSphereRadiusFactor?: number;
  27569. expandable?: boolean;
  27570. useModelMaterial?: boolean;
  27571. enableMultiMaterial?: boolean;
  27572. });
  27573. /**
  27574. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27575. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27576. * @returns the created mesh
  27577. */
  27578. buildMesh(): Mesh;
  27579. /**
  27580. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27581. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27582. * Thus the particles generated from `digest()` have their property `position` set yet.
  27583. * @param mesh ( Mesh ) is the mesh to be digested
  27584. * @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
  27585. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27586. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27587. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27588. * @returns the current SPS
  27589. */
  27590. digest(mesh: Mesh, options?: {
  27591. facetNb?: number;
  27592. number?: number;
  27593. delta?: number;
  27594. storage?: [];
  27595. }): SolidParticleSystem;
  27596. /**
  27597. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27598. * @hidden
  27599. */
  27600. private _unrotateFixedNormals;
  27601. /**
  27602. * Resets the temporary working copy particle
  27603. * @hidden
  27604. */
  27605. private _resetCopy;
  27606. /**
  27607. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27608. * @param p the current index in the positions array to be updated
  27609. * @param ind the current index in the indices array
  27610. * @param shape a Vector3 array, the shape geometry
  27611. * @param positions the positions array to be updated
  27612. * @param meshInd the shape indices array
  27613. * @param indices the indices array to be updated
  27614. * @param meshUV the shape uv array
  27615. * @param uvs the uv array to be updated
  27616. * @param meshCol the shape color array
  27617. * @param colors the color array to be updated
  27618. * @param meshNor the shape normals array
  27619. * @param normals the normals array to be updated
  27620. * @param idx the particle index
  27621. * @param idxInShape the particle index in its shape
  27622. * @param options the addShape() method passed options
  27623. * @model the particle model
  27624. * @hidden
  27625. */
  27626. private _meshBuilder;
  27627. /**
  27628. * Returns a shape Vector3 array from positions float array
  27629. * @param positions float array
  27630. * @returns a vector3 array
  27631. * @hidden
  27632. */
  27633. private _posToShape;
  27634. /**
  27635. * Returns a shapeUV array from a float uvs (array deep copy)
  27636. * @param uvs as a float array
  27637. * @returns a shapeUV array
  27638. * @hidden
  27639. */
  27640. private _uvsToShapeUV;
  27641. /**
  27642. * Adds a new particle object in the particles array
  27643. * @param idx particle index in particles array
  27644. * @param id particle id
  27645. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27646. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27647. * @param model particle ModelShape object
  27648. * @param shapeId model shape identifier
  27649. * @param idxInShape index of the particle in the current model
  27650. * @param bInfo model bounding info object
  27651. * @param storage target storage array, if any
  27652. * @hidden
  27653. */
  27654. private _addParticle;
  27655. /**
  27656. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27657. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27658. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27659. * @param nb (positive integer) the number of particles to be created from this model
  27660. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27661. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27662. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27663. * @returns the number of shapes in the system
  27664. */
  27665. addShape(mesh: Mesh, nb: number, options?: {
  27666. positionFunction?: any;
  27667. vertexFunction?: any;
  27668. storage?: [];
  27669. }): number;
  27670. /**
  27671. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27672. * @hidden
  27673. */
  27674. private _rebuildParticle;
  27675. /**
  27676. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27677. * @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.
  27678. * @returns the SPS.
  27679. */
  27680. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27681. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27682. * Returns an array with the removed particles.
  27683. * 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.
  27684. * The SPS can't be empty so at least one particle needs to remain in place.
  27685. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27686. * @param start index of the first particle to remove
  27687. * @param end index of the last particle to remove (included)
  27688. * @returns an array populated with the removed particles
  27689. */
  27690. removeParticles(start: number, end: number): SolidParticle[];
  27691. /**
  27692. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27693. * @param solidParticleArray an array populated with Solid Particles objects
  27694. * @returns the SPS
  27695. */
  27696. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27697. /**
  27698. * Creates a new particle and modifies the SPS mesh geometry :
  27699. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27700. * - calls _addParticle() to populate the particle array
  27701. * factorized code from addShape() and insertParticlesFromArray()
  27702. * @param idx particle index in the particles array
  27703. * @param i particle index in its shape
  27704. * @param modelShape particle ModelShape object
  27705. * @param shape shape vertex array
  27706. * @param meshInd shape indices array
  27707. * @param meshUV shape uv array
  27708. * @param meshCol shape color array
  27709. * @param meshNor shape normals array
  27710. * @param bbInfo shape bounding info
  27711. * @param storage target particle storage
  27712. * @options addShape() passed options
  27713. * @hidden
  27714. */
  27715. private _insertNewParticle;
  27716. /**
  27717. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27718. * This method calls `updateParticle()` for each particle of the SPS.
  27719. * For an animated SPS, it is usually called within the render loop.
  27720. * 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.
  27721. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27722. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27723. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27724. * @returns the SPS.
  27725. */
  27726. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27727. /**
  27728. * Disposes the SPS.
  27729. */
  27730. dispose(): void;
  27731. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27732. * idx is the particle index in the SPS
  27733. * faceId is the picked face index counted within this particle.
  27734. * Returns null if the pickInfo can't identify a picked particle.
  27735. * @param pickingInfo (PickingInfo object)
  27736. * @returns {idx: number, faceId: number} or null
  27737. */
  27738. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27739. idx: number;
  27740. faceId: number;
  27741. }>;
  27742. /**
  27743. * Returns a SolidParticle object from its identifier : particle.id
  27744. * @param id (integer) the particle Id
  27745. * @returns the searched particle or null if not found in the SPS.
  27746. */
  27747. getParticleById(id: number): Nullable<SolidParticle>;
  27748. /**
  27749. * Returns a new array populated with the particles having the passed shapeId.
  27750. * @param shapeId (integer) the shape identifier
  27751. * @returns a new solid particle array
  27752. */
  27753. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27754. /**
  27755. * Populates the passed array "ref" with the particles having the passed shapeId.
  27756. * @param shapeId the shape identifier
  27757. * @returns the SPS
  27758. * @param ref
  27759. */
  27760. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27761. /**
  27762. * Computes the required SubMeshes according the materials assigned to the particles.
  27763. * @returns the solid particle system.
  27764. * Does nothing if called before the SPS mesh is built.
  27765. */
  27766. computeSubMeshes(): SolidParticleSystem;
  27767. /**
  27768. * Sorts the solid particles by material when MultiMaterial is enabled.
  27769. * Updates the indices32 array.
  27770. * Updates the indicesByMaterial array.
  27771. * Updates the mesh indices array.
  27772. * @returns the SPS
  27773. * @hidden
  27774. */
  27775. private _sortParticlesByMaterial;
  27776. /**
  27777. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27778. * @hidden
  27779. */
  27780. private _setMaterialIndexesById;
  27781. /**
  27782. * Returns an array with unique values of Materials from the passed array
  27783. * @param array the material array to be checked and filtered
  27784. * @hidden
  27785. */
  27786. private _filterUniqueMaterialId;
  27787. /**
  27788. * Sets a new Standard Material as _defaultMaterial if not already set.
  27789. * @hidden
  27790. */
  27791. private _setDefaultMaterial;
  27792. /**
  27793. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27794. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27795. * @returns the SPS.
  27796. */
  27797. refreshVisibleSize(): SolidParticleSystem;
  27798. /**
  27799. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27800. * @param size the size (float) of the visibility box
  27801. * note : this doesn't lock the SPS mesh bounding box.
  27802. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27803. */
  27804. setVisibilityBox(size: number): void;
  27805. /**
  27806. * Gets whether the SPS as always visible or not
  27807. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27808. */
  27809. get isAlwaysVisible(): boolean;
  27810. /**
  27811. * Sets the SPS as always visible or not
  27812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27813. */
  27814. set isAlwaysVisible(val: boolean);
  27815. /**
  27816. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27818. */
  27819. set isVisibilityBoxLocked(val: boolean);
  27820. /**
  27821. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27822. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27823. */
  27824. get isVisibilityBoxLocked(): boolean;
  27825. /**
  27826. * Tells to `setParticles()` to compute the particle rotations or not.
  27827. * Default value : true. The SPS is faster when it's set to false.
  27828. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27829. */
  27830. set computeParticleRotation(val: boolean);
  27831. /**
  27832. * Tells to `setParticles()` to compute the particle colors or not.
  27833. * Default value : true. The SPS is faster when it's set to false.
  27834. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27835. */
  27836. set computeParticleColor(val: boolean);
  27837. set computeParticleTexture(val: boolean);
  27838. /**
  27839. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27840. * Default value : false. The SPS is faster when it's set to false.
  27841. * Note : the particle custom vertex positions aren't stored values.
  27842. */
  27843. set computeParticleVertex(val: boolean);
  27844. /**
  27845. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27846. */
  27847. set computeBoundingBox(val: boolean);
  27848. /**
  27849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27851. * Default : `true`
  27852. */
  27853. set depthSortParticles(val: boolean);
  27854. /**
  27855. * Gets if `setParticles()` computes the particle rotations or not.
  27856. * Default value : true. The SPS is faster when it's set to false.
  27857. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27858. */
  27859. get computeParticleRotation(): boolean;
  27860. /**
  27861. * Gets if `setParticles()` computes the particle colors or not.
  27862. * Default value : true. The SPS is faster when it's set to false.
  27863. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27864. */
  27865. get computeParticleColor(): boolean;
  27866. /**
  27867. * Gets if `setParticles()` computes the particle textures or not.
  27868. * Default value : true. The SPS is faster when it's set to false.
  27869. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27870. */
  27871. get computeParticleTexture(): boolean;
  27872. /**
  27873. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27874. * Default value : false. The SPS is faster when it's set to false.
  27875. * Note : the particle custom vertex positions aren't stored values.
  27876. */
  27877. get computeParticleVertex(): boolean;
  27878. /**
  27879. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27880. */
  27881. get computeBoundingBox(): boolean;
  27882. /**
  27883. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27884. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27885. * Default : `true`
  27886. */
  27887. get depthSortParticles(): boolean;
  27888. /**
  27889. * Gets if the SPS is created as expandable at construction time.
  27890. * Default : `false`
  27891. */
  27892. get expandable(): boolean;
  27893. /**
  27894. * Gets if the SPS supports the Multi Materials
  27895. */
  27896. get multimaterialEnabled(): boolean;
  27897. /**
  27898. * Gets if the SPS uses the model materials for its own multimaterial.
  27899. */
  27900. get useModelMaterial(): boolean;
  27901. /**
  27902. * The SPS used material array.
  27903. */
  27904. get materials(): Material[];
  27905. /**
  27906. * Sets the SPS MultiMaterial from the passed materials.
  27907. * Note : the passed array is internally copied and not used then by reference.
  27908. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27909. */
  27910. setMultiMaterial(materials: Material[]): void;
  27911. /**
  27912. * The SPS computed multimaterial object
  27913. */
  27914. get multimaterial(): MultiMaterial;
  27915. set multimaterial(mm: MultiMaterial);
  27916. /**
  27917. * If the subMeshes must be updated on the next call to setParticles()
  27918. */
  27919. get autoUpdateSubMeshes(): boolean;
  27920. set autoUpdateSubMeshes(val: boolean);
  27921. /**
  27922. * This function does nothing. It may be overwritten to set all the particle first values.
  27923. * The SPS doesn't call this function, you may have to call it by your own.
  27924. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27925. */
  27926. initParticles(): void;
  27927. /**
  27928. * This function does nothing. It may be overwritten to recycle a particle.
  27929. * The SPS doesn't call this function, you may have to call it by your own.
  27930. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27931. * @param particle The particle to recycle
  27932. * @returns the recycled particle
  27933. */
  27934. recycleParticle(particle: SolidParticle): SolidParticle;
  27935. /**
  27936. * Updates a particle : this function should be overwritten by the user.
  27937. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27938. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27939. * @example : just set a particle position or velocity and recycle conditions
  27940. * @param particle The particle to update
  27941. * @returns the updated particle
  27942. */
  27943. updateParticle(particle: SolidParticle): SolidParticle;
  27944. /**
  27945. * Updates a vertex of a particle : it can be overwritten by the user.
  27946. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27947. * @param particle the current particle
  27948. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  27949. * @param pt the index of the current vertex in the particle shape
  27950. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27951. * @example : just set a vertex particle position or color
  27952. * @returns the sps
  27953. */
  27954. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  27955. /**
  27956. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27957. * This does nothing and may be overwritten by the user.
  27958. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27959. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27960. * @param update the boolean update value actually passed to setParticles()
  27961. */
  27962. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27963. /**
  27964. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27965. * This will be passed three parameters.
  27966. * This does nothing and may be overwritten by the user.
  27967. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27968. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27969. * @param update the boolean update value actually passed to setParticles()
  27970. */
  27971. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27972. }
  27973. }
  27974. declare module BABYLON {
  27975. /**
  27976. * Represents one particle of a solid particle system.
  27977. */
  27978. export class SolidParticle {
  27979. /**
  27980. * particle global index
  27981. */
  27982. idx: number;
  27983. /**
  27984. * particle identifier
  27985. */
  27986. id: number;
  27987. /**
  27988. * The color of the particle
  27989. */
  27990. color: Nullable<Color4>;
  27991. /**
  27992. * The world space position of the particle.
  27993. */
  27994. position: Vector3;
  27995. /**
  27996. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27997. */
  27998. rotation: Vector3;
  27999. /**
  28000. * The world space rotation quaternion of the particle.
  28001. */
  28002. rotationQuaternion: Nullable<Quaternion>;
  28003. /**
  28004. * The scaling of the particle.
  28005. */
  28006. scaling: Vector3;
  28007. /**
  28008. * The uvs of the particle.
  28009. */
  28010. uvs: Vector4;
  28011. /**
  28012. * The current speed of the particle.
  28013. */
  28014. velocity: Vector3;
  28015. /**
  28016. * The pivot point in the particle local space.
  28017. */
  28018. pivot: Vector3;
  28019. /**
  28020. * Must the particle be translated from its pivot point in its local space ?
  28021. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28022. * Default : false
  28023. */
  28024. translateFromPivot: boolean;
  28025. /**
  28026. * Is the particle active or not ?
  28027. */
  28028. alive: boolean;
  28029. /**
  28030. * Is the particle visible or not ?
  28031. */
  28032. isVisible: boolean;
  28033. /**
  28034. * Index of this particle in the global "positions" array (Internal use)
  28035. * @hidden
  28036. */
  28037. _pos: number;
  28038. /**
  28039. * @hidden Index of this particle in the global "indices" array (Internal use)
  28040. */
  28041. _ind: number;
  28042. /**
  28043. * @hidden ModelShape of this particle (Internal use)
  28044. */
  28045. _model: ModelShape;
  28046. /**
  28047. * ModelShape id of this particle
  28048. */
  28049. shapeId: number;
  28050. /**
  28051. * Index of the particle in its shape id
  28052. */
  28053. idxInShape: number;
  28054. /**
  28055. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28056. */
  28057. _modelBoundingInfo: BoundingInfo;
  28058. /**
  28059. * @hidden Particle BoundingInfo object (Internal use)
  28060. */
  28061. _boundingInfo: BoundingInfo;
  28062. /**
  28063. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28064. */
  28065. _sps: SolidParticleSystem;
  28066. /**
  28067. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28068. */
  28069. _stillInvisible: boolean;
  28070. /**
  28071. * @hidden Last computed particle rotation matrix
  28072. */
  28073. _rotationMatrix: number[];
  28074. /**
  28075. * Parent particle Id, if any.
  28076. * Default null.
  28077. */
  28078. parentId: Nullable<number>;
  28079. /**
  28080. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28081. */
  28082. materialIndex: Nullable<number>;
  28083. /**
  28084. * Custom object or properties.
  28085. */
  28086. props: Nullable<any>;
  28087. /**
  28088. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28089. * The possible values are :
  28090. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28091. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28092. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28093. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28094. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28095. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28096. * */
  28097. cullingStrategy: number;
  28098. /**
  28099. * @hidden Internal global position in the SPS.
  28100. */
  28101. _globalPosition: Vector3;
  28102. /**
  28103. * Creates a Solid Particle object.
  28104. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28105. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28106. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28107. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28108. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28109. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28110. * @param shapeId (integer) is the model shape identifier in the SPS.
  28111. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28112. * @param sps defines the sps it is associated to
  28113. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28114. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28115. */
  28116. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28117. /**
  28118. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28119. * @param target the particle target
  28120. * @returns the current particle
  28121. */
  28122. copyToRef(target: SolidParticle): SolidParticle;
  28123. /**
  28124. * Legacy support, changed scale to scaling
  28125. */
  28126. get scale(): Vector3;
  28127. /**
  28128. * Legacy support, changed scale to scaling
  28129. */
  28130. set scale(scale: Vector3);
  28131. /**
  28132. * Legacy support, changed quaternion to rotationQuaternion
  28133. */
  28134. get quaternion(): Nullable<Quaternion>;
  28135. /**
  28136. * Legacy support, changed quaternion to rotationQuaternion
  28137. */
  28138. set quaternion(q: Nullable<Quaternion>);
  28139. /**
  28140. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28141. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28142. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28143. * @returns true if it intersects
  28144. */
  28145. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28146. /**
  28147. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28148. * A particle is in the frustum if its bounding box intersects the frustum
  28149. * @param frustumPlanes defines the frustum to test
  28150. * @returns true if the particle is in the frustum planes
  28151. */
  28152. isInFrustum(frustumPlanes: Plane[]): boolean;
  28153. /**
  28154. * get the rotation matrix of the particle
  28155. * @hidden
  28156. */
  28157. getRotationMatrix(m: Matrix): void;
  28158. }
  28159. /**
  28160. * Represents the shape of the model used by one particle of a solid particle system.
  28161. * SPS internal tool, don't use it manually.
  28162. */
  28163. export class ModelShape {
  28164. /**
  28165. * The shape id
  28166. * @hidden
  28167. */
  28168. shapeID: number;
  28169. /**
  28170. * flat array of model positions (internal use)
  28171. * @hidden
  28172. */
  28173. _shape: Vector3[];
  28174. /**
  28175. * flat array of model UVs (internal use)
  28176. * @hidden
  28177. */
  28178. _shapeUV: number[];
  28179. /**
  28180. * color array of the model
  28181. * @hidden
  28182. */
  28183. _shapeColors: number[];
  28184. /**
  28185. * indices array of the model
  28186. * @hidden
  28187. */
  28188. _indices: number[];
  28189. /**
  28190. * normals array of the model
  28191. * @hidden
  28192. */
  28193. _normals: number[];
  28194. /**
  28195. * length of the shape in the model indices array (internal use)
  28196. * @hidden
  28197. */
  28198. _indicesLength: number;
  28199. /**
  28200. * Custom position function (internal use)
  28201. * @hidden
  28202. */
  28203. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28204. /**
  28205. * Custom vertex function (internal use)
  28206. * @hidden
  28207. */
  28208. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28209. /**
  28210. * Model material (internal use)
  28211. * @hidden
  28212. */
  28213. _material: Nullable<Material>;
  28214. /**
  28215. * 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.
  28216. * SPS internal tool, don't use it manually.
  28217. * @hidden
  28218. */
  28219. 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>);
  28220. }
  28221. /**
  28222. * Represents a Depth Sorted Particle in the solid particle system.
  28223. * @hidden
  28224. */
  28225. export class DepthSortedParticle {
  28226. /**
  28227. * Particle index
  28228. */
  28229. idx: number;
  28230. /**
  28231. * Index of the particle in the "indices" array
  28232. */
  28233. ind: number;
  28234. /**
  28235. * Length of the particle shape in the "indices" array
  28236. */
  28237. indicesLength: number;
  28238. /**
  28239. * Squared distance from the particle to the camera
  28240. */
  28241. sqDistance: number;
  28242. /**
  28243. * Material index when used with MultiMaterials
  28244. */
  28245. materialIndex: number;
  28246. /**
  28247. * Creates a new sorted particle
  28248. * @param materialIndex
  28249. */
  28250. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28251. }
  28252. /**
  28253. * Represents a solid particle vertex
  28254. */
  28255. export class SolidParticleVertex {
  28256. /**
  28257. * Vertex position
  28258. */
  28259. position: Vector3;
  28260. /**
  28261. * Vertex color
  28262. */
  28263. color: Color4;
  28264. /**
  28265. * Vertex UV
  28266. */
  28267. uv: Vector2;
  28268. /**
  28269. * Creates a new solid particle vertex
  28270. */
  28271. constructor();
  28272. /** Vertex x coordinate */
  28273. get x(): number;
  28274. set x(val: number);
  28275. /** Vertex y coordinate */
  28276. get y(): number;
  28277. set y(val: number);
  28278. /** Vertex z coordinate */
  28279. get z(): number;
  28280. set z(val: number);
  28281. }
  28282. }
  28283. declare module BABYLON {
  28284. /**
  28285. * @hidden
  28286. */
  28287. export class _MeshCollisionData {
  28288. _checkCollisions: boolean;
  28289. _collisionMask: number;
  28290. _collisionGroup: number;
  28291. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28292. _collider: Nullable<Collider>;
  28293. _oldPositionForCollisions: Vector3;
  28294. _diffPositionForCollisions: Vector3;
  28295. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28296. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28297. }
  28298. }
  28299. declare module BABYLON {
  28300. /** @hidden */
  28301. class _FacetDataStorage {
  28302. facetPositions: Vector3[];
  28303. facetNormals: Vector3[];
  28304. facetPartitioning: number[][];
  28305. facetNb: number;
  28306. partitioningSubdivisions: number;
  28307. partitioningBBoxRatio: number;
  28308. facetDataEnabled: boolean;
  28309. facetParameters: any;
  28310. bbSize: Vector3;
  28311. subDiv: {
  28312. max: number;
  28313. X: number;
  28314. Y: number;
  28315. Z: number;
  28316. };
  28317. facetDepthSort: boolean;
  28318. facetDepthSortEnabled: boolean;
  28319. depthSortedIndices: IndicesArray;
  28320. depthSortedFacets: {
  28321. ind: number;
  28322. sqDistance: number;
  28323. }[];
  28324. facetDepthSortFunction: (f1: {
  28325. ind: number;
  28326. sqDistance: number;
  28327. }, f2: {
  28328. ind: number;
  28329. sqDistance: number;
  28330. }) => number;
  28331. facetDepthSortFrom: Vector3;
  28332. facetDepthSortOrigin: Vector3;
  28333. invertedMatrix: Matrix;
  28334. }
  28335. /**
  28336. * @hidden
  28337. **/
  28338. class _InternalAbstractMeshDataInfo {
  28339. _hasVertexAlpha: boolean;
  28340. _useVertexColors: boolean;
  28341. _numBoneInfluencers: number;
  28342. _applyFog: boolean;
  28343. _receiveShadows: boolean;
  28344. _facetData: _FacetDataStorage;
  28345. _visibility: number;
  28346. _skeleton: Nullable<Skeleton>;
  28347. _layerMask: number;
  28348. _computeBonesUsingShaders: boolean;
  28349. _isActive: boolean;
  28350. _onlyForInstances: boolean;
  28351. _isActiveIntermediate: boolean;
  28352. _onlyForInstancesIntermediate: boolean;
  28353. _actAsRegularMesh: boolean;
  28354. }
  28355. /**
  28356. * Class used to store all common mesh properties
  28357. */
  28358. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28359. /** No occlusion */
  28360. static OCCLUSION_TYPE_NONE: number;
  28361. /** Occlusion set to optimisitic */
  28362. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28363. /** Occlusion set to strict */
  28364. static OCCLUSION_TYPE_STRICT: number;
  28365. /** Use an accurante occlusion algorithm */
  28366. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28367. /** Use a conservative occlusion algorithm */
  28368. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28369. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28370. * Test order :
  28371. * Is the bounding sphere outside the frustum ?
  28372. * If not, are the bounding box vertices outside the frustum ?
  28373. * It not, then the cullable object is in the frustum.
  28374. */
  28375. static readonly CULLINGSTRATEGY_STANDARD: number;
  28376. /** Culling strategy : Bounding Sphere Only.
  28377. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28378. * It's also less accurate than the standard because some not visible objects can still be selected.
  28379. * Test : is the bounding sphere outside the frustum ?
  28380. * If not, then the cullable object is in the frustum.
  28381. */
  28382. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28383. /** Culling strategy : Optimistic Inclusion.
  28384. * This in an inclusion test first, then the standard exclusion test.
  28385. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28386. * 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.
  28387. * Anyway, it's as accurate as the standard strategy.
  28388. * Test :
  28389. * Is the cullable object bounding sphere center in the frustum ?
  28390. * If not, apply the default culling strategy.
  28391. */
  28392. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28393. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28394. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28395. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28396. * 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.
  28397. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28398. * Test :
  28399. * Is the cullable object bounding sphere center in the frustum ?
  28400. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28401. */
  28402. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28403. /**
  28404. * No billboard
  28405. */
  28406. static get BILLBOARDMODE_NONE(): number;
  28407. /** Billboard on X axis */
  28408. static get BILLBOARDMODE_X(): number;
  28409. /** Billboard on Y axis */
  28410. static get BILLBOARDMODE_Y(): number;
  28411. /** Billboard on Z axis */
  28412. static get BILLBOARDMODE_Z(): number;
  28413. /** Billboard on all axes */
  28414. static get BILLBOARDMODE_ALL(): number;
  28415. /** Billboard on using position instead of orientation */
  28416. static get BILLBOARDMODE_USE_POSITION(): number;
  28417. /** @hidden */
  28418. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28419. /**
  28420. * The culling strategy to use to check whether the mesh must be rendered or not.
  28421. * This value can be changed at any time and will be used on the next render mesh selection.
  28422. * The possible values are :
  28423. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28424. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28425. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28426. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28427. * Please read each static variable documentation to get details about the culling process.
  28428. * */
  28429. cullingStrategy: number;
  28430. /**
  28431. * Gets the number of facets in the mesh
  28432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28433. */
  28434. get facetNb(): number;
  28435. /**
  28436. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28438. */
  28439. get partitioningSubdivisions(): number;
  28440. set partitioningSubdivisions(nb: number);
  28441. /**
  28442. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28443. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28445. */
  28446. get partitioningBBoxRatio(): number;
  28447. set partitioningBBoxRatio(ratio: number);
  28448. /**
  28449. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28450. * Works only for updatable meshes.
  28451. * Doesn't work with multi-materials
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28453. */
  28454. get mustDepthSortFacets(): boolean;
  28455. set mustDepthSortFacets(sort: boolean);
  28456. /**
  28457. * The location (Vector3) where the facet depth sort must be computed from.
  28458. * By default, the active camera position.
  28459. * Used only when facet depth sort is enabled
  28460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28461. */
  28462. get facetDepthSortFrom(): Vector3;
  28463. set facetDepthSortFrom(location: Vector3);
  28464. /**
  28465. * gets a boolean indicating if facetData is enabled
  28466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28467. */
  28468. get isFacetDataEnabled(): boolean;
  28469. /** @hidden */
  28470. _updateNonUniformScalingState(value: boolean): boolean;
  28471. /**
  28472. * An event triggered when this mesh collides with another one
  28473. */
  28474. onCollideObservable: Observable<AbstractMesh>;
  28475. /** Set a function to call when this mesh collides with another one */
  28476. set onCollide(callback: () => void);
  28477. /**
  28478. * An event triggered when the collision's position changes
  28479. */
  28480. onCollisionPositionChangeObservable: Observable<Vector3>;
  28481. /** Set a function to call when the collision's position changes */
  28482. set onCollisionPositionChange(callback: () => void);
  28483. /**
  28484. * An event triggered when material is changed
  28485. */
  28486. onMaterialChangedObservable: Observable<AbstractMesh>;
  28487. /**
  28488. * Gets or sets the orientation for POV movement & rotation
  28489. */
  28490. definedFacingForward: boolean;
  28491. /** @hidden */
  28492. _occlusionQuery: Nullable<WebGLQuery>;
  28493. /** @hidden */
  28494. _renderingGroup: Nullable<RenderingGroup>;
  28495. /**
  28496. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28497. */
  28498. get visibility(): number;
  28499. /**
  28500. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28501. */
  28502. set visibility(value: number);
  28503. /** Gets or sets the alpha index used to sort transparent meshes
  28504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28505. */
  28506. alphaIndex: number;
  28507. /**
  28508. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28509. */
  28510. isVisible: boolean;
  28511. /**
  28512. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28513. */
  28514. isPickable: boolean;
  28515. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28516. showSubMeshesBoundingBox: boolean;
  28517. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28518. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28519. */
  28520. isBlocker: boolean;
  28521. /**
  28522. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28523. */
  28524. enablePointerMoveEvents: boolean;
  28525. /**
  28526. * Specifies the rendering group id for this mesh (0 by default)
  28527. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28528. */
  28529. renderingGroupId: number;
  28530. private _material;
  28531. /** Gets or sets current material */
  28532. get material(): Nullable<Material>;
  28533. set material(value: Nullable<Material>);
  28534. /**
  28535. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28536. * @see http://doc.babylonjs.com/babylon101/shadows
  28537. */
  28538. get receiveShadows(): boolean;
  28539. set receiveShadows(value: boolean);
  28540. /** Defines color to use when rendering outline */
  28541. outlineColor: Color3;
  28542. /** Define width to use when rendering outline */
  28543. outlineWidth: number;
  28544. /** Defines color to use when rendering overlay */
  28545. overlayColor: Color3;
  28546. /** Defines alpha to use when rendering overlay */
  28547. overlayAlpha: number;
  28548. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28549. get hasVertexAlpha(): boolean;
  28550. set hasVertexAlpha(value: boolean);
  28551. /** 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) */
  28552. get useVertexColors(): boolean;
  28553. set useVertexColors(value: boolean);
  28554. /**
  28555. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28556. */
  28557. get computeBonesUsingShaders(): boolean;
  28558. set computeBonesUsingShaders(value: boolean);
  28559. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28560. get numBoneInfluencers(): number;
  28561. set numBoneInfluencers(value: number);
  28562. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28563. get applyFog(): boolean;
  28564. set applyFog(value: boolean);
  28565. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28566. useOctreeForRenderingSelection: boolean;
  28567. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28568. useOctreeForPicking: boolean;
  28569. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28570. useOctreeForCollisions: boolean;
  28571. /**
  28572. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28573. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28574. */
  28575. get layerMask(): number;
  28576. set layerMask(value: number);
  28577. /**
  28578. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28579. */
  28580. alwaysSelectAsActiveMesh: boolean;
  28581. /**
  28582. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28583. */
  28584. doNotSyncBoundingInfo: boolean;
  28585. /**
  28586. * Gets or sets the current action manager
  28587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28588. */
  28589. actionManager: Nullable<AbstractActionManager>;
  28590. private _meshCollisionData;
  28591. /**
  28592. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28594. */
  28595. ellipsoid: Vector3;
  28596. /**
  28597. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28599. */
  28600. ellipsoidOffset: Vector3;
  28601. /**
  28602. * Gets or sets a collision mask used to mask collisions (default is -1).
  28603. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28604. */
  28605. get collisionMask(): number;
  28606. set collisionMask(mask: number);
  28607. /**
  28608. * Gets or sets the current collision group mask (-1 by default).
  28609. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28610. */
  28611. get collisionGroup(): number;
  28612. set collisionGroup(mask: number);
  28613. /**
  28614. * Gets or sets current surrounding meshes (null by default).
  28615. *
  28616. * By default collision detection is tested against every mesh in the scene.
  28617. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28618. * meshes will be tested for the collision.
  28619. *
  28620. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28621. */
  28622. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28623. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28624. /**
  28625. * Defines edge width used when edgesRenderer is enabled
  28626. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28627. */
  28628. edgesWidth: number;
  28629. /**
  28630. * Defines edge color used when edgesRenderer is enabled
  28631. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28632. */
  28633. edgesColor: Color4;
  28634. /** @hidden */
  28635. _edgesRenderer: Nullable<IEdgesRenderer>;
  28636. /** @hidden */
  28637. _masterMesh: Nullable<AbstractMesh>;
  28638. /** @hidden */
  28639. _boundingInfo: Nullable<BoundingInfo>;
  28640. /** @hidden */
  28641. _renderId: number;
  28642. /**
  28643. * Gets or sets the list of subMeshes
  28644. * @see http://doc.babylonjs.com/how_to/multi_materials
  28645. */
  28646. subMeshes: SubMesh[];
  28647. /** @hidden */
  28648. _intersectionsInProgress: AbstractMesh[];
  28649. /** @hidden */
  28650. _unIndexed: boolean;
  28651. /** @hidden */
  28652. _lightSources: Light[];
  28653. /** Gets the list of lights affecting that mesh */
  28654. get lightSources(): Light[];
  28655. /** @hidden */
  28656. get _positions(): Nullable<Vector3[]>;
  28657. /** @hidden */
  28658. _waitingData: {
  28659. lods: Nullable<any>;
  28660. actions: Nullable<any>;
  28661. freezeWorldMatrix: Nullable<boolean>;
  28662. };
  28663. /** @hidden */
  28664. _bonesTransformMatrices: Nullable<Float32Array>;
  28665. /** @hidden */
  28666. _transformMatrixTexture: Nullable<RawTexture>;
  28667. /**
  28668. * Gets or sets a skeleton to apply skining transformations
  28669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28670. */
  28671. set skeleton(value: Nullable<Skeleton>);
  28672. get skeleton(): Nullable<Skeleton>;
  28673. /**
  28674. * An event triggered when the mesh is rebuilt.
  28675. */
  28676. onRebuildObservable: Observable<AbstractMesh>;
  28677. /**
  28678. * Creates a new AbstractMesh
  28679. * @param name defines the name of the mesh
  28680. * @param scene defines the hosting scene
  28681. */
  28682. constructor(name: string, scene?: Nullable<Scene>);
  28683. /**
  28684. * Returns the string "AbstractMesh"
  28685. * @returns "AbstractMesh"
  28686. */
  28687. getClassName(): string;
  28688. /**
  28689. * Gets a string representation of the current mesh
  28690. * @param fullDetails defines a boolean indicating if full details must be included
  28691. * @returns a string representation of the current mesh
  28692. */
  28693. toString(fullDetails?: boolean): string;
  28694. /**
  28695. * @hidden
  28696. */
  28697. protected _getEffectiveParent(): Nullable<Node>;
  28698. /** @hidden */
  28699. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28700. /** @hidden */
  28701. _rebuild(): void;
  28702. /** @hidden */
  28703. _resyncLightSources(): void;
  28704. /** @hidden */
  28705. _resyncLightSource(light: Light): void;
  28706. /** @hidden */
  28707. _unBindEffect(): void;
  28708. /** @hidden */
  28709. _removeLightSource(light: Light, dispose: boolean): void;
  28710. private _markSubMeshesAsDirty;
  28711. /** @hidden */
  28712. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28713. /** @hidden */
  28714. _markSubMeshesAsAttributesDirty(): void;
  28715. /** @hidden */
  28716. _markSubMeshesAsMiscDirty(): void;
  28717. /**
  28718. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28719. */
  28720. get scaling(): Vector3;
  28721. set scaling(newScaling: Vector3);
  28722. /**
  28723. * Returns true if the mesh is blocked. Implemented by child classes
  28724. */
  28725. get isBlocked(): boolean;
  28726. /**
  28727. * Returns the mesh itself by default. Implemented by child classes
  28728. * @param camera defines the camera to use to pick the right LOD level
  28729. * @returns the currentAbstractMesh
  28730. */
  28731. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28732. /**
  28733. * Returns 0 by default. Implemented by child classes
  28734. * @returns an integer
  28735. */
  28736. getTotalVertices(): number;
  28737. /**
  28738. * Returns a positive integer : the total number of indices in this mesh geometry.
  28739. * @returns the numner of indices or zero if the mesh has no geometry.
  28740. */
  28741. getTotalIndices(): number;
  28742. /**
  28743. * Returns null by default. Implemented by child classes
  28744. * @returns null
  28745. */
  28746. getIndices(): Nullable<IndicesArray>;
  28747. /**
  28748. * Returns the array of the requested vertex data kind. Implemented by child classes
  28749. * @param kind defines the vertex data kind to use
  28750. * @returns null
  28751. */
  28752. getVerticesData(kind: string): Nullable<FloatArray>;
  28753. /**
  28754. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28755. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28756. * Note that a new underlying VertexBuffer object is created each call.
  28757. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28758. * @param kind defines vertex data kind:
  28759. * * VertexBuffer.PositionKind
  28760. * * VertexBuffer.UVKind
  28761. * * VertexBuffer.UV2Kind
  28762. * * VertexBuffer.UV3Kind
  28763. * * VertexBuffer.UV4Kind
  28764. * * VertexBuffer.UV5Kind
  28765. * * VertexBuffer.UV6Kind
  28766. * * VertexBuffer.ColorKind
  28767. * * VertexBuffer.MatricesIndicesKind
  28768. * * VertexBuffer.MatricesIndicesExtraKind
  28769. * * VertexBuffer.MatricesWeightsKind
  28770. * * VertexBuffer.MatricesWeightsExtraKind
  28771. * @param data defines the data source
  28772. * @param updatable defines if the data must be flagged as updatable (or static)
  28773. * @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
  28774. * @returns the current mesh
  28775. */
  28776. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28777. /**
  28778. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28779. * If the mesh has no geometry, it is simply returned as it is.
  28780. * @param kind defines vertex data kind:
  28781. * * VertexBuffer.PositionKind
  28782. * * VertexBuffer.UVKind
  28783. * * VertexBuffer.UV2Kind
  28784. * * VertexBuffer.UV3Kind
  28785. * * VertexBuffer.UV4Kind
  28786. * * VertexBuffer.UV5Kind
  28787. * * VertexBuffer.UV6Kind
  28788. * * VertexBuffer.ColorKind
  28789. * * VertexBuffer.MatricesIndicesKind
  28790. * * VertexBuffer.MatricesIndicesExtraKind
  28791. * * VertexBuffer.MatricesWeightsKind
  28792. * * VertexBuffer.MatricesWeightsExtraKind
  28793. * @param data defines the data source
  28794. * @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
  28795. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28796. * @returns the current mesh
  28797. */
  28798. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28799. /**
  28800. * Sets the mesh indices,
  28801. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28802. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28803. * @param totalVertices Defines the total number of vertices
  28804. * @returns the current mesh
  28805. */
  28806. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28807. /**
  28808. * Gets a boolean indicating if specific vertex data is present
  28809. * @param kind defines the vertex data kind to use
  28810. * @returns true is data kind is present
  28811. */
  28812. isVerticesDataPresent(kind: string): boolean;
  28813. /**
  28814. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28815. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28816. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28817. * @returns a BoundingInfo
  28818. */
  28819. getBoundingInfo(): BoundingInfo;
  28820. /**
  28821. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28822. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28823. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28824. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28825. * @returns the current mesh
  28826. */
  28827. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28828. /**
  28829. * Overwrite the current bounding info
  28830. * @param boundingInfo defines the new bounding info
  28831. * @returns the current mesh
  28832. */
  28833. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28834. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28835. get useBones(): boolean;
  28836. /** @hidden */
  28837. _preActivate(): void;
  28838. /** @hidden */
  28839. _preActivateForIntermediateRendering(renderId: number): void;
  28840. /** @hidden */
  28841. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28842. /** @hidden */
  28843. _postActivate(): void;
  28844. /** @hidden */
  28845. _freeze(): void;
  28846. /** @hidden */
  28847. _unFreeze(): void;
  28848. /**
  28849. * Gets the current world matrix
  28850. * @returns a Matrix
  28851. */
  28852. getWorldMatrix(): Matrix;
  28853. /** @hidden */
  28854. _getWorldMatrixDeterminant(): number;
  28855. /**
  28856. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28857. */
  28858. get isAnInstance(): boolean;
  28859. /**
  28860. * Gets a boolean indicating if this mesh has instances
  28861. */
  28862. get hasInstances(): boolean;
  28863. /**
  28864. * Perform relative position change from the point of view of behind the front of the mesh.
  28865. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28866. * Supports definition of mesh facing forward or backward
  28867. * @param amountRight defines the distance on the right axis
  28868. * @param amountUp defines the distance on the up axis
  28869. * @param amountForward defines the distance on the forward axis
  28870. * @returns the current mesh
  28871. */
  28872. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28873. /**
  28874. * Calculate relative position change from the point of view of behind the front of the mesh.
  28875. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28876. * Supports definition of mesh facing forward or backward
  28877. * @param amountRight defines the distance on the right axis
  28878. * @param amountUp defines the distance on the up axis
  28879. * @param amountForward defines the distance on the forward axis
  28880. * @returns the new displacement vector
  28881. */
  28882. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28883. /**
  28884. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28885. * Supports definition of mesh facing forward or backward
  28886. * @param flipBack defines the flip
  28887. * @param twirlClockwise defines the twirl
  28888. * @param tiltRight defines the tilt
  28889. * @returns the current mesh
  28890. */
  28891. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28892. /**
  28893. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28894. * Supports definition of mesh facing forward or backward.
  28895. * @param flipBack defines the flip
  28896. * @param twirlClockwise defines the twirl
  28897. * @param tiltRight defines the tilt
  28898. * @returns the new rotation vector
  28899. */
  28900. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28901. /**
  28902. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28903. * This means the mesh underlying bounding box and sphere are recomputed.
  28904. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28905. * @returns the current mesh
  28906. */
  28907. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28908. /** @hidden */
  28909. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28910. /** @hidden */
  28911. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28912. /** @hidden */
  28913. _updateBoundingInfo(): AbstractMesh;
  28914. /** @hidden */
  28915. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28916. /** @hidden */
  28917. protected _afterComputeWorldMatrix(): void;
  28918. /** @hidden */
  28919. get _effectiveMesh(): AbstractMesh;
  28920. /**
  28921. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28922. * A mesh is in the frustum if its bounding box intersects the frustum
  28923. * @param frustumPlanes defines the frustum to test
  28924. * @returns true if the mesh is in the frustum planes
  28925. */
  28926. isInFrustum(frustumPlanes: Plane[]): boolean;
  28927. /**
  28928. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28929. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28930. * @param frustumPlanes defines the frustum to test
  28931. * @returns true if the mesh is completely in the frustum planes
  28932. */
  28933. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28934. /**
  28935. * True if the mesh intersects another mesh or a SolidParticle object
  28936. * @param mesh defines a target mesh or SolidParticle to test
  28937. * @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)
  28938. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28939. * @returns true if there is an intersection
  28940. */
  28941. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28942. /**
  28943. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28944. * @param point defines the point to test
  28945. * @returns true if there is an intersection
  28946. */
  28947. intersectsPoint(point: Vector3): boolean;
  28948. /**
  28949. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28950. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28951. */
  28952. get checkCollisions(): boolean;
  28953. set checkCollisions(collisionEnabled: boolean);
  28954. /**
  28955. * Gets Collider object used to compute collisions (not physics)
  28956. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28957. */
  28958. get collider(): Nullable<Collider>;
  28959. /**
  28960. * Move the mesh using collision engine
  28961. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28962. * @param displacement defines the requested displacement vector
  28963. * @returns the current mesh
  28964. */
  28965. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28966. private _onCollisionPositionChange;
  28967. /** @hidden */
  28968. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28969. /** @hidden */
  28970. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28971. /** @hidden */
  28972. _checkCollision(collider: Collider): AbstractMesh;
  28973. /** @hidden */
  28974. _generatePointsArray(): boolean;
  28975. /**
  28976. * Checks if the passed Ray intersects with the mesh
  28977. * @param ray defines the ray to use
  28978. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28979. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28980. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28981. * @returns the picking info
  28982. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28983. */
  28984. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28985. /**
  28986. * Clones the current mesh
  28987. * @param name defines the mesh name
  28988. * @param newParent defines the new mesh parent
  28989. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28990. * @returns the new mesh
  28991. */
  28992. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28993. /**
  28994. * Disposes all the submeshes of the current meshnp
  28995. * @returns the current mesh
  28996. */
  28997. releaseSubMeshes(): AbstractMesh;
  28998. /**
  28999. * Releases resources associated with this abstract mesh.
  29000. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29001. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29002. */
  29003. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29004. /**
  29005. * Adds the passed mesh as a child to the current mesh
  29006. * @param mesh defines the child mesh
  29007. * @returns the current mesh
  29008. */
  29009. addChild(mesh: AbstractMesh): AbstractMesh;
  29010. /**
  29011. * Removes the passed mesh from the current mesh children list
  29012. * @param mesh defines the child mesh
  29013. * @returns the current mesh
  29014. */
  29015. removeChild(mesh: AbstractMesh): AbstractMesh;
  29016. /** @hidden */
  29017. private _initFacetData;
  29018. /**
  29019. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29020. * This method can be called within the render loop.
  29021. * 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
  29022. * @returns the current mesh
  29023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29024. */
  29025. updateFacetData(): AbstractMesh;
  29026. /**
  29027. * Returns the facetLocalNormals array.
  29028. * The normals are expressed in the mesh local spac
  29029. * @returns an array of Vector3
  29030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29031. */
  29032. getFacetLocalNormals(): Vector3[];
  29033. /**
  29034. * Returns the facetLocalPositions array.
  29035. * The facet positions are expressed in the mesh local space
  29036. * @returns an array of Vector3
  29037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29038. */
  29039. getFacetLocalPositions(): Vector3[];
  29040. /**
  29041. * Returns the facetLocalPartioning array
  29042. * @returns an array of array of numbers
  29043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29044. */
  29045. getFacetLocalPartitioning(): number[][];
  29046. /**
  29047. * Returns the i-th facet position in the world system.
  29048. * This method allocates a new Vector3 per call
  29049. * @param i defines the facet index
  29050. * @returns a new Vector3
  29051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29052. */
  29053. getFacetPosition(i: number): Vector3;
  29054. /**
  29055. * Sets the reference Vector3 with the i-th facet position in the world system
  29056. * @param i defines the facet index
  29057. * @param ref defines the target vector
  29058. * @returns the current mesh
  29059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29060. */
  29061. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29062. /**
  29063. * Returns the i-th facet normal in the world system.
  29064. * This method allocates a new Vector3 per call
  29065. * @param i defines the facet index
  29066. * @returns a new Vector3
  29067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29068. */
  29069. getFacetNormal(i: number): Vector3;
  29070. /**
  29071. * Sets the reference Vector3 with the i-th facet normal in the world system
  29072. * @param i defines the facet index
  29073. * @param ref defines the target vector
  29074. * @returns the current mesh
  29075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29076. */
  29077. getFacetNormalToRef(i: number, ref: Vector3): this;
  29078. /**
  29079. * 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)
  29080. * @param x defines x coordinate
  29081. * @param y defines y coordinate
  29082. * @param z defines z coordinate
  29083. * @returns the array of facet indexes
  29084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29085. */
  29086. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29087. /**
  29088. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29089. * @param projected sets as the (x,y,z) world projection on the facet
  29090. * @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
  29091. * @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
  29092. * @param x defines x coordinate
  29093. * @param y defines y coordinate
  29094. * @param z defines z coordinate
  29095. * @returns the face index if found (or null instead)
  29096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29097. */
  29098. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29099. /**
  29100. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29101. * @param projected sets as the (x,y,z) local projection on the facet
  29102. * @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
  29103. * @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
  29104. * @param x defines x coordinate
  29105. * @param y defines y coordinate
  29106. * @param z defines z coordinate
  29107. * @returns the face index if found (or null instead)
  29108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29109. */
  29110. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29111. /**
  29112. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29113. * @returns the parameters
  29114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29115. */
  29116. getFacetDataParameters(): any;
  29117. /**
  29118. * Disables the feature FacetData and frees the related memory
  29119. * @returns the current mesh
  29120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29121. */
  29122. disableFacetData(): AbstractMesh;
  29123. /**
  29124. * Updates the AbstractMesh indices array
  29125. * @param indices defines the data source
  29126. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29127. * @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)
  29128. * @returns the current mesh
  29129. */
  29130. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29131. /**
  29132. * Creates new normals data for the mesh
  29133. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29134. * @returns the current mesh
  29135. */
  29136. createNormals(updatable: boolean): AbstractMesh;
  29137. /**
  29138. * Align the mesh with a normal
  29139. * @param normal defines the normal to use
  29140. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29141. * @returns the current mesh
  29142. */
  29143. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29144. /** @hidden */
  29145. _checkOcclusionQuery(): boolean;
  29146. /**
  29147. * Disables the mesh edge rendering mode
  29148. * @returns the currentAbstractMesh
  29149. */
  29150. disableEdgesRendering(): AbstractMesh;
  29151. /**
  29152. * Enables the edge rendering mode on the mesh.
  29153. * This mode makes the mesh edges visible
  29154. * @param epsilon defines the maximal distance between two angles to detect a face
  29155. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29156. * @returns the currentAbstractMesh
  29157. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29158. */
  29159. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29160. }
  29161. }
  29162. declare module BABYLON {
  29163. /**
  29164. * Interface used to define ActionEvent
  29165. */
  29166. export interface IActionEvent {
  29167. /** The mesh or sprite that triggered the action */
  29168. source: any;
  29169. /** The X mouse cursor position at the time of the event */
  29170. pointerX: number;
  29171. /** The Y mouse cursor position at the time of the event */
  29172. pointerY: number;
  29173. /** The mesh that is currently pointed at (can be null) */
  29174. meshUnderPointer: Nullable<AbstractMesh>;
  29175. /** the original (browser) event that triggered the ActionEvent */
  29176. sourceEvent?: any;
  29177. /** additional data for the event */
  29178. additionalData?: any;
  29179. }
  29180. /**
  29181. * ActionEvent is the event being sent when an action is triggered.
  29182. */
  29183. export class ActionEvent implements IActionEvent {
  29184. /** The mesh or sprite that triggered the action */
  29185. source: any;
  29186. /** The X mouse cursor position at the time of the event */
  29187. pointerX: number;
  29188. /** The Y mouse cursor position at the time of the event */
  29189. pointerY: number;
  29190. /** The mesh that is currently pointed at (can be null) */
  29191. meshUnderPointer: Nullable<AbstractMesh>;
  29192. /** the original (browser) event that triggered the ActionEvent */
  29193. sourceEvent?: any;
  29194. /** additional data for the event */
  29195. additionalData?: any;
  29196. /**
  29197. * Creates a new ActionEvent
  29198. * @param source The mesh or sprite that triggered the action
  29199. * @param pointerX The X mouse cursor position at the time of the event
  29200. * @param pointerY The Y mouse cursor position at the time of the event
  29201. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29202. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29203. * @param additionalData additional data for the event
  29204. */
  29205. constructor(
  29206. /** The mesh or sprite that triggered the action */
  29207. source: any,
  29208. /** The X mouse cursor position at the time of the event */
  29209. pointerX: number,
  29210. /** The Y mouse cursor position at the time of the event */
  29211. pointerY: number,
  29212. /** The mesh that is currently pointed at (can be null) */
  29213. meshUnderPointer: Nullable<AbstractMesh>,
  29214. /** the original (browser) event that triggered the ActionEvent */
  29215. sourceEvent?: any,
  29216. /** additional data for the event */
  29217. additionalData?: any);
  29218. /**
  29219. * Helper function to auto-create an ActionEvent from a source mesh.
  29220. * @param source The source mesh that triggered the event
  29221. * @param evt The original (browser) event
  29222. * @param additionalData additional data for the event
  29223. * @returns the new ActionEvent
  29224. */
  29225. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29226. /**
  29227. * Helper function to auto-create an ActionEvent from a source sprite
  29228. * @param source The source sprite that triggered the event
  29229. * @param scene Scene associated with the sprite
  29230. * @param evt The original (browser) event
  29231. * @param additionalData additional data for the event
  29232. * @returns the new ActionEvent
  29233. */
  29234. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29235. /**
  29236. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29237. * @param scene the scene where the event occurred
  29238. * @param evt The original (browser) event
  29239. * @returns the new ActionEvent
  29240. */
  29241. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29242. /**
  29243. * Helper function to auto-create an ActionEvent from a primitive
  29244. * @param prim defines the target primitive
  29245. * @param pointerPos defines the pointer position
  29246. * @param evt The original (browser) event
  29247. * @param additionalData additional data for the event
  29248. * @returns the new ActionEvent
  29249. */
  29250. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29251. }
  29252. }
  29253. declare module BABYLON {
  29254. /**
  29255. * Abstract class used to decouple action Manager from scene and meshes.
  29256. * Do not instantiate.
  29257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29258. */
  29259. export abstract class AbstractActionManager implements IDisposable {
  29260. /** Gets the list of active triggers */
  29261. static Triggers: {
  29262. [key: string]: number;
  29263. };
  29264. /** Gets the cursor to use when hovering items */
  29265. hoverCursor: string;
  29266. /** Gets the list of actions */
  29267. actions: IAction[];
  29268. /**
  29269. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29270. */
  29271. isRecursive: boolean;
  29272. /**
  29273. * Releases all associated resources
  29274. */
  29275. abstract dispose(): void;
  29276. /**
  29277. * Does this action manager has pointer triggers
  29278. */
  29279. abstract get hasPointerTriggers(): boolean;
  29280. /**
  29281. * Does this action manager has pick triggers
  29282. */
  29283. abstract get hasPickTriggers(): boolean;
  29284. /**
  29285. * Process a specific trigger
  29286. * @param trigger defines the trigger to process
  29287. * @param evt defines the event details to be processed
  29288. */
  29289. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29290. /**
  29291. * Does this action manager handles actions of any of the given triggers
  29292. * @param triggers defines the triggers to be tested
  29293. * @return a boolean indicating whether one (or more) of the triggers is handled
  29294. */
  29295. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29296. /**
  29297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29298. * speed.
  29299. * @param triggerA defines the trigger to be tested
  29300. * @param triggerB defines the trigger to be tested
  29301. * @return a boolean indicating whether one (or more) of the triggers is handled
  29302. */
  29303. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29304. /**
  29305. * Does this action manager handles actions of a given trigger
  29306. * @param trigger defines the trigger to be tested
  29307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29308. * @return whether the trigger is handled
  29309. */
  29310. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29311. /**
  29312. * Serialize this manager to a JSON object
  29313. * @param name defines the property name to store this manager
  29314. * @returns a JSON representation of this manager
  29315. */
  29316. abstract serialize(name: string): any;
  29317. /**
  29318. * Registers an action to this action manager
  29319. * @param action defines the action to be registered
  29320. * @return the action amended (prepared) after registration
  29321. */
  29322. abstract registerAction(action: IAction): Nullable<IAction>;
  29323. /**
  29324. * Unregisters an action to this action manager
  29325. * @param action defines the action to be unregistered
  29326. * @return a boolean indicating whether the action has been unregistered
  29327. */
  29328. abstract unregisterAction(action: IAction): Boolean;
  29329. /**
  29330. * Does exist one action manager with at least one trigger
  29331. **/
  29332. static get HasTriggers(): boolean;
  29333. /**
  29334. * Does exist one action manager with at least one pick trigger
  29335. **/
  29336. static get HasPickTriggers(): boolean;
  29337. /**
  29338. * Does exist one action manager that handles actions of a given trigger
  29339. * @param trigger defines the trigger to be tested
  29340. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29341. **/
  29342. static HasSpecificTrigger(trigger: number): boolean;
  29343. }
  29344. }
  29345. declare module BABYLON {
  29346. /**
  29347. * Defines how a node can be built from a string name.
  29348. */
  29349. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29350. /**
  29351. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29352. */
  29353. export class Node implements IBehaviorAware<Node> {
  29354. /** @hidden */
  29355. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29356. private static _NodeConstructors;
  29357. /**
  29358. * Add a new node constructor
  29359. * @param type defines the type name of the node to construct
  29360. * @param constructorFunc defines the constructor function
  29361. */
  29362. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29363. /**
  29364. * Returns a node constructor based on type name
  29365. * @param type defines the type name
  29366. * @param name defines the new node name
  29367. * @param scene defines the hosting scene
  29368. * @param options defines optional options to transmit to constructors
  29369. * @returns the new constructor or null
  29370. */
  29371. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29372. /**
  29373. * Gets or sets the name of the node
  29374. */
  29375. name: string;
  29376. /**
  29377. * Gets or sets the id of the node
  29378. */
  29379. id: string;
  29380. /**
  29381. * Gets or sets the unique id of the node
  29382. */
  29383. uniqueId: number;
  29384. /**
  29385. * Gets or sets a string used to store user defined state for the node
  29386. */
  29387. state: string;
  29388. /**
  29389. * Gets or sets an object used to store user defined information for the node
  29390. */
  29391. metadata: any;
  29392. /**
  29393. * For internal use only. Please do not use.
  29394. */
  29395. reservedDataStore: any;
  29396. /**
  29397. * List of inspectable custom properties (used by the Inspector)
  29398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29399. */
  29400. inspectableCustomProperties: IInspectable[];
  29401. private _doNotSerialize;
  29402. /**
  29403. * Gets or sets a boolean used to define if the node must be serialized
  29404. */
  29405. get doNotSerialize(): boolean;
  29406. set doNotSerialize(value: boolean);
  29407. /** @hidden */
  29408. _isDisposed: boolean;
  29409. /**
  29410. * Gets a list of Animations associated with the node
  29411. */
  29412. animations: Animation[];
  29413. protected _ranges: {
  29414. [name: string]: Nullable<AnimationRange>;
  29415. };
  29416. /**
  29417. * Callback raised when the node is ready to be used
  29418. */
  29419. onReady: Nullable<(node: Node) => void>;
  29420. private _isEnabled;
  29421. private _isParentEnabled;
  29422. private _isReady;
  29423. /** @hidden */
  29424. _currentRenderId: number;
  29425. private _parentUpdateId;
  29426. /** @hidden */
  29427. _childUpdateId: number;
  29428. /** @hidden */
  29429. _waitingParentId: Nullable<string>;
  29430. /** @hidden */
  29431. _scene: Scene;
  29432. /** @hidden */
  29433. _cache: any;
  29434. private _parentNode;
  29435. private _children;
  29436. /** @hidden */
  29437. _worldMatrix: Matrix;
  29438. /** @hidden */
  29439. _worldMatrixDeterminant: number;
  29440. /** @hidden */
  29441. _worldMatrixDeterminantIsDirty: boolean;
  29442. /** @hidden */
  29443. private _sceneRootNodesIndex;
  29444. /**
  29445. * Gets a boolean indicating if the node has been disposed
  29446. * @returns true if the node was disposed
  29447. */
  29448. isDisposed(): boolean;
  29449. /**
  29450. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29451. * @see https://doc.babylonjs.com/how_to/parenting
  29452. */
  29453. set parent(parent: Nullable<Node>);
  29454. get parent(): Nullable<Node>;
  29455. /** @hidden */
  29456. _addToSceneRootNodes(): void;
  29457. /** @hidden */
  29458. _removeFromSceneRootNodes(): void;
  29459. private _animationPropertiesOverride;
  29460. /**
  29461. * Gets or sets the animation properties override
  29462. */
  29463. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29464. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29465. /**
  29466. * Gets a string idenfifying the name of the class
  29467. * @returns "Node" string
  29468. */
  29469. getClassName(): string;
  29470. /** @hidden */
  29471. readonly _isNode: boolean;
  29472. /**
  29473. * An event triggered when the mesh is disposed
  29474. */
  29475. onDisposeObservable: Observable<Node>;
  29476. private _onDisposeObserver;
  29477. /**
  29478. * Sets a callback that will be raised when the node will be disposed
  29479. */
  29480. set onDispose(callback: () => void);
  29481. /**
  29482. * Creates a new Node
  29483. * @param name the name and id to be given to this node
  29484. * @param scene the scene this node will be added to
  29485. */
  29486. constructor(name: string, scene?: Nullable<Scene>);
  29487. /**
  29488. * Gets the scene of the node
  29489. * @returns a scene
  29490. */
  29491. getScene(): Scene;
  29492. /**
  29493. * Gets the engine of the node
  29494. * @returns a Engine
  29495. */
  29496. getEngine(): Engine;
  29497. private _behaviors;
  29498. /**
  29499. * Attach a behavior to the node
  29500. * @see http://doc.babylonjs.com/features/behaviour
  29501. * @param behavior defines the behavior to attach
  29502. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29503. * @returns the current Node
  29504. */
  29505. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29506. /**
  29507. * Remove an attached behavior
  29508. * @see http://doc.babylonjs.com/features/behaviour
  29509. * @param behavior defines the behavior to attach
  29510. * @returns the current Node
  29511. */
  29512. removeBehavior(behavior: Behavior<Node>): Node;
  29513. /**
  29514. * Gets the list of attached behaviors
  29515. * @see http://doc.babylonjs.com/features/behaviour
  29516. */
  29517. get behaviors(): Behavior<Node>[];
  29518. /**
  29519. * Gets an attached behavior by name
  29520. * @param name defines the name of the behavior to look for
  29521. * @see http://doc.babylonjs.com/features/behaviour
  29522. * @returns null if behavior was not found else the requested behavior
  29523. */
  29524. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29525. /**
  29526. * Returns the latest update of the World matrix
  29527. * @returns a Matrix
  29528. */
  29529. getWorldMatrix(): Matrix;
  29530. /** @hidden */
  29531. _getWorldMatrixDeterminant(): number;
  29532. /**
  29533. * Returns directly the latest state of the mesh World matrix.
  29534. * A Matrix is returned.
  29535. */
  29536. get worldMatrixFromCache(): Matrix;
  29537. /** @hidden */
  29538. _initCache(): void;
  29539. /** @hidden */
  29540. updateCache(force?: boolean): void;
  29541. /** @hidden */
  29542. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29543. /** @hidden */
  29544. _updateCache(ignoreParentClass?: boolean): void;
  29545. /** @hidden */
  29546. _isSynchronized(): boolean;
  29547. /** @hidden */
  29548. _markSyncedWithParent(): void;
  29549. /** @hidden */
  29550. isSynchronizedWithParent(): boolean;
  29551. /** @hidden */
  29552. isSynchronized(): boolean;
  29553. /**
  29554. * Is this node ready to be used/rendered
  29555. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29556. * @return true if the node is ready
  29557. */
  29558. isReady(completeCheck?: boolean): boolean;
  29559. /**
  29560. * Is this node enabled?
  29561. * 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
  29562. * @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
  29563. * @return whether this node (and its parent) is enabled
  29564. */
  29565. isEnabled(checkAncestors?: boolean): boolean;
  29566. /** @hidden */
  29567. protected _syncParentEnabledState(): void;
  29568. /**
  29569. * Set the enabled state of this node
  29570. * @param value defines the new enabled state
  29571. */
  29572. setEnabled(value: boolean): void;
  29573. /**
  29574. * Is this node a descendant of the given node?
  29575. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29576. * @param ancestor defines the parent node to inspect
  29577. * @returns a boolean indicating if this node is a descendant of the given node
  29578. */
  29579. isDescendantOf(ancestor: Node): boolean;
  29580. /** @hidden */
  29581. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29582. /**
  29583. * Will return all nodes that have this node as ascendant
  29584. * @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
  29585. * @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
  29586. * @return all children nodes of all types
  29587. */
  29588. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29589. /**
  29590. * Get all child-meshes of this node
  29591. * @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)
  29592. * @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
  29593. * @returns an array of AbstractMesh
  29594. */
  29595. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29596. /**
  29597. * Get all direct children of this node
  29598. * @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
  29599. * @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)
  29600. * @returns an array of Node
  29601. */
  29602. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29603. /** @hidden */
  29604. _setReady(state: boolean): void;
  29605. /**
  29606. * Get an animation by name
  29607. * @param name defines the name of the animation to look for
  29608. * @returns null if not found else the requested animation
  29609. */
  29610. getAnimationByName(name: string): Nullable<Animation>;
  29611. /**
  29612. * Creates an animation range for this node
  29613. * @param name defines the name of the range
  29614. * @param from defines the starting key
  29615. * @param to defines the end key
  29616. */
  29617. createAnimationRange(name: string, from: number, to: number): void;
  29618. /**
  29619. * Delete a specific animation range
  29620. * @param name defines the name of the range to delete
  29621. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29622. */
  29623. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29624. /**
  29625. * Get an animation range by name
  29626. * @param name defines the name of the animation range to look for
  29627. * @returns null if not found else the requested animation range
  29628. */
  29629. getAnimationRange(name: string): Nullable<AnimationRange>;
  29630. /**
  29631. * Gets the list of all animation ranges defined on this node
  29632. * @returns an array
  29633. */
  29634. getAnimationRanges(): Nullable<AnimationRange>[];
  29635. /**
  29636. * Will start the animation sequence
  29637. * @param name defines the range frames for animation sequence
  29638. * @param loop defines if the animation should loop (false by default)
  29639. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29640. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29641. * @returns the object created for this animation. If range does not exist, it will return null
  29642. */
  29643. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29644. /**
  29645. * Serialize animation ranges into a JSON compatible object
  29646. * @returns serialization object
  29647. */
  29648. serializeAnimationRanges(): any;
  29649. /**
  29650. * Computes the world matrix of the node
  29651. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29652. * @returns the world matrix
  29653. */
  29654. computeWorldMatrix(force?: boolean): Matrix;
  29655. /**
  29656. * Releases resources associated with this node.
  29657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29659. */
  29660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29661. /**
  29662. * Parse animation range data from a serialization object and store them into a given node
  29663. * @param node defines where to store the animation ranges
  29664. * @param parsedNode defines the serialization object to read data from
  29665. * @param scene defines the hosting scene
  29666. */
  29667. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29668. /**
  29669. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29670. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29671. * @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
  29672. * @returns the new bounding vectors
  29673. */
  29674. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29675. min: Vector3;
  29676. max: Vector3;
  29677. };
  29678. }
  29679. }
  29680. declare module BABYLON {
  29681. /**
  29682. * @hidden
  29683. */
  29684. export class _IAnimationState {
  29685. key: number;
  29686. repeatCount: number;
  29687. workValue?: any;
  29688. loopMode?: number;
  29689. offsetValue?: any;
  29690. highLimitValue?: any;
  29691. }
  29692. /**
  29693. * Class used to store any kind of animation
  29694. */
  29695. export class Animation {
  29696. /**Name of the animation */
  29697. name: string;
  29698. /**Property to animate */
  29699. targetProperty: string;
  29700. /**The frames per second of the animation */
  29701. framePerSecond: number;
  29702. /**The data type of the animation */
  29703. dataType: number;
  29704. /**The loop mode of the animation */
  29705. loopMode?: number | undefined;
  29706. /**Specifies if blending should be enabled */
  29707. enableBlending?: boolean | undefined;
  29708. /**
  29709. * Use matrix interpolation instead of using direct key value when animating matrices
  29710. */
  29711. static AllowMatricesInterpolation: boolean;
  29712. /**
  29713. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29714. */
  29715. static AllowMatrixDecomposeForInterpolation: boolean;
  29716. /**
  29717. * Stores the key frames of the animation
  29718. */
  29719. private _keys;
  29720. /**
  29721. * Stores the easing function of the animation
  29722. */
  29723. private _easingFunction;
  29724. /**
  29725. * @hidden Internal use only
  29726. */
  29727. _runtimeAnimations: RuntimeAnimation[];
  29728. /**
  29729. * The set of event that will be linked to this animation
  29730. */
  29731. private _events;
  29732. /**
  29733. * Stores an array of target property paths
  29734. */
  29735. targetPropertyPath: string[];
  29736. /**
  29737. * Stores the blending speed of the animation
  29738. */
  29739. blendingSpeed: number;
  29740. /**
  29741. * Stores the animation ranges for the animation
  29742. */
  29743. private _ranges;
  29744. /**
  29745. * @hidden Internal use
  29746. */
  29747. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29748. /**
  29749. * Sets up an animation
  29750. * @param property The property to animate
  29751. * @param animationType The animation type to apply
  29752. * @param framePerSecond The frames per second of the animation
  29753. * @param easingFunction The easing function used in the animation
  29754. * @returns The created animation
  29755. */
  29756. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29757. /**
  29758. * Create and start an animation on a node
  29759. * @param name defines the name of the global animation that will be run on all nodes
  29760. * @param node defines the root node where the animation will take place
  29761. * @param targetProperty defines property to animate
  29762. * @param framePerSecond defines the number of frame per second yo use
  29763. * @param totalFrame defines the number of frames in total
  29764. * @param from defines the initial value
  29765. * @param to defines the final value
  29766. * @param loopMode defines which loop mode you want to use (off by default)
  29767. * @param easingFunction defines the easing function to use (linear by default)
  29768. * @param onAnimationEnd defines the callback to call when animation end
  29769. * @returns the animatable created for this animation
  29770. */
  29771. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29772. /**
  29773. * Create and start an animation on a node and its descendants
  29774. * @param name defines the name of the global animation that will be run on all nodes
  29775. * @param node defines the root node where the animation will take place
  29776. * @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
  29777. * @param targetProperty defines property to animate
  29778. * @param framePerSecond defines the number of frame per second to use
  29779. * @param totalFrame defines the number of frames in total
  29780. * @param from defines the initial value
  29781. * @param to defines the final value
  29782. * @param loopMode defines which loop mode you want to use (off by default)
  29783. * @param easingFunction defines the easing function to use (linear by default)
  29784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29785. * @returns the list of animatables created for all nodes
  29786. * @example https://www.babylonjs-playground.com/#MH0VLI
  29787. */
  29788. 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[]>;
  29789. /**
  29790. * Creates a new animation, merges it with the existing animations and starts it
  29791. * @param name Name of the animation
  29792. * @param node Node which contains the scene that begins the animations
  29793. * @param targetProperty Specifies which property to animate
  29794. * @param framePerSecond The frames per second of the animation
  29795. * @param totalFrame The total number of frames
  29796. * @param from The frame at the beginning of the animation
  29797. * @param to The frame at the end of the animation
  29798. * @param loopMode Specifies the loop mode of the animation
  29799. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29800. * @param onAnimationEnd Callback to run once the animation is complete
  29801. * @returns Nullable animation
  29802. */
  29803. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29804. /**
  29805. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29806. * @param sourceAnimation defines the Animation containing keyframes to convert
  29807. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29808. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29809. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29810. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29811. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29812. */
  29813. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29814. /**
  29815. * Transition property of an host to the target Value
  29816. * @param property The property to transition
  29817. * @param targetValue The target Value of the property
  29818. * @param host The object where the property to animate belongs
  29819. * @param scene Scene used to run the animation
  29820. * @param frameRate Framerate (in frame/s) to use
  29821. * @param transition The transition type we want to use
  29822. * @param duration The duration of the animation, in milliseconds
  29823. * @param onAnimationEnd Callback trigger at the end of the animation
  29824. * @returns Nullable animation
  29825. */
  29826. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29827. /**
  29828. * Return the array of runtime animations currently using this animation
  29829. */
  29830. get runtimeAnimations(): RuntimeAnimation[];
  29831. /**
  29832. * Specifies if any of the runtime animations are currently running
  29833. */
  29834. get hasRunningRuntimeAnimations(): boolean;
  29835. /**
  29836. * Initializes the animation
  29837. * @param name Name of the animation
  29838. * @param targetProperty Property to animate
  29839. * @param framePerSecond The frames per second of the animation
  29840. * @param dataType The data type of the animation
  29841. * @param loopMode The loop mode of the animation
  29842. * @param enableBlending Specifies if blending should be enabled
  29843. */
  29844. constructor(
  29845. /**Name of the animation */
  29846. name: string,
  29847. /**Property to animate */
  29848. targetProperty: string,
  29849. /**The frames per second of the animation */
  29850. framePerSecond: number,
  29851. /**The data type of the animation */
  29852. dataType: number,
  29853. /**The loop mode of the animation */
  29854. loopMode?: number | undefined,
  29855. /**Specifies if blending should be enabled */
  29856. enableBlending?: boolean | undefined);
  29857. /**
  29858. * Converts the animation to a string
  29859. * @param fullDetails support for multiple levels of logging within scene loading
  29860. * @returns String form of the animation
  29861. */
  29862. toString(fullDetails?: boolean): string;
  29863. /**
  29864. * Add an event to this animation
  29865. * @param event Event to add
  29866. */
  29867. addEvent(event: AnimationEvent): void;
  29868. /**
  29869. * Remove all events found at the given frame
  29870. * @param frame The frame to remove events from
  29871. */
  29872. removeEvents(frame: number): void;
  29873. /**
  29874. * Retrieves all the events from the animation
  29875. * @returns Events from the animation
  29876. */
  29877. getEvents(): AnimationEvent[];
  29878. /**
  29879. * Creates an animation range
  29880. * @param name Name of the animation range
  29881. * @param from Starting frame of the animation range
  29882. * @param to Ending frame of the animation
  29883. */
  29884. createRange(name: string, from: number, to: number): void;
  29885. /**
  29886. * Deletes an animation range by name
  29887. * @param name Name of the animation range to delete
  29888. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29889. */
  29890. deleteRange(name: string, deleteFrames?: boolean): void;
  29891. /**
  29892. * Gets the animation range by name, or null if not defined
  29893. * @param name Name of the animation range
  29894. * @returns Nullable animation range
  29895. */
  29896. getRange(name: string): Nullable<AnimationRange>;
  29897. /**
  29898. * Gets the key frames from the animation
  29899. * @returns The key frames of the animation
  29900. */
  29901. getKeys(): Array<IAnimationKey>;
  29902. /**
  29903. * Gets the highest frame rate of the animation
  29904. * @returns Highest frame rate of the animation
  29905. */
  29906. getHighestFrame(): number;
  29907. /**
  29908. * Gets the easing function of the animation
  29909. * @returns Easing function of the animation
  29910. */
  29911. getEasingFunction(): IEasingFunction;
  29912. /**
  29913. * Sets the easing function of the animation
  29914. * @param easingFunction A custom mathematical formula for animation
  29915. */
  29916. setEasingFunction(easingFunction: EasingFunction): void;
  29917. /**
  29918. * Interpolates a scalar linearly
  29919. * @param startValue Start value of the animation curve
  29920. * @param endValue End value of the animation curve
  29921. * @param gradient Scalar amount to interpolate
  29922. * @returns Interpolated scalar value
  29923. */
  29924. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29925. /**
  29926. * Interpolates a scalar cubically
  29927. * @param startValue Start value of the animation curve
  29928. * @param outTangent End tangent of the animation
  29929. * @param endValue End value of the animation curve
  29930. * @param inTangent Start tangent of the animation curve
  29931. * @param gradient Scalar amount to interpolate
  29932. * @returns Interpolated scalar value
  29933. */
  29934. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29935. /**
  29936. * Interpolates a quaternion using a spherical linear interpolation
  29937. * @param startValue Start value of the animation curve
  29938. * @param endValue End value of the animation curve
  29939. * @param gradient Scalar amount to interpolate
  29940. * @returns Interpolated quaternion value
  29941. */
  29942. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29943. /**
  29944. * Interpolates a quaternion cubically
  29945. * @param startValue Start value of the animation curve
  29946. * @param outTangent End tangent of the animation curve
  29947. * @param endValue End value of the animation curve
  29948. * @param inTangent Start tangent of the animation curve
  29949. * @param gradient Scalar amount to interpolate
  29950. * @returns Interpolated quaternion value
  29951. */
  29952. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29953. /**
  29954. * Interpolates a Vector3 linearl
  29955. * @param startValue Start value of the animation curve
  29956. * @param endValue End value of the animation curve
  29957. * @param gradient Scalar amount to interpolate
  29958. * @returns Interpolated scalar value
  29959. */
  29960. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29961. /**
  29962. * Interpolates a Vector3 cubically
  29963. * @param startValue Start value of the animation curve
  29964. * @param outTangent End tangent of the animation
  29965. * @param endValue End value of the animation curve
  29966. * @param inTangent Start tangent of the animation curve
  29967. * @param gradient Scalar amount to interpolate
  29968. * @returns InterpolatedVector3 value
  29969. */
  29970. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29971. /**
  29972. * Interpolates a Vector2 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 Vector2 value
  29977. */
  29978. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29979. /**
  29980. * Interpolates a Vector2 cubically
  29981. * @param startValue Start value of the animation curve
  29982. * @param outTangent End tangent of the animation
  29983. * @param endValue End value of the animation curve
  29984. * @param inTangent Start tangent of the animation curve
  29985. * @param gradient Scalar amount to interpolate
  29986. * @returns Interpolated Vector2 value
  29987. */
  29988. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29989. /**
  29990. * Interpolates a size linearly
  29991. * @param startValue Start value of the animation curve
  29992. * @param endValue End value of the animation curve
  29993. * @param gradient Scalar amount to interpolate
  29994. * @returns Interpolated Size value
  29995. */
  29996. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29997. /**
  29998. * Interpolates a Color3 linearly
  29999. * @param startValue Start value of the animation curve
  30000. * @param endValue End value of the animation curve
  30001. * @param gradient Scalar amount to interpolate
  30002. * @returns Interpolated Color3 value
  30003. */
  30004. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30005. /**
  30006. * Interpolates a Color4 linearly
  30007. * @param startValue Start value of the animation curve
  30008. * @param endValue End value of the animation curve
  30009. * @param gradient Scalar amount to interpolate
  30010. * @returns Interpolated Color3 value
  30011. */
  30012. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30013. /**
  30014. * @hidden Internal use only
  30015. */
  30016. _getKeyValue(value: any): any;
  30017. /**
  30018. * @hidden Internal use only
  30019. */
  30020. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30021. /**
  30022. * Defines the function to use to interpolate matrices
  30023. * @param startValue defines the start matrix
  30024. * @param endValue defines the end matrix
  30025. * @param gradient defines the gradient between both matrices
  30026. * @param result defines an optional target matrix where to store the interpolation
  30027. * @returns the interpolated matrix
  30028. */
  30029. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30030. /**
  30031. * Makes a copy of the animation
  30032. * @returns Cloned animation
  30033. */
  30034. clone(): Animation;
  30035. /**
  30036. * Sets the key frames of the animation
  30037. * @param values The animation key frames to set
  30038. */
  30039. setKeys(values: Array<IAnimationKey>): void;
  30040. /**
  30041. * Serializes the animation to an object
  30042. * @returns Serialized object
  30043. */
  30044. serialize(): any;
  30045. /**
  30046. * Float animation type
  30047. */
  30048. static readonly ANIMATIONTYPE_FLOAT: number;
  30049. /**
  30050. * Vector3 animation type
  30051. */
  30052. static readonly ANIMATIONTYPE_VECTOR3: number;
  30053. /**
  30054. * Quaternion animation type
  30055. */
  30056. static readonly ANIMATIONTYPE_QUATERNION: number;
  30057. /**
  30058. * Matrix animation type
  30059. */
  30060. static readonly ANIMATIONTYPE_MATRIX: number;
  30061. /**
  30062. * Color3 animation type
  30063. */
  30064. static readonly ANIMATIONTYPE_COLOR3: number;
  30065. /**
  30066. * Color3 animation type
  30067. */
  30068. static readonly ANIMATIONTYPE_COLOR4: number;
  30069. /**
  30070. * Vector2 animation type
  30071. */
  30072. static readonly ANIMATIONTYPE_VECTOR2: number;
  30073. /**
  30074. * Size animation type
  30075. */
  30076. static readonly ANIMATIONTYPE_SIZE: number;
  30077. /**
  30078. * Relative Loop Mode
  30079. */
  30080. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30081. /**
  30082. * Cycle Loop Mode
  30083. */
  30084. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30085. /**
  30086. * Constant Loop Mode
  30087. */
  30088. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30089. /** @hidden */
  30090. static _UniversalLerp(left: any, right: any, amount: number): any;
  30091. /**
  30092. * Parses an animation object and creates an animation
  30093. * @param parsedAnimation Parsed animation object
  30094. * @returns Animation object
  30095. */
  30096. static Parse(parsedAnimation: any): Animation;
  30097. /**
  30098. * Appends the serialized animations from the source animations
  30099. * @param source Source containing the animations
  30100. * @param destination Target to store the animations
  30101. */
  30102. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30103. }
  30104. }
  30105. declare module BABYLON {
  30106. /**
  30107. * Interface containing an array of animations
  30108. */
  30109. export interface IAnimatable {
  30110. /**
  30111. * Array of animations
  30112. */
  30113. animations: Nullable<Array<Animation>>;
  30114. }
  30115. }
  30116. declare module BABYLON {
  30117. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30118. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30119. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30120. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30121. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30122. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30123. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30124. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30125. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30126. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30127. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30128. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30129. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30130. /**
  30131. * Decorator used to define property that can be serialized as reference to a camera
  30132. * @param sourceName defines the name of the property to decorate
  30133. */
  30134. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30135. /**
  30136. * Class used to help serialization objects
  30137. */
  30138. export class SerializationHelper {
  30139. /** @hidden */
  30140. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30141. /** @hidden */
  30142. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30143. /** @hidden */
  30144. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30145. /** @hidden */
  30146. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30147. /**
  30148. * Appends the serialized animations from the source animations
  30149. * @param source Source containing the animations
  30150. * @param destination Target to store the animations
  30151. */
  30152. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30153. /**
  30154. * Static function used to serialized a specific entity
  30155. * @param entity defines the entity to serialize
  30156. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30157. * @returns a JSON compatible object representing the serialization of the entity
  30158. */
  30159. static Serialize<T>(entity: T, serializationObject?: any): any;
  30160. /**
  30161. * Creates a new entity from a serialization data object
  30162. * @param creationFunction defines a function used to instanciated the new entity
  30163. * @param source defines the source serialization data
  30164. * @param scene defines the hosting scene
  30165. * @param rootUrl defines the root url for resources
  30166. * @returns a new entity
  30167. */
  30168. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30169. /**
  30170. * Clones an object
  30171. * @param creationFunction defines the function used to instanciate the new object
  30172. * @param source defines the source object
  30173. * @returns the cloned object
  30174. */
  30175. static Clone<T>(creationFunction: () => T, source: T): T;
  30176. /**
  30177. * Instanciates a new object based on a source one (some data will be shared between both object)
  30178. * @param creationFunction defines the function used to instanciate the new object
  30179. * @param source defines the source object
  30180. * @returns the new object
  30181. */
  30182. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30183. }
  30184. }
  30185. declare module BABYLON {
  30186. /**
  30187. * Base class of all the textures in babylon.
  30188. * It groups all the common properties the materials, post process, lights... might need
  30189. * in order to make a correct use of the texture.
  30190. */
  30191. export class BaseTexture implements IAnimatable {
  30192. /**
  30193. * Default anisotropic filtering level for the application.
  30194. * It is set to 4 as a good tradeoff between perf and quality.
  30195. */
  30196. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30197. /**
  30198. * Gets or sets the unique id of the texture
  30199. */
  30200. uniqueId: number;
  30201. /**
  30202. * Define the name of the texture.
  30203. */
  30204. name: string;
  30205. /**
  30206. * Gets or sets an object used to store user defined information.
  30207. */
  30208. metadata: any;
  30209. /**
  30210. * For internal use only. Please do not use.
  30211. */
  30212. reservedDataStore: any;
  30213. private _hasAlpha;
  30214. /**
  30215. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30216. */
  30217. set hasAlpha(value: boolean);
  30218. get hasAlpha(): boolean;
  30219. /**
  30220. * Defines if the alpha value should be determined via the rgb values.
  30221. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30222. */
  30223. getAlphaFromRGB: boolean;
  30224. /**
  30225. * Intensity or strength of the texture.
  30226. * It is commonly used by materials to fine tune the intensity of the texture
  30227. */
  30228. level: number;
  30229. /**
  30230. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30231. * This is part of the texture as textures usually maps to one uv set.
  30232. */
  30233. coordinatesIndex: number;
  30234. private _coordinatesMode;
  30235. /**
  30236. * How a texture is mapped.
  30237. *
  30238. * | Value | Type | Description |
  30239. * | ----- | ----------------------------------- | ----------- |
  30240. * | 0 | EXPLICIT_MODE | |
  30241. * | 1 | SPHERICAL_MODE | |
  30242. * | 2 | PLANAR_MODE | |
  30243. * | 3 | CUBIC_MODE | |
  30244. * | 4 | PROJECTION_MODE | |
  30245. * | 5 | SKYBOX_MODE | |
  30246. * | 6 | INVCUBIC_MODE | |
  30247. * | 7 | EQUIRECTANGULAR_MODE | |
  30248. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30249. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30250. */
  30251. set coordinatesMode(value: number);
  30252. get coordinatesMode(): number;
  30253. /**
  30254. * | Value | Type | Description |
  30255. * | ----- | ------------------ | ----------- |
  30256. * | 0 | CLAMP_ADDRESSMODE | |
  30257. * | 1 | WRAP_ADDRESSMODE | |
  30258. * | 2 | MIRROR_ADDRESSMODE | |
  30259. */
  30260. wrapU: number;
  30261. /**
  30262. * | Value | Type | Description |
  30263. * | ----- | ------------------ | ----------- |
  30264. * | 0 | CLAMP_ADDRESSMODE | |
  30265. * | 1 | WRAP_ADDRESSMODE | |
  30266. * | 2 | MIRROR_ADDRESSMODE | |
  30267. */
  30268. wrapV: number;
  30269. /**
  30270. * | Value | Type | Description |
  30271. * | ----- | ------------------ | ----------- |
  30272. * | 0 | CLAMP_ADDRESSMODE | |
  30273. * | 1 | WRAP_ADDRESSMODE | |
  30274. * | 2 | MIRROR_ADDRESSMODE | |
  30275. */
  30276. wrapR: number;
  30277. /**
  30278. * With compliant hardware and browser (supporting anisotropic filtering)
  30279. * this defines the level of anisotropic filtering in the texture.
  30280. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30281. */
  30282. anisotropicFilteringLevel: number;
  30283. /**
  30284. * Define if the texture is a cube texture or if false a 2d texture.
  30285. */
  30286. get isCube(): boolean;
  30287. set isCube(value: boolean);
  30288. /**
  30289. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30290. */
  30291. get is3D(): boolean;
  30292. set is3D(value: boolean);
  30293. /**
  30294. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30295. */
  30296. get is2DArray(): boolean;
  30297. set is2DArray(value: boolean);
  30298. /**
  30299. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30300. * HDR texture are usually stored in linear space.
  30301. * This only impacts the PBR and Background materials
  30302. */
  30303. gammaSpace: boolean;
  30304. /**
  30305. * Gets or sets whether or not the texture contains RGBD data.
  30306. */
  30307. get isRGBD(): boolean;
  30308. set isRGBD(value: boolean);
  30309. /**
  30310. * Is Z inverted in the texture (useful in a cube texture).
  30311. */
  30312. invertZ: boolean;
  30313. /**
  30314. * Are mip maps generated for this texture or not.
  30315. */
  30316. get noMipmap(): boolean;
  30317. /**
  30318. * @hidden
  30319. */
  30320. lodLevelInAlpha: boolean;
  30321. /**
  30322. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30323. */
  30324. get lodGenerationOffset(): number;
  30325. set lodGenerationOffset(value: number);
  30326. /**
  30327. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30328. */
  30329. get lodGenerationScale(): number;
  30330. set lodGenerationScale(value: number);
  30331. /**
  30332. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30333. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30334. * average roughness values.
  30335. */
  30336. get linearSpecularLOD(): boolean;
  30337. set linearSpecularLOD(value: boolean);
  30338. /**
  30339. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30340. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30341. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30342. */
  30343. get irradianceTexture(): Nullable<BaseTexture>;
  30344. set irradianceTexture(value: Nullable<BaseTexture>);
  30345. /**
  30346. * Define if the texture is a render target.
  30347. */
  30348. isRenderTarget: boolean;
  30349. /**
  30350. * Define the unique id of the texture in the scene.
  30351. */
  30352. get uid(): string;
  30353. /**
  30354. * Return a string representation of the texture.
  30355. * @returns the texture as a string
  30356. */
  30357. toString(): string;
  30358. /**
  30359. * Get the class name of the texture.
  30360. * @returns "BaseTexture"
  30361. */
  30362. getClassName(): string;
  30363. /**
  30364. * Define the list of animation attached to the texture.
  30365. */
  30366. animations: Animation[];
  30367. /**
  30368. * An event triggered when the texture is disposed.
  30369. */
  30370. onDisposeObservable: Observable<BaseTexture>;
  30371. private _onDisposeObserver;
  30372. /**
  30373. * Callback triggered when the texture has been disposed.
  30374. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30375. */
  30376. set onDispose(callback: () => void);
  30377. /**
  30378. * Define the current state of the loading sequence when in delayed load mode.
  30379. */
  30380. delayLoadState: number;
  30381. private _scene;
  30382. /** @hidden */
  30383. _texture: Nullable<InternalTexture>;
  30384. private _uid;
  30385. /**
  30386. * Define if the texture is preventinga material to render or not.
  30387. * If not and the texture is not ready, the engine will use a default black texture instead.
  30388. */
  30389. get isBlocking(): boolean;
  30390. /**
  30391. * Instantiates a new BaseTexture.
  30392. * Base class of all the textures in babylon.
  30393. * It groups all the common properties the materials, post process, lights... might need
  30394. * in order to make a correct use of the texture.
  30395. * @param scene Define the scene the texture blongs to
  30396. */
  30397. constructor(scene: Nullable<Scene>);
  30398. /** @hidden */
  30399. _setScene(scene: Nullable<Scene>): void;
  30400. /**
  30401. * Get the scene the texture belongs to.
  30402. * @returns the scene or null if undefined
  30403. */
  30404. getScene(): Nullable<Scene>;
  30405. /**
  30406. * Get the texture transform matrix used to offset tile the texture for istance.
  30407. * @returns the transformation matrix
  30408. */
  30409. getTextureMatrix(): Matrix;
  30410. /**
  30411. * Get the texture reflection matrix used to rotate/transform the reflection.
  30412. * @returns the reflection matrix
  30413. */
  30414. getReflectionTextureMatrix(): Matrix;
  30415. /**
  30416. * Get the underlying lower level texture from Babylon.
  30417. * @returns the insternal texture
  30418. */
  30419. getInternalTexture(): Nullable<InternalTexture>;
  30420. /**
  30421. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30422. * @returns true if ready or not blocking
  30423. */
  30424. isReadyOrNotBlocking(): boolean;
  30425. /**
  30426. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30427. * @returns true if fully ready
  30428. */
  30429. isReady(): boolean;
  30430. private _cachedSize;
  30431. /**
  30432. * Get the size of the texture.
  30433. * @returns the texture size.
  30434. */
  30435. getSize(): ISize;
  30436. /**
  30437. * Get the base size of the texture.
  30438. * It can be different from the size if the texture has been resized for POT for instance
  30439. * @returns the base size
  30440. */
  30441. getBaseSize(): ISize;
  30442. /**
  30443. * Update the sampling mode of the texture.
  30444. * Default is Trilinear mode.
  30445. *
  30446. * | Value | Type | Description |
  30447. * | ----- | ------------------ | ----------- |
  30448. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30449. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30450. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30451. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30452. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30453. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30454. * | 7 | NEAREST_LINEAR | |
  30455. * | 8 | NEAREST_NEAREST | |
  30456. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30457. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30458. * | 11 | LINEAR_LINEAR | |
  30459. * | 12 | LINEAR_NEAREST | |
  30460. *
  30461. * > _mag_: magnification filter (close to the viewer)
  30462. * > _min_: minification filter (far from the viewer)
  30463. * > _mip_: filter used between mip map levels
  30464. *@param samplingMode Define the new sampling mode of the texture
  30465. */
  30466. updateSamplingMode(samplingMode: number): void;
  30467. /**
  30468. * Scales the texture if is `canRescale()`
  30469. * @param ratio the resize factor we want to use to rescale
  30470. */
  30471. scale(ratio: number): void;
  30472. /**
  30473. * Get if the texture can rescale.
  30474. */
  30475. get canRescale(): boolean;
  30476. /** @hidden */
  30477. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30478. /** @hidden */
  30479. _rebuild(): void;
  30480. /**
  30481. * Triggers the load sequence in delayed load mode.
  30482. */
  30483. delayLoad(): void;
  30484. /**
  30485. * Clones the texture.
  30486. * @returns the cloned texture
  30487. */
  30488. clone(): Nullable<BaseTexture>;
  30489. /**
  30490. * Get the texture underlying type (INT, FLOAT...)
  30491. */
  30492. get textureType(): number;
  30493. /**
  30494. * Get the texture underlying format (RGB, RGBA...)
  30495. */
  30496. get textureFormat(): number;
  30497. /**
  30498. * Indicates that textures need to be re-calculated for all materials
  30499. */
  30500. protected _markAllSubMeshesAsTexturesDirty(): void;
  30501. /**
  30502. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30503. * This will returns an RGBA array buffer containing either in values (0-255) or
  30504. * float values (0-1) depending of the underlying buffer type.
  30505. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30506. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30507. * @param buffer defines a user defined buffer to fill with data (can be null)
  30508. * @returns The Array buffer containing the pixels data.
  30509. */
  30510. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30511. /**
  30512. * Release and destroy the underlying lower level texture aka internalTexture.
  30513. */
  30514. releaseInternalTexture(): void;
  30515. /** @hidden */
  30516. get _lodTextureHigh(): Nullable<BaseTexture>;
  30517. /** @hidden */
  30518. get _lodTextureMid(): Nullable<BaseTexture>;
  30519. /** @hidden */
  30520. get _lodTextureLow(): Nullable<BaseTexture>;
  30521. /**
  30522. * Dispose the texture and release its associated resources.
  30523. */
  30524. dispose(): void;
  30525. /**
  30526. * Serialize the texture into a JSON representation that can be parsed later on.
  30527. * @returns the JSON representation of the texture
  30528. */
  30529. serialize(): any;
  30530. /**
  30531. * Helper function to be called back once a list of texture contains only ready textures.
  30532. * @param textures Define the list of textures to wait for
  30533. * @param callback Define the callback triggered once the entire list will be ready
  30534. */
  30535. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30536. }
  30537. }
  30538. declare module BABYLON {
  30539. /**
  30540. * Options to be used when creating an effect.
  30541. */
  30542. export interface IEffectCreationOptions {
  30543. /**
  30544. * Atrributes that will be used in the shader.
  30545. */
  30546. attributes: string[];
  30547. /**
  30548. * Uniform varible names that will be set in the shader.
  30549. */
  30550. uniformsNames: string[];
  30551. /**
  30552. * Uniform buffer variable names that will be set in the shader.
  30553. */
  30554. uniformBuffersNames: string[];
  30555. /**
  30556. * Sampler texture variable names that will be set in the shader.
  30557. */
  30558. samplers: string[];
  30559. /**
  30560. * Define statements that will be set in the shader.
  30561. */
  30562. defines: any;
  30563. /**
  30564. * Possible fallbacks for this effect to improve performance when needed.
  30565. */
  30566. fallbacks: Nullable<IEffectFallbacks>;
  30567. /**
  30568. * Callback that will be called when the shader is compiled.
  30569. */
  30570. onCompiled: Nullable<(effect: Effect) => void>;
  30571. /**
  30572. * Callback that will be called if an error occurs during shader compilation.
  30573. */
  30574. onError: Nullable<(effect: Effect, errors: string) => void>;
  30575. /**
  30576. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30577. */
  30578. indexParameters?: any;
  30579. /**
  30580. * Max number of lights that can be used in the shader.
  30581. */
  30582. maxSimultaneousLights?: number;
  30583. /**
  30584. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30585. */
  30586. transformFeedbackVaryings?: Nullable<string[]>;
  30587. }
  30588. /**
  30589. * Effect containing vertex and fragment shader that can be executed on an object.
  30590. */
  30591. export class Effect implements IDisposable {
  30592. /**
  30593. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30594. */
  30595. static ShadersRepository: string;
  30596. /**
  30597. * Enable logging of the shader code when a compilation error occurs
  30598. */
  30599. static LogShaderCodeOnCompilationError: boolean;
  30600. /**
  30601. * Name of the effect.
  30602. */
  30603. name: any;
  30604. /**
  30605. * String container all the define statements that should be set on the shader.
  30606. */
  30607. defines: string;
  30608. /**
  30609. * Callback that will be called when the shader is compiled.
  30610. */
  30611. onCompiled: Nullable<(effect: Effect) => void>;
  30612. /**
  30613. * Callback that will be called if an error occurs during shader compilation.
  30614. */
  30615. onError: Nullable<(effect: Effect, errors: string) => void>;
  30616. /**
  30617. * Callback that will be called when effect is bound.
  30618. */
  30619. onBind: Nullable<(effect: Effect) => void>;
  30620. /**
  30621. * Unique ID of the effect.
  30622. */
  30623. uniqueId: number;
  30624. /**
  30625. * Observable that will be called when the shader is compiled.
  30626. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30627. */
  30628. onCompileObservable: Observable<Effect>;
  30629. /**
  30630. * Observable that will be called if an error occurs during shader compilation.
  30631. */
  30632. onErrorObservable: Observable<Effect>;
  30633. /** @hidden */
  30634. _onBindObservable: Nullable<Observable<Effect>>;
  30635. /**
  30636. * @hidden
  30637. * Specifies if the effect was previously ready
  30638. */
  30639. _wasPreviouslyReady: boolean;
  30640. /**
  30641. * Observable that will be called when effect is bound.
  30642. */
  30643. get onBindObservable(): Observable<Effect>;
  30644. /** @hidden */
  30645. _bonesComputationForcedToCPU: boolean;
  30646. private static _uniqueIdSeed;
  30647. private _engine;
  30648. private _uniformBuffersNames;
  30649. private _uniformBuffersNamesList;
  30650. private _uniformsNames;
  30651. private _samplerList;
  30652. private _samplers;
  30653. private _isReady;
  30654. private _compilationError;
  30655. private _allFallbacksProcessed;
  30656. private _attributesNames;
  30657. private _attributes;
  30658. private _attributeLocationByName;
  30659. private _uniforms;
  30660. /**
  30661. * Key for the effect.
  30662. * @hidden
  30663. */
  30664. _key: string;
  30665. private _indexParameters;
  30666. private _fallbacks;
  30667. private _vertexSourceCode;
  30668. private _fragmentSourceCode;
  30669. private _vertexSourceCodeOverride;
  30670. private _fragmentSourceCodeOverride;
  30671. private _transformFeedbackVaryings;
  30672. /**
  30673. * Compiled shader to webGL program.
  30674. * @hidden
  30675. */
  30676. _pipelineContext: Nullable<IPipelineContext>;
  30677. private _valueCache;
  30678. private static _baseCache;
  30679. /**
  30680. * Instantiates an effect.
  30681. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30682. * @param baseName Name of the effect.
  30683. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30684. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30685. * @param samplers List of sampler variables that will be passed to the shader.
  30686. * @param engine Engine to be used to render the effect
  30687. * @param defines Define statements to be added to the shader.
  30688. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30689. * @param onCompiled Callback that will be called when the shader is compiled.
  30690. * @param onError Callback that will be called if an error occurs during shader compilation.
  30691. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30692. */
  30693. 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);
  30694. private _useFinalCode;
  30695. /**
  30696. * Unique key for this effect
  30697. */
  30698. get key(): string;
  30699. /**
  30700. * If the effect has been compiled and prepared.
  30701. * @returns if the effect is compiled and prepared.
  30702. */
  30703. isReady(): boolean;
  30704. private _isReadyInternal;
  30705. /**
  30706. * The engine the effect was initialized with.
  30707. * @returns the engine.
  30708. */
  30709. getEngine(): Engine;
  30710. /**
  30711. * The pipeline context for this effect
  30712. * @returns the associated pipeline context
  30713. */
  30714. getPipelineContext(): Nullable<IPipelineContext>;
  30715. /**
  30716. * The set of names of attribute variables for the shader.
  30717. * @returns An array of attribute names.
  30718. */
  30719. getAttributesNames(): string[];
  30720. /**
  30721. * Returns the attribute at the given index.
  30722. * @param index The index of the attribute.
  30723. * @returns The location of the attribute.
  30724. */
  30725. getAttributeLocation(index: number): number;
  30726. /**
  30727. * Returns the attribute based on the name of the variable.
  30728. * @param name of the attribute to look up.
  30729. * @returns the attribute location.
  30730. */
  30731. getAttributeLocationByName(name: string): number;
  30732. /**
  30733. * The number of attributes.
  30734. * @returns the numnber of attributes.
  30735. */
  30736. getAttributesCount(): number;
  30737. /**
  30738. * Gets the index of a uniform variable.
  30739. * @param uniformName of the uniform to look up.
  30740. * @returns the index.
  30741. */
  30742. getUniformIndex(uniformName: string): number;
  30743. /**
  30744. * Returns the attribute based on the name of the variable.
  30745. * @param uniformName of the uniform to look up.
  30746. * @returns the location of the uniform.
  30747. */
  30748. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30749. /**
  30750. * Returns an array of sampler variable names
  30751. * @returns The array of sampler variable names.
  30752. */
  30753. getSamplers(): string[];
  30754. /**
  30755. * Returns an array of uniform variable names
  30756. * @returns The array of uniform variable names.
  30757. */
  30758. getUniformNames(): string[];
  30759. /**
  30760. * Returns an array of uniform buffer variable names
  30761. * @returns The array of uniform buffer variable names.
  30762. */
  30763. getUniformBuffersNames(): string[];
  30764. /**
  30765. * Returns the index parameters used to create the effect
  30766. * @returns The index parameters object
  30767. */
  30768. getIndexParameters(): any;
  30769. /**
  30770. * The error from the last compilation.
  30771. * @returns the error string.
  30772. */
  30773. getCompilationError(): string;
  30774. /**
  30775. * Gets a boolean indicating that all fallbacks were used during compilation
  30776. * @returns true if all fallbacks were used
  30777. */
  30778. allFallbacksProcessed(): boolean;
  30779. /**
  30780. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30781. * @param func The callback to be used.
  30782. */
  30783. executeWhenCompiled(func: (effect: Effect) => void): void;
  30784. private _checkIsReady;
  30785. private _loadShader;
  30786. /**
  30787. * Gets the vertex shader source code of this effect
  30788. */
  30789. get vertexSourceCode(): string;
  30790. /**
  30791. * Gets the fragment shader source code of this effect
  30792. */
  30793. get fragmentSourceCode(): string;
  30794. /**
  30795. * Recompiles the webGL program
  30796. * @param vertexSourceCode The source code for the vertex shader.
  30797. * @param fragmentSourceCode The source code for the fragment shader.
  30798. * @param onCompiled Callback called when completed.
  30799. * @param onError Callback called on error.
  30800. * @hidden
  30801. */
  30802. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30803. /**
  30804. * Prepares the effect
  30805. * @hidden
  30806. */
  30807. _prepareEffect(): void;
  30808. private _getShaderCodeAndErrorLine;
  30809. private _processCompilationErrors;
  30810. /**
  30811. * Checks if the effect is supported. (Must be called after compilation)
  30812. */
  30813. get isSupported(): boolean;
  30814. /**
  30815. * Binds a texture to the engine to be used as output of the shader.
  30816. * @param channel Name of the output variable.
  30817. * @param texture Texture to bind.
  30818. * @hidden
  30819. */
  30820. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30821. /**
  30822. * Sets a texture on the engine to be used in the shader.
  30823. * @param channel Name of the sampler variable.
  30824. * @param texture Texture to set.
  30825. */
  30826. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30827. /**
  30828. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30829. * @param channel Name of the sampler variable.
  30830. * @param texture Texture to set.
  30831. */
  30832. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30833. /**
  30834. * Sets an array of textures on the engine to be used in the shader.
  30835. * @param channel Name of the variable.
  30836. * @param textures Textures to set.
  30837. */
  30838. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30839. /**
  30840. * 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)
  30841. * @param channel Name of the sampler variable.
  30842. * @param postProcess Post process to get the input texture from.
  30843. */
  30844. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30845. /**
  30846. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30847. * 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)
  30848. * @param channel Name of the sampler variable.
  30849. * @param postProcess Post process to get the output texture from.
  30850. */
  30851. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30852. /** @hidden */
  30853. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30854. /** @hidden */
  30855. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30856. /** @hidden */
  30857. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30858. /** @hidden */
  30859. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30860. /**
  30861. * Binds a buffer to a uniform.
  30862. * @param buffer Buffer to bind.
  30863. * @param name Name of the uniform variable to bind to.
  30864. */
  30865. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30866. /**
  30867. * Binds block to a uniform.
  30868. * @param blockName Name of the block to bind.
  30869. * @param index Index to bind.
  30870. */
  30871. bindUniformBlock(blockName: string, index: number): void;
  30872. /**
  30873. * Sets an interger value on a uniform variable.
  30874. * @param uniformName Name of the variable.
  30875. * @param value Value to be set.
  30876. * @returns this effect.
  30877. */
  30878. setInt(uniformName: string, value: number): Effect;
  30879. /**
  30880. * Sets an int 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. setIntArray(uniformName: string, array: Int32Array): Effect;
  30886. /**
  30887. * 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)
  30888. * @param uniformName Name of the variable.
  30889. * @param array array to be set.
  30890. * @returns this effect.
  30891. */
  30892. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30893. /**
  30894. * 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)
  30895. * @param uniformName Name of the variable.
  30896. * @param array array to be set.
  30897. * @returns this effect.
  30898. */
  30899. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30900. /**
  30901. * 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)
  30902. * @param uniformName Name of the variable.
  30903. * @param array array to be set.
  30904. * @returns this effect.
  30905. */
  30906. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30907. /**
  30908. * Sets an float 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. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30914. /**
  30915. * 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)
  30916. * @param uniformName Name of the variable.
  30917. * @param array array to be set.
  30918. * @returns this effect.
  30919. */
  30920. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30921. /**
  30922. * 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)
  30923. * @param uniformName Name of the variable.
  30924. * @param array array to be set.
  30925. * @returns this effect.
  30926. */
  30927. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30928. /**
  30929. * 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)
  30930. * @param uniformName Name of the variable.
  30931. * @param array array to be set.
  30932. * @returns this effect.
  30933. */
  30934. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30935. /**
  30936. * Sets an array on a uniform variable.
  30937. * @param uniformName Name of the variable.
  30938. * @param array array to be set.
  30939. * @returns this effect.
  30940. */
  30941. setArray(uniformName: string, array: number[]): Effect;
  30942. /**
  30943. * 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)
  30944. * @param uniformName Name of the variable.
  30945. * @param array array to be set.
  30946. * @returns this effect.
  30947. */
  30948. setArray2(uniformName: string, array: number[]): Effect;
  30949. /**
  30950. * 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)
  30951. * @param uniformName Name of the variable.
  30952. * @param array array to be set.
  30953. * @returns this effect.
  30954. */
  30955. setArray3(uniformName: string, array: number[]): Effect;
  30956. /**
  30957. * 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)
  30958. * @param uniformName Name of the variable.
  30959. * @param array array to be set.
  30960. * @returns this effect.
  30961. */
  30962. setArray4(uniformName: string, array: number[]): Effect;
  30963. /**
  30964. * Sets matrices on a uniform variable.
  30965. * @param uniformName Name of the variable.
  30966. * @param matrices matrices to be set.
  30967. * @returns this effect.
  30968. */
  30969. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30970. /**
  30971. * Sets matrix on a uniform variable.
  30972. * @param uniformName Name of the variable.
  30973. * @param matrix matrix to be set.
  30974. * @returns this effect.
  30975. */
  30976. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30977. /**
  30978. * 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)
  30979. * @param uniformName Name of the variable.
  30980. * @param matrix matrix to be set.
  30981. * @returns this effect.
  30982. */
  30983. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30984. /**
  30985. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30986. * @param uniformName Name of the variable.
  30987. * @param matrix matrix to be set.
  30988. * @returns this effect.
  30989. */
  30990. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30991. /**
  30992. * Sets a float on a uniform variable.
  30993. * @param uniformName Name of the variable.
  30994. * @param value value to be set.
  30995. * @returns this effect.
  30996. */
  30997. setFloat(uniformName: string, value: number): Effect;
  30998. /**
  30999. * Sets a boolean on a uniform variable.
  31000. * @param uniformName Name of the variable.
  31001. * @param bool value to be set.
  31002. * @returns this effect.
  31003. */
  31004. setBool(uniformName: string, bool: boolean): Effect;
  31005. /**
  31006. * Sets a Vector2 on a uniform variable.
  31007. * @param uniformName Name of the variable.
  31008. * @param vector2 vector2 to be set.
  31009. * @returns this effect.
  31010. */
  31011. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31012. /**
  31013. * Sets a float2 on a uniform variable.
  31014. * @param uniformName Name of the variable.
  31015. * @param x First float in float2.
  31016. * @param y Second float in float2.
  31017. * @returns this effect.
  31018. */
  31019. setFloat2(uniformName: string, x: number, y: number): Effect;
  31020. /**
  31021. * Sets a Vector3 on a uniform variable.
  31022. * @param uniformName Name of the variable.
  31023. * @param vector3 Value to be set.
  31024. * @returns this effect.
  31025. */
  31026. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31027. /**
  31028. * Sets a float3 on a uniform variable.
  31029. * @param uniformName Name of the variable.
  31030. * @param x First float in float3.
  31031. * @param y Second float in float3.
  31032. * @param z Third float in float3.
  31033. * @returns this effect.
  31034. */
  31035. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31036. /**
  31037. * Sets a Vector4 on a uniform variable.
  31038. * @param uniformName Name of the variable.
  31039. * @param vector4 Value to be set.
  31040. * @returns this effect.
  31041. */
  31042. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31043. /**
  31044. * Sets a float4 on a uniform variable.
  31045. * @param uniformName Name of the variable.
  31046. * @param x First float in float4.
  31047. * @param y Second float in float4.
  31048. * @param z Third float in float4.
  31049. * @param w Fourth float in float4.
  31050. * @returns this effect.
  31051. */
  31052. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31053. /**
  31054. * Sets a Color3 on a uniform variable.
  31055. * @param uniformName Name of the variable.
  31056. * @param color3 Value to be set.
  31057. * @returns this effect.
  31058. */
  31059. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31060. /**
  31061. * Sets a Color4 on a uniform variable.
  31062. * @param uniformName Name of the variable.
  31063. * @param color3 Value to be set.
  31064. * @param alpha Alpha value to be set.
  31065. * @returns this effect.
  31066. */
  31067. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31068. /**
  31069. * Sets a Color4 on a uniform variable
  31070. * @param uniformName defines the name of the variable
  31071. * @param color4 defines the value to be set
  31072. * @returns this effect.
  31073. */
  31074. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31075. /** Release all associated resources */
  31076. dispose(): void;
  31077. /**
  31078. * This function will add a new shader to the shader store
  31079. * @param name the name of the shader
  31080. * @param pixelShader optional pixel shader content
  31081. * @param vertexShader optional vertex shader content
  31082. */
  31083. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31084. /**
  31085. * Store of each shader (The can be looked up using effect.key)
  31086. */
  31087. static ShadersStore: {
  31088. [key: string]: string;
  31089. };
  31090. /**
  31091. * Store of each included file for a shader (The can be looked up using effect.key)
  31092. */
  31093. static IncludesShadersStore: {
  31094. [key: string]: string;
  31095. };
  31096. /**
  31097. * Resets the cache of effects.
  31098. */
  31099. static ResetCache(): void;
  31100. }
  31101. }
  31102. declare module BABYLON {
  31103. /**
  31104. * Interface used to describe the capabilities of the engine relatively to the current browser
  31105. */
  31106. export interface EngineCapabilities {
  31107. /** Maximum textures units per fragment shader */
  31108. maxTexturesImageUnits: number;
  31109. /** Maximum texture units per vertex shader */
  31110. maxVertexTextureImageUnits: number;
  31111. /** Maximum textures units in the entire pipeline */
  31112. maxCombinedTexturesImageUnits: number;
  31113. /** Maximum texture size */
  31114. maxTextureSize: number;
  31115. /** Maximum texture samples */
  31116. maxSamples?: number;
  31117. /** Maximum cube texture size */
  31118. maxCubemapTextureSize: number;
  31119. /** Maximum render texture size */
  31120. maxRenderTextureSize: number;
  31121. /** Maximum number of vertex attributes */
  31122. maxVertexAttribs: number;
  31123. /** Maximum number of varyings */
  31124. maxVaryingVectors: number;
  31125. /** Maximum number of uniforms per vertex shader */
  31126. maxVertexUniformVectors: number;
  31127. /** Maximum number of uniforms per fragment shader */
  31128. maxFragmentUniformVectors: number;
  31129. /** Defines if standard derivates (dx/dy) are supported */
  31130. standardDerivatives: boolean;
  31131. /** Defines if s3tc texture compression is supported */
  31132. s3tc?: WEBGL_compressed_texture_s3tc;
  31133. /** Defines if pvrtc texture compression is supported */
  31134. pvrtc: any;
  31135. /** Defines if etc1 texture compression is supported */
  31136. etc1: any;
  31137. /** Defines if etc2 texture compression is supported */
  31138. etc2: any;
  31139. /** Defines if astc texture compression is supported */
  31140. astc: any;
  31141. /** Defines if float textures are supported */
  31142. textureFloat: boolean;
  31143. /** Defines if vertex array objects are supported */
  31144. vertexArrayObject: boolean;
  31145. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31146. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31147. /** Gets the maximum level of anisotropy supported */
  31148. maxAnisotropy: number;
  31149. /** Defines if instancing is supported */
  31150. instancedArrays: boolean;
  31151. /** Defines if 32 bits indices are supported */
  31152. uintIndices: boolean;
  31153. /** Defines if high precision shaders are supported */
  31154. highPrecisionShaderSupported: boolean;
  31155. /** Defines if depth reading in the fragment shader is supported */
  31156. fragmentDepthSupported: boolean;
  31157. /** Defines if float texture linear filtering is supported*/
  31158. textureFloatLinearFiltering: boolean;
  31159. /** Defines if rendering to float textures is supported */
  31160. textureFloatRender: boolean;
  31161. /** Defines if half float textures are supported*/
  31162. textureHalfFloat: boolean;
  31163. /** Defines if half float texture linear filtering is supported*/
  31164. textureHalfFloatLinearFiltering: boolean;
  31165. /** Defines if rendering to half float textures is supported */
  31166. textureHalfFloatRender: boolean;
  31167. /** Defines if textureLOD shader command is supported */
  31168. textureLOD: boolean;
  31169. /** Defines if draw buffers extension is supported */
  31170. drawBuffersExtension: boolean;
  31171. /** Defines if depth textures are supported */
  31172. depthTextureExtension: boolean;
  31173. /** Defines if float color buffer are supported */
  31174. colorBufferFloat: boolean;
  31175. /** Gets disjoint timer query extension (null if not supported) */
  31176. timerQuery?: EXT_disjoint_timer_query;
  31177. /** Defines if timestamp can be used with timer query */
  31178. canUseTimestampForTimerQuery: boolean;
  31179. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31180. multiview?: any;
  31181. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31182. oculusMultiview?: any;
  31183. /** Function used to let the system compiles shaders in background */
  31184. parallelShaderCompile?: {
  31185. COMPLETION_STATUS_KHR: number;
  31186. };
  31187. /** Max number of texture samples for MSAA */
  31188. maxMSAASamples: number;
  31189. /** Defines if the blend min max extension is supported */
  31190. blendMinMax: boolean;
  31191. }
  31192. }
  31193. declare module BABYLON {
  31194. /**
  31195. * @hidden
  31196. **/
  31197. export class DepthCullingState {
  31198. private _isDepthTestDirty;
  31199. private _isDepthMaskDirty;
  31200. private _isDepthFuncDirty;
  31201. private _isCullFaceDirty;
  31202. private _isCullDirty;
  31203. private _isZOffsetDirty;
  31204. private _isFrontFaceDirty;
  31205. private _depthTest;
  31206. private _depthMask;
  31207. private _depthFunc;
  31208. private _cull;
  31209. private _cullFace;
  31210. private _zOffset;
  31211. private _frontFace;
  31212. /**
  31213. * Initializes the state.
  31214. */
  31215. constructor();
  31216. get isDirty(): boolean;
  31217. get zOffset(): number;
  31218. set zOffset(value: number);
  31219. get cullFace(): Nullable<number>;
  31220. set cullFace(value: Nullable<number>);
  31221. get cull(): Nullable<boolean>;
  31222. set cull(value: Nullable<boolean>);
  31223. get depthFunc(): Nullable<number>;
  31224. set depthFunc(value: Nullable<number>);
  31225. get depthMask(): boolean;
  31226. set depthMask(value: boolean);
  31227. get depthTest(): boolean;
  31228. set depthTest(value: boolean);
  31229. get frontFace(): Nullable<number>;
  31230. set frontFace(value: Nullable<number>);
  31231. reset(): void;
  31232. apply(gl: WebGLRenderingContext): void;
  31233. }
  31234. }
  31235. declare module BABYLON {
  31236. /**
  31237. * @hidden
  31238. **/
  31239. export class StencilState {
  31240. /** 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 */
  31241. static readonly ALWAYS: number;
  31242. /** Passed to stencilOperation to specify that stencil value must be kept */
  31243. static readonly KEEP: number;
  31244. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31245. static readonly REPLACE: number;
  31246. private _isStencilTestDirty;
  31247. private _isStencilMaskDirty;
  31248. private _isStencilFuncDirty;
  31249. private _isStencilOpDirty;
  31250. private _stencilTest;
  31251. private _stencilMask;
  31252. private _stencilFunc;
  31253. private _stencilFuncRef;
  31254. private _stencilFuncMask;
  31255. private _stencilOpStencilFail;
  31256. private _stencilOpDepthFail;
  31257. private _stencilOpStencilDepthPass;
  31258. get isDirty(): boolean;
  31259. get stencilFunc(): number;
  31260. set stencilFunc(value: number);
  31261. get stencilFuncRef(): number;
  31262. set stencilFuncRef(value: number);
  31263. get stencilFuncMask(): number;
  31264. set stencilFuncMask(value: number);
  31265. get stencilOpStencilFail(): number;
  31266. set stencilOpStencilFail(value: number);
  31267. get stencilOpDepthFail(): number;
  31268. set stencilOpDepthFail(value: number);
  31269. get stencilOpStencilDepthPass(): number;
  31270. set stencilOpStencilDepthPass(value: number);
  31271. get stencilMask(): number;
  31272. set stencilMask(value: number);
  31273. get stencilTest(): boolean;
  31274. set stencilTest(value: boolean);
  31275. constructor();
  31276. reset(): void;
  31277. apply(gl: WebGLRenderingContext): void;
  31278. }
  31279. }
  31280. declare module BABYLON {
  31281. /**
  31282. * @hidden
  31283. **/
  31284. export class AlphaState {
  31285. private _isAlphaBlendDirty;
  31286. private _isBlendFunctionParametersDirty;
  31287. private _isBlendEquationParametersDirty;
  31288. private _isBlendConstantsDirty;
  31289. private _alphaBlend;
  31290. private _blendFunctionParameters;
  31291. private _blendEquationParameters;
  31292. private _blendConstants;
  31293. /**
  31294. * Initializes the state.
  31295. */
  31296. constructor();
  31297. get isDirty(): boolean;
  31298. get alphaBlend(): boolean;
  31299. set alphaBlend(value: boolean);
  31300. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31301. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31302. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31303. reset(): void;
  31304. apply(gl: WebGLRenderingContext): void;
  31305. }
  31306. }
  31307. declare module BABYLON {
  31308. /** @hidden */
  31309. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31310. attributeProcessor(attribute: string): string;
  31311. varyingProcessor(varying: string, isFragment: boolean): string;
  31312. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31313. }
  31314. }
  31315. declare module BABYLON {
  31316. /**
  31317. * Interface for attribute information associated with buffer instanciation
  31318. */
  31319. export interface InstancingAttributeInfo {
  31320. /**
  31321. * Name of the GLSL attribute
  31322. * if attribute index is not specified, this is used to retrieve the index from the effect
  31323. */
  31324. attributeName: string;
  31325. /**
  31326. * Index/offset of the attribute in the vertex shader
  31327. * if not specified, this will be computes from the name.
  31328. */
  31329. index?: number;
  31330. /**
  31331. * size of the attribute, 1, 2, 3 or 4
  31332. */
  31333. attributeSize: number;
  31334. /**
  31335. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31336. */
  31337. offset: number;
  31338. /**
  31339. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31340. * default to 1
  31341. */
  31342. divisor?: number;
  31343. /**
  31344. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31345. * default is FLOAT
  31346. */
  31347. attributeType?: number;
  31348. /**
  31349. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31350. */
  31351. normalized?: boolean;
  31352. }
  31353. }
  31354. declare module BABYLON {
  31355. interface ThinEngine {
  31356. /**
  31357. * Update a video texture
  31358. * @param texture defines the texture to update
  31359. * @param video defines the video element to use
  31360. * @param invertY defines if data must be stored with Y axis inverted
  31361. */
  31362. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31363. }
  31364. }
  31365. declare module BABYLON {
  31366. /**
  31367. * Settings for finer control over video usage
  31368. */
  31369. export interface VideoTextureSettings {
  31370. /**
  31371. * Applies `autoplay` to video, if specified
  31372. */
  31373. autoPlay?: boolean;
  31374. /**
  31375. * Applies `loop` to video, if specified
  31376. */
  31377. loop?: boolean;
  31378. /**
  31379. * Automatically updates internal texture from video at every frame in the render loop
  31380. */
  31381. autoUpdateTexture: boolean;
  31382. /**
  31383. * Image src displayed during the video loading or until the user interacts with the video.
  31384. */
  31385. poster?: string;
  31386. }
  31387. /**
  31388. * If you want to display a video in your scene, this is the special texture for that.
  31389. * This special texture works similar to other textures, with the exception of a few parameters.
  31390. * @see https://doc.babylonjs.com/how_to/video_texture
  31391. */
  31392. export class VideoTexture extends Texture {
  31393. /**
  31394. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31395. */
  31396. readonly autoUpdateTexture: boolean;
  31397. /**
  31398. * The video instance used by the texture internally
  31399. */
  31400. readonly video: HTMLVideoElement;
  31401. private _onUserActionRequestedObservable;
  31402. /**
  31403. * Event triggerd when a dom action is required by the user to play the video.
  31404. * This happens due to recent changes in browser policies preventing video to auto start.
  31405. */
  31406. get onUserActionRequestedObservable(): Observable<Texture>;
  31407. private _generateMipMaps;
  31408. private _engine;
  31409. private _stillImageCaptured;
  31410. private _displayingPosterTexture;
  31411. private _settings;
  31412. private _createInternalTextureOnEvent;
  31413. private _frameId;
  31414. private _currentSrc;
  31415. /**
  31416. * Creates a video texture.
  31417. * If you want to display a video in your scene, this is the special texture for that.
  31418. * This special texture works similar to other textures, with the exception of a few parameters.
  31419. * @see https://doc.babylonjs.com/how_to/video_texture
  31420. * @param name optional name, will detect from video source, if not defined
  31421. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31422. * @param scene is obviously the current scene.
  31423. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31424. * @param invertY is false by default but can be used to invert video on Y axis
  31425. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31426. * @param settings allows finer control over video usage
  31427. */
  31428. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31429. private _getName;
  31430. private _getVideo;
  31431. private _createInternalTexture;
  31432. private reset;
  31433. /**
  31434. * @hidden Internal method to initiate `update`.
  31435. */
  31436. _rebuild(): void;
  31437. /**
  31438. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31439. */
  31440. update(): void;
  31441. /**
  31442. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31443. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31444. */
  31445. updateTexture(isVisible: boolean): void;
  31446. protected _updateInternalTexture: () => void;
  31447. /**
  31448. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31449. * @param url New url.
  31450. */
  31451. updateURL(url: string): void;
  31452. /**
  31453. * Clones the texture.
  31454. * @returns the cloned texture
  31455. */
  31456. clone(): VideoTexture;
  31457. /**
  31458. * Dispose the texture and release its associated resources.
  31459. */
  31460. dispose(): void;
  31461. /**
  31462. * Creates a video texture straight from a stream.
  31463. * @param scene Define the scene the texture should be created in
  31464. * @param stream Define the stream the texture should be created from
  31465. * @returns The created video texture as a promise
  31466. */
  31467. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31468. /**
  31469. * Creates a video texture straight from your WebCam video feed.
  31470. * @param scene Define the scene the texture should be created in
  31471. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31472. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31473. * @returns The created video texture as a promise
  31474. */
  31475. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31476. minWidth: number;
  31477. maxWidth: number;
  31478. minHeight: number;
  31479. maxHeight: number;
  31480. deviceId: string;
  31481. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31482. /**
  31483. * Creates a video texture straight from your WebCam video feed.
  31484. * @param scene Define the scene the texture should be created in
  31485. * @param onReady Define a callback to triggered once the texture will be ready
  31486. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31487. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31488. */
  31489. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31490. minWidth: number;
  31491. maxWidth: number;
  31492. minHeight: number;
  31493. maxHeight: number;
  31494. deviceId: string;
  31495. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31496. }
  31497. }
  31498. declare module BABYLON {
  31499. /**
  31500. * Defines the interface used by objects working like Scene
  31501. * @hidden
  31502. */
  31503. export interface ISceneLike {
  31504. _addPendingData(data: any): void;
  31505. _removePendingData(data: any): void;
  31506. offlineProvider: IOfflineProvider;
  31507. }
  31508. /** Interface defining initialization parameters for Engine class */
  31509. export interface EngineOptions extends WebGLContextAttributes {
  31510. /**
  31511. * Defines if the engine should no exceed a specified device ratio
  31512. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31513. */
  31514. limitDeviceRatio?: number;
  31515. /**
  31516. * Defines if webvr should be enabled automatically
  31517. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31518. */
  31519. autoEnableWebVR?: boolean;
  31520. /**
  31521. * Defines if webgl2 should be turned off even if supported
  31522. * @see http://doc.babylonjs.com/features/webgl2
  31523. */
  31524. disableWebGL2Support?: boolean;
  31525. /**
  31526. * Defines if webaudio should be initialized as well
  31527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31528. */
  31529. audioEngine?: boolean;
  31530. /**
  31531. * Defines if animations should run using a deterministic lock step
  31532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31533. */
  31534. deterministicLockstep?: boolean;
  31535. /** Defines the maximum steps to use with deterministic lock step mode */
  31536. lockstepMaxSteps?: number;
  31537. /** Defines the seconds between each deterministic lock step */
  31538. timeStep?: number;
  31539. /**
  31540. * Defines that engine should ignore context lost events
  31541. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31542. */
  31543. doNotHandleContextLost?: boolean;
  31544. /**
  31545. * Defines that engine should ignore modifying touch action attribute and style
  31546. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31547. */
  31548. doNotHandleTouchAction?: boolean;
  31549. /**
  31550. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31551. */
  31552. useHighPrecisionFloats?: boolean;
  31553. }
  31554. /**
  31555. * The base engine class (root of all engines)
  31556. */
  31557. export class ThinEngine {
  31558. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31559. static ExceptionList: ({
  31560. key: string;
  31561. capture: string;
  31562. captureConstraint: number;
  31563. targets: string[];
  31564. } | {
  31565. key: string;
  31566. capture: null;
  31567. captureConstraint: null;
  31568. targets: string[];
  31569. })[];
  31570. /** @hidden */
  31571. static _TextureLoaders: IInternalTextureLoader[];
  31572. /**
  31573. * Returns the current npm package of the sdk
  31574. */
  31575. static get NpmPackage(): string;
  31576. /**
  31577. * Returns the current version of the framework
  31578. */
  31579. static get Version(): string;
  31580. /**
  31581. * Returns a string describing the current engine
  31582. */
  31583. get description(): string;
  31584. /**
  31585. * Gets or sets the epsilon value used by collision engine
  31586. */
  31587. static CollisionsEpsilon: number;
  31588. /**
  31589. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31590. */
  31591. static get ShadersRepository(): string;
  31592. static set ShadersRepository(value: string);
  31593. /** @hidden */
  31594. _shaderProcessor: IShaderProcessor;
  31595. /**
  31596. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31597. */
  31598. forcePOTTextures: boolean;
  31599. /**
  31600. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31601. */
  31602. isFullscreen: boolean;
  31603. /**
  31604. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31605. */
  31606. cullBackFaces: boolean;
  31607. /**
  31608. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31609. */
  31610. renderEvenInBackground: boolean;
  31611. /**
  31612. * Gets or sets a boolean indicating that cache can be kept between frames
  31613. */
  31614. preventCacheWipeBetweenFrames: boolean;
  31615. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31616. validateShaderPrograms: boolean;
  31617. /**
  31618. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31619. * This can provide greater z depth for distant objects.
  31620. */
  31621. useReverseDepthBuffer: boolean;
  31622. /**
  31623. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31624. */
  31625. disableUniformBuffers: boolean;
  31626. /** @hidden */
  31627. _uniformBuffers: UniformBuffer[];
  31628. /**
  31629. * Gets a boolean indicating that the engine supports uniform buffers
  31630. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31631. */
  31632. get supportsUniformBuffers(): boolean;
  31633. /** @hidden */
  31634. _gl: WebGLRenderingContext;
  31635. /** @hidden */
  31636. _webGLVersion: number;
  31637. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31638. protected _windowIsBackground: boolean;
  31639. protected _creationOptions: EngineOptions;
  31640. protected _highPrecisionShadersAllowed: boolean;
  31641. /** @hidden */
  31642. get _shouldUseHighPrecisionShader(): boolean;
  31643. /**
  31644. * Gets a boolean indicating that only power of 2 textures are supported
  31645. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31646. */
  31647. get needPOTTextures(): boolean;
  31648. /** @hidden */
  31649. _badOS: boolean;
  31650. /** @hidden */
  31651. _badDesktopOS: boolean;
  31652. private _hardwareScalingLevel;
  31653. /** @hidden */
  31654. _caps: EngineCapabilities;
  31655. private _isStencilEnable;
  31656. private _glVersion;
  31657. private _glRenderer;
  31658. private _glVendor;
  31659. /** @hidden */
  31660. _videoTextureSupported: boolean;
  31661. protected _renderingQueueLaunched: boolean;
  31662. protected _activeRenderLoops: (() => void)[];
  31663. /**
  31664. * Observable signaled when a context lost event is raised
  31665. */
  31666. onContextLostObservable: Observable<ThinEngine>;
  31667. /**
  31668. * Observable signaled when a context restored event is raised
  31669. */
  31670. onContextRestoredObservable: Observable<ThinEngine>;
  31671. private _onContextLost;
  31672. private _onContextRestored;
  31673. protected _contextWasLost: boolean;
  31674. /** @hidden */
  31675. _doNotHandleContextLost: boolean;
  31676. /**
  31677. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31679. */
  31680. get doNotHandleContextLost(): boolean;
  31681. set doNotHandleContextLost(value: boolean);
  31682. /**
  31683. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31684. */
  31685. disableVertexArrayObjects: boolean;
  31686. /** @hidden */
  31687. protected _colorWrite: boolean;
  31688. /** @hidden */
  31689. protected _colorWriteChanged: boolean;
  31690. /** @hidden */
  31691. protected _depthCullingState: DepthCullingState;
  31692. /** @hidden */
  31693. protected _stencilState: StencilState;
  31694. /** @hidden */
  31695. _alphaState: AlphaState;
  31696. /** @hidden */
  31697. _alphaMode: number;
  31698. /** @hidden */
  31699. _alphaEquation: number;
  31700. /** @hidden */
  31701. _internalTexturesCache: InternalTexture[];
  31702. /** @hidden */
  31703. protected _activeChannel: number;
  31704. private _currentTextureChannel;
  31705. /** @hidden */
  31706. protected _boundTexturesCache: {
  31707. [key: string]: Nullable<InternalTexture>;
  31708. };
  31709. /** @hidden */
  31710. protected _currentEffect: Nullable<Effect>;
  31711. /** @hidden */
  31712. protected _currentProgram: Nullable<WebGLProgram>;
  31713. private _compiledEffects;
  31714. private _vertexAttribArraysEnabled;
  31715. /** @hidden */
  31716. protected _cachedViewport: Nullable<IViewportLike>;
  31717. private _cachedVertexArrayObject;
  31718. /** @hidden */
  31719. protected _cachedVertexBuffers: any;
  31720. /** @hidden */
  31721. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31722. /** @hidden */
  31723. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31724. /** @hidden */
  31725. _currentRenderTarget: Nullable<InternalTexture>;
  31726. private _uintIndicesCurrentlySet;
  31727. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31728. /** @hidden */
  31729. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31730. private _currentBufferPointers;
  31731. private _currentInstanceLocations;
  31732. private _currentInstanceBuffers;
  31733. private _textureUnits;
  31734. /** @hidden */
  31735. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31736. /** @hidden */
  31737. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31738. /** @hidden */
  31739. _boundRenderFunction: any;
  31740. private _vaoRecordInProgress;
  31741. private _mustWipeVertexAttributes;
  31742. private _emptyTexture;
  31743. private _emptyCubeTexture;
  31744. private _emptyTexture3D;
  31745. private _emptyTexture2DArray;
  31746. /** @hidden */
  31747. _frameHandler: number;
  31748. private _nextFreeTextureSlots;
  31749. private _maxSimultaneousTextures;
  31750. private _activeRequests;
  31751. /** @hidden */
  31752. _transformTextureUrl: Nullable<(url: string) => string>;
  31753. protected get _supportsHardwareTextureRescaling(): boolean;
  31754. private _framebufferDimensionsObject;
  31755. /**
  31756. * sets the object from which width and height will be taken from when getting render width and height
  31757. * Will fallback to the gl object
  31758. * @param dimensions the framebuffer width and height that will be used.
  31759. */
  31760. set framebufferDimensionsObject(dimensions: Nullable<{
  31761. framebufferWidth: number;
  31762. framebufferHeight: number;
  31763. }>);
  31764. /**
  31765. * Gets the current viewport
  31766. */
  31767. get currentViewport(): Nullable<IViewportLike>;
  31768. /**
  31769. * Gets the default empty texture
  31770. */
  31771. get emptyTexture(): InternalTexture;
  31772. /**
  31773. * Gets the default empty 3D texture
  31774. */
  31775. get emptyTexture3D(): InternalTexture;
  31776. /**
  31777. * Gets the default empty 2D array texture
  31778. */
  31779. get emptyTexture2DArray(): InternalTexture;
  31780. /**
  31781. * Gets the default empty cube texture
  31782. */
  31783. get emptyCubeTexture(): InternalTexture;
  31784. /**
  31785. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31786. */
  31787. readonly premultipliedAlpha: boolean;
  31788. /**
  31789. * Observable event triggered before each texture is initialized
  31790. */
  31791. onBeforeTextureInitObservable: Observable<Texture>;
  31792. /**
  31793. * Creates a new engine
  31794. * @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
  31795. * @param antialias defines enable antialiasing (default: false)
  31796. * @param options defines further options to be sent to the getContext() function
  31797. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31798. */
  31799. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31800. private _rebuildInternalTextures;
  31801. private _rebuildEffects;
  31802. /**
  31803. * Gets a boolean indicating if all created effects are ready
  31804. * @returns true if all effects are ready
  31805. */
  31806. areAllEffectsReady(): boolean;
  31807. protected _rebuildBuffers(): void;
  31808. protected _initGLContext(): void;
  31809. /**
  31810. * Gets version of the current webGL context
  31811. */
  31812. get webGLVersion(): number;
  31813. /**
  31814. * Gets a string idenfifying the name of the class
  31815. * @returns "Engine" string
  31816. */
  31817. getClassName(): string;
  31818. /**
  31819. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31820. */
  31821. get isStencilEnable(): boolean;
  31822. /** @hidden */
  31823. _prepareWorkingCanvas(): void;
  31824. /**
  31825. * Reset the texture cache to empty state
  31826. */
  31827. resetTextureCache(): void;
  31828. /**
  31829. * Gets an object containing information about the current webGL context
  31830. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31831. */
  31832. getGlInfo(): {
  31833. vendor: string;
  31834. renderer: string;
  31835. version: string;
  31836. };
  31837. /**
  31838. * Defines the hardware scaling level.
  31839. * By default the hardware scaling level is computed from the window device ratio.
  31840. * 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.
  31841. * @param level defines the level to use
  31842. */
  31843. setHardwareScalingLevel(level: number): void;
  31844. /**
  31845. * Gets the current hardware scaling level.
  31846. * By default the hardware scaling level is computed from the window device ratio.
  31847. * 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.
  31848. * @returns a number indicating the current hardware scaling level
  31849. */
  31850. getHardwareScalingLevel(): number;
  31851. /**
  31852. * Gets the list of loaded textures
  31853. * @returns an array containing all loaded textures
  31854. */
  31855. getLoadedTexturesCache(): InternalTexture[];
  31856. /**
  31857. * Gets the object containing all engine capabilities
  31858. * @returns the EngineCapabilities object
  31859. */
  31860. getCaps(): EngineCapabilities;
  31861. /**
  31862. * stop executing a render loop function and remove it from the execution array
  31863. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31864. */
  31865. stopRenderLoop(renderFunction?: () => void): void;
  31866. /** @hidden */
  31867. _renderLoop(): void;
  31868. /**
  31869. * Gets the HTML canvas attached with the current webGL context
  31870. * @returns a HTML canvas
  31871. */
  31872. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31873. /**
  31874. * Gets host window
  31875. * @returns the host window object
  31876. */
  31877. getHostWindow(): Nullable<Window>;
  31878. /**
  31879. * Gets the current render width
  31880. * @param useScreen defines if screen size must be used (or the current render target if any)
  31881. * @returns a number defining the current render width
  31882. */
  31883. getRenderWidth(useScreen?: boolean): number;
  31884. /**
  31885. * Gets the current render height
  31886. * @param useScreen defines if screen size must be used (or the current render target if any)
  31887. * @returns a number defining the current render height
  31888. */
  31889. getRenderHeight(useScreen?: boolean): number;
  31890. /**
  31891. * Can be used to override the current requestAnimationFrame requester.
  31892. * @hidden
  31893. */
  31894. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31895. /**
  31896. * Register and execute a render loop. The engine can have more than one render function
  31897. * @param renderFunction defines the function to continuously execute
  31898. */
  31899. runRenderLoop(renderFunction: () => void): void;
  31900. /**
  31901. * Clear the current render buffer or the current render target (if any is set up)
  31902. * @param color defines the color to use
  31903. * @param backBuffer defines if the back buffer must be cleared
  31904. * @param depth defines if the depth buffer must be cleared
  31905. * @param stencil defines if the stencil buffer must be cleared
  31906. */
  31907. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31908. private _viewportCached;
  31909. /** @hidden */
  31910. _viewport(x: number, y: number, width: number, height: number): void;
  31911. /**
  31912. * Set the WebGL's viewport
  31913. * @param viewport defines the viewport element to be used
  31914. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31915. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31916. */
  31917. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31918. /**
  31919. * Begin a new frame
  31920. */
  31921. beginFrame(): void;
  31922. /**
  31923. * Enf the current frame
  31924. */
  31925. endFrame(): void;
  31926. /**
  31927. * Resize the view according to the canvas' size
  31928. */
  31929. resize(): void;
  31930. /**
  31931. * Force a specific size of the canvas
  31932. * @param width defines the new canvas' width
  31933. * @param height defines the new canvas' height
  31934. */
  31935. setSize(width: number, height: number): void;
  31936. /**
  31937. * Binds the frame buffer to the specified texture.
  31938. * @param texture The texture to render to or null for the default canvas
  31939. * @param faceIndex The face of the texture to render to in case of cube texture
  31940. * @param requiredWidth The width of the target to render to
  31941. * @param requiredHeight The height of the target to render to
  31942. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31943. * @param lodLevel defines the lod level to bind to the frame buffer
  31944. * @param layer defines the 2d array index to bind to frame buffer to
  31945. */
  31946. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31947. /** @hidden */
  31948. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31949. /**
  31950. * Unbind the current render target texture from the webGL context
  31951. * @param texture defines the render target texture to unbind
  31952. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31953. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31954. */
  31955. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31956. /**
  31957. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31958. */
  31959. flushFramebuffer(): void;
  31960. /**
  31961. * Unbind the current render target and bind the default framebuffer
  31962. */
  31963. restoreDefaultFramebuffer(): void;
  31964. /** @hidden */
  31965. protected _resetVertexBufferBinding(): void;
  31966. /**
  31967. * Creates a vertex buffer
  31968. * @param data the data for the vertex buffer
  31969. * @returns the new WebGL static buffer
  31970. */
  31971. createVertexBuffer(data: DataArray): DataBuffer;
  31972. private _createVertexBuffer;
  31973. /**
  31974. * Creates a dynamic vertex buffer
  31975. * @param data the data for the dynamic vertex buffer
  31976. * @returns the new WebGL dynamic buffer
  31977. */
  31978. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31979. protected _resetIndexBufferBinding(): void;
  31980. /**
  31981. * Creates a new index buffer
  31982. * @param indices defines the content of the index buffer
  31983. * @param updatable defines if the index buffer must be updatable
  31984. * @returns a new webGL buffer
  31985. */
  31986. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31987. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31988. /**
  31989. * Bind a webGL buffer to the webGL context
  31990. * @param buffer defines the buffer to bind
  31991. */
  31992. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31993. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31994. private bindBuffer;
  31995. /**
  31996. * update the bound buffer with the given data
  31997. * @param data defines the data to update
  31998. */
  31999. updateArrayBuffer(data: Float32Array): void;
  32000. private _vertexAttribPointer;
  32001. /** @hidden */
  32002. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32003. private _bindVertexBuffersAttributes;
  32004. /**
  32005. * Records a vertex array object
  32006. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32007. * @param vertexBuffers defines the list of vertex buffers to store
  32008. * @param indexBuffer defines the index buffer to store
  32009. * @param effect defines the effect to store
  32010. * @returns the new vertex array object
  32011. */
  32012. recordVertexArrayObject(vertexBuffers: {
  32013. [key: string]: VertexBuffer;
  32014. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32015. /**
  32016. * Bind a specific vertex array object
  32017. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32018. * @param vertexArrayObject defines the vertex array object to bind
  32019. * @param indexBuffer defines the index buffer to bind
  32020. */
  32021. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32022. /**
  32023. * Bind webGl buffers directly to the webGL context
  32024. * @param vertexBuffer defines the vertex buffer to bind
  32025. * @param indexBuffer defines the index buffer to bind
  32026. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32027. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32028. * @param effect defines the effect associated with the vertex buffer
  32029. */
  32030. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32031. private _unbindVertexArrayObject;
  32032. /**
  32033. * Bind a list of vertex buffers to the webGL context
  32034. * @param vertexBuffers defines the list of vertex buffers to bind
  32035. * @param indexBuffer defines the index buffer to bind
  32036. * @param effect defines the effect associated with the vertex buffers
  32037. */
  32038. bindBuffers(vertexBuffers: {
  32039. [key: string]: Nullable<VertexBuffer>;
  32040. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32041. /**
  32042. * Unbind all instance attributes
  32043. */
  32044. unbindInstanceAttributes(): void;
  32045. /**
  32046. * Release and free the memory of a vertex array object
  32047. * @param vao defines the vertex array object to delete
  32048. */
  32049. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32050. /** @hidden */
  32051. _releaseBuffer(buffer: DataBuffer): boolean;
  32052. protected _deleteBuffer(buffer: DataBuffer): void;
  32053. /**
  32054. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32055. * @param instancesBuffer defines the webGL buffer to update and bind
  32056. * @param data defines the data to store in the buffer
  32057. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32058. */
  32059. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32060. /**
  32061. * Bind the content of a webGL buffer used with instantiation
  32062. * @param instancesBuffer defines the webGL buffer to bind
  32063. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32064. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32065. */
  32066. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32067. /**
  32068. * Disable the instance attribute corresponding to the name in parameter
  32069. * @param name defines the name of the attribute to disable
  32070. */
  32071. disableInstanceAttributeByName(name: string): void;
  32072. /**
  32073. * Disable the instance attribute corresponding to the location in parameter
  32074. * @param attributeLocation defines the attribute location of the attribute to disable
  32075. */
  32076. disableInstanceAttribute(attributeLocation: number): void;
  32077. /**
  32078. * Disable the attribute corresponding to the location in parameter
  32079. * @param attributeLocation defines the attribute location of the attribute to disable
  32080. */
  32081. disableAttributeByIndex(attributeLocation: number): void;
  32082. /**
  32083. * Send a draw order
  32084. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32085. * @param indexStart defines the starting index
  32086. * @param indexCount defines the number of index to draw
  32087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32088. */
  32089. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32090. /**
  32091. * Draw a list of points
  32092. * @param verticesStart defines the index of first vertex to draw
  32093. * @param verticesCount defines the count of vertices to draw
  32094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32095. */
  32096. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32097. /**
  32098. * Draw a list of unindexed primitives
  32099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32100. * @param verticesStart defines the index of first vertex to draw
  32101. * @param verticesCount defines the count of vertices to draw
  32102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32103. */
  32104. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32105. /**
  32106. * Draw a list of indexed primitives
  32107. * @param fillMode defines the primitive to use
  32108. * @param indexStart defines the starting index
  32109. * @param indexCount defines the number of index to draw
  32110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32111. */
  32112. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32113. /**
  32114. * Draw a list of unindexed primitives
  32115. * @param fillMode defines the primitive to use
  32116. * @param verticesStart defines the index of first vertex to draw
  32117. * @param verticesCount defines the count of vertices to draw
  32118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32119. */
  32120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32121. private _drawMode;
  32122. /** @hidden */
  32123. protected _reportDrawCall(): void;
  32124. /** @hidden */
  32125. _releaseEffect(effect: Effect): void;
  32126. /** @hidden */
  32127. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32128. /**
  32129. * Create a new effect (used to store vertex/fragment shaders)
  32130. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32131. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32132. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32133. * @param samplers defines an array of string used to represent textures
  32134. * @param defines defines the string containing the defines to use to compile the shaders
  32135. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32136. * @param onCompiled defines a function to call when the effect creation is successful
  32137. * @param onError defines a function to call when the effect creation has failed
  32138. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32139. * @returns the new Effect
  32140. */
  32141. 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;
  32142. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32143. private _compileShader;
  32144. private _compileRawShader;
  32145. /** @hidden */
  32146. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32147. /**
  32148. * Directly creates a webGL program
  32149. * @param pipelineContext defines the pipeline context to attach to
  32150. * @param vertexCode defines the vertex shader code to use
  32151. * @param fragmentCode defines the fragment shader code to use
  32152. * @param context defines the webGL context to use (if not set, the current one will be used)
  32153. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32154. * @returns the new webGL program
  32155. */
  32156. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32157. /**
  32158. * Creates a webGL program
  32159. * @param pipelineContext defines the pipeline context to attach to
  32160. * @param vertexCode defines the vertex shader code to use
  32161. * @param fragmentCode defines the fragment shader code to use
  32162. * @param defines defines the string containing the defines to use to compile the shaders
  32163. * @param context defines the webGL context to use (if not set, the current one will be used)
  32164. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32165. * @returns the new webGL program
  32166. */
  32167. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32168. /**
  32169. * Creates a new pipeline context
  32170. * @returns the new pipeline
  32171. */
  32172. createPipelineContext(): IPipelineContext;
  32173. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32174. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32175. /** @hidden */
  32176. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32177. /** @hidden */
  32178. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32179. /** @hidden */
  32180. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32181. /**
  32182. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32183. * @param pipelineContext defines the pipeline context to use
  32184. * @param uniformsNames defines the list of uniform names
  32185. * @returns an array of webGL uniform locations
  32186. */
  32187. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32188. /**
  32189. * Gets the lsit of active attributes for a given webGL program
  32190. * @param pipelineContext defines the pipeline context to use
  32191. * @param attributesNames defines the list of attribute names to get
  32192. * @returns an array of indices indicating the offset of each attribute
  32193. */
  32194. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32195. /**
  32196. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32197. * @param effect defines the effect to activate
  32198. */
  32199. enableEffect(effect: Nullable<Effect>): void;
  32200. /**
  32201. * Set the value of an uniform to a number (int)
  32202. * @param uniform defines the webGL uniform location where to store the value
  32203. * @param value defines the int number to store
  32204. */
  32205. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32206. /**
  32207. * Set the value of an uniform to an array of int32
  32208. * @param uniform defines the webGL uniform location where to store the value
  32209. * @param array defines the array of int32 to store
  32210. */
  32211. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32212. /**
  32213. * Set the value of an uniform to an array of int32 (stored as vec2)
  32214. * @param uniform defines the webGL uniform location where to store the value
  32215. * @param array defines the array of int32 to store
  32216. */
  32217. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32218. /**
  32219. * Set the value of an uniform to an array of int32 (stored as vec3)
  32220. * @param uniform defines the webGL uniform location where to store the value
  32221. * @param array defines the array of int32 to store
  32222. */
  32223. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32224. /**
  32225. * Set the value of an uniform to an array of int32 (stored as vec4)
  32226. * @param uniform defines the webGL uniform location where to store the value
  32227. * @param array defines the array of int32 to store
  32228. */
  32229. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32230. /**
  32231. * Set the value of an uniform to an array of number
  32232. * @param uniform defines the webGL uniform location where to store the value
  32233. * @param array defines the array of number to store
  32234. */
  32235. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32236. /**
  32237. * Set the value of an uniform to an array of number (stored as vec2)
  32238. * @param uniform defines the webGL uniform location where to store the value
  32239. * @param array defines the array of number to store
  32240. */
  32241. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32242. /**
  32243. * Set the value of an uniform to an array of number (stored as vec3)
  32244. * @param uniform defines the webGL uniform location where to store the value
  32245. * @param array defines the array of number to store
  32246. */
  32247. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32248. /**
  32249. * Set the value of an uniform to an array of number (stored as vec4)
  32250. * @param uniform defines the webGL uniform location where to store the value
  32251. * @param array defines the array of number to store
  32252. */
  32253. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32254. /**
  32255. * Set the value of an uniform to an array of float32 (stored as matrices)
  32256. * @param uniform defines the webGL uniform location where to store the value
  32257. * @param matrices defines the array of float32 to store
  32258. */
  32259. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32260. /**
  32261. * Set the value of an uniform to a matrix (3x3)
  32262. * @param uniform defines the webGL uniform location where to store the value
  32263. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32264. */
  32265. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32266. /**
  32267. * Set the value of an uniform to a matrix (2x2)
  32268. * @param uniform defines the webGL uniform location where to store the value
  32269. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32270. */
  32271. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32272. /**
  32273. * Set the value of an uniform to a number (float)
  32274. * @param uniform defines the webGL uniform location where to store the value
  32275. * @param value defines the float number to store
  32276. */
  32277. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32278. /**
  32279. * Set the value of an uniform to a vec2
  32280. * @param uniform defines the webGL uniform location where to store the value
  32281. * @param x defines the 1st component of the value
  32282. * @param y defines the 2nd component of the value
  32283. */
  32284. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32285. /**
  32286. * Set the value of an uniform to a vec3
  32287. * @param uniform defines the webGL uniform location where to store the value
  32288. * @param x defines the 1st component of the value
  32289. * @param y defines the 2nd component of the value
  32290. * @param z defines the 3rd component of the value
  32291. */
  32292. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32293. /**
  32294. * Set the value of an uniform to a vec4
  32295. * @param uniform defines the webGL uniform location where to store the value
  32296. * @param x defines the 1st component of the value
  32297. * @param y defines the 2nd component of the value
  32298. * @param z defines the 3rd component of the value
  32299. * @param w defines the 4th component of the value
  32300. */
  32301. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32302. /**
  32303. * Apply all cached states (depth, culling, stencil and alpha)
  32304. */
  32305. applyStates(): void;
  32306. /**
  32307. * Enable or disable color writing
  32308. * @param enable defines the state to set
  32309. */
  32310. setColorWrite(enable: boolean): void;
  32311. /**
  32312. * Gets a boolean indicating if color writing is enabled
  32313. * @returns the current color writing state
  32314. */
  32315. getColorWrite(): boolean;
  32316. /**
  32317. * Gets the depth culling state manager
  32318. */
  32319. get depthCullingState(): DepthCullingState;
  32320. /**
  32321. * Gets the alpha state manager
  32322. */
  32323. get alphaState(): AlphaState;
  32324. /**
  32325. * Gets the stencil state manager
  32326. */
  32327. get stencilState(): StencilState;
  32328. /**
  32329. * Clears the list of texture accessible through engine.
  32330. * This can help preventing texture load conflict due to name collision.
  32331. */
  32332. clearInternalTexturesCache(): void;
  32333. /**
  32334. * Force the entire cache to be cleared
  32335. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32336. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32337. */
  32338. wipeCaches(bruteForce?: boolean): void;
  32339. /** @hidden */
  32340. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32341. min: number;
  32342. mag: number;
  32343. };
  32344. /** @hidden */
  32345. _createTexture(): WebGLTexture;
  32346. /**
  32347. * Usually called from Texture.ts.
  32348. * Passed information to create a WebGLTexture
  32349. * @param url defines a value which contains one of the following:
  32350. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32351. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32352. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32353. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32354. * @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)
  32355. * @param scene needed for loading to the correct scene
  32356. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32357. * @param onLoad optional callback to be called upon successful completion
  32358. * @param onError optional callback to be called upon failure
  32359. * @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
  32360. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32361. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32362. * @param forcedExtension defines the extension to use to pick the right loader
  32363. * @param mimeType defines an optional mime type
  32364. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32365. */
  32366. 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;
  32367. /**
  32368. * Loads an image as an HTMLImageElement.
  32369. * @param input url string, ArrayBuffer, or Blob to load
  32370. * @param onLoad callback called when the image successfully loads
  32371. * @param onError callback called when the image fails to load
  32372. * @param offlineProvider offline provider for caching
  32373. * @param mimeType optional mime type
  32374. * @returns the HTMLImageElement of the loaded image
  32375. * @hidden
  32376. */
  32377. 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>;
  32378. /**
  32379. * @hidden
  32380. */
  32381. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32382. private _unpackFlipYCached;
  32383. /**
  32384. * In case you are sharing the context with other applications, it might
  32385. * be interested to not cache the unpack flip y state to ensure a consistent
  32386. * value would be set.
  32387. */
  32388. enableUnpackFlipYCached: boolean;
  32389. /** @hidden */
  32390. _unpackFlipY(value: boolean): void;
  32391. /** @hidden */
  32392. _getUnpackAlignement(): number;
  32393. private _getTextureTarget;
  32394. /**
  32395. * Update the sampling mode of a given texture
  32396. * @param samplingMode defines the required sampling mode
  32397. * @param texture defines the texture to update
  32398. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32399. */
  32400. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32401. /**
  32402. * Update the sampling mode of a given texture
  32403. * @param texture defines the texture to update
  32404. * @param wrapU defines the texture wrap mode of the u coordinates
  32405. * @param wrapV defines the texture wrap mode of the v coordinates
  32406. * @param wrapR defines the texture wrap mode of the r coordinates
  32407. */
  32408. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32409. /** @hidden */
  32410. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32411. width: number;
  32412. height: number;
  32413. layers?: number;
  32414. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32415. /** @hidden */
  32416. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32417. /** @hidden */
  32418. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32419. /**
  32420. * Update a portion of an internal texture
  32421. * @param texture defines the texture to update
  32422. * @param imageData defines the data to store into the texture
  32423. * @param xOffset defines the x coordinates of the update rectangle
  32424. * @param yOffset defines the y coordinates of the update rectangle
  32425. * @param width defines the width of the update rectangle
  32426. * @param height defines the height of the update rectangle
  32427. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32428. * @param lod defines the lod level to update (0 by default)
  32429. */
  32430. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32431. /** @hidden */
  32432. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32433. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32434. private _prepareWebGLTexture;
  32435. /** @hidden */
  32436. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32437. private _getDepthStencilBuffer;
  32438. /** @hidden */
  32439. _releaseFramebufferObjects(texture: InternalTexture): void;
  32440. /** @hidden */
  32441. _releaseTexture(texture: InternalTexture): void;
  32442. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32443. protected _setProgram(program: WebGLProgram): void;
  32444. protected _boundUniforms: {
  32445. [key: number]: WebGLUniformLocation;
  32446. };
  32447. /**
  32448. * Binds an effect to the webGL context
  32449. * @param effect defines the effect to bind
  32450. */
  32451. bindSamplers(effect: Effect): void;
  32452. private _activateCurrentTexture;
  32453. /** @hidden */
  32454. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32455. /** @hidden */
  32456. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32457. /**
  32458. * Unbind all textures from the webGL context
  32459. */
  32460. unbindAllTextures(): void;
  32461. /**
  32462. * Sets a texture to the according uniform.
  32463. * @param channel The texture channel
  32464. * @param uniform The uniform to set
  32465. * @param texture The texture to apply
  32466. */
  32467. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32468. private _bindSamplerUniformToChannel;
  32469. private _getTextureWrapMode;
  32470. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32471. /**
  32472. * Sets an array of texture to the webGL context
  32473. * @param channel defines the channel where the texture array must be set
  32474. * @param uniform defines the associated uniform location
  32475. * @param textures defines the array of textures to bind
  32476. */
  32477. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32478. /** @hidden */
  32479. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32480. private _setTextureParameterFloat;
  32481. private _setTextureParameterInteger;
  32482. /**
  32483. * Unbind all vertex attributes from the webGL context
  32484. */
  32485. unbindAllAttributes(): void;
  32486. /**
  32487. * 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
  32488. */
  32489. releaseEffects(): void;
  32490. /**
  32491. * Dispose and release all associated resources
  32492. */
  32493. dispose(): void;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Get the current error code of the webGL context
  32506. * @returns the error code
  32507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32508. */
  32509. getError(): number;
  32510. private _canRenderToFloatFramebuffer;
  32511. private _canRenderToHalfFloatFramebuffer;
  32512. private _canRenderToFramebuffer;
  32513. /** @hidden */
  32514. _getWebGLTextureType(type: number): number;
  32515. /** @hidden */
  32516. _getInternalFormat(format: number): number;
  32517. /** @hidden */
  32518. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32519. /** @hidden */
  32520. _getRGBAMultiSampleBufferFormat(type: number): number;
  32521. /** @hidden */
  32522. _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;
  32523. /**
  32524. * Loads a file from a url
  32525. * @param url url to load
  32526. * @param onSuccess callback called when the file successfully loads
  32527. * @param onProgress callback called while file is loading (if the server supports this mode)
  32528. * @param offlineProvider defines the offline provider for caching
  32529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32530. * @param onError callback called when the file fails to load
  32531. * @returns a file request object
  32532. * @hidden
  32533. */
  32534. 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;
  32535. /**
  32536. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32537. * @param x defines the x coordinate of the rectangle where pixels must be read
  32538. * @param y defines the y coordinate of the rectangle where pixels must be read
  32539. * @param width defines the width of the rectangle where pixels must be read
  32540. * @param height defines the height of the rectangle where pixels must be read
  32541. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32542. * @returns a Uint8Array containing RGBA colors
  32543. */
  32544. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32545. private static _isSupported;
  32546. /**
  32547. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32548. * @returns true if the engine can be created
  32549. * @ignorenaming
  32550. */
  32551. static isSupported(): boolean;
  32552. /**
  32553. * Find the next highest power of two.
  32554. * @param x Number to start search from.
  32555. * @return Next highest power of two.
  32556. */
  32557. static CeilingPOT(x: number): number;
  32558. /**
  32559. * Find the next lowest power of two.
  32560. * @param x Number to start search from.
  32561. * @return Next lowest power of two.
  32562. */
  32563. static FloorPOT(x: number): number;
  32564. /**
  32565. * Find the nearest power of two.
  32566. * @param x Number to start search from.
  32567. * @return Next nearest power of two.
  32568. */
  32569. static NearestPOT(x: number): number;
  32570. /**
  32571. * Get the closest exponent of two
  32572. * @param value defines the value to approximate
  32573. * @param max defines the maximum value to return
  32574. * @param mode defines how to define the closest value
  32575. * @returns closest exponent of two of the given value
  32576. */
  32577. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32578. /**
  32579. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32580. * @param func - the function to be called
  32581. * @param requester - the object that will request the next frame. Falls back to window.
  32582. * @returns frame number
  32583. */
  32584. static QueueNewFrame(func: () => void, requester?: any): number;
  32585. /**
  32586. * Gets host document
  32587. * @returns the host document object
  32588. */
  32589. getHostDocument(): Nullable<Document>;
  32590. }
  32591. }
  32592. declare module BABYLON {
  32593. /**
  32594. * Class representing spherical harmonics coefficients to the 3rd degree
  32595. */
  32596. export class SphericalHarmonics {
  32597. /**
  32598. * Defines whether or not the harmonics have been prescaled for rendering.
  32599. */
  32600. preScaled: boolean;
  32601. /**
  32602. * The l0,0 coefficients of the spherical harmonics
  32603. */
  32604. l00: Vector3;
  32605. /**
  32606. * The l1,-1 coefficients of the spherical harmonics
  32607. */
  32608. l1_1: Vector3;
  32609. /**
  32610. * The l1,0 coefficients of the spherical harmonics
  32611. */
  32612. l10: Vector3;
  32613. /**
  32614. * The l1,1 coefficients of the spherical harmonics
  32615. */
  32616. l11: Vector3;
  32617. /**
  32618. * The l2,-2 coefficients of the spherical harmonics
  32619. */
  32620. l2_2: Vector3;
  32621. /**
  32622. * The l2,-1 coefficients of the spherical harmonics
  32623. */
  32624. l2_1: Vector3;
  32625. /**
  32626. * The l2,0 coefficients of the spherical harmonics
  32627. */
  32628. l20: Vector3;
  32629. /**
  32630. * The l2,1 coefficients of the spherical harmonics
  32631. */
  32632. l21: Vector3;
  32633. /**
  32634. * The l2,2 coefficients of the spherical harmonics
  32635. */
  32636. l22: Vector3;
  32637. /**
  32638. * Adds a light to the spherical harmonics
  32639. * @param direction the direction of the light
  32640. * @param color the color of the light
  32641. * @param deltaSolidAngle the delta solid angle of the light
  32642. */
  32643. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32644. /**
  32645. * Scales the spherical harmonics by the given amount
  32646. * @param scale the amount to scale
  32647. */
  32648. scaleInPlace(scale: number): void;
  32649. /**
  32650. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32651. *
  32652. * ```
  32653. * E_lm = A_l * L_lm
  32654. * ```
  32655. *
  32656. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32657. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32658. * the scaling factors are given in equation 9.
  32659. */
  32660. convertIncidentRadianceToIrradiance(): void;
  32661. /**
  32662. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32663. *
  32664. * ```
  32665. * L = (1/pi) * E * rho
  32666. * ```
  32667. *
  32668. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32669. */
  32670. convertIrradianceToLambertianRadiance(): void;
  32671. /**
  32672. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32673. * required operations at run time.
  32674. *
  32675. * This is simply done by scaling back the SH with Ylm constants parameter.
  32676. * The trigonometric part being applied by the shader at run time.
  32677. */
  32678. preScaleForRendering(): void;
  32679. /**
  32680. * Constructs a spherical harmonics from an array.
  32681. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32682. * @returns the spherical harmonics
  32683. */
  32684. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32685. /**
  32686. * Gets the spherical harmonics from polynomial
  32687. * @param polynomial the spherical polynomial
  32688. * @returns the spherical harmonics
  32689. */
  32690. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32691. }
  32692. /**
  32693. * Class representing spherical polynomial coefficients to the 3rd degree
  32694. */
  32695. export class SphericalPolynomial {
  32696. private _harmonics;
  32697. /**
  32698. * The spherical harmonics used to create the polynomials.
  32699. */
  32700. get preScaledHarmonics(): SphericalHarmonics;
  32701. /**
  32702. * The x coefficients of the spherical polynomial
  32703. */
  32704. x: Vector3;
  32705. /**
  32706. * The y coefficients of the spherical polynomial
  32707. */
  32708. y: Vector3;
  32709. /**
  32710. * The z coefficients of the spherical polynomial
  32711. */
  32712. z: Vector3;
  32713. /**
  32714. * The xx coefficients of the spherical polynomial
  32715. */
  32716. xx: Vector3;
  32717. /**
  32718. * The yy coefficients of the spherical polynomial
  32719. */
  32720. yy: Vector3;
  32721. /**
  32722. * The zz coefficients of the spherical polynomial
  32723. */
  32724. zz: Vector3;
  32725. /**
  32726. * The xy coefficients of the spherical polynomial
  32727. */
  32728. xy: Vector3;
  32729. /**
  32730. * The yz coefficients of the spherical polynomial
  32731. */
  32732. yz: Vector3;
  32733. /**
  32734. * The zx coefficients of the spherical polynomial
  32735. */
  32736. zx: Vector3;
  32737. /**
  32738. * Adds an ambient color to the spherical polynomial
  32739. * @param color the color to add
  32740. */
  32741. addAmbient(color: Color3): void;
  32742. /**
  32743. * Scales the spherical polynomial by the given amount
  32744. * @param scale the amount to scale
  32745. */
  32746. scaleInPlace(scale: number): void;
  32747. /**
  32748. * Gets the spherical polynomial from harmonics
  32749. * @param harmonics the spherical harmonics
  32750. * @returns the spherical polynomial
  32751. */
  32752. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32753. /**
  32754. * Constructs a spherical polynomial from an array.
  32755. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32756. * @returns the spherical polynomial
  32757. */
  32758. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32759. }
  32760. }
  32761. declare module BABYLON {
  32762. /**
  32763. * Defines the source of the internal texture
  32764. */
  32765. export enum InternalTextureSource {
  32766. /**
  32767. * The source of the texture data is unknown
  32768. */
  32769. Unknown = 0,
  32770. /**
  32771. * Texture data comes from an URL
  32772. */
  32773. Url = 1,
  32774. /**
  32775. * Texture data is only used for temporary storage
  32776. */
  32777. Temp = 2,
  32778. /**
  32779. * Texture data comes from raw data (ArrayBuffer)
  32780. */
  32781. Raw = 3,
  32782. /**
  32783. * Texture content is dynamic (video or dynamic texture)
  32784. */
  32785. Dynamic = 4,
  32786. /**
  32787. * Texture content is generated by rendering to it
  32788. */
  32789. RenderTarget = 5,
  32790. /**
  32791. * Texture content is part of a multi render target process
  32792. */
  32793. MultiRenderTarget = 6,
  32794. /**
  32795. * Texture data comes from a cube data file
  32796. */
  32797. Cube = 7,
  32798. /**
  32799. * Texture data comes from a raw cube data
  32800. */
  32801. CubeRaw = 8,
  32802. /**
  32803. * Texture data come from a prefiltered cube data file
  32804. */
  32805. CubePrefiltered = 9,
  32806. /**
  32807. * Texture content is raw 3D data
  32808. */
  32809. Raw3D = 10,
  32810. /**
  32811. * Texture content is raw 2D array data
  32812. */
  32813. Raw2DArray = 11,
  32814. /**
  32815. * Texture content is a depth texture
  32816. */
  32817. Depth = 12,
  32818. /**
  32819. * Texture data comes from a raw cube data encoded with RGBD
  32820. */
  32821. CubeRawRGBD = 13
  32822. }
  32823. /**
  32824. * Class used to store data associated with WebGL texture data for the engine
  32825. * This class should not be used directly
  32826. */
  32827. export class InternalTexture {
  32828. /** @hidden */
  32829. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32830. /**
  32831. * Defines if the texture is ready
  32832. */
  32833. isReady: boolean;
  32834. /**
  32835. * Defines if the texture is a cube texture
  32836. */
  32837. isCube: boolean;
  32838. /**
  32839. * Defines if the texture contains 3D data
  32840. */
  32841. is3D: boolean;
  32842. /**
  32843. * Defines if the texture contains 2D array data
  32844. */
  32845. is2DArray: boolean;
  32846. /**
  32847. * Defines if the texture contains multiview data
  32848. */
  32849. isMultiview: boolean;
  32850. /**
  32851. * Gets the URL used to load this texture
  32852. */
  32853. url: string;
  32854. /**
  32855. * Gets the sampling mode of the texture
  32856. */
  32857. samplingMode: number;
  32858. /**
  32859. * Gets a boolean indicating if the texture needs mipmaps generation
  32860. */
  32861. generateMipMaps: boolean;
  32862. /**
  32863. * Gets the number of samples used by the texture (WebGL2+ only)
  32864. */
  32865. samples: number;
  32866. /**
  32867. * Gets the type of the texture (int, float...)
  32868. */
  32869. type: number;
  32870. /**
  32871. * Gets the format of the texture (RGB, RGBA...)
  32872. */
  32873. format: number;
  32874. /**
  32875. * Observable called when the texture is loaded
  32876. */
  32877. onLoadedObservable: Observable<InternalTexture>;
  32878. /**
  32879. * Gets the width of the texture
  32880. */
  32881. width: number;
  32882. /**
  32883. * Gets the height of the texture
  32884. */
  32885. height: number;
  32886. /**
  32887. * Gets the depth of the texture
  32888. */
  32889. depth: number;
  32890. /**
  32891. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32892. */
  32893. baseWidth: number;
  32894. /**
  32895. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32896. */
  32897. baseHeight: number;
  32898. /**
  32899. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32900. */
  32901. baseDepth: number;
  32902. /**
  32903. * Gets a boolean indicating if the texture is inverted on Y axis
  32904. */
  32905. invertY: boolean;
  32906. /** @hidden */
  32907. _invertVScale: boolean;
  32908. /** @hidden */
  32909. _associatedChannel: number;
  32910. /** @hidden */
  32911. _source: InternalTextureSource;
  32912. /** @hidden */
  32913. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32914. /** @hidden */
  32915. _bufferView: Nullable<ArrayBufferView>;
  32916. /** @hidden */
  32917. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32918. /** @hidden */
  32919. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32920. /** @hidden */
  32921. _size: number;
  32922. /** @hidden */
  32923. _extension: string;
  32924. /** @hidden */
  32925. _files: Nullable<string[]>;
  32926. /** @hidden */
  32927. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32928. /** @hidden */
  32929. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32930. /** @hidden */
  32931. _framebuffer: Nullable<WebGLFramebuffer>;
  32932. /** @hidden */
  32933. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32934. /** @hidden */
  32935. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32936. /** @hidden */
  32937. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32938. /** @hidden */
  32939. _attachments: Nullable<number[]>;
  32940. /** @hidden */
  32941. _cachedCoordinatesMode: Nullable<number>;
  32942. /** @hidden */
  32943. _cachedWrapU: Nullable<number>;
  32944. /** @hidden */
  32945. _cachedWrapV: Nullable<number>;
  32946. /** @hidden */
  32947. _cachedWrapR: Nullable<number>;
  32948. /** @hidden */
  32949. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32950. /** @hidden */
  32951. _isDisabled: boolean;
  32952. /** @hidden */
  32953. _compression: Nullable<string>;
  32954. /** @hidden */
  32955. _generateStencilBuffer: boolean;
  32956. /** @hidden */
  32957. _generateDepthBuffer: boolean;
  32958. /** @hidden */
  32959. _comparisonFunction: number;
  32960. /** @hidden */
  32961. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32962. /** @hidden */
  32963. _lodGenerationScale: number;
  32964. /** @hidden */
  32965. _lodGenerationOffset: number;
  32966. /** @hidden */
  32967. _depthStencilTexture: Nullable<InternalTexture>;
  32968. /** @hidden */
  32969. _colorTextureArray: Nullable<WebGLTexture>;
  32970. /** @hidden */
  32971. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32972. /** @hidden */
  32973. _lodTextureHigh: Nullable<BaseTexture>;
  32974. /** @hidden */
  32975. _lodTextureMid: Nullable<BaseTexture>;
  32976. /** @hidden */
  32977. _lodTextureLow: Nullable<BaseTexture>;
  32978. /** @hidden */
  32979. _isRGBD: boolean;
  32980. /** @hidden */
  32981. _linearSpecularLOD: boolean;
  32982. /** @hidden */
  32983. _irradianceTexture: Nullable<BaseTexture>;
  32984. /** @hidden */
  32985. _webGLTexture: Nullable<WebGLTexture>;
  32986. /** @hidden */
  32987. _references: number;
  32988. private _engine;
  32989. /**
  32990. * Gets the Engine the texture belongs to.
  32991. * @returns The babylon engine
  32992. */
  32993. getEngine(): ThinEngine;
  32994. /**
  32995. * Gets the data source type of the texture
  32996. */
  32997. get source(): InternalTextureSource;
  32998. /**
  32999. * Creates a new InternalTexture
  33000. * @param engine defines the engine to use
  33001. * @param source defines the type of data that will be used
  33002. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33003. */
  33004. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33005. /**
  33006. * Increments the number of references (ie. the number of Texture that point to it)
  33007. */
  33008. incrementReferences(): void;
  33009. /**
  33010. * Change the size of the texture (not the size of the content)
  33011. * @param width defines the new width
  33012. * @param height defines the new height
  33013. * @param depth defines the new depth (1 by default)
  33014. */
  33015. updateSize(width: int, height: int, depth?: int): void;
  33016. /** @hidden */
  33017. _rebuild(): void;
  33018. /** @hidden */
  33019. _swapAndDie(target: InternalTexture): void;
  33020. /**
  33021. * Dispose the current allocated resources
  33022. */
  33023. dispose(): void;
  33024. }
  33025. }
  33026. declare module BABYLON {
  33027. /**
  33028. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33030. */
  33031. export class Analyser {
  33032. /**
  33033. * Gets or sets the smoothing
  33034. * @ignorenaming
  33035. */
  33036. SMOOTHING: number;
  33037. /**
  33038. * Gets or sets the FFT table size
  33039. * @ignorenaming
  33040. */
  33041. FFT_SIZE: number;
  33042. /**
  33043. * Gets or sets the bar graph amplitude
  33044. * @ignorenaming
  33045. */
  33046. BARGRAPHAMPLITUDE: number;
  33047. /**
  33048. * Gets or sets the position of the debug canvas
  33049. * @ignorenaming
  33050. */
  33051. DEBUGCANVASPOS: {
  33052. x: number;
  33053. y: number;
  33054. };
  33055. /**
  33056. * Gets or sets the debug canvas size
  33057. * @ignorenaming
  33058. */
  33059. DEBUGCANVASSIZE: {
  33060. width: number;
  33061. height: number;
  33062. };
  33063. private _byteFreqs;
  33064. private _byteTime;
  33065. private _floatFreqs;
  33066. private _webAudioAnalyser;
  33067. private _debugCanvas;
  33068. private _debugCanvasContext;
  33069. private _scene;
  33070. private _registerFunc;
  33071. private _audioEngine;
  33072. /**
  33073. * Creates a new analyser
  33074. * @param scene defines hosting scene
  33075. */
  33076. constructor(scene: Scene);
  33077. /**
  33078. * Get the number of data values you will have to play with for the visualization
  33079. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33080. * @returns a number
  33081. */
  33082. getFrequencyBinCount(): number;
  33083. /**
  33084. * Gets the current frequency data as a byte array
  33085. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33086. * @returns a Uint8Array
  33087. */
  33088. getByteFrequencyData(): Uint8Array;
  33089. /**
  33090. * Gets the current waveform as a byte array
  33091. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33092. * @returns a Uint8Array
  33093. */
  33094. getByteTimeDomainData(): Uint8Array;
  33095. /**
  33096. * Gets the current frequency data as a float array
  33097. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33098. * @returns a Float32Array
  33099. */
  33100. getFloatFrequencyData(): Float32Array;
  33101. /**
  33102. * Renders the debug canvas
  33103. */
  33104. drawDebugCanvas(): void;
  33105. /**
  33106. * Stops rendering the debug canvas and removes it
  33107. */
  33108. stopDebugCanvas(): void;
  33109. /**
  33110. * Connects two audio nodes
  33111. * @param inputAudioNode defines first node to connect
  33112. * @param outputAudioNode defines second node to connect
  33113. */
  33114. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33115. /**
  33116. * Releases all associated resources
  33117. */
  33118. dispose(): void;
  33119. }
  33120. }
  33121. declare module BABYLON {
  33122. /**
  33123. * This represents an audio engine and it is responsible
  33124. * to play, synchronize and analyse sounds throughout the application.
  33125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33126. */
  33127. export interface IAudioEngine extends IDisposable {
  33128. /**
  33129. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33130. */
  33131. readonly canUseWebAudio: boolean;
  33132. /**
  33133. * Gets the current AudioContext if available.
  33134. */
  33135. readonly audioContext: Nullable<AudioContext>;
  33136. /**
  33137. * The master gain node defines the global audio volume of your audio engine.
  33138. */
  33139. readonly masterGain: GainNode;
  33140. /**
  33141. * Gets whether or not mp3 are supported by your browser.
  33142. */
  33143. readonly isMP3supported: boolean;
  33144. /**
  33145. * Gets whether or not ogg are supported by your browser.
  33146. */
  33147. readonly isOGGsupported: boolean;
  33148. /**
  33149. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33150. * @ignoreNaming
  33151. */
  33152. WarnedWebAudioUnsupported: boolean;
  33153. /**
  33154. * Defines if the audio engine relies on a custom unlocked button.
  33155. * In this case, the embedded button will not be displayed.
  33156. */
  33157. useCustomUnlockedButton: boolean;
  33158. /**
  33159. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33160. */
  33161. readonly unlocked: boolean;
  33162. /**
  33163. * Event raised when audio has been unlocked on the browser.
  33164. */
  33165. onAudioUnlockedObservable: Observable<AudioEngine>;
  33166. /**
  33167. * Event raised when audio has been locked on the browser.
  33168. */
  33169. onAudioLockedObservable: Observable<AudioEngine>;
  33170. /**
  33171. * Flags the audio engine in Locked state.
  33172. * This happens due to new browser policies preventing audio to autoplay.
  33173. */
  33174. lock(): void;
  33175. /**
  33176. * Unlocks the audio engine once a user action has been done on the dom.
  33177. * This is helpful to resume play once browser policies have been satisfied.
  33178. */
  33179. unlock(): void;
  33180. /**
  33181. * Gets the global volume sets on the master gain.
  33182. * @returns the global volume if set or -1 otherwise
  33183. */
  33184. getGlobalVolume(): number;
  33185. /**
  33186. * Sets the global volume of your experience (sets on the master gain).
  33187. * @param newVolume Defines the new global volume of the application
  33188. */
  33189. setGlobalVolume(newVolume: number): void;
  33190. /**
  33191. * Connect the audio engine to an audio analyser allowing some amazing
  33192. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33194. * @param analyser The analyser to connect to the engine
  33195. */
  33196. connectToAnalyser(analyser: Analyser): void;
  33197. }
  33198. /**
  33199. * This represents the default audio engine used in babylon.
  33200. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33202. */
  33203. export class AudioEngine implements IAudioEngine {
  33204. private _audioContext;
  33205. private _audioContextInitialized;
  33206. private _muteButton;
  33207. private _hostElement;
  33208. /**
  33209. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33210. */
  33211. canUseWebAudio: boolean;
  33212. /**
  33213. * The master gain node defines the global audio volume of your audio engine.
  33214. */
  33215. masterGain: GainNode;
  33216. /**
  33217. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33218. * @ignoreNaming
  33219. */
  33220. WarnedWebAudioUnsupported: boolean;
  33221. /**
  33222. * Gets whether or not mp3 are supported by your browser.
  33223. */
  33224. isMP3supported: boolean;
  33225. /**
  33226. * Gets whether or not ogg are supported by your browser.
  33227. */
  33228. isOGGsupported: boolean;
  33229. /**
  33230. * Gets whether audio has been unlocked on the device.
  33231. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33232. * a user interaction has happened.
  33233. */
  33234. unlocked: boolean;
  33235. /**
  33236. * Defines if the audio engine relies on a custom unlocked button.
  33237. * In this case, the embedded button will not be displayed.
  33238. */
  33239. useCustomUnlockedButton: boolean;
  33240. /**
  33241. * Event raised when audio has been unlocked on the browser.
  33242. */
  33243. onAudioUnlockedObservable: Observable<AudioEngine>;
  33244. /**
  33245. * Event raised when audio has been locked on the browser.
  33246. */
  33247. onAudioLockedObservable: Observable<AudioEngine>;
  33248. /**
  33249. * Gets the current AudioContext if available.
  33250. */
  33251. get audioContext(): Nullable<AudioContext>;
  33252. private _connectedAnalyser;
  33253. /**
  33254. * Instantiates a new audio engine.
  33255. *
  33256. * There should be only one per page as some browsers restrict the number
  33257. * of audio contexts you can create.
  33258. * @param hostElement defines the host element where to display the mute icon if necessary
  33259. */
  33260. constructor(hostElement?: Nullable<HTMLElement>);
  33261. /**
  33262. * Flags the audio engine in Locked state.
  33263. * This happens due to new browser policies preventing audio to autoplay.
  33264. */
  33265. lock(): void;
  33266. /**
  33267. * Unlocks the audio engine once a user action has been done on the dom.
  33268. * This is helpful to resume play once browser policies have been satisfied.
  33269. */
  33270. unlock(): void;
  33271. private _resumeAudioContext;
  33272. private _initializeAudioContext;
  33273. private _tryToRun;
  33274. private _triggerRunningState;
  33275. private _triggerSuspendedState;
  33276. private _displayMuteButton;
  33277. private _moveButtonToTopLeft;
  33278. private _onResize;
  33279. private _hideMuteButton;
  33280. /**
  33281. * Destroy and release the resources associated with the audio ccontext.
  33282. */
  33283. dispose(): void;
  33284. /**
  33285. * Gets the global volume sets on the master gain.
  33286. * @returns the global volume if set or -1 otherwise
  33287. */
  33288. getGlobalVolume(): number;
  33289. /**
  33290. * Sets the global volume of your experience (sets on the master gain).
  33291. * @param newVolume Defines the new global volume of the application
  33292. */
  33293. setGlobalVolume(newVolume: number): void;
  33294. /**
  33295. * Connect the audio engine to an audio analyser allowing some amazing
  33296. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33298. * @param analyser The analyser to connect to the engine
  33299. */
  33300. connectToAnalyser(analyser: Analyser): void;
  33301. }
  33302. }
  33303. declare module BABYLON {
  33304. /**
  33305. * Interface used to present a loading screen while loading a scene
  33306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33307. */
  33308. export interface ILoadingScreen {
  33309. /**
  33310. * Function called to display the loading screen
  33311. */
  33312. displayLoadingUI: () => void;
  33313. /**
  33314. * Function called to hide the loading screen
  33315. */
  33316. hideLoadingUI: () => void;
  33317. /**
  33318. * Gets or sets the color to use for the background
  33319. */
  33320. loadingUIBackgroundColor: string;
  33321. /**
  33322. * Gets or sets the text to display while loading
  33323. */
  33324. loadingUIText: string;
  33325. }
  33326. /**
  33327. * Class used for the default loading screen
  33328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33329. */
  33330. export class DefaultLoadingScreen implements ILoadingScreen {
  33331. private _renderingCanvas;
  33332. private _loadingText;
  33333. private _loadingDivBackgroundColor;
  33334. private _loadingDiv;
  33335. private _loadingTextDiv;
  33336. /** Gets or sets the logo url to use for the default loading screen */
  33337. static DefaultLogoUrl: string;
  33338. /** Gets or sets the spinner url to use for the default loading screen */
  33339. static DefaultSpinnerUrl: string;
  33340. /**
  33341. * Creates a new default loading screen
  33342. * @param _renderingCanvas defines the canvas used to render the scene
  33343. * @param _loadingText defines the default text to display
  33344. * @param _loadingDivBackgroundColor defines the default background color
  33345. */
  33346. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33347. /**
  33348. * Function called to display the loading screen
  33349. */
  33350. displayLoadingUI(): void;
  33351. /**
  33352. * Function called to hide the loading screen
  33353. */
  33354. hideLoadingUI(): void;
  33355. /**
  33356. * Gets or sets the text to display while loading
  33357. */
  33358. set loadingUIText(text: string);
  33359. get loadingUIText(): string;
  33360. /**
  33361. * Gets or sets the color to use for the background
  33362. */
  33363. get loadingUIBackgroundColor(): string;
  33364. set loadingUIBackgroundColor(color: string);
  33365. private _resizeLoadingUI;
  33366. }
  33367. }
  33368. declare module BABYLON {
  33369. /**
  33370. * Interface for any object that can request an animation frame
  33371. */
  33372. export interface ICustomAnimationFrameRequester {
  33373. /**
  33374. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33375. */
  33376. renderFunction?: Function;
  33377. /**
  33378. * Called to request the next frame to render to
  33379. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33380. */
  33381. requestAnimationFrame: Function;
  33382. /**
  33383. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33384. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33385. */
  33386. requestID?: number;
  33387. }
  33388. }
  33389. declare module BABYLON {
  33390. /**
  33391. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33392. */
  33393. export class PerformanceMonitor {
  33394. private _enabled;
  33395. private _rollingFrameTime;
  33396. private _lastFrameTimeMs;
  33397. /**
  33398. * constructor
  33399. * @param frameSampleSize The number of samples required to saturate the sliding window
  33400. */
  33401. constructor(frameSampleSize?: number);
  33402. /**
  33403. * Samples current frame
  33404. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33405. */
  33406. sampleFrame(timeMs?: number): void;
  33407. /**
  33408. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33409. */
  33410. get averageFrameTime(): number;
  33411. /**
  33412. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33413. */
  33414. get averageFrameTimeVariance(): number;
  33415. /**
  33416. * Returns the frame time of the most recent frame
  33417. */
  33418. get instantaneousFrameTime(): number;
  33419. /**
  33420. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33421. */
  33422. get averageFPS(): number;
  33423. /**
  33424. * Returns the average framerate in frames per second using the most recent frame time
  33425. */
  33426. get instantaneousFPS(): number;
  33427. /**
  33428. * Returns true if enough samples have been taken to completely fill the sliding window
  33429. */
  33430. get isSaturated(): boolean;
  33431. /**
  33432. * Enables contributions to the sliding window sample set
  33433. */
  33434. enable(): void;
  33435. /**
  33436. * Disables contributions to the sliding window sample set
  33437. * Samples will not be interpolated over the disabled period
  33438. */
  33439. disable(): void;
  33440. /**
  33441. * Returns true if sampling is enabled
  33442. */
  33443. get isEnabled(): boolean;
  33444. /**
  33445. * Resets performance monitor
  33446. */
  33447. reset(): void;
  33448. }
  33449. /**
  33450. * RollingAverage
  33451. *
  33452. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33453. */
  33454. export class RollingAverage {
  33455. /**
  33456. * Current average
  33457. */
  33458. average: number;
  33459. /**
  33460. * Current variance
  33461. */
  33462. variance: number;
  33463. protected _samples: Array<number>;
  33464. protected _sampleCount: number;
  33465. protected _pos: number;
  33466. protected _m2: number;
  33467. /**
  33468. * constructor
  33469. * @param length The number of samples required to saturate the sliding window
  33470. */
  33471. constructor(length: number);
  33472. /**
  33473. * Adds a sample to the sample set
  33474. * @param v The sample value
  33475. */
  33476. add(v: number): void;
  33477. /**
  33478. * Returns previously added values or null if outside of history or outside the sliding window domain
  33479. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33480. * @return Value previously recorded with add() or null if outside of range
  33481. */
  33482. history(i: number): number;
  33483. /**
  33484. * Returns true if enough samples have been taken to completely fill the sliding window
  33485. * @return true if sample-set saturated
  33486. */
  33487. isSaturated(): boolean;
  33488. /**
  33489. * Resets the rolling average (equivalent to 0 samples taken so far)
  33490. */
  33491. reset(): void;
  33492. /**
  33493. * Wraps a value around the sample range boundaries
  33494. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33495. * @return Wrapped position in sample range
  33496. */
  33497. protected _wrapPosition(i: number): number;
  33498. }
  33499. }
  33500. declare module BABYLON {
  33501. /**
  33502. * This class is used to track a performance counter which is number based.
  33503. * The user has access to many properties which give statistics of different nature.
  33504. *
  33505. * The implementer can track two kinds of Performance Counter: time and count.
  33506. * 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.
  33507. * 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.
  33508. */
  33509. export class PerfCounter {
  33510. /**
  33511. * Gets or sets a global boolean to turn on and off all the counters
  33512. */
  33513. static Enabled: boolean;
  33514. /**
  33515. * Returns the smallest value ever
  33516. */
  33517. get min(): number;
  33518. /**
  33519. * Returns the biggest value ever
  33520. */
  33521. get max(): number;
  33522. /**
  33523. * Returns the average value since the performance counter is running
  33524. */
  33525. get average(): number;
  33526. /**
  33527. * Returns the average value of the last second the counter was monitored
  33528. */
  33529. get lastSecAverage(): number;
  33530. /**
  33531. * Returns the current value
  33532. */
  33533. get current(): number;
  33534. /**
  33535. * Gets the accumulated total
  33536. */
  33537. get total(): number;
  33538. /**
  33539. * Gets the total value count
  33540. */
  33541. get count(): number;
  33542. /**
  33543. * Creates a new counter
  33544. */
  33545. constructor();
  33546. /**
  33547. * Call this method to start monitoring a new frame.
  33548. * 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.
  33549. */
  33550. fetchNewFrame(): void;
  33551. /**
  33552. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33553. * @param newCount the count value to add to the monitored count
  33554. * @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.
  33555. */
  33556. addCount(newCount: number, fetchResult: boolean): void;
  33557. /**
  33558. * Start monitoring this performance counter
  33559. */
  33560. beginMonitoring(): void;
  33561. /**
  33562. * Compute the time lapsed since the previous beginMonitoring() call.
  33563. * @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
  33564. */
  33565. endMonitoring(newFrame?: boolean): void;
  33566. private _fetchResult;
  33567. private _startMonitoringTime;
  33568. private _min;
  33569. private _max;
  33570. private _average;
  33571. private _current;
  33572. private _totalValueCount;
  33573. private _totalAccumulated;
  33574. private _lastSecAverage;
  33575. private _lastSecAccumulated;
  33576. private _lastSecTime;
  33577. private _lastSecValueCount;
  33578. }
  33579. }
  33580. declare module BABYLON {
  33581. interface ThinEngine {
  33582. /**
  33583. * Sets alpha constants used by some alpha blending modes
  33584. * @param r defines the red component
  33585. * @param g defines the green component
  33586. * @param b defines the blue component
  33587. * @param a defines the alpha component
  33588. */
  33589. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33590. /**
  33591. * Sets the current alpha mode
  33592. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33593. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33594. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33595. */
  33596. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33597. /**
  33598. * Gets the current alpha mode
  33599. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33600. * @returns the current alpha mode
  33601. */
  33602. getAlphaMode(): number;
  33603. /**
  33604. * Sets the current alpha equation
  33605. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33606. */
  33607. setAlphaEquation(equation: number): void;
  33608. /**
  33609. * Gets the current alpha equation.
  33610. * @returns the current alpha equation
  33611. */
  33612. getAlphaEquation(): number;
  33613. }
  33614. }
  33615. declare module BABYLON {
  33616. /**
  33617. * Defines the interface used by display changed events
  33618. */
  33619. export interface IDisplayChangedEventArgs {
  33620. /** Gets the vrDisplay object (if any) */
  33621. vrDisplay: Nullable<any>;
  33622. /** Gets a boolean indicating if webVR is supported */
  33623. vrSupported: boolean;
  33624. }
  33625. /**
  33626. * Defines the interface used by objects containing a viewport (like a camera)
  33627. */
  33628. interface IViewportOwnerLike {
  33629. /**
  33630. * Gets or sets the viewport
  33631. */
  33632. viewport: IViewportLike;
  33633. }
  33634. /**
  33635. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33636. */
  33637. export class Engine extends ThinEngine {
  33638. /** Defines that alpha blending is disabled */
  33639. static readonly ALPHA_DISABLE: number;
  33640. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33641. static readonly ALPHA_ADD: number;
  33642. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33643. static readonly ALPHA_COMBINE: number;
  33644. /** Defines that alpha blending to DEST - SRC * DEST */
  33645. static readonly ALPHA_SUBTRACT: number;
  33646. /** Defines that alpha blending to SRC * DEST */
  33647. static readonly ALPHA_MULTIPLY: number;
  33648. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33649. static readonly ALPHA_MAXIMIZED: number;
  33650. /** Defines that alpha blending to SRC + DEST */
  33651. static readonly ALPHA_ONEONE: number;
  33652. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33653. static readonly ALPHA_PREMULTIPLIED: number;
  33654. /**
  33655. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33656. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33657. */
  33658. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33659. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33660. static readonly ALPHA_INTERPOLATE: number;
  33661. /**
  33662. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33663. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33664. */
  33665. static readonly ALPHA_SCREENMODE: number;
  33666. /** Defines that the ressource is not delayed*/
  33667. static readonly DELAYLOADSTATE_NONE: number;
  33668. /** Defines that the ressource was successfully delay loaded */
  33669. static readonly DELAYLOADSTATE_LOADED: number;
  33670. /** Defines that the ressource is currently delay loading */
  33671. static readonly DELAYLOADSTATE_LOADING: number;
  33672. /** Defines that the ressource is delayed and has not started loading */
  33673. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33675. static readonly NEVER: number;
  33676. /** 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 */
  33677. static readonly ALWAYS: number;
  33678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33679. static readonly LESS: number;
  33680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33681. static readonly EQUAL: number;
  33682. /** 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 */
  33683. static readonly LEQUAL: number;
  33684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33685. static readonly GREATER: number;
  33686. /** 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 */
  33687. static readonly GEQUAL: number;
  33688. /** 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 */
  33689. static readonly NOTEQUAL: number;
  33690. /** Passed to stencilOperation to specify that stencil value must be kept */
  33691. static readonly KEEP: number;
  33692. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33693. static readonly REPLACE: number;
  33694. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33695. static readonly INCR: number;
  33696. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33697. static readonly DECR: number;
  33698. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33699. static readonly INVERT: number;
  33700. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33701. static readonly INCR_WRAP: number;
  33702. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33703. static readonly DECR_WRAP: number;
  33704. /** Texture is not repeating outside of 0..1 UVs */
  33705. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33706. /** Texture is repeating outside of 0..1 UVs */
  33707. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33708. /** Texture is repeating and mirrored */
  33709. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33710. /** ALPHA */
  33711. static readonly TEXTUREFORMAT_ALPHA: number;
  33712. /** LUMINANCE */
  33713. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33714. /** LUMINANCE_ALPHA */
  33715. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33716. /** RGB */
  33717. static readonly TEXTUREFORMAT_RGB: number;
  33718. /** RGBA */
  33719. static readonly TEXTUREFORMAT_RGBA: number;
  33720. /** RED */
  33721. static readonly TEXTUREFORMAT_RED: number;
  33722. /** RED (2nd reference) */
  33723. static readonly TEXTUREFORMAT_R: number;
  33724. /** RG */
  33725. static readonly TEXTUREFORMAT_RG: number;
  33726. /** RED_INTEGER */
  33727. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33728. /** RED_INTEGER (2nd reference) */
  33729. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33730. /** RG_INTEGER */
  33731. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33732. /** RGB_INTEGER */
  33733. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33734. /** RGBA_INTEGER */
  33735. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33736. /** UNSIGNED_BYTE */
  33737. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33738. /** UNSIGNED_BYTE (2nd reference) */
  33739. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33740. /** FLOAT */
  33741. static readonly TEXTURETYPE_FLOAT: number;
  33742. /** HALF_FLOAT */
  33743. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33744. /** BYTE */
  33745. static readonly TEXTURETYPE_BYTE: number;
  33746. /** SHORT */
  33747. static readonly TEXTURETYPE_SHORT: number;
  33748. /** UNSIGNED_SHORT */
  33749. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33750. /** INT */
  33751. static readonly TEXTURETYPE_INT: number;
  33752. /** UNSIGNED_INT */
  33753. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33754. /** UNSIGNED_SHORT_4_4_4_4 */
  33755. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33756. /** UNSIGNED_SHORT_5_5_5_1 */
  33757. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33758. /** UNSIGNED_SHORT_5_6_5 */
  33759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33760. /** UNSIGNED_INT_2_10_10_10_REV */
  33761. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33762. /** UNSIGNED_INT_24_8 */
  33763. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33764. /** UNSIGNED_INT_10F_11F_11F_REV */
  33765. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33766. /** UNSIGNED_INT_5_9_9_9_REV */
  33767. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33768. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33769. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33770. /** nearest is mag = nearest and min = nearest and mip = linear */
  33771. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33773. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33774. /** Trilinear is mag = linear and min = linear and mip = linear */
  33775. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33776. /** nearest is mag = nearest and min = nearest and mip = linear */
  33777. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33779. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33780. /** Trilinear is mag = linear and min = linear and mip = linear */
  33781. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33782. /** mag = nearest and min = nearest and mip = nearest */
  33783. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33784. /** mag = nearest and min = linear and mip = nearest */
  33785. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33786. /** mag = nearest and min = linear and mip = linear */
  33787. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33788. /** mag = nearest and min = linear and mip = none */
  33789. static readonly TEXTURE_NEAREST_LINEAR: number;
  33790. /** mag = nearest and min = nearest and mip = none */
  33791. static readonly TEXTURE_NEAREST_NEAREST: number;
  33792. /** mag = linear and min = nearest and mip = nearest */
  33793. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33794. /** mag = linear and min = nearest and mip = linear */
  33795. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33796. /** mag = linear and min = linear and mip = none */
  33797. static readonly TEXTURE_LINEAR_LINEAR: number;
  33798. /** mag = linear and min = nearest and mip = none */
  33799. static readonly TEXTURE_LINEAR_NEAREST: number;
  33800. /** Explicit coordinates mode */
  33801. static readonly TEXTURE_EXPLICIT_MODE: number;
  33802. /** Spherical coordinates mode */
  33803. static readonly TEXTURE_SPHERICAL_MODE: number;
  33804. /** Planar coordinates mode */
  33805. static readonly TEXTURE_PLANAR_MODE: number;
  33806. /** Cubic coordinates mode */
  33807. static readonly TEXTURE_CUBIC_MODE: number;
  33808. /** Projection coordinates mode */
  33809. static readonly TEXTURE_PROJECTION_MODE: number;
  33810. /** Skybox coordinates mode */
  33811. static readonly TEXTURE_SKYBOX_MODE: number;
  33812. /** Inverse Cubic coordinates mode */
  33813. static readonly TEXTURE_INVCUBIC_MODE: number;
  33814. /** Equirectangular coordinates mode */
  33815. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33816. /** Equirectangular Fixed coordinates mode */
  33817. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33818. /** Equirectangular Fixed Mirrored coordinates mode */
  33819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33820. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33821. static readonly SCALEMODE_FLOOR: number;
  33822. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33823. static readonly SCALEMODE_NEAREST: number;
  33824. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33825. static readonly SCALEMODE_CEILING: number;
  33826. /**
  33827. * Returns the current npm package of the sdk
  33828. */
  33829. static get NpmPackage(): string;
  33830. /**
  33831. * Returns the current version of the framework
  33832. */
  33833. static get Version(): string;
  33834. /** Gets the list of created engines */
  33835. static get Instances(): Engine[];
  33836. /**
  33837. * Gets the latest created engine
  33838. */
  33839. static get LastCreatedEngine(): Nullable<Engine>;
  33840. /**
  33841. * Gets the latest created scene
  33842. */
  33843. static get LastCreatedScene(): Nullable<Scene>;
  33844. /**
  33845. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33846. * @param flag defines which part of the materials must be marked as dirty
  33847. * @param predicate defines a predicate used to filter which materials should be affected
  33848. */
  33849. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33850. /**
  33851. * Method called to create the default loading screen.
  33852. * This can be overriden in your own app.
  33853. * @param canvas The rendering canvas element
  33854. * @returns The loading screen
  33855. */
  33856. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33857. /**
  33858. * Method called to create the default rescale post process on each engine.
  33859. */
  33860. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33861. /**
  33862. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33863. **/
  33864. enableOfflineSupport: boolean;
  33865. /**
  33866. * 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)
  33867. **/
  33868. disableManifestCheck: boolean;
  33869. /**
  33870. * Gets the list of created scenes
  33871. */
  33872. scenes: Scene[];
  33873. /**
  33874. * Event raised when a new scene is created
  33875. */
  33876. onNewSceneAddedObservable: Observable<Scene>;
  33877. /**
  33878. * Gets the list of created postprocesses
  33879. */
  33880. postProcesses: PostProcess[];
  33881. /**
  33882. * Gets a boolean indicating if the pointer is currently locked
  33883. */
  33884. isPointerLock: boolean;
  33885. /**
  33886. * Observable event triggered each time the rendering canvas is resized
  33887. */
  33888. onResizeObservable: Observable<Engine>;
  33889. /**
  33890. * Observable event triggered each time the canvas loses focus
  33891. */
  33892. onCanvasBlurObservable: Observable<Engine>;
  33893. /**
  33894. * Observable event triggered each time the canvas gains focus
  33895. */
  33896. onCanvasFocusObservable: Observable<Engine>;
  33897. /**
  33898. * Observable event triggered each time the canvas receives pointerout event
  33899. */
  33900. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33901. /**
  33902. * Observable raised when the engine begins a new frame
  33903. */
  33904. onBeginFrameObservable: Observable<Engine>;
  33905. /**
  33906. * If set, will be used to request the next animation frame for the render loop
  33907. */
  33908. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33909. /**
  33910. * Observable raised when the engine ends the current frame
  33911. */
  33912. onEndFrameObservable: Observable<Engine>;
  33913. /**
  33914. * Observable raised when the engine is about to compile a shader
  33915. */
  33916. onBeforeShaderCompilationObservable: Observable<Engine>;
  33917. /**
  33918. * Observable raised when the engine has jsut compiled a shader
  33919. */
  33920. onAfterShaderCompilationObservable: Observable<Engine>;
  33921. /**
  33922. * Gets the audio engine
  33923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33924. * @ignorenaming
  33925. */
  33926. static audioEngine: IAudioEngine;
  33927. /**
  33928. * Default AudioEngine factory responsible of creating the Audio Engine.
  33929. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33930. */
  33931. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33932. /**
  33933. * Default offline support factory responsible of creating a tool used to store data locally.
  33934. * By default, this will create a Database object if the workload has been embedded.
  33935. */
  33936. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33937. private _loadingScreen;
  33938. private _pointerLockRequested;
  33939. private _dummyFramebuffer;
  33940. private _rescalePostProcess;
  33941. private _deterministicLockstep;
  33942. private _lockstepMaxSteps;
  33943. private _timeStep;
  33944. protected get _supportsHardwareTextureRescaling(): boolean;
  33945. private _fps;
  33946. private _deltaTime;
  33947. /** @hidden */
  33948. _drawCalls: PerfCounter;
  33949. /** 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 */
  33950. canvasTabIndex: number;
  33951. /**
  33952. * Turn this value on if you want to pause FPS computation when in background
  33953. */
  33954. disablePerformanceMonitorInBackground: boolean;
  33955. private _performanceMonitor;
  33956. /**
  33957. * Gets the performance monitor attached to this engine
  33958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33959. */
  33960. get performanceMonitor(): PerformanceMonitor;
  33961. private _onFocus;
  33962. private _onBlur;
  33963. private _onCanvasPointerOut;
  33964. private _onCanvasBlur;
  33965. private _onCanvasFocus;
  33966. private _onFullscreenChange;
  33967. private _onPointerLockChange;
  33968. /**
  33969. * Gets the HTML element used to attach event listeners
  33970. * @returns a HTML element
  33971. */
  33972. getInputElement(): Nullable<HTMLElement>;
  33973. /**
  33974. * Creates a new engine
  33975. * @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
  33976. * @param antialias defines enable antialiasing (default: false)
  33977. * @param options defines further options to be sent to the getContext() function
  33978. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33979. */
  33980. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33981. /**
  33982. * Gets current aspect ratio
  33983. * @param viewportOwner defines the camera to use to get the aspect ratio
  33984. * @param useScreen defines if screen size must be used (or the current render target if any)
  33985. * @returns a number defining the aspect ratio
  33986. */
  33987. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33988. /**
  33989. * Gets current screen aspect ratio
  33990. * @returns a number defining the aspect ratio
  33991. */
  33992. getScreenAspectRatio(): number;
  33993. /**
  33994. * Gets the client rect of the HTML canvas attached with the current webGL context
  33995. * @returns a client rectanglee
  33996. */
  33997. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33998. /**
  33999. * Gets the client rect of the HTML element used for events
  34000. * @returns a client rectanglee
  34001. */
  34002. getInputElementClientRect(): Nullable<ClientRect>;
  34003. /**
  34004. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34006. * @returns true if engine is in deterministic lock step mode
  34007. */
  34008. isDeterministicLockStep(): boolean;
  34009. /**
  34010. * Gets the max steps when engine is running in deterministic lock step
  34011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34012. * @returns the max steps
  34013. */
  34014. getLockstepMaxSteps(): number;
  34015. /**
  34016. * Returns the time in ms between steps when using deterministic lock step.
  34017. * @returns time step in (ms)
  34018. */
  34019. getTimeStep(): number;
  34020. /**
  34021. * Force the mipmap generation for the given render target texture
  34022. * @param texture defines the render target texture to use
  34023. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34024. */
  34025. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34026. /** States */
  34027. /**
  34028. * Set various states to the webGL context
  34029. * @param culling defines backface culling state
  34030. * @param zOffset defines the value to apply to zOffset (0 by default)
  34031. * @param force defines if states must be applied even if cache is up to date
  34032. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34033. */
  34034. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34035. /**
  34036. * Set the z offset to apply to current rendering
  34037. * @param value defines the offset to apply
  34038. */
  34039. setZOffset(value: number): void;
  34040. /**
  34041. * Gets the current value of the zOffset
  34042. * @returns the current zOffset state
  34043. */
  34044. getZOffset(): number;
  34045. /**
  34046. * Enable or disable depth buffering
  34047. * @param enable defines the state to set
  34048. */
  34049. setDepthBuffer(enable: boolean): void;
  34050. /**
  34051. * Gets a boolean indicating if depth writing is enabled
  34052. * @returns the current depth writing state
  34053. */
  34054. getDepthWrite(): boolean;
  34055. /**
  34056. * Enable or disable depth writing
  34057. * @param enable defines the state to set
  34058. */
  34059. setDepthWrite(enable: boolean): void;
  34060. /**
  34061. * Gets a boolean indicating if stencil buffer is enabled
  34062. * @returns the current stencil buffer state
  34063. */
  34064. getStencilBuffer(): boolean;
  34065. /**
  34066. * Enable or disable the stencil buffer
  34067. * @param enable defines if the stencil buffer must be enabled or disabled
  34068. */
  34069. setStencilBuffer(enable: boolean): void;
  34070. /**
  34071. * Gets the current stencil mask
  34072. * @returns a number defining the new stencil mask to use
  34073. */
  34074. getStencilMask(): number;
  34075. /**
  34076. * Sets the current stencil mask
  34077. * @param mask defines the new stencil mask to use
  34078. */
  34079. setStencilMask(mask: number): void;
  34080. /**
  34081. * Gets the current stencil function
  34082. * @returns a number defining the stencil function to use
  34083. */
  34084. getStencilFunction(): number;
  34085. /**
  34086. * Gets the current stencil reference value
  34087. * @returns a number defining the stencil reference value to use
  34088. */
  34089. getStencilFunctionReference(): number;
  34090. /**
  34091. * Gets the current stencil mask
  34092. * @returns a number defining the stencil mask to use
  34093. */
  34094. getStencilFunctionMask(): number;
  34095. /**
  34096. * Sets the current stencil function
  34097. * @param stencilFunc defines the new stencil function to use
  34098. */
  34099. setStencilFunction(stencilFunc: number): void;
  34100. /**
  34101. * Sets the current stencil reference
  34102. * @param reference defines the new stencil reference to use
  34103. */
  34104. setStencilFunctionReference(reference: number): void;
  34105. /**
  34106. * Sets the current stencil mask
  34107. * @param mask defines the new stencil mask to use
  34108. */
  34109. setStencilFunctionMask(mask: number): void;
  34110. /**
  34111. * Gets the current stencil operation when stencil fails
  34112. * @returns a number defining stencil operation to use when stencil fails
  34113. */
  34114. getStencilOperationFail(): number;
  34115. /**
  34116. * Gets the current stencil operation when depth fails
  34117. * @returns a number defining stencil operation to use when depth fails
  34118. */
  34119. getStencilOperationDepthFail(): number;
  34120. /**
  34121. * Gets the current stencil operation when stencil passes
  34122. * @returns a number defining stencil operation to use when stencil passes
  34123. */
  34124. getStencilOperationPass(): number;
  34125. /**
  34126. * Sets the stencil operation to use when stencil fails
  34127. * @param operation defines the stencil operation to use when stencil fails
  34128. */
  34129. setStencilOperationFail(operation: number): void;
  34130. /**
  34131. * Sets the stencil operation to use when depth fails
  34132. * @param operation defines the stencil operation to use when depth fails
  34133. */
  34134. setStencilOperationDepthFail(operation: number): void;
  34135. /**
  34136. * Sets the stencil operation to use when stencil passes
  34137. * @param operation defines the stencil operation to use when stencil passes
  34138. */
  34139. setStencilOperationPass(operation: number): void;
  34140. /**
  34141. * Sets a boolean indicating if the dithering state is enabled or disabled
  34142. * @param value defines the dithering state
  34143. */
  34144. setDitheringState(value: boolean): void;
  34145. /**
  34146. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34147. * @param value defines the rasterizer state
  34148. */
  34149. setRasterizerState(value: boolean): void;
  34150. /**
  34151. * Gets the current depth function
  34152. * @returns a number defining the depth function
  34153. */
  34154. getDepthFunction(): Nullable<number>;
  34155. /**
  34156. * Sets the current depth function
  34157. * @param depthFunc defines the function to use
  34158. */
  34159. setDepthFunction(depthFunc: number): void;
  34160. /**
  34161. * Sets the current depth function to GREATER
  34162. */
  34163. setDepthFunctionToGreater(): void;
  34164. /**
  34165. * Sets the current depth function to GEQUAL
  34166. */
  34167. setDepthFunctionToGreaterOrEqual(): void;
  34168. /**
  34169. * Sets the current depth function to LESS
  34170. */
  34171. setDepthFunctionToLess(): void;
  34172. /**
  34173. * Sets the current depth function to LEQUAL
  34174. */
  34175. setDepthFunctionToLessOrEqual(): void;
  34176. private _cachedStencilBuffer;
  34177. private _cachedStencilFunction;
  34178. private _cachedStencilMask;
  34179. private _cachedStencilOperationPass;
  34180. private _cachedStencilOperationFail;
  34181. private _cachedStencilOperationDepthFail;
  34182. private _cachedStencilReference;
  34183. /**
  34184. * Caches the the state of the stencil buffer
  34185. */
  34186. cacheStencilState(): void;
  34187. /**
  34188. * Restores the state of the stencil buffer
  34189. */
  34190. restoreStencilState(): void;
  34191. /**
  34192. * Directly set the WebGL Viewport
  34193. * @param x defines the x coordinate of the viewport (in screen space)
  34194. * @param y defines the y coordinate of the viewport (in screen space)
  34195. * @param width defines the width of the viewport (in screen space)
  34196. * @param height defines the height of the viewport (in screen space)
  34197. * @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
  34198. */
  34199. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34200. /**
  34201. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34202. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34203. * @param y defines the y-coordinate of the corner of the clear rectangle
  34204. * @param width defines the width of the clear rectangle
  34205. * @param height defines the height of the clear rectangle
  34206. * @param clearColor defines the clear color
  34207. */
  34208. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34209. /**
  34210. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34211. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34212. * @param y defines the y-coordinate of the corner of the clear rectangle
  34213. * @param width defines the width of the clear rectangle
  34214. * @param height defines the height of the clear rectangle
  34215. */
  34216. enableScissor(x: number, y: number, width: number, height: number): void;
  34217. /**
  34218. * Disable previously set scissor test rectangle
  34219. */
  34220. disableScissor(): void;
  34221. protected _reportDrawCall(): void;
  34222. /**
  34223. * Initializes a webVR display and starts listening to display change events
  34224. * The onVRDisplayChangedObservable will be notified upon these changes
  34225. * @returns The onVRDisplayChangedObservable
  34226. */
  34227. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34228. /** @hidden */
  34229. _prepareVRComponent(): void;
  34230. /** @hidden */
  34231. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34232. /** @hidden */
  34233. _submitVRFrame(): void;
  34234. /**
  34235. * Call this function to leave webVR mode
  34236. * Will do nothing if webVR is not supported or if there is no webVR device
  34237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34238. */
  34239. disableVR(): void;
  34240. /**
  34241. * Gets a boolean indicating that the system is in VR mode and is presenting
  34242. * @returns true if VR mode is engaged
  34243. */
  34244. isVRPresenting(): boolean;
  34245. /** @hidden */
  34246. _requestVRFrame(): void;
  34247. /** @hidden */
  34248. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34249. /**
  34250. * Gets the source code of the vertex shader associated with a specific webGL program
  34251. * @param program defines the program to use
  34252. * @returns a string containing the source code of the vertex shader associated with the program
  34253. */
  34254. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34255. /**
  34256. * Gets the source code of the fragment shader associated with a specific webGL program
  34257. * @param program defines the program to use
  34258. * @returns a string containing the source code of the fragment shader associated with the program
  34259. */
  34260. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34261. /**
  34262. * Sets a depth stencil texture from a render target to the according uniform.
  34263. * @param channel The texture channel
  34264. * @param uniform The uniform to set
  34265. * @param texture The render target texture containing the depth stencil texture to apply
  34266. */
  34267. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34268. /**
  34269. * Sets a texture to the webGL context from a postprocess
  34270. * @param channel defines the channel to use
  34271. * @param postProcess defines the source postprocess
  34272. */
  34273. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34274. /**
  34275. * Binds the output of the passed in post process to the texture channel specified
  34276. * @param channel The channel the texture should be bound to
  34277. * @param postProcess The post process which's output should be bound
  34278. */
  34279. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34280. protected _rebuildBuffers(): void;
  34281. /** @hidden */
  34282. _renderFrame(): void;
  34283. _renderLoop(): void;
  34284. /** @hidden */
  34285. _renderViews(): boolean;
  34286. /**
  34287. * Toggle full screen mode
  34288. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34289. */
  34290. switchFullscreen(requestPointerLock: boolean): void;
  34291. /**
  34292. * Enters full screen mode
  34293. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34294. */
  34295. enterFullscreen(requestPointerLock: boolean): void;
  34296. /**
  34297. * Exits full screen mode
  34298. */
  34299. exitFullscreen(): void;
  34300. /**
  34301. * Enters Pointerlock mode
  34302. */
  34303. enterPointerlock(): void;
  34304. /**
  34305. * Exits Pointerlock mode
  34306. */
  34307. exitPointerlock(): void;
  34308. /**
  34309. * Begin a new frame
  34310. */
  34311. beginFrame(): void;
  34312. /**
  34313. * Enf the current frame
  34314. */
  34315. endFrame(): void;
  34316. resize(): void;
  34317. /**
  34318. * Force a specific size of the canvas
  34319. * @param width defines the new canvas' width
  34320. * @param height defines the new canvas' height
  34321. */
  34322. setSize(width: number, height: number): void;
  34323. /**
  34324. * Updates a dynamic vertex buffer.
  34325. * @param vertexBuffer the vertex buffer to update
  34326. * @param data the data used to update the vertex buffer
  34327. * @param byteOffset the byte offset of the data
  34328. * @param byteLength the byte length of the data
  34329. */
  34330. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34331. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34332. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34333. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34334. _releaseTexture(texture: InternalTexture): void;
  34335. /**
  34336. * @hidden
  34337. * Rescales a texture
  34338. * @param source input texutre
  34339. * @param destination destination texture
  34340. * @param scene scene to use to render the resize
  34341. * @param internalFormat format to use when resizing
  34342. * @param onComplete callback to be called when resize has completed
  34343. */
  34344. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34345. /**
  34346. * Gets the current framerate
  34347. * @returns a number representing the framerate
  34348. */
  34349. getFps(): number;
  34350. /**
  34351. * Gets the time spent between current and previous frame
  34352. * @returns a number representing the delta time in ms
  34353. */
  34354. getDeltaTime(): number;
  34355. private _measureFps;
  34356. /** @hidden */
  34357. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34358. /**
  34359. * Update a dynamic index buffer
  34360. * @param indexBuffer defines the target index buffer
  34361. * @param indices defines the data to update
  34362. * @param offset defines the offset in the target index buffer where update should start
  34363. */
  34364. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34365. /**
  34366. * Updates the sample count of a render target texture
  34367. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34368. * @param texture defines the texture to update
  34369. * @param samples defines the sample count to set
  34370. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34371. */
  34372. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34373. /**
  34374. * Updates a depth texture Comparison Mode and Function.
  34375. * If the comparison Function is equal to 0, the mode will be set to none.
  34376. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34377. * @param texture The texture to set the comparison function for
  34378. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34379. */
  34380. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34381. /**
  34382. * Creates a webGL buffer to use with instanciation
  34383. * @param capacity defines the size of the buffer
  34384. * @returns the webGL buffer
  34385. */
  34386. createInstancesBuffer(capacity: number): DataBuffer;
  34387. /**
  34388. * Delete a webGL buffer used with instanciation
  34389. * @param buffer defines the webGL buffer to delete
  34390. */
  34391. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34392. private _clientWaitAsync;
  34393. /** @hidden */
  34394. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34395. /** @hidden */
  34396. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34397. dispose(): void;
  34398. private _disableTouchAction;
  34399. /**
  34400. * Display the loading screen
  34401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34402. */
  34403. displayLoadingUI(): void;
  34404. /**
  34405. * Hide the loading screen
  34406. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34407. */
  34408. hideLoadingUI(): void;
  34409. /**
  34410. * Gets the current loading screen object
  34411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34412. */
  34413. get loadingScreen(): ILoadingScreen;
  34414. /**
  34415. * Sets the current loading screen object
  34416. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34417. */
  34418. set loadingScreen(loadingScreen: ILoadingScreen);
  34419. /**
  34420. * Sets the current loading screen text
  34421. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34422. */
  34423. set loadingUIText(text: string);
  34424. /**
  34425. * Sets the current loading screen background color
  34426. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34427. */
  34428. set loadingUIBackgroundColor(color: string);
  34429. /** Pointerlock and fullscreen */
  34430. /**
  34431. * Ask the browser to promote the current element to pointerlock mode
  34432. * @param element defines the DOM element to promote
  34433. */
  34434. static _RequestPointerlock(element: HTMLElement): void;
  34435. /**
  34436. * Asks the browser to exit pointerlock mode
  34437. */
  34438. static _ExitPointerlock(): void;
  34439. /**
  34440. * Ask the browser to promote the current element to fullscreen rendering mode
  34441. * @param element defines the DOM element to promote
  34442. */
  34443. static _RequestFullscreen(element: HTMLElement): void;
  34444. /**
  34445. * Asks the browser to exit fullscreen mode
  34446. */
  34447. static _ExitFullscreen(): void;
  34448. }
  34449. }
  34450. declare module BABYLON {
  34451. /**
  34452. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34453. * during the life time of the application.
  34454. */
  34455. export class EngineStore {
  34456. /** Gets the list of created engines */
  34457. static Instances: Engine[];
  34458. /** @hidden */
  34459. static _LastCreatedScene: Nullable<Scene>;
  34460. /**
  34461. * Gets the latest created engine
  34462. */
  34463. static get LastCreatedEngine(): Nullable<Engine>;
  34464. /**
  34465. * Gets the latest created scene
  34466. */
  34467. static get LastCreatedScene(): Nullable<Scene>;
  34468. /**
  34469. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34470. * @ignorenaming
  34471. */
  34472. static UseFallbackTexture: boolean;
  34473. /**
  34474. * Texture content used if a texture cannot loaded
  34475. * @ignorenaming
  34476. */
  34477. static FallbackTexture: string;
  34478. }
  34479. }
  34480. declare module BABYLON {
  34481. /**
  34482. * Helper class that provides a small promise polyfill
  34483. */
  34484. export class PromisePolyfill {
  34485. /**
  34486. * Static function used to check if the polyfill is required
  34487. * If this is the case then the function will inject the polyfill to window.Promise
  34488. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34489. */
  34490. static Apply(force?: boolean): void;
  34491. }
  34492. }
  34493. declare module BABYLON {
  34494. /**
  34495. * Interface for screenshot methods with describe argument called `size` as object with options
  34496. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34497. */
  34498. export interface IScreenshotSize {
  34499. /**
  34500. * number in pixels for canvas height
  34501. */
  34502. height?: number;
  34503. /**
  34504. * multiplier allowing render at a higher or lower resolution
  34505. * If value is defined then height and width will be ignored and taken from camera
  34506. */
  34507. precision?: number;
  34508. /**
  34509. * number in pixels for canvas width
  34510. */
  34511. width?: number;
  34512. }
  34513. }
  34514. declare module BABYLON {
  34515. interface IColor4Like {
  34516. r: float;
  34517. g: float;
  34518. b: float;
  34519. a: float;
  34520. }
  34521. /**
  34522. * Class containing a set of static utilities functions
  34523. */
  34524. export class Tools {
  34525. /**
  34526. * Gets or sets the base URL to use to load assets
  34527. */
  34528. static get BaseUrl(): string;
  34529. static set BaseUrl(value: string);
  34530. /**
  34531. * Enable/Disable Custom HTTP Request Headers globally.
  34532. * default = false
  34533. * @see CustomRequestHeaders
  34534. */
  34535. static UseCustomRequestHeaders: boolean;
  34536. /**
  34537. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34538. * i.e. when loading files, where the server/service expects an Authorization header
  34539. */
  34540. static CustomRequestHeaders: {
  34541. [key: string]: string;
  34542. };
  34543. /**
  34544. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34545. */
  34546. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34547. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34548. /**
  34549. * Default behaviour for cors in the application.
  34550. * It can be a string if the expected behavior is identical in the entire app.
  34551. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34552. */
  34553. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34554. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34555. /**
  34556. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34557. * @ignorenaming
  34558. */
  34559. static get UseFallbackTexture(): boolean;
  34560. static set UseFallbackTexture(value: boolean);
  34561. /**
  34562. * Use this object to register external classes like custom textures or material
  34563. * to allow the laoders to instantiate them
  34564. */
  34565. static get RegisteredExternalClasses(): {
  34566. [key: string]: Object;
  34567. };
  34568. static set RegisteredExternalClasses(classes: {
  34569. [key: string]: Object;
  34570. });
  34571. /**
  34572. * Texture content used if a texture cannot loaded
  34573. * @ignorenaming
  34574. */
  34575. static get fallbackTexture(): string;
  34576. static set fallbackTexture(value: string);
  34577. /**
  34578. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34579. * @param u defines the coordinate on X axis
  34580. * @param v defines the coordinate on Y axis
  34581. * @param width defines the width of the source data
  34582. * @param height defines the height of the source data
  34583. * @param pixels defines the source byte array
  34584. * @param color defines the output color
  34585. */
  34586. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34587. /**
  34588. * Interpolates between a and b via alpha
  34589. * @param a The lower value (returned when alpha = 0)
  34590. * @param b The upper value (returned when alpha = 1)
  34591. * @param alpha The interpolation-factor
  34592. * @return The mixed value
  34593. */
  34594. static Mix(a: number, b: number, alpha: number): number;
  34595. /**
  34596. * Tries to instantiate a new object from a given class name
  34597. * @param className defines the class name to instantiate
  34598. * @returns the new object or null if the system was not able to do the instantiation
  34599. */
  34600. static Instantiate(className: string): any;
  34601. /**
  34602. * Provides a slice function that will work even on IE
  34603. * @param data defines the array to slice
  34604. * @param start defines the start of the data (optional)
  34605. * @param end defines the end of the data (optional)
  34606. * @returns the new sliced array
  34607. */
  34608. static Slice<T>(data: T, start?: number, end?: number): T;
  34609. /**
  34610. * Polyfill for setImmediate
  34611. * @param action defines the action to execute after the current execution block
  34612. */
  34613. static SetImmediate(action: () => void): void;
  34614. /**
  34615. * Function indicating if a number is an exponent of 2
  34616. * @param value defines the value to test
  34617. * @returns true if the value is an exponent of 2
  34618. */
  34619. static IsExponentOfTwo(value: number): boolean;
  34620. private static _tmpFloatArray;
  34621. /**
  34622. * Returns the nearest 32-bit single precision float representation of a Number
  34623. * @param value A Number. If the parameter is of a different type, it will get converted
  34624. * to a number or to NaN if it cannot be converted
  34625. * @returns number
  34626. */
  34627. static FloatRound(value: number): number;
  34628. /**
  34629. * Extracts the filename from a path
  34630. * @param path defines the path to use
  34631. * @returns the filename
  34632. */
  34633. static GetFilename(path: string): string;
  34634. /**
  34635. * Extracts the "folder" part of a path (everything before the filename).
  34636. * @param uri The URI to extract the info from
  34637. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34638. * @returns The "folder" part of the path
  34639. */
  34640. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34641. /**
  34642. * Extracts text content from a DOM element hierarchy
  34643. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34644. */
  34645. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34646. /**
  34647. * Convert an angle in radians to degrees
  34648. * @param angle defines the angle to convert
  34649. * @returns the angle in degrees
  34650. */
  34651. static ToDegrees(angle: number): number;
  34652. /**
  34653. * Convert an angle in degrees to radians
  34654. * @param angle defines the angle to convert
  34655. * @returns the angle in radians
  34656. */
  34657. static ToRadians(angle: number): number;
  34658. /**
  34659. * Returns an array if obj is not an array
  34660. * @param obj defines the object to evaluate as an array
  34661. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34662. * @returns either obj directly if obj is an array or a new array containing obj
  34663. */
  34664. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34665. /**
  34666. * Gets the pointer prefix to use
  34667. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34668. */
  34669. static GetPointerPrefix(): string;
  34670. /**
  34671. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34672. * @param url define the url we are trying
  34673. * @param element define the dom element where to configure the cors policy
  34674. */
  34675. static SetCorsBehavior(url: string | string[], element: {
  34676. crossOrigin: string | null;
  34677. }): void;
  34678. /**
  34679. * Removes unwanted characters from an url
  34680. * @param url defines the url to clean
  34681. * @returns the cleaned url
  34682. */
  34683. static CleanUrl(url: string): string;
  34684. /**
  34685. * Gets or sets a function used to pre-process url before using them to load assets
  34686. */
  34687. static get PreprocessUrl(): (url: string) => string;
  34688. static set PreprocessUrl(processor: (url: string) => string);
  34689. /**
  34690. * Loads an image as an HTMLImageElement.
  34691. * @param input url string, ArrayBuffer, or Blob to load
  34692. * @param onLoad callback called when the image successfully loads
  34693. * @param onError callback called when the image fails to load
  34694. * @param offlineProvider offline provider for caching
  34695. * @param mimeType optional mime type
  34696. * @returns the HTMLImageElement of the loaded image
  34697. */
  34698. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34699. /**
  34700. * Loads a file from a url
  34701. * @param url url string, ArrayBuffer, or Blob to load
  34702. * @param onSuccess callback called when the file successfully loads
  34703. * @param onProgress callback called while file is loading (if the server supports this mode)
  34704. * @param offlineProvider defines the offline provider for caching
  34705. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34706. * @param onError callback called when the file fails to load
  34707. * @returns a file request object
  34708. */
  34709. 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;
  34710. /**
  34711. * Loads a file from a url
  34712. * @param url the file url to load
  34713. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34714. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34715. */
  34716. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34717. /**
  34718. * Load a script (identified by an url). When the url returns, the
  34719. * content of this file is added into a new script element, attached to the DOM (body element)
  34720. * @param scriptUrl defines the url of the script to laod
  34721. * @param onSuccess defines the callback called when the script is loaded
  34722. * @param onError defines the callback to call if an error occurs
  34723. * @param scriptId defines the id of the script element
  34724. */
  34725. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34726. /**
  34727. * Load an asynchronous script (identified by an url). When the url returns, the
  34728. * content of this file is added into a new script element, attached to the DOM (body element)
  34729. * @param scriptUrl defines the url of the script to laod
  34730. * @param scriptId defines the id of the script element
  34731. * @returns a promise request object
  34732. */
  34733. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34734. /**
  34735. * Loads a file from a blob
  34736. * @param fileToLoad defines the blob to use
  34737. * @param callback defines the callback to call when data is loaded
  34738. * @param progressCallback defines the callback to call during loading process
  34739. * @returns a file request object
  34740. */
  34741. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34742. /**
  34743. * Reads a file from a File object
  34744. * @param file defines the file to load
  34745. * @param onSuccess defines the callback to call when data is loaded
  34746. * @param onProgress defines the callback to call during loading process
  34747. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34748. * @param onError defines the callback to call when an error occurs
  34749. * @returns a file request object
  34750. */
  34751. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34752. /**
  34753. * Creates a data url from a given string content
  34754. * @param content defines the content to convert
  34755. * @returns the new data url link
  34756. */
  34757. static FileAsURL(content: string): string;
  34758. /**
  34759. * Format the given number to a specific decimal format
  34760. * @param value defines the number to format
  34761. * @param decimals defines the number of decimals to use
  34762. * @returns the formatted string
  34763. */
  34764. static Format(value: number, decimals?: number): string;
  34765. /**
  34766. * Tries to copy an object by duplicating every property
  34767. * @param source defines the source object
  34768. * @param destination defines the target object
  34769. * @param doNotCopyList defines a list of properties to avoid
  34770. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34771. */
  34772. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34773. /**
  34774. * Gets a boolean indicating if the given object has no own property
  34775. * @param obj defines the object to test
  34776. * @returns true if object has no own property
  34777. */
  34778. static IsEmpty(obj: any): boolean;
  34779. /**
  34780. * Function used to register events at window level
  34781. * @param windowElement defines the Window object to use
  34782. * @param events defines the events to register
  34783. */
  34784. static RegisterTopRootEvents(windowElement: Window, events: {
  34785. name: string;
  34786. handler: Nullable<(e: FocusEvent) => any>;
  34787. }[]): void;
  34788. /**
  34789. * Function used to unregister events from window level
  34790. * @param windowElement defines the Window object to use
  34791. * @param events defines the events to unregister
  34792. */
  34793. static UnregisterTopRootEvents(windowElement: Window, events: {
  34794. name: string;
  34795. handler: Nullable<(e: FocusEvent) => any>;
  34796. }[]): void;
  34797. /**
  34798. * @ignore
  34799. */
  34800. static _ScreenshotCanvas: HTMLCanvasElement;
  34801. /**
  34802. * Dumps the current bound framebuffer
  34803. * @param width defines the rendering width
  34804. * @param height defines the rendering height
  34805. * @param engine defines the hosting engine
  34806. * @param successCallback defines the callback triggered once the data are available
  34807. * @param mimeType defines the mime type of the result
  34808. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34809. */
  34810. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34811. /**
  34812. * Converts the canvas data to blob.
  34813. * This acts as a polyfill for browsers not supporting the to blob function.
  34814. * @param canvas Defines the canvas to extract the data from
  34815. * @param successCallback Defines the callback triggered once the data are available
  34816. * @param mimeType Defines the mime type of the result
  34817. */
  34818. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34819. /**
  34820. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34821. * @param successCallback defines the callback triggered once the data are available
  34822. * @param mimeType defines the mime type of the result
  34823. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34824. */
  34825. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34826. /**
  34827. * Downloads a blob in the browser
  34828. * @param blob defines the blob to download
  34829. * @param fileName defines the name of the downloaded file
  34830. */
  34831. static Download(blob: Blob, fileName: string): void;
  34832. /**
  34833. * Captures a screenshot of the current rendering
  34834. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34835. * @param engine defines the rendering engine
  34836. * @param camera defines the source camera
  34837. * @param size This parameter can be set to a single number or to an object with the
  34838. * following (optional) properties: precision, width, height. If a single number is passed,
  34839. * it will be used for both width and height. If an object is passed, the screenshot size
  34840. * will be derived from the parameters. The precision property is a multiplier allowing
  34841. * rendering at a higher or lower resolution
  34842. * @param successCallback defines the callback receives a single parameter which contains the
  34843. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34844. * src parameter of an <img> to display it
  34845. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34846. * Check your browser for supported MIME types
  34847. */
  34848. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34849. /**
  34850. * Captures a screenshot of the current rendering
  34851. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34852. * @param engine defines the rendering engine
  34853. * @param camera defines the source camera
  34854. * @param size This parameter can be set to a single number or to an object with the
  34855. * following (optional) properties: precision, width, height. If a single number is passed,
  34856. * it will be used for both width and height. If an object is passed, the screenshot size
  34857. * will be derived from the parameters. The precision property is a multiplier allowing
  34858. * rendering at a higher or lower resolution
  34859. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34860. * Check your browser for supported MIME types
  34861. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34862. * to the src parameter of an <img> to display it
  34863. */
  34864. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34865. /**
  34866. * Generates an image screenshot from the specified camera.
  34867. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34868. * @param engine The engine to use for rendering
  34869. * @param camera The camera to use for rendering
  34870. * @param size This parameter can be set to a single number or to an object with the
  34871. * following (optional) properties: precision, width, height. If a single number is passed,
  34872. * it will be used for both width and height. If an object is passed, the screenshot size
  34873. * will be derived from the parameters. The precision property is a multiplier allowing
  34874. * rendering at a higher or lower resolution
  34875. * @param successCallback The callback receives a single parameter which contains the
  34876. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34877. * src parameter of an <img> to display it
  34878. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34879. * Check your browser for supported MIME types
  34880. * @param samples Texture samples (default: 1)
  34881. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34882. * @param fileName A name for for the downloaded file.
  34883. */
  34884. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34885. /**
  34886. * Generates an image screenshot from the specified camera.
  34887. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34888. * @param engine The engine to use for rendering
  34889. * @param camera The camera to use for rendering
  34890. * @param size This parameter can be set to a single number or to an object with the
  34891. * following (optional) properties: precision, width, height. If a single number is passed,
  34892. * it will be used for both width and height. If an object is passed, the screenshot size
  34893. * will be derived from the parameters. The precision property is a multiplier allowing
  34894. * rendering at a higher or lower resolution
  34895. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34896. * Check your browser for supported MIME types
  34897. * @param samples Texture samples (default: 1)
  34898. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34899. * @param fileName A name for for the downloaded file.
  34900. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34901. * to the src parameter of an <img> to display it
  34902. */
  34903. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34904. /**
  34905. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34906. * Be aware Math.random() could cause collisions, but:
  34907. * "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"
  34908. * @returns a pseudo random id
  34909. */
  34910. static RandomId(): string;
  34911. /**
  34912. * Test if the given uri is a base64 string
  34913. * @param uri The uri to test
  34914. * @return True if the uri is a base64 string or false otherwise
  34915. */
  34916. static IsBase64(uri: string): boolean;
  34917. /**
  34918. * Decode the given base64 uri.
  34919. * @param uri The uri to decode
  34920. * @return The decoded base64 data.
  34921. */
  34922. static DecodeBase64(uri: string): ArrayBuffer;
  34923. /**
  34924. * Gets the absolute url.
  34925. * @param url the input url
  34926. * @return the absolute url
  34927. */
  34928. static GetAbsoluteUrl(url: string): string;
  34929. /**
  34930. * No log
  34931. */
  34932. static readonly NoneLogLevel: number;
  34933. /**
  34934. * Only message logs
  34935. */
  34936. static readonly MessageLogLevel: number;
  34937. /**
  34938. * Only warning logs
  34939. */
  34940. static readonly WarningLogLevel: number;
  34941. /**
  34942. * Only error logs
  34943. */
  34944. static readonly ErrorLogLevel: number;
  34945. /**
  34946. * All logs
  34947. */
  34948. static readonly AllLogLevel: number;
  34949. /**
  34950. * Gets a value indicating the number of loading errors
  34951. * @ignorenaming
  34952. */
  34953. static get errorsCount(): number;
  34954. /**
  34955. * Callback called when a new log is added
  34956. */
  34957. static OnNewCacheEntry: (entry: string) => void;
  34958. /**
  34959. * Log a message to the console
  34960. * @param message defines the message to log
  34961. */
  34962. static Log(message: string): void;
  34963. /**
  34964. * Write a warning message to the console
  34965. * @param message defines the message to log
  34966. */
  34967. static Warn(message: string): void;
  34968. /**
  34969. * Write an error message to the console
  34970. * @param message defines the message to log
  34971. */
  34972. static Error(message: string): void;
  34973. /**
  34974. * Gets current log cache (list of logs)
  34975. */
  34976. static get LogCache(): string;
  34977. /**
  34978. * Clears the log cache
  34979. */
  34980. static ClearLogCache(): void;
  34981. /**
  34982. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34983. */
  34984. static set LogLevels(level: number);
  34985. /**
  34986. * Checks if the window object exists
  34987. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34988. */
  34989. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34990. /**
  34991. * No performance log
  34992. */
  34993. static readonly PerformanceNoneLogLevel: number;
  34994. /**
  34995. * Use user marks to log performance
  34996. */
  34997. static readonly PerformanceUserMarkLogLevel: number;
  34998. /**
  34999. * Log performance to the console
  35000. */
  35001. static readonly PerformanceConsoleLogLevel: number;
  35002. private static _performance;
  35003. /**
  35004. * Sets the current performance log level
  35005. */
  35006. static set PerformanceLogLevel(level: number);
  35007. private static _StartPerformanceCounterDisabled;
  35008. private static _EndPerformanceCounterDisabled;
  35009. private static _StartUserMark;
  35010. private static _EndUserMark;
  35011. private static _StartPerformanceConsole;
  35012. private static _EndPerformanceConsole;
  35013. /**
  35014. * Starts a performance counter
  35015. */
  35016. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35017. /**
  35018. * Ends a specific performance coutner
  35019. */
  35020. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35021. /**
  35022. * Gets either window.performance.now() if supported or Date.now() else
  35023. */
  35024. static get Now(): number;
  35025. /**
  35026. * This method will return the name of the class used to create the instance of the given object.
  35027. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35028. * @param object the object to get the class name from
  35029. * @param isType defines if the object is actually a type
  35030. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35031. */
  35032. static GetClassName(object: any, isType?: boolean): string;
  35033. /**
  35034. * Gets the first element of an array satisfying a given predicate
  35035. * @param array defines the array to browse
  35036. * @param predicate defines the predicate to use
  35037. * @returns null if not found or the element
  35038. */
  35039. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35040. /**
  35041. * This method will return the name of the full name of the class, including its owning module (if any).
  35042. * 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).
  35043. * @param object the object to get the class name from
  35044. * @param isType defines if the object is actually a type
  35045. * @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.
  35046. * @ignorenaming
  35047. */
  35048. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35049. /**
  35050. * Returns a promise that resolves after the given amount of time.
  35051. * @param delay Number of milliseconds to delay
  35052. * @returns Promise that resolves after the given amount of time
  35053. */
  35054. static DelayAsync(delay: number): Promise<void>;
  35055. /**
  35056. * Utility function to detect if the current user agent is Safari
  35057. * @returns whether or not the current user agent is safari
  35058. */
  35059. static IsSafari(): boolean;
  35060. }
  35061. /**
  35062. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35063. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35064. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35065. * @param name The name of the class, case should be preserved
  35066. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35067. */
  35068. export function className(name: string, module?: string): (target: Object) => void;
  35069. /**
  35070. * An implementation of a loop for asynchronous functions.
  35071. */
  35072. export class AsyncLoop {
  35073. /**
  35074. * Defines the number of iterations for the loop
  35075. */
  35076. iterations: number;
  35077. /**
  35078. * Defines the current index of the loop.
  35079. */
  35080. index: number;
  35081. private _done;
  35082. private _fn;
  35083. private _successCallback;
  35084. /**
  35085. * Constructor.
  35086. * @param iterations the number of iterations.
  35087. * @param func the function to run each iteration
  35088. * @param successCallback the callback that will be called upon succesful execution
  35089. * @param offset starting offset.
  35090. */
  35091. constructor(
  35092. /**
  35093. * Defines the number of iterations for the loop
  35094. */
  35095. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35096. /**
  35097. * Execute the next iteration. Must be called after the last iteration was finished.
  35098. */
  35099. executeNext(): void;
  35100. /**
  35101. * Break the loop and run the success callback.
  35102. */
  35103. breakLoop(): void;
  35104. /**
  35105. * Create and run an async loop.
  35106. * @param iterations the number of iterations.
  35107. * @param fn the function to run each iteration
  35108. * @param successCallback the callback that will be called upon succesful execution
  35109. * @param offset starting offset.
  35110. * @returns the created async loop object
  35111. */
  35112. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35113. /**
  35114. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35115. * @param iterations total number of iterations
  35116. * @param syncedIterations number of synchronous iterations in each async iteration.
  35117. * @param fn the function to call each iteration.
  35118. * @param callback a success call back that will be called when iterating stops.
  35119. * @param breakFunction a break condition (optional)
  35120. * @param timeout timeout settings for the setTimeout function. default - 0.
  35121. * @returns the created async loop object
  35122. */
  35123. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35124. }
  35125. }
  35126. declare module BABYLON {
  35127. /**
  35128. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35129. * The underlying implementation relies on an associative array to ensure the best performances.
  35130. * The value can be anything including 'null' but except 'undefined'
  35131. */
  35132. export class StringDictionary<T> {
  35133. /**
  35134. * This will clear this dictionary and copy the content from the 'source' one.
  35135. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35136. * @param source the dictionary to take the content from and copy to this dictionary
  35137. */
  35138. copyFrom(source: StringDictionary<T>): void;
  35139. /**
  35140. * Get a value based from its key
  35141. * @param key the given key to get the matching value from
  35142. * @return the value if found, otherwise undefined is returned
  35143. */
  35144. get(key: string): T | undefined;
  35145. /**
  35146. * Get a value from its key or add it if it doesn't exist.
  35147. * This method will ensure you that a given key/data will be present in the dictionary.
  35148. * @param key the given key to get the matching value from
  35149. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35150. * The factory will only be invoked if there's no data for the given key.
  35151. * @return the value corresponding to the key.
  35152. */
  35153. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35154. /**
  35155. * Get a value from its key if present in the dictionary otherwise add it
  35156. * @param key the key to get the value from
  35157. * @param val if there's no such key/value pair in the dictionary add it with this value
  35158. * @return the value corresponding to the key
  35159. */
  35160. getOrAdd(key: string, val: T): T;
  35161. /**
  35162. * Check if there's a given key in the dictionary
  35163. * @param key the key to check for
  35164. * @return true if the key is present, false otherwise
  35165. */
  35166. contains(key: string): boolean;
  35167. /**
  35168. * Add a new key and its corresponding value
  35169. * @param key the key to add
  35170. * @param value the value corresponding to the key
  35171. * @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
  35172. */
  35173. add(key: string, value: T): boolean;
  35174. /**
  35175. * Update a specific value associated to a key
  35176. * @param key defines the key to use
  35177. * @param value defines the value to store
  35178. * @returns true if the value was updated (or false if the key was not found)
  35179. */
  35180. set(key: string, value: T): boolean;
  35181. /**
  35182. * Get the element of the given key and remove it from the dictionary
  35183. * @param key defines the key to search
  35184. * @returns the value associated with the key or null if not found
  35185. */
  35186. getAndRemove(key: string): Nullable<T>;
  35187. /**
  35188. * Remove a key/value from the dictionary.
  35189. * @param key the key to remove
  35190. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35191. */
  35192. remove(key: string): boolean;
  35193. /**
  35194. * Clear the whole content of the dictionary
  35195. */
  35196. clear(): void;
  35197. /**
  35198. * Gets the current count
  35199. */
  35200. get count(): number;
  35201. /**
  35202. * Execute a callback on each key/val of the dictionary.
  35203. * Note that you can remove any element in this dictionary in the callback implementation
  35204. * @param callback the callback to execute on a given key/value pair
  35205. */
  35206. forEach(callback: (key: string, val: T) => void): void;
  35207. /**
  35208. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35209. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35210. * Note that you can remove any element in this dictionary in the callback implementation
  35211. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35212. * @returns the first item
  35213. */
  35214. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35215. private _count;
  35216. private _data;
  35217. }
  35218. }
  35219. declare module BABYLON {
  35220. /** @hidden */
  35221. export interface ICollisionCoordinator {
  35222. createCollider(): Collider;
  35223. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35224. init(scene: Scene): void;
  35225. }
  35226. /** @hidden */
  35227. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35228. private _scene;
  35229. private _scaledPosition;
  35230. private _scaledVelocity;
  35231. private _finalPosition;
  35232. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35233. createCollider(): Collider;
  35234. init(scene: Scene): void;
  35235. private _collideWithWorld;
  35236. }
  35237. }
  35238. declare module BABYLON {
  35239. /**
  35240. * Class used to manage all inputs for the scene.
  35241. */
  35242. export class InputManager {
  35243. /** The distance in pixel that you have to move to prevent some events */
  35244. static DragMovementThreshold: number;
  35245. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35246. static LongPressDelay: number;
  35247. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35248. static DoubleClickDelay: number;
  35249. /** If you need to check double click without raising a single click at first click, enable this flag */
  35250. static ExclusiveDoubleClickMode: boolean;
  35251. private _wheelEventName;
  35252. private _onPointerMove;
  35253. private _onPointerDown;
  35254. private _onPointerUp;
  35255. private _initClickEvent;
  35256. private _initActionManager;
  35257. private _delayedSimpleClick;
  35258. private _delayedSimpleClickTimeout;
  35259. private _previousDelayedSimpleClickTimeout;
  35260. private _meshPickProceed;
  35261. private _previousButtonPressed;
  35262. private _currentPickResult;
  35263. private _previousPickResult;
  35264. private _totalPointersPressed;
  35265. private _doubleClickOccured;
  35266. private _pointerOverMesh;
  35267. private _pickedDownMesh;
  35268. private _pickedUpMesh;
  35269. private _pointerX;
  35270. private _pointerY;
  35271. private _unTranslatedPointerX;
  35272. private _unTranslatedPointerY;
  35273. private _startingPointerPosition;
  35274. private _previousStartingPointerPosition;
  35275. private _startingPointerTime;
  35276. private _previousStartingPointerTime;
  35277. private _pointerCaptures;
  35278. private _onKeyDown;
  35279. private _onKeyUp;
  35280. private _onCanvasFocusObserver;
  35281. private _onCanvasBlurObserver;
  35282. private _scene;
  35283. /**
  35284. * Creates a new InputManager
  35285. * @param scene defines the hosting scene
  35286. */
  35287. constructor(scene: Scene);
  35288. /**
  35289. * Gets the mesh that is currently under the pointer
  35290. */
  35291. get meshUnderPointer(): Nullable<AbstractMesh>;
  35292. /**
  35293. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35294. */
  35295. get unTranslatedPointer(): Vector2;
  35296. /**
  35297. * Gets or sets the current on-screen X position of the pointer
  35298. */
  35299. get pointerX(): number;
  35300. set pointerX(value: number);
  35301. /**
  35302. * Gets or sets the current on-screen Y position of the pointer
  35303. */
  35304. get pointerY(): number;
  35305. set pointerY(value: number);
  35306. private _updatePointerPosition;
  35307. private _processPointerMove;
  35308. private _setRayOnPointerInfo;
  35309. private _checkPrePointerObservable;
  35310. /**
  35311. * Use this method to simulate a pointer move on a mesh
  35312. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35313. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35314. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35315. */
  35316. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35317. /**
  35318. * Use this method to simulate a pointer down on a mesh
  35319. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35320. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35321. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35322. */
  35323. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35324. private _processPointerDown;
  35325. /** @hidden */
  35326. _isPointerSwiping(): boolean;
  35327. /**
  35328. * Use this method to simulate a pointer up on a mesh
  35329. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35330. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35331. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35332. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35333. */
  35334. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35335. private _processPointerUp;
  35336. /**
  35337. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35338. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35339. * @returns true if the pointer was captured
  35340. */
  35341. isPointerCaptured(pointerId?: number): boolean;
  35342. /**
  35343. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35344. * @param attachUp defines if you want to attach events to pointerup
  35345. * @param attachDown defines if you want to attach events to pointerdown
  35346. * @param attachMove defines if you want to attach events to pointermove
  35347. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35348. */
  35349. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35350. /**
  35351. * Detaches all event handlers
  35352. */
  35353. detachControl(): void;
  35354. /**
  35355. * Force the value of meshUnderPointer
  35356. * @param mesh defines the mesh to use
  35357. */
  35358. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35359. /**
  35360. * Gets the mesh under the pointer
  35361. * @returns a Mesh or null if no mesh is under the pointer
  35362. */
  35363. getPointerOverMesh(): Nullable<AbstractMesh>;
  35364. }
  35365. }
  35366. declare module BABYLON {
  35367. /**
  35368. * Helper class used to generate session unique ID
  35369. */
  35370. export class UniqueIdGenerator {
  35371. private static _UniqueIdCounter;
  35372. /**
  35373. * Gets an unique (relatively to the current scene) Id
  35374. */
  35375. static get UniqueId(): number;
  35376. }
  35377. }
  35378. declare module BABYLON {
  35379. /**
  35380. * This class defines the direct association between an animation and a target
  35381. */
  35382. export class TargetedAnimation {
  35383. /**
  35384. * Animation to perform
  35385. */
  35386. animation: Animation;
  35387. /**
  35388. * Target to animate
  35389. */
  35390. target: any;
  35391. /**
  35392. * Serialize the object
  35393. * @returns the JSON object representing the current entity
  35394. */
  35395. serialize(): any;
  35396. }
  35397. /**
  35398. * Use this class to create coordinated animations on multiple targets
  35399. */
  35400. export class AnimationGroup implements IDisposable {
  35401. /** The name of the animation group */
  35402. name: string;
  35403. private _scene;
  35404. private _targetedAnimations;
  35405. private _animatables;
  35406. private _from;
  35407. private _to;
  35408. private _isStarted;
  35409. private _isPaused;
  35410. private _speedRatio;
  35411. private _loopAnimation;
  35412. private _isAdditive;
  35413. /**
  35414. * Gets or sets the unique id of the node
  35415. */
  35416. uniqueId: number;
  35417. /**
  35418. * This observable will notify when one animation have ended
  35419. */
  35420. onAnimationEndObservable: Observable<TargetedAnimation>;
  35421. /**
  35422. * Observer raised when one animation loops
  35423. */
  35424. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35425. /**
  35426. * Observer raised when all animations have looped
  35427. */
  35428. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35429. /**
  35430. * This observable will notify when all animations have ended.
  35431. */
  35432. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35433. /**
  35434. * This observable will notify when all animations have paused.
  35435. */
  35436. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35437. /**
  35438. * This observable will notify when all animations are playing.
  35439. */
  35440. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35441. /**
  35442. * Gets the first frame
  35443. */
  35444. get from(): number;
  35445. /**
  35446. * Gets the last frame
  35447. */
  35448. get to(): number;
  35449. /**
  35450. * Define if the animations are started
  35451. */
  35452. get isStarted(): boolean;
  35453. /**
  35454. * Gets a value indicating that the current group is playing
  35455. */
  35456. get isPlaying(): boolean;
  35457. /**
  35458. * Gets or sets the speed ratio to use for all animations
  35459. */
  35460. get speedRatio(): number;
  35461. /**
  35462. * Gets or sets the speed ratio to use for all animations
  35463. */
  35464. set speedRatio(value: number);
  35465. /**
  35466. * Gets or sets if all animations should loop or not
  35467. */
  35468. get loopAnimation(): boolean;
  35469. set loopAnimation(value: boolean);
  35470. /**
  35471. * Gets or sets if all animations should be evaluated additively
  35472. */
  35473. get isAdditive(): boolean;
  35474. set isAdditive(value: boolean);
  35475. /**
  35476. * Gets the targeted animations for this animation group
  35477. */
  35478. get targetedAnimations(): Array<TargetedAnimation>;
  35479. /**
  35480. * returning the list of animatables controlled by this animation group.
  35481. */
  35482. get animatables(): Array<Animatable>;
  35483. /**
  35484. * Instantiates a new Animation Group.
  35485. * This helps managing several animations at once.
  35486. * @see http://doc.babylonjs.com/how_to/group
  35487. * @param name Defines the name of the group
  35488. * @param scene Defines the scene the group belongs to
  35489. */
  35490. constructor(
  35491. /** The name of the animation group */
  35492. name: string, scene?: Nullable<Scene>);
  35493. /**
  35494. * Add an animation (with its target) in the group
  35495. * @param animation defines the animation we want to add
  35496. * @param target defines the target of the animation
  35497. * @returns the TargetedAnimation object
  35498. */
  35499. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35500. /**
  35501. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35502. * It can add constant keys at begin or end
  35503. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35504. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35505. * @returns the animation group
  35506. */
  35507. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35508. private _animationLoopCount;
  35509. private _animationLoopFlags;
  35510. private _processLoop;
  35511. /**
  35512. * Start all animations on given targets
  35513. * @param loop defines if animations must loop
  35514. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35515. * @param from defines the from key (optional)
  35516. * @param to defines the to key (optional)
  35517. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35518. * @returns the current animation group
  35519. */
  35520. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35521. /**
  35522. * Pause all animations
  35523. * @returns the animation group
  35524. */
  35525. pause(): AnimationGroup;
  35526. /**
  35527. * Play all animations to initial state
  35528. * This function will start() the animations if they were not started or will restart() them if they were paused
  35529. * @param loop defines if animations must loop
  35530. * @returns the animation group
  35531. */
  35532. play(loop?: boolean): AnimationGroup;
  35533. /**
  35534. * Reset all animations to initial state
  35535. * @returns the animation group
  35536. */
  35537. reset(): AnimationGroup;
  35538. /**
  35539. * Restart animations from key 0
  35540. * @returns the animation group
  35541. */
  35542. restart(): AnimationGroup;
  35543. /**
  35544. * Stop all animations
  35545. * @returns the animation group
  35546. */
  35547. stop(): AnimationGroup;
  35548. /**
  35549. * Set animation weight for all animatables
  35550. * @param weight defines the weight to use
  35551. * @return the animationGroup
  35552. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35553. */
  35554. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35555. /**
  35556. * Synchronize and normalize all animatables with a source animatable
  35557. * @param root defines the root animatable to synchronize with
  35558. * @return the animationGroup
  35559. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35560. */
  35561. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35562. /**
  35563. * Goes to a specific frame in this animation group
  35564. * @param frame the frame number to go to
  35565. * @return the animationGroup
  35566. */
  35567. goToFrame(frame: number): AnimationGroup;
  35568. /**
  35569. * Dispose all associated resources
  35570. */
  35571. dispose(): void;
  35572. private _checkAnimationGroupEnded;
  35573. /**
  35574. * Clone the current animation group and returns a copy
  35575. * @param newName defines the name of the new group
  35576. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35577. * @returns the new aniamtion group
  35578. */
  35579. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35580. /**
  35581. * Serializes the animationGroup to an object
  35582. * @returns Serialized object
  35583. */
  35584. serialize(): any;
  35585. /**
  35586. * Returns a new AnimationGroup object parsed from the source provided.
  35587. * @param parsedAnimationGroup defines the source
  35588. * @param scene defines the scene that will receive the animationGroup
  35589. * @returns a new AnimationGroup
  35590. */
  35591. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35592. /**
  35593. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35594. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35595. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35596. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35597. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35598. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35599. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35600. */
  35601. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35602. /**
  35603. * Returns the string "AnimationGroup"
  35604. * @returns "AnimationGroup"
  35605. */
  35606. getClassName(): string;
  35607. /**
  35608. * Creates a detailled string about the object
  35609. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35610. * @returns a string representing the object
  35611. */
  35612. toString(fullDetails?: boolean): string;
  35613. }
  35614. }
  35615. declare module BABYLON {
  35616. /**
  35617. * Define an interface for all classes that will hold resources
  35618. */
  35619. export interface IDisposable {
  35620. /**
  35621. * Releases all held resources
  35622. */
  35623. dispose(): void;
  35624. }
  35625. /** Interface defining initialization parameters for Scene class */
  35626. export interface SceneOptions {
  35627. /**
  35628. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35629. * It will improve performance when the number of geometries becomes important.
  35630. */
  35631. useGeometryUniqueIdsMap?: boolean;
  35632. /**
  35633. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35634. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35635. */
  35636. useMaterialMeshMap?: boolean;
  35637. /**
  35638. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35639. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35640. */
  35641. useClonedMeshMap?: boolean;
  35642. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35643. virtual?: boolean;
  35644. }
  35645. /**
  35646. * Represents a scene to be rendered by the engine.
  35647. * @see http://doc.babylonjs.com/features/scene
  35648. */
  35649. export class Scene extends AbstractScene implements IAnimatable {
  35650. /** The fog is deactivated */
  35651. static readonly FOGMODE_NONE: number;
  35652. /** The fog density is following an exponential function */
  35653. static readonly FOGMODE_EXP: number;
  35654. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35655. static readonly FOGMODE_EXP2: number;
  35656. /** The fog density is following a linear function. */
  35657. static readonly FOGMODE_LINEAR: number;
  35658. /**
  35659. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35661. */
  35662. static MinDeltaTime: number;
  35663. /**
  35664. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35665. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35666. */
  35667. static MaxDeltaTime: number;
  35668. /**
  35669. * Factory used to create the default material.
  35670. * @param name The name of the material to create
  35671. * @param scene The scene to create the material for
  35672. * @returns The default material
  35673. */
  35674. static DefaultMaterialFactory(scene: Scene): Material;
  35675. /**
  35676. * Factory used to create the a collision coordinator.
  35677. * @returns The collision coordinator
  35678. */
  35679. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35680. /** @hidden */
  35681. _inputManager: InputManager;
  35682. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35683. cameraToUseForPointers: Nullable<Camera>;
  35684. /** @hidden */
  35685. readonly _isScene: boolean;
  35686. /** @hidden */
  35687. _blockEntityCollection: boolean;
  35688. /**
  35689. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35690. */
  35691. autoClear: boolean;
  35692. /**
  35693. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35694. */
  35695. autoClearDepthAndStencil: boolean;
  35696. /**
  35697. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35698. */
  35699. clearColor: Color4;
  35700. /**
  35701. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35702. */
  35703. ambientColor: Color3;
  35704. /**
  35705. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35706. * It should only be one of the following (if not the default embedded one):
  35707. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35708. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35709. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35710. * The material properties need to be setup according to the type of texture in use.
  35711. */
  35712. environmentBRDFTexture: BaseTexture;
  35713. /** @hidden */
  35714. protected _environmentTexture: Nullable<BaseTexture>;
  35715. /**
  35716. * Texture used in all pbr material as the reflection texture.
  35717. * As in the majority of the scene they are the same (exception for multi room and so on),
  35718. * this is easier to reference from here than from all the materials.
  35719. */
  35720. get environmentTexture(): Nullable<BaseTexture>;
  35721. /**
  35722. * Texture used in all pbr material as the reflection texture.
  35723. * As in the majority of the scene they are the same (exception for multi room and so on),
  35724. * this is easier to set here than in all the materials.
  35725. */
  35726. set environmentTexture(value: Nullable<BaseTexture>);
  35727. /** @hidden */
  35728. protected _environmentIntensity: number;
  35729. /**
  35730. * Intensity of the environment in all pbr material.
  35731. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35732. * As in the majority of the scene they are the same (exception for multi room and so on),
  35733. * this is easier to reference from here than from all the materials.
  35734. */
  35735. get environmentIntensity(): number;
  35736. /**
  35737. * Intensity of the environment in all pbr material.
  35738. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35739. * As in the majority of the scene they are the same (exception for multi room and so on),
  35740. * this is easier to set here than in all the materials.
  35741. */
  35742. set environmentIntensity(value: number);
  35743. /** @hidden */
  35744. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35745. /**
  35746. * Default image processing configuration used either in the rendering
  35747. * Forward main pass or through the imageProcessingPostProcess if present.
  35748. * As in the majority of the scene they are the same (exception for multi camera),
  35749. * this is easier to reference from here than from all the materials and post process.
  35750. *
  35751. * No setter as we it is a shared configuration, you can set the values instead.
  35752. */
  35753. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35754. private _forceWireframe;
  35755. /**
  35756. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35757. */
  35758. set forceWireframe(value: boolean);
  35759. get forceWireframe(): boolean;
  35760. private _skipFrustumClipping;
  35761. /**
  35762. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35763. */
  35764. set skipFrustumClipping(value: boolean);
  35765. get skipFrustumClipping(): boolean;
  35766. private _forcePointsCloud;
  35767. /**
  35768. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35769. */
  35770. set forcePointsCloud(value: boolean);
  35771. get forcePointsCloud(): boolean;
  35772. /**
  35773. * Gets or sets the active clipplane 1
  35774. */
  35775. clipPlane: Nullable<Plane>;
  35776. /**
  35777. * Gets or sets the active clipplane 2
  35778. */
  35779. clipPlane2: Nullable<Plane>;
  35780. /**
  35781. * Gets or sets the active clipplane 3
  35782. */
  35783. clipPlane3: Nullable<Plane>;
  35784. /**
  35785. * Gets or sets the active clipplane 4
  35786. */
  35787. clipPlane4: Nullable<Plane>;
  35788. /**
  35789. * Gets or sets the active clipplane 5
  35790. */
  35791. clipPlane5: Nullable<Plane>;
  35792. /**
  35793. * Gets or sets the active clipplane 6
  35794. */
  35795. clipPlane6: Nullable<Plane>;
  35796. /**
  35797. * Gets or sets a boolean indicating if animations are enabled
  35798. */
  35799. animationsEnabled: boolean;
  35800. private _animationPropertiesOverride;
  35801. /**
  35802. * Gets or sets the animation properties override
  35803. */
  35804. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35805. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35806. /**
  35807. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35808. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35809. */
  35810. useConstantAnimationDeltaTime: boolean;
  35811. /**
  35812. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35813. * Please note that it requires to run a ray cast through the scene on every frame
  35814. */
  35815. constantlyUpdateMeshUnderPointer: boolean;
  35816. /**
  35817. * Defines the HTML cursor to use when hovering over interactive elements
  35818. */
  35819. hoverCursor: string;
  35820. /**
  35821. * Defines the HTML default cursor to use (empty by default)
  35822. */
  35823. defaultCursor: string;
  35824. /**
  35825. * Defines whether cursors are handled by the scene.
  35826. */
  35827. doNotHandleCursors: boolean;
  35828. /**
  35829. * This is used to call preventDefault() on pointer down
  35830. * in order to block unwanted artifacts like system double clicks
  35831. */
  35832. preventDefaultOnPointerDown: boolean;
  35833. /**
  35834. * This is used to call preventDefault() on pointer up
  35835. * in order to block unwanted artifacts like system double clicks
  35836. */
  35837. preventDefaultOnPointerUp: boolean;
  35838. /**
  35839. * Gets or sets user defined metadata
  35840. */
  35841. metadata: any;
  35842. /**
  35843. * For internal use only. Please do not use.
  35844. */
  35845. reservedDataStore: any;
  35846. /**
  35847. * Gets the name of the plugin used to load this scene (null by default)
  35848. */
  35849. loadingPluginName: string;
  35850. /**
  35851. * Use this array to add regular expressions used to disable offline support for specific urls
  35852. */
  35853. disableOfflineSupportExceptionRules: RegExp[];
  35854. /**
  35855. * An event triggered when the scene is disposed.
  35856. */
  35857. onDisposeObservable: Observable<Scene>;
  35858. private _onDisposeObserver;
  35859. /** Sets a function to be executed when this scene is disposed. */
  35860. set onDispose(callback: () => void);
  35861. /**
  35862. * An event triggered before rendering the scene (right after animations and physics)
  35863. */
  35864. onBeforeRenderObservable: Observable<Scene>;
  35865. private _onBeforeRenderObserver;
  35866. /** Sets a function to be executed before rendering this scene */
  35867. set beforeRender(callback: Nullable<() => void>);
  35868. /**
  35869. * An event triggered after rendering the scene
  35870. */
  35871. onAfterRenderObservable: Observable<Scene>;
  35872. /**
  35873. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35874. */
  35875. onAfterRenderCameraObservable: Observable<Camera>;
  35876. private _onAfterRenderObserver;
  35877. /** Sets a function to be executed after rendering this scene */
  35878. set afterRender(callback: Nullable<() => void>);
  35879. /**
  35880. * An event triggered before animating the scene
  35881. */
  35882. onBeforeAnimationsObservable: Observable<Scene>;
  35883. /**
  35884. * An event triggered after animations processing
  35885. */
  35886. onAfterAnimationsObservable: Observable<Scene>;
  35887. /**
  35888. * An event triggered before draw calls are ready to be sent
  35889. */
  35890. onBeforeDrawPhaseObservable: Observable<Scene>;
  35891. /**
  35892. * An event triggered after draw calls have been sent
  35893. */
  35894. onAfterDrawPhaseObservable: Observable<Scene>;
  35895. /**
  35896. * An event triggered when the scene is ready
  35897. */
  35898. onReadyObservable: Observable<Scene>;
  35899. /**
  35900. * An event triggered before rendering a camera
  35901. */
  35902. onBeforeCameraRenderObservable: Observable<Camera>;
  35903. private _onBeforeCameraRenderObserver;
  35904. /** Sets a function to be executed before rendering a camera*/
  35905. set beforeCameraRender(callback: () => void);
  35906. /**
  35907. * An event triggered after rendering a camera
  35908. */
  35909. onAfterCameraRenderObservable: Observable<Camera>;
  35910. private _onAfterCameraRenderObserver;
  35911. /** Sets a function to be executed after rendering a camera*/
  35912. set afterCameraRender(callback: () => void);
  35913. /**
  35914. * An event triggered when active meshes evaluation is about to start
  35915. */
  35916. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35917. /**
  35918. * An event triggered when active meshes evaluation is done
  35919. */
  35920. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35921. /**
  35922. * An event triggered when particles rendering is about to start
  35923. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35924. */
  35925. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35926. /**
  35927. * An event triggered when particles rendering is done
  35928. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35929. */
  35930. onAfterParticlesRenderingObservable: Observable<Scene>;
  35931. /**
  35932. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35933. */
  35934. onDataLoadedObservable: Observable<Scene>;
  35935. /**
  35936. * An event triggered when a camera is created
  35937. */
  35938. onNewCameraAddedObservable: Observable<Camera>;
  35939. /**
  35940. * An event triggered when a camera is removed
  35941. */
  35942. onCameraRemovedObservable: Observable<Camera>;
  35943. /**
  35944. * An event triggered when a light is created
  35945. */
  35946. onNewLightAddedObservable: Observable<Light>;
  35947. /**
  35948. * An event triggered when a light is removed
  35949. */
  35950. onLightRemovedObservable: Observable<Light>;
  35951. /**
  35952. * An event triggered when a geometry is created
  35953. */
  35954. onNewGeometryAddedObservable: Observable<Geometry>;
  35955. /**
  35956. * An event triggered when a geometry is removed
  35957. */
  35958. onGeometryRemovedObservable: Observable<Geometry>;
  35959. /**
  35960. * An event triggered when a transform node is created
  35961. */
  35962. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35963. /**
  35964. * An event triggered when a transform node is removed
  35965. */
  35966. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35967. /**
  35968. * An event triggered when a mesh is created
  35969. */
  35970. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35971. /**
  35972. * An event triggered when a mesh is removed
  35973. */
  35974. onMeshRemovedObservable: Observable<AbstractMesh>;
  35975. /**
  35976. * An event triggered when a skeleton is created
  35977. */
  35978. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35979. /**
  35980. * An event triggered when a skeleton is removed
  35981. */
  35982. onSkeletonRemovedObservable: Observable<Skeleton>;
  35983. /**
  35984. * An event triggered when a material is created
  35985. */
  35986. onNewMaterialAddedObservable: Observable<Material>;
  35987. /**
  35988. * An event triggered when a material is removed
  35989. */
  35990. onMaterialRemovedObservable: Observable<Material>;
  35991. /**
  35992. * An event triggered when a texture is created
  35993. */
  35994. onNewTextureAddedObservable: Observable<BaseTexture>;
  35995. /**
  35996. * An event triggered when a texture is removed
  35997. */
  35998. onTextureRemovedObservable: Observable<BaseTexture>;
  35999. /**
  36000. * An event triggered when render targets are about to be rendered
  36001. * Can happen multiple times per frame.
  36002. */
  36003. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36004. /**
  36005. * An event triggered when render targets were rendered.
  36006. * Can happen multiple times per frame.
  36007. */
  36008. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36009. /**
  36010. * An event triggered before calculating deterministic simulation step
  36011. */
  36012. onBeforeStepObservable: Observable<Scene>;
  36013. /**
  36014. * An event triggered after calculating deterministic simulation step
  36015. */
  36016. onAfterStepObservable: Observable<Scene>;
  36017. /**
  36018. * An event triggered when the activeCamera property is updated
  36019. */
  36020. onActiveCameraChanged: Observable<Scene>;
  36021. /**
  36022. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36023. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36024. * 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)
  36025. */
  36026. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36027. /**
  36028. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36029. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36030. * 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)
  36031. */
  36032. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36033. /**
  36034. * This Observable will when a mesh has been imported into the scene.
  36035. */
  36036. onMeshImportedObservable: Observable<AbstractMesh>;
  36037. /**
  36038. * This Observable will when an animation file has been imported into the scene.
  36039. */
  36040. onAnimationFileImportedObservable: Observable<Scene>;
  36041. /**
  36042. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36043. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36044. */
  36045. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36046. /** @hidden */
  36047. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36048. /**
  36049. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36050. */
  36051. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36052. /**
  36053. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36054. */
  36055. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36056. /**
  36057. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36058. */
  36059. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36060. /** Callback called when a pointer move is detected */
  36061. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36062. /** Callback called when a pointer down is detected */
  36063. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36064. /** Callback called when a pointer up is detected */
  36065. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36066. /** Callback called when a pointer pick is detected */
  36067. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36068. /**
  36069. * 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).
  36070. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36071. */
  36072. onPrePointerObservable: Observable<PointerInfoPre>;
  36073. /**
  36074. * Observable event triggered each time an input event is received from the rendering canvas
  36075. */
  36076. onPointerObservable: Observable<PointerInfo>;
  36077. /**
  36078. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36079. */
  36080. get unTranslatedPointer(): Vector2;
  36081. /**
  36082. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36083. */
  36084. static get DragMovementThreshold(): number;
  36085. static set DragMovementThreshold(value: number);
  36086. /**
  36087. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36088. */
  36089. static get LongPressDelay(): number;
  36090. static set LongPressDelay(value: number);
  36091. /**
  36092. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36093. */
  36094. static get DoubleClickDelay(): number;
  36095. static set DoubleClickDelay(value: number);
  36096. /** If you need to check double click without raising a single click at first click, enable this flag */
  36097. static get ExclusiveDoubleClickMode(): boolean;
  36098. static set ExclusiveDoubleClickMode(value: boolean);
  36099. /** @hidden */
  36100. _mirroredCameraPosition: Nullable<Vector3>;
  36101. /**
  36102. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36103. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36104. */
  36105. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36106. /**
  36107. * Observable event triggered each time an keyboard event is received from the hosting window
  36108. */
  36109. onKeyboardObservable: Observable<KeyboardInfo>;
  36110. private _useRightHandedSystem;
  36111. /**
  36112. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36113. */
  36114. set useRightHandedSystem(value: boolean);
  36115. get useRightHandedSystem(): boolean;
  36116. private _timeAccumulator;
  36117. private _currentStepId;
  36118. private _currentInternalStep;
  36119. /**
  36120. * Sets the step Id used by deterministic lock step
  36121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36122. * @param newStepId defines the step Id
  36123. */
  36124. setStepId(newStepId: number): void;
  36125. /**
  36126. * Gets the step Id used by deterministic lock step
  36127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36128. * @returns the step Id
  36129. */
  36130. getStepId(): number;
  36131. /**
  36132. * Gets the internal step used by deterministic lock step
  36133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36134. * @returns the internal step
  36135. */
  36136. getInternalStep(): number;
  36137. private _fogEnabled;
  36138. /**
  36139. * Gets or sets a boolean indicating if fog is enabled on this scene
  36140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36141. * (Default is true)
  36142. */
  36143. set fogEnabled(value: boolean);
  36144. get fogEnabled(): boolean;
  36145. private _fogMode;
  36146. /**
  36147. * Gets or sets the fog mode to use
  36148. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36149. * | mode | value |
  36150. * | --- | --- |
  36151. * | FOGMODE_NONE | 0 |
  36152. * | FOGMODE_EXP | 1 |
  36153. * | FOGMODE_EXP2 | 2 |
  36154. * | FOGMODE_LINEAR | 3 |
  36155. */
  36156. set fogMode(value: number);
  36157. get fogMode(): number;
  36158. /**
  36159. * Gets or sets the fog color to use
  36160. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36161. * (Default is Color3(0.2, 0.2, 0.3))
  36162. */
  36163. fogColor: Color3;
  36164. /**
  36165. * Gets or sets the fog density to use
  36166. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36167. * (Default is 0.1)
  36168. */
  36169. fogDensity: number;
  36170. /**
  36171. * Gets or sets the fog start distance to use
  36172. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36173. * (Default is 0)
  36174. */
  36175. fogStart: number;
  36176. /**
  36177. * Gets or sets the fog end distance to use
  36178. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36179. * (Default is 1000)
  36180. */
  36181. fogEnd: number;
  36182. private _shadowsEnabled;
  36183. /**
  36184. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36185. */
  36186. set shadowsEnabled(value: boolean);
  36187. get shadowsEnabled(): boolean;
  36188. private _lightsEnabled;
  36189. /**
  36190. * Gets or sets a boolean indicating if lights are enabled on this scene
  36191. */
  36192. set lightsEnabled(value: boolean);
  36193. get lightsEnabled(): boolean;
  36194. /** All of the active cameras added to this scene. */
  36195. activeCameras: Camera[];
  36196. /** @hidden */
  36197. _activeCamera: Nullable<Camera>;
  36198. /** Gets or sets the current active camera */
  36199. get activeCamera(): Nullable<Camera>;
  36200. set activeCamera(value: Nullable<Camera>);
  36201. private _defaultMaterial;
  36202. /** The default material used on meshes when no material is affected */
  36203. get defaultMaterial(): Material;
  36204. /** The default material used on meshes when no material is affected */
  36205. set defaultMaterial(value: Material);
  36206. private _texturesEnabled;
  36207. /**
  36208. * Gets or sets a boolean indicating if textures are enabled on this scene
  36209. */
  36210. set texturesEnabled(value: boolean);
  36211. get texturesEnabled(): boolean;
  36212. /**
  36213. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36214. */
  36215. physicsEnabled: boolean;
  36216. /**
  36217. * Gets or sets a boolean indicating if particles are enabled on this scene
  36218. */
  36219. particlesEnabled: boolean;
  36220. /**
  36221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36222. */
  36223. spritesEnabled: boolean;
  36224. private _skeletonsEnabled;
  36225. /**
  36226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36227. */
  36228. set skeletonsEnabled(value: boolean);
  36229. get skeletonsEnabled(): boolean;
  36230. /**
  36231. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36232. */
  36233. lensFlaresEnabled: boolean;
  36234. /**
  36235. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36237. */
  36238. collisionsEnabled: boolean;
  36239. private _collisionCoordinator;
  36240. /** @hidden */
  36241. get collisionCoordinator(): ICollisionCoordinator;
  36242. /**
  36243. * Defines the gravity applied to this scene (used only for collisions)
  36244. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36245. */
  36246. gravity: Vector3;
  36247. /**
  36248. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36249. */
  36250. postProcessesEnabled: boolean;
  36251. /**
  36252. * The list of postprocesses added to the scene
  36253. */
  36254. postProcesses: PostProcess[];
  36255. /**
  36256. * Gets the current postprocess manager
  36257. */
  36258. postProcessManager: PostProcessManager;
  36259. /**
  36260. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36261. */
  36262. renderTargetsEnabled: boolean;
  36263. /**
  36264. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36265. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36266. */
  36267. dumpNextRenderTargets: boolean;
  36268. /**
  36269. * The list of user defined render targets added to the scene
  36270. */
  36271. customRenderTargets: RenderTargetTexture[];
  36272. /**
  36273. * Defines if texture loading must be delayed
  36274. * If true, textures will only be loaded when they need to be rendered
  36275. */
  36276. useDelayedTextureLoading: boolean;
  36277. /**
  36278. * Gets the list of meshes imported to the scene through SceneLoader
  36279. */
  36280. importedMeshesFiles: String[];
  36281. /**
  36282. * Gets or sets a boolean indicating if probes are enabled on this scene
  36283. */
  36284. probesEnabled: boolean;
  36285. /**
  36286. * Gets or sets the current offline provider to use to store scene data
  36287. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36288. */
  36289. offlineProvider: IOfflineProvider;
  36290. /**
  36291. * Gets or sets the action manager associated with the scene
  36292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36293. */
  36294. actionManager: AbstractActionManager;
  36295. private _meshesForIntersections;
  36296. /**
  36297. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36298. */
  36299. proceduralTexturesEnabled: boolean;
  36300. private _engine;
  36301. private _totalVertices;
  36302. /** @hidden */
  36303. _activeIndices: PerfCounter;
  36304. /** @hidden */
  36305. _activeParticles: PerfCounter;
  36306. /** @hidden */
  36307. _activeBones: PerfCounter;
  36308. private _animationRatio;
  36309. /** @hidden */
  36310. _animationTimeLast: number;
  36311. /** @hidden */
  36312. _animationTime: number;
  36313. /**
  36314. * Gets or sets a general scale for animation speed
  36315. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36316. */
  36317. animationTimeScale: number;
  36318. /** @hidden */
  36319. _cachedMaterial: Nullable<Material>;
  36320. /** @hidden */
  36321. _cachedEffect: Nullable<Effect>;
  36322. /** @hidden */
  36323. _cachedVisibility: Nullable<number>;
  36324. private _renderId;
  36325. private _frameId;
  36326. private _executeWhenReadyTimeoutId;
  36327. private _intermediateRendering;
  36328. private _viewUpdateFlag;
  36329. private _projectionUpdateFlag;
  36330. /** @hidden */
  36331. _toBeDisposed: Nullable<IDisposable>[];
  36332. private _activeRequests;
  36333. /** @hidden */
  36334. _pendingData: any[];
  36335. private _isDisposed;
  36336. /**
  36337. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36338. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36339. */
  36340. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36341. private _activeMeshes;
  36342. private _processedMaterials;
  36343. private _renderTargets;
  36344. /** @hidden */
  36345. _activeParticleSystems: SmartArray<IParticleSystem>;
  36346. private _activeSkeletons;
  36347. private _softwareSkinnedMeshes;
  36348. private _renderingManager;
  36349. /** @hidden */
  36350. _activeAnimatables: Animatable[];
  36351. private _transformMatrix;
  36352. private _sceneUbo;
  36353. /** @hidden */
  36354. _viewMatrix: Matrix;
  36355. private _projectionMatrix;
  36356. /** @hidden */
  36357. _forcedViewPosition: Nullable<Vector3>;
  36358. /** @hidden */
  36359. _frustumPlanes: Plane[];
  36360. /**
  36361. * Gets the list of frustum planes (built from the active camera)
  36362. */
  36363. get frustumPlanes(): Plane[];
  36364. /**
  36365. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36366. * This is useful if there are more lights that the maximum simulteanous authorized
  36367. */
  36368. requireLightSorting: boolean;
  36369. /** @hidden */
  36370. readonly useMaterialMeshMap: boolean;
  36371. /** @hidden */
  36372. readonly useClonedMeshMap: boolean;
  36373. private _externalData;
  36374. private _uid;
  36375. /**
  36376. * @hidden
  36377. * Backing store of defined scene components.
  36378. */
  36379. _components: ISceneComponent[];
  36380. /**
  36381. * @hidden
  36382. * Backing store of defined scene components.
  36383. */
  36384. _serializableComponents: ISceneSerializableComponent[];
  36385. /**
  36386. * List of components to register on the next registration step.
  36387. */
  36388. private _transientComponents;
  36389. /**
  36390. * Registers the transient components if needed.
  36391. */
  36392. private _registerTransientComponents;
  36393. /**
  36394. * @hidden
  36395. * Add a component to the scene.
  36396. * Note that the ccomponent could be registered on th next frame if this is called after
  36397. * the register component stage.
  36398. * @param component Defines the component to add to the scene
  36399. */
  36400. _addComponent(component: ISceneComponent): void;
  36401. /**
  36402. * @hidden
  36403. * Gets a component from the scene.
  36404. * @param name defines the name of the component to retrieve
  36405. * @returns the component or null if not present
  36406. */
  36407. _getComponent(name: string): Nullable<ISceneComponent>;
  36408. /**
  36409. * @hidden
  36410. * Defines the actions happening before camera updates.
  36411. */
  36412. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36413. /**
  36414. * @hidden
  36415. * Defines the actions happening before clear the canvas.
  36416. */
  36417. _beforeClearStage: Stage<SimpleStageAction>;
  36418. /**
  36419. * @hidden
  36420. * Defines the actions when collecting render targets for the frame.
  36421. */
  36422. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36423. /**
  36424. * @hidden
  36425. * Defines the actions happening for one camera in the frame.
  36426. */
  36427. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36428. /**
  36429. * @hidden
  36430. * Defines the actions happening during the per mesh ready checks.
  36431. */
  36432. _isReadyForMeshStage: Stage<MeshStageAction>;
  36433. /**
  36434. * @hidden
  36435. * Defines the actions happening before evaluate active mesh checks.
  36436. */
  36437. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36438. /**
  36439. * @hidden
  36440. * Defines the actions happening during the evaluate sub mesh checks.
  36441. */
  36442. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36443. /**
  36444. * @hidden
  36445. * Defines the actions happening during the active mesh stage.
  36446. */
  36447. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36448. /**
  36449. * @hidden
  36450. * Defines the actions happening during the per camera render target step.
  36451. */
  36452. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36453. /**
  36454. * @hidden
  36455. * Defines the actions happening just before the active camera is drawing.
  36456. */
  36457. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36458. /**
  36459. * @hidden
  36460. * Defines the actions happening just before a render target is drawing.
  36461. */
  36462. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36463. /**
  36464. * @hidden
  36465. * Defines the actions happening just before a rendering group is drawing.
  36466. */
  36467. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36468. /**
  36469. * @hidden
  36470. * Defines the actions happening just before a mesh is drawing.
  36471. */
  36472. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36473. /**
  36474. * @hidden
  36475. * Defines the actions happening just after a mesh has been drawn.
  36476. */
  36477. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36478. /**
  36479. * @hidden
  36480. * Defines the actions happening just after a rendering group has been drawn.
  36481. */
  36482. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36483. /**
  36484. * @hidden
  36485. * Defines the actions happening just after the active camera has been drawn.
  36486. */
  36487. _afterCameraDrawStage: Stage<CameraStageAction>;
  36488. /**
  36489. * @hidden
  36490. * Defines the actions happening just after a render target has been drawn.
  36491. */
  36492. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36493. /**
  36494. * @hidden
  36495. * Defines the actions happening just after rendering all cameras and computing intersections.
  36496. */
  36497. _afterRenderStage: Stage<SimpleStageAction>;
  36498. /**
  36499. * @hidden
  36500. * Defines the actions happening when a pointer move event happens.
  36501. */
  36502. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36503. /**
  36504. * @hidden
  36505. * Defines the actions happening when a pointer down event happens.
  36506. */
  36507. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36508. /**
  36509. * @hidden
  36510. * Defines the actions happening when a pointer up event happens.
  36511. */
  36512. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36513. /**
  36514. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36515. */
  36516. private geometriesByUniqueId;
  36517. /**
  36518. * Creates a new Scene
  36519. * @param engine defines the engine to use to render this scene
  36520. * @param options defines the scene options
  36521. */
  36522. constructor(engine: Engine, options?: SceneOptions);
  36523. /**
  36524. * Gets a string idenfifying the name of the class
  36525. * @returns "Scene" string
  36526. */
  36527. getClassName(): string;
  36528. private _defaultMeshCandidates;
  36529. /**
  36530. * @hidden
  36531. */
  36532. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36533. private _defaultSubMeshCandidates;
  36534. /**
  36535. * @hidden
  36536. */
  36537. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36538. /**
  36539. * Sets the default candidate providers for the scene.
  36540. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36541. * and getCollidingSubMeshCandidates to their default function
  36542. */
  36543. setDefaultCandidateProviders(): void;
  36544. /**
  36545. * Gets the mesh that is currently under the pointer
  36546. */
  36547. get meshUnderPointer(): Nullable<AbstractMesh>;
  36548. /**
  36549. * Gets or sets the current on-screen X position of the pointer
  36550. */
  36551. get pointerX(): number;
  36552. set pointerX(value: number);
  36553. /**
  36554. * Gets or sets the current on-screen Y position of the pointer
  36555. */
  36556. get pointerY(): number;
  36557. set pointerY(value: number);
  36558. /**
  36559. * Gets the cached material (ie. the latest rendered one)
  36560. * @returns the cached material
  36561. */
  36562. getCachedMaterial(): Nullable<Material>;
  36563. /**
  36564. * Gets the cached effect (ie. the latest rendered one)
  36565. * @returns the cached effect
  36566. */
  36567. getCachedEffect(): Nullable<Effect>;
  36568. /**
  36569. * Gets the cached visibility state (ie. the latest rendered one)
  36570. * @returns the cached visibility state
  36571. */
  36572. getCachedVisibility(): Nullable<number>;
  36573. /**
  36574. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36575. * @param material defines the current material
  36576. * @param effect defines the current effect
  36577. * @param visibility defines the current visibility state
  36578. * @returns true if one parameter is not cached
  36579. */
  36580. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36581. /**
  36582. * Gets the engine associated with the scene
  36583. * @returns an Engine
  36584. */
  36585. getEngine(): Engine;
  36586. /**
  36587. * Gets the total number of vertices rendered per frame
  36588. * @returns the total number of vertices rendered per frame
  36589. */
  36590. getTotalVertices(): number;
  36591. /**
  36592. * Gets the performance counter for total vertices
  36593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36594. */
  36595. get totalVerticesPerfCounter(): PerfCounter;
  36596. /**
  36597. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36598. * @returns the total number of active indices rendered per frame
  36599. */
  36600. getActiveIndices(): number;
  36601. /**
  36602. * Gets the performance counter for active indices
  36603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36604. */
  36605. get totalActiveIndicesPerfCounter(): PerfCounter;
  36606. /**
  36607. * Gets the total number of active particles rendered per frame
  36608. * @returns the total number of active particles rendered per frame
  36609. */
  36610. getActiveParticles(): number;
  36611. /**
  36612. * Gets the performance counter for active particles
  36613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36614. */
  36615. get activeParticlesPerfCounter(): PerfCounter;
  36616. /**
  36617. * Gets the total number of active bones rendered per frame
  36618. * @returns the total number of active bones rendered per frame
  36619. */
  36620. getActiveBones(): number;
  36621. /**
  36622. * Gets the performance counter for active bones
  36623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36624. */
  36625. get activeBonesPerfCounter(): PerfCounter;
  36626. /**
  36627. * Gets the array of active meshes
  36628. * @returns an array of AbstractMesh
  36629. */
  36630. getActiveMeshes(): SmartArray<AbstractMesh>;
  36631. /**
  36632. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36633. * @returns a number
  36634. */
  36635. getAnimationRatio(): number;
  36636. /**
  36637. * Gets an unique Id for the current render phase
  36638. * @returns a number
  36639. */
  36640. getRenderId(): number;
  36641. /**
  36642. * Gets an unique Id for the current frame
  36643. * @returns a number
  36644. */
  36645. getFrameId(): number;
  36646. /** Call this function if you want to manually increment the render Id*/
  36647. incrementRenderId(): void;
  36648. private _createUbo;
  36649. /**
  36650. * Use this method to simulate a pointer move on a mesh
  36651. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36652. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36653. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36654. * @returns the current scene
  36655. */
  36656. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36657. /**
  36658. * Use this method to simulate a pointer down on a mesh
  36659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36662. * @returns the current scene
  36663. */
  36664. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36665. /**
  36666. * Use this method to simulate a pointer up on a mesh
  36667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36670. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36671. * @returns the current scene
  36672. */
  36673. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36674. /**
  36675. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36676. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36677. * @returns true if the pointer was captured
  36678. */
  36679. isPointerCaptured(pointerId?: number): boolean;
  36680. /**
  36681. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36682. * @param attachUp defines if you want to attach events to pointerup
  36683. * @param attachDown defines if you want to attach events to pointerdown
  36684. * @param attachMove defines if you want to attach events to pointermove
  36685. */
  36686. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36687. /** Detaches all event handlers*/
  36688. detachControl(): void;
  36689. /**
  36690. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36691. * Delay loaded resources are not taking in account
  36692. * @return true if all required resources are ready
  36693. */
  36694. isReady(): boolean;
  36695. /** Resets all cached information relative to material (including effect and visibility) */
  36696. resetCachedMaterial(): void;
  36697. /**
  36698. * Registers a function to be called before every frame render
  36699. * @param func defines the function to register
  36700. */
  36701. registerBeforeRender(func: () => void): void;
  36702. /**
  36703. * Unregisters a function called before every frame render
  36704. * @param func defines the function to unregister
  36705. */
  36706. unregisterBeforeRender(func: () => void): void;
  36707. /**
  36708. * Registers a function to be called after every frame render
  36709. * @param func defines the function to register
  36710. */
  36711. registerAfterRender(func: () => void): void;
  36712. /**
  36713. * Unregisters a function called after every frame render
  36714. * @param func defines the function to unregister
  36715. */
  36716. unregisterAfterRender(func: () => void): void;
  36717. private _executeOnceBeforeRender;
  36718. /**
  36719. * The provided function will run before render once and will be disposed afterwards.
  36720. * A timeout delay can be provided so that the function will be executed in N ms.
  36721. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36722. * @param func The function to be executed.
  36723. * @param timeout optional delay in ms
  36724. */
  36725. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36726. /** @hidden */
  36727. _addPendingData(data: any): void;
  36728. /** @hidden */
  36729. _removePendingData(data: any): void;
  36730. /**
  36731. * Returns the number of items waiting to be loaded
  36732. * @returns the number of items waiting to be loaded
  36733. */
  36734. getWaitingItemsCount(): number;
  36735. /**
  36736. * Returns a boolean indicating if the scene is still loading data
  36737. */
  36738. get isLoading(): boolean;
  36739. /**
  36740. * Registers a function to be executed when the scene is ready
  36741. * @param {Function} func - the function to be executed
  36742. */
  36743. executeWhenReady(func: () => void): void;
  36744. /**
  36745. * Returns a promise that resolves when the scene is ready
  36746. * @returns A promise that resolves when the scene is ready
  36747. */
  36748. whenReadyAsync(): Promise<void>;
  36749. /** @hidden */
  36750. _checkIsReady(): void;
  36751. /**
  36752. * Gets all animatable attached to the scene
  36753. */
  36754. get animatables(): Animatable[];
  36755. /**
  36756. * Resets the last animation time frame.
  36757. * Useful to override when animations start running when loading a scene for the first time.
  36758. */
  36759. resetLastAnimationTimeFrame(): void;
  36760. /**
  36761. * Gets the current view matrix
  36762. * @returns a Matrix
  36763. */
  36764. getViewMatrix(): Matrix;
  36765. /**
  36766. * Gets the current projection matrix
  36767. * @returns a Matrix
  36768. */
  36769. getProjectionMatrix(): Matrix;
  36770. /**
  36771. * Gets the current transform matrix
  36772. * @returns a Matrix made of View * Projection
  36773. */
  36774. getTransformMatrix(): Matrix;
  36775. /**
  36776. * Sets the current transform matrix
  36777. * @param viewL defines the View matrix to use
  36778. * @param projectionL defines the Projection matrix to use
  36779. * @param viewR defines the right View matrix to use (if provided)
  36780. * @param projectionR defines the right Projection matrix to use (if provided)
  36781. */
  36782. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36783. /**
  36784. * Gets the uniform buffer used to store scene data
  36785. * @returns a UniformBuffer
  36786. */
  36787. getSceneUniformBuffer(): UniformBuffer;
  36788. /**
  36789. * Gets an unique (relatively to the current scene) Id
  36790. * @returns an unique number for the scene
  36791. */
  36792. getUniqueId(): number;
  36793. /**
  36794. * Add a mesh to the list of scene's meshes
  36795. * @param newMesh defines the mesh to add
  36796. * @param recursive if all child meshes should also be added to the scene
  36797. */
  36798. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36799. /**
  36800. * Remove a mesh for the list of scene's meshes
  36801. * @param toRemove defines the mesh to remove
  36802. * @param recursive if all child meshes should also be removed from the scene
  36803. * @returns the index where the mesh was in the mesh list
  36804. */
  36805. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36806. /**
  36807. * Add a transform node to the list of scene's transform nodes
  36808. * @param newTransformNode defines the transform node to add
  36809. */
  36810. addTransformNode(newTransformNode: TransformNode): void;
  36811. /**
  36812. * Remove a transform node for the list of scene's transform nodes
  36813. * @param toRemove defines the transform node to remove
  36814. * @returns the index where the transform node was in the transform node list
  36815. */
  36816. removeTransformNode(toRemove: TransformNode): number;
  36817. /**
  36818. * Remove a skeleton for the list of scene's skeletons
  36819. * @param toRemove defines the skeleton to remove
  36820. * @returns the index where the skeleton was in the skeleton list
  36821. */
  36822. removeSkeleton(toRemove: Skeleton): number;
  36823. /**
  36824. * Remove a morph target for the list of scene's morph targets
  36825. * @param toRemove defines the morph target to remove
  36826. * @returns the index where the morph target was in the morph target list
  36827. */
  36828. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36829. /**
  36830. * Remove a light for the list of scene's lights
  36831. * @param toRemove defines the light to remove
  36832. * @returns the index where the light was in the light list
  36833. */
  36834. removeLight(toRemove: Light): number;
  36835. /**
  36836. * Remove a camera for the list of scene's cameras
  36837. * @param toRemove defines the camera to remove
  36838. * @returns the index where the camera was in the camera list
  36839. */
  36840. removeCamera(toRemove: Camera): number;
  36841. /**
  36842. * Remove a particle system for the list of scene's particle systems
  36843. * @param toRemove defines the particle system to remove
  36844. * @returns the index where the particle system was in the particle system list
  36845. */
  36846. removeParticleSystem(toRemove: IParticleSystem): number;
  36847. /**
  36848. * Remove a animation for the list of scene's animations
  36849. * @param toRemove defines the animation to remove
  36850. * @returns the index where the animation was in the animation list
  36851. */
  36852. removeAnimation(toRemove: Animation): number;
  36853. /**
  36854. * Will stop the animation of the given target
  36855. * @param target - the target
  36856. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36857. * @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)
  36858. */
  36859. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36860. /**
  36861. * Removes the given animation group from this scene.
  36862. * @param toRemove The animation group to remove
  36863. * @returns The index of the removed animation group
  36864. */
  36865. removeAnimationGroup(toRemove: AnimationGroup): number;
  36866. /**
  36867. * Removes the given multi-material from this scene.
  36868. * @param toRemove The multi-material to remove
  36869. * @returns The index of the removed multi-material
  36870. */
  36871. removeMultiMaterial(toRemove: MultiMaterial): number;
  36872. /**
  36873. * Removes the given material from this scene.
  36874. * @param toRemove The material to remove
  36875. * @returns The index of the removed material
  36876. */
  36877. removeMaterial(toRemove: Material): number;
  36878. /**
  36879. * Removes the given action manager from this scene.
  36880. * @param toRemove The action manager to remove
  36881. * @returns The index of the removed action manager
  36882. */
  36883. removeActionManager(toRemove: AbstractActionManager): number;
  36884. /**
  36885. * Removes the given texture from this scene.
  36886. * @param toRemove The texture to remove
  36887. * @returns The index of the removed texture
  36888. */
  36889. removeTexture(toRemove: BaseTexture): number;
  36890. /**
  36891. * Adds the given light to this scene
  36892. * @param newLight The light to add
  36893. */
  36894. addLight(newLight: Light): void;
  36895. /**
  36896. * Sorts the list list based on light priorities
  36897. */
  36898. sortLightsByPriority(): void;
  36899. /**
  36900. * Adds the given camera to this scene
  36901. * @param newCamera The camera to add
  36902. */
  36903. addCamera(newCamera: Camera): void;
  36904. /**
  36905. * Adds the given skeleton to this scene
  36906. * @param newSkeleton The skeleton to add
  36907. */
  36908. addSkeleton(newSkeleton: Skeleton): void;
  36909. /**
  36910. * Adds the given particle system to this scene
  36911. * @param newParticleSystem The particle system to add
  36912. */
  36913. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36914. /**
  36915. * Adds the given animation to this scene
  36916. * @param newAnimation The animation to add
  36917. */
  36918. addAnimation(newAnimation: Animation): void;
  36919. /**
  36920. * Adds the given animation group to this scene.
  36921. * @param newAnimationGroup The animation group to add
  36922. */
  36923. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36924. /**
  36925. * Adds the given multi-material to this scene
  36926. * @param newMultiMaterial The multi-material to add
  36927. */
  36928. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36929. /**
  36930. * Adds the given material to this scene
  36931. * @param newMaterial The material to add
  36932. */
  36933. addMaterial(newMaterial: Material): void;
  36934. /**
  36935. * Adds the given morph target to this scene
  36936. * @param newMorphTargetManager The morph target to add
  36937. */
  36938. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36939. /**
  36940. * Adds the given geometry to this scene
  36941. * @param newGeometry The geometry to add
  36942. */
  36943. addGeometry(newGeometry: Geometry): void;
  36944. /**
  36945. * Adds the given action manager to this scene
  36946. * @param newActionManager The action manager to add
  36947. */
  36948. addActionManager(newActionManager: AbstractActionManager): void;
  36949. /**
  36950. * Adds the given texture to this scene.
  36951. * @param newTexture The texture to add
  36952. */
  36953. addTexture(newTexture: BaseTexture): void;
  36954. /**
  36955. * Switch active camera
  36956. * @param newCamera defines the new active camera
  36957. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36958. */
  36959. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36960. /**
  36961. * sets the active camera of the scene using its ID
  36962. * @param id defines the camera's ID
  36963. * @return the new active camera or null if none found.
  36964. */
  36965. setActiveCameraByID(id: string): Nullable<Camera>;
  36966. /**
  36967. * sets the active camera of the scene using its name
  36968. * @param name defines the camera's name
  36969. * @returns the new active camera or null if none found.
  36970. */
  36971. setActiveCameraByName(name: string): Nullable<Camera>;
  36972. /**
  36973. * get an animation group using its name
  36974. * @param name defines the material's name
  36975. * @return the animation group or null if none found.
  36976. */
  36977. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36978. /**
  36979. * Get a material using its unique id
  36980. * @param uniqueId defines the material's unique id
  36981. * @return the material or null if none found.
  36982. */
  36983. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36984. /**
  36985. * get a material using its id
  36986. * @param id defines the material's ID
  36987. * @return the material or null if none found.
  36988. */
  36989. getMaterialByID(id: string): Nullable<Material>;
  36990. /**
  36991. * Gets a the last added material using a given id
  36992. * @param id defines the material's ID
  36993. * @return the last material with the given id or null if none found.
  36994. */
  36995. getLastMaterialByID(id: string): Nullable<Material>;
  36996. /**
  36997. * Gets a material using its name
  36998. * @param name defines the material's name
  36999. * @return the material or null if none found.
  37000. */
  37001. getMaterialByName(name: string): Nullable<Material>;
  37002. /**
  37003. * Get a texture using its unique id
  37004. * @param uniqueId defines the texture's unique id
  37005. * @return the texture or null if none found.
  37006. */
  37007. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37008. /**
  37009. * Gets a camera using its id
  37010. * @param id defines the id to look for
  37011. * @returns the camera or null if not found
  37012. */
  37013. getCameraByID(id: string): Nullable<Camera>;
  37014. /**
  37015. * Gets a camera using its unique id
  37016. * @param uniqueId defines the unique id to look for
  37017. * @returns the camera or null if not found
  37018. */
  37019. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37020. /**
  37021. * Gets a camera using its name
  37022. * @param name defines the camera's name
  37023. * @return the camera or null if none found.
  37024. */
  37025. getCameraByName(name: string): Nullable<Camera>;
  37026. /**
  37027. * Gets a bone using its id
  37028. * @param id defines the bone's id
  37029. * @return the bone or null if not found
  37030. */
  37031. getBoneByID(id: string): Nullable<Bone>;
  37032. /**
  37033. * Gets a bone using its id
  37034. * @param name defines the bone's name
  37035. * @return the bone or null if not found
  37036. */
  37037. getBoneByName(name: string): Nullable<Bone>;
  37038. /**
  37039. * Gets a light node using its name
  37040. * @param name defines the the light's name
  37041. * @return the light or null if none found.
  37042. */
  37043. getLightByName(name: string): Nullable<Light>;
  37044. /**
  37045. * Gets a light node using its id
  37046. * @param id defines the light's id
  37047. * @return the light or null if none found.
  37048. */
  37049. getLightByID(id: string): Nullable<Light>;
  37050. /**
  37051. * Gets a light node using its scene-generated unique ID
  37052. * @param uniqueId defines the light's unique id
  37053. * @return the light or null if none found.
  37054. */
  37055. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37056. /**
  37057. * Gets a particle system by id
  37058. * @param id defines the particle system id
  37059. * @return the corresponding system or null if none found
  37060. */
  37061. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37062. /**
  37063. * Gets a geometry using its ID
  37064. * @param id defines the geometry's id
  37065. * @return the geometry or null if none found.
  37066. */
  37067. getGeometryByID(id: string): Nullable<Geometry>;
  37068. private _getGeometryByUniqueID;
  37069. /**
  37070. * Add a new geometry to this scene
  37071. * @param geometry defines the geometry to be added to the scene.
  37072. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37073. * @return a boolean defining if the geometry was added or not
  37074. */
  37075. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37076. /**
  37077. * Removes an existing geometry
  37078. * @param geometry defines the geometry to be removed from the scene
  37079. * @return a boolean defining if the geometry was removed or not
  37080. */
  37081. removeGeometry(geometry: Geometry): boolean;
  37082. /**
  37083. * Gets the list of geometries attached to the scene
  37084. * @returns an array of Geometry
  37085. */
  37086. getGeometries(): Geometry[];
  37087. /**
  37088. * Gets the first added mesh found of a given ID
  37089. * @param id defines the id to search for
  37090. * @return the mesh found or null if not found at all
  37091. */
  37092. getMeshByID(id: string): Nullable<AbstractMesh>;
  37093. /**
  37094. * Gets a list of meshes using their id
  37095. * @param id defines the id to search for
  37096. * @returns a list of meshes
  37097. */
  37098. getMeshesByID(id: string): Array<AbstractMesh>;
  37099. /**
  37100. * Gets the first added transform node found of a given ID
  37101. * @param id defines the id to search for
  37102. * @return the found transform node or null if not found at all.
  37103. */
  37104. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37105. /**
  37106. * Gets a transform node with its auto-generated unique id
  37107. * @param uniqueId efines the unique id to search for
  37108. * @return the found transform node or null if not found at all.
  37109. */
  37110. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37111. /**
  37112. * Gets a list of transform nodes using their id
  37113. * @param id defines the id to search for
  37114. * @returns a list of transform nodes
  37115. */
  37116. getTransformNodesByID(id: string): Array<TransformNode>;
  37117. /**
  37118. * Gets a mesh with its auto-generated unique id
  37119. * @param uniqueId defines the unique id to search for
  37120. * @return the found mesh or null if not found at all.
  37121. */
  37122. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37123. /**
  37124. * Gets a the last added mesh using a given id
  37125. * @param id defines the id to search for
  37126. * @return the found mesh or null if not found at all.
  37127. */
  37128. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37129. /**
  37130. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37131. * @param id defines the id to search for
  37132. * @return the found node or null if not found at all
  37133. */
  37134. getLastEntryByID(id: string): Nullable<Node>;
  37135. /**
  37136. * Gets a node (Mesh, Camera, Light) using a given id
  37137. * @param id defines the id to search for
  37138. * @return the found node or null if not found at all
  37139. */
  37140. getNodeByID(id: string): Nullable<Node>;
  37141. /**
  37142. * Gets a node (Mesh, Camera, Light) using a given name
  37143. * @param name defines the name to search for
  37144. * @return the found node or null if not found at all.
  37145. */
  37146. getNodeByName(name: string): Nullable<Node>;
  37147. /**
  37148. * Gets a mesh using a given name
  37149. * @param name defines the name to search for
  37150. * @return the found mesh or null if not found at all.
  37151. */
  37152. getMeshByName(name: string): Nullable<AbstractMesh>;
  37153. /**
  37154. * Gets a transform node using a given name
  37155. * @param name defines the name to search for
  37156. * @return the found transform node or null if not found at all.
  37157. */
  37158. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37159. /**
  37160. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37161. * @param id defines the id to search for
  37162. * @return the found skeleton or null if not found at all.
  37163. */
  37164. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37165. /**
  37166. * Gets a skeleton using a given auto generated unique id
  37167. * @param uniqueId defines the unique id to search for
  37168. * @return the found skeleton or null if not found at all.
  37169. */
  37170. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37171. /**
  37172. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37173. * @param id defines the id to search for
  37174. * @return the found skeleton or null if not found at all.
  37175. */
  37176. getSkeletonById(id: string): Nullable<Skeleton>;
  37177. /**
  37178. * Gets a skeleton using a given name
  37179. * @param name defines the name to search for
  37180. * @return the found skeleton or null if not found at all.
  37181. */
  37182. getSkeletonByName(name: string): Nullable<Skeleton>;
  37183. /**
  37184. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37185. * @param id defines the id to search for
  37186. * @return the found morph target manager or null if not found at all.
  37187. */
  37188. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37189. /**
  37190. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37191. * @param id defines the id to search for
  37192. * @return the found morph target or null if not found at all.
  37193. */
  37194. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37195. /**
  37196. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37197. * @param name defines the name to search for
  37198. * @return the found morph target or null if not found at all.
  37199. */
  37200. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37201. /**
  37202. * Gets a boolean indicating if the given mesh is active
  37203. * @param mesh defines the mesh to look for
  37204. * @returns true if the mesh is in the active list
  37205. */
  37206. isActiveMesh(mesh: AbstractMesh): boolean;
  37207. /**
  37208. * Return a unique id as a string which can serve as an identifier for the scene
  37209. */
  37210. get uid(): string;
  37211. /**
  37212. * Add an externaly attached data from its key.
  37213. * This method call will fail and return false, if such key already exists.
  37214. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37215. * @param key the unique key that identifies the data
  37216. * @param data the data object to associate to the key for this Engine instance
  37217. * @return true if no such key were already present and the data was added successfully, false otherwise
  37218. */
  37219. addExternalData<T>(key: string, data: T): boolean;
  37220. /**
  37221. * Get an externaly attached data from its key
  37222. * @param key the unique key that identifies the data
  37223. * @return the associated data, if present (can be null), or undefined if not present
  37224. */
  37225. getExternalData<T>(key: string): Nullable<T>;
  37226. /**
  37227. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37228. * @param key the unique key that identifies the data
  37229. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37230. * @return the associated data, can be null if the factory returned null.
  37231. */
  37232. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37233. /**
  37234. * Remove an externaly attached data from the Engine instance
  37235. * @param key the unique key that identifies the data
  37236. * @return true if the data was successfully removed, false if it doesn't exist
  37237. */
  37238. removeExternalData(key: string): boolean;
  37239. private _evaluateSubMesh;
  37240. /**
  37241. * Clear the processed materials smart array preventing retention point in material dispose.
  37242. */
  37243. freeProcessedMaterials(): void;
  37244. private _preventFreeActiveMeshesAndRenderingGroups;
  37245. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37246. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37247. * when disposing several meshes in a row or a hierarchy of meshes.
  37248. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37249. */
  37250. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37251. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37252. /**
  37253. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37254. */
  37255. freeActiveMeshes(): void;
  37256. /**
  37257. * Clear the info related to rendering groups preventing retention points during dispose.
  37258. */
  37259. freeRenderingGroups(): void;
  37260. /** @hidden */
  37261. _isInIntermediateRendering(): boolean;
  37262. /**
  37263. * Lambda returning the list of potentially active meshes.
  37264. */
  37265. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37266. /**
  37267. * Lambda returning the list of potentially active sub meshes.
  37268. */
  37269. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37270. /**
  37271. * Lambda returning the list of potentially intersecting sub meshes.
  37272. */
  37273. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37274. /**
  37275. * Lambda returning the list of potentially colliding sub meshes.
  37276. */
  37277. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37278. private _activeMeshesFrozen;
  37279. private _skipEvaluateActiveMeshesCompletely;
  37280. /**
  37281. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37282. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37283. * @returns the current scene
  37284. */
  37285. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37286. /**
  37287. * Use this function to restart evaluating active meshes on every frame
  37288. * @returns the current scene
  37289. */
  37290. unfreezeActiveMeshes(): Scene;
  37291. private _evaluateActiveMeshes;
  37292. private _activeMesh;
  37293. /**
  37294. * Update the transform matrix to update from the current active camera
  37295. * @param force defines a boolean used to force the update even if cache is up to date
  37296. */
  37297. updateTransformMatrix(force?: boolean): void;
  37298. private _bindFrameBuffer;
  37299. /** @hidden */
  37300. _allowPostProcessClearColor: boolean;
  37301. /** @hidden */
  37302. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37303. private _processSubCameras;
  37304. private _checkIntersections;
  37305. /** @hidden */
  37306. _advancePhysicsEngineStep(step: number): void;
  37307. /**
  37308. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37309. */
  37310. getDeterministicFrameTime: () => number;
  37311. /** @hidden */
  37312. _animate(): void;
  37313. /** Execute all animations (for a frame) */
  37314. animate(): void;
  37315. /**
  37316. * Render the scene
  37317. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37318. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37319. */
  37320. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37321. /**
  37322. * Freeze all materials
  37323. * A frozen material will not be updatable but should be faster to render
  37324. */
  37325. freezeMaterials(): void;
  37326. /**
  37327. * Unfreeze all materials
  37328. * A frozen material will not be updatable but should be faster to render
  37329. */
  37330. unfreezeMaterials(): void;
  37331. /**
  37332. * Releases all held ressources
  37333. */
  37334. dispose(): void;
  37335. /**
  37336. * Gets if the scene is already disposed
  37337. */
  37338. get isDisposed(): boolean;
  37339. /**
  37340. * Call this function to reduce memory footprint of the scene.
  37341. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37342. */
  37343. clearCachedVertexData(): void;
  37344. /**
  37345. * This function will remove the local cached buffer data from texture.
  37346. * It will save memory but will prevent the texture from being rebuilt
  37347. */
  37348. cleanCachedTextureBuffer(): void;
  37349. /**
  37350. * Get the world extend vectors with an optional filter
  37351. *
  37352. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37353. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37354. */
  37355. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37356. min: Vector3;
  37357. max: Vector3;
  37358. };
  37359. /**
  37360. * Creates a ray that can be used to pick in the scene
  37361. * @param x defines the x coordinate of the origin (on-screen)
  37362. * @param y defines the y coordinate of the origin (on-screen)
  37363. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37364. * @param camera defines the camera to use for the picking
  37365. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37366. * @returns a Ray
  37367. */
  37368. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37369. /**
  37370. * Creates a ray that can be used to pick in the scene
  37371. * @param x defines the x coordinate of the origin (on-screen)
  37372. * @param y defines the y coordinate of the origin (on-screen)
  37373. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37374. * @param result defines the ray where to store the picking ray
  37375. * @param camera defines the camera to use for the picking
  37376. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37377. * @returns the current scene
  37378. */
  37379. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37380. /**
  37381. * Creates a ray that can be used to pick in the scene
  37382. * @param x defines the x coordinate of the origin (on-screen)
  37383. * @param y defines the y coordinate of the origin (on-screen)
  37384. * @param camera defines the camera to use for the picking
  37385. * @returns a Ray
  37386. */
  37387. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37388. /**
  37389. * Creates a ray that can be used to pick in the scene
  37390. * @param x defines the x coordinate of the origin (on-screen)
  37391. * @param y defines the y coordinate of the origin (on-screen)
  37392. * @param result defines the ray where to store the picking ray
  37393. * @param camera defines the camera to use for the picking
  37394. * @returns the current scene
  37395. */
  37396. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37397. /** Launch a ray to try to pick a mesh in the scene
  37398. * @param x position on screen
  37399. * @param 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 fastCheck defines if the first intersection will be used (and not the closest)
  37402. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37404. * @returns a PickingInfo
  37405. */
  37406. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37407. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37408. * @param x position on screen
  37409. * @param y position on screen
  37410. * @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
  37411. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37412. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37413. * @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)
  37414. */
  37415. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37416. /** Use the given ray to pick a mesh in the scene
  37417. * @param ray The ray to use to pick meshes
  37418. * @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
  37419. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37420. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37421. * @returns a PickingInfo
  37422. */
  37423. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37424. /**
  37425. * Launch a ray to try to pick a mesh in the scene
  37426. * @param x X position on screen
  37427. * @param y Y position on screen
  37428. * @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
  37429. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37430. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37431. * @returns an array of PickingInfo
  37432. */
  37433. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37434. /**
  37435. * Launch a ray to try to pick a mesh in the scene
  37436. * @param ray Ray to use
  37437. * @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
  37438. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37439. * @returns an array of PickingInfo
  37440. */
  37441. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37442. /**
  37443. * Force the value of meshUnderPointer
  37444. * @param mesh defines the mesh to use
  37445. */
  37446. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37447. /**
  37448. * Gets the mesh under the pointer
  37449. * @returns a Mesh or null if no mesh is under the pointer
  37450. */
  37451. getPointerOverMesh(): Nullable<AbstractMesh>;
  37452. /** @hidden */
  37453. _rebuildGeometries(): void;
  37454. /** @hidden */
  37455. _rebuildTextures(): void;
  37456. private _getByTags;
  37457. /**
  37458. * Get a list of meshes by tags
  37459. * @param tagsQuery defines the tags query to use
  37460. * @param forEach defines a predicate used to filter results
  37461. * @returns an array of Mesh
  37462. */
  37463. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37464. /**
  37465. * Get a list of cameras by tags
  37466. * @param tagsQuery defines the tags query to use
  37467. * @param forEach defines a predicate used to filter results
  37468. * @returns an array of Camera
  37469. */
  37470. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37471. /**
  37472. * Get a list of lights by tags
  37473. * @param tagsQuery defines the tags query to use
  37474. * @param forEach defines a predicate used to filter results
  37475. * @returns an array of Light
  37476. */
  37477. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37478. /**
  37479. * Get a list of materials by tags
  37480. * @param tagsQuery defines the tags query to use
  37481. * @param forEach defines a predicate used to filter results
  37482. * @returns an array of Material
  37483. */
  37484. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37485. /**
  37486. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37487. * This allowed control for front to back rendering or reversly depending of the special needs.
  37488. *
  37489. * @param renderingGroupId The rendering group id corresponding to its index
  37490. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37491. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37492. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37493. */
  37494. 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;
  37495. /**
  37496. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37497. *
  37498. * @param renderingGroupId The rendering group id corresponding to its index
  37499. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37500. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37501. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37502. */
  37503. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37504. /**
  37505. * Gets the current auto clear configuration for one rendering group of the rendering
  37506. * manager.
  37507. * @param index the rendering group index to get the information for
  37508. * @returns The auto clear setup for the requested rendering group
  37509. */
  37510. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37511. private _blockMaterialDirtyMechanism;
  37512. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37513. get blockMaterialDirtyMechanism(): boolean;
  37514. set blockMaterialDirtyMechanism(value: boolean);
  37515. /**
  37516. * Will flag all materials as dirty to trigger new shader compilation
  37517. * @param flag defines the flag used to specify which material part must be marked as dirty
  37518. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37519. */
  37520. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37521. /** @hidden */
  37522. _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;
  37523. /** @hidden */
  37524. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37525. /** @hidden */
  37526. _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;
  37527. /** @hidden */
  37528. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37529. /** @hidden */
  37530. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37531. /** @hidden */
  37532. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37533. }
  37534. }
  37535. declare module BABYLON {
  37536. /**
  37537. * Set of assets to keep when moving a scene into an asset container.
  37538. */
  37539. export class KeepAssets extends AbstractScene {
  37540. }
  37541. /**
  37542. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37543. */
  37544. export class InstantiatedEntries {
  37545. /**
  37546. * List of new root nodes (eg. nodes with no parent)
  37547. */
  37548. rootNodes: TransformNode[];
  37549. /**
  37550. * List of new skeletons
  37551. */
  37552. skeletons: Skeleton[];
  37553. /**
  37554. * List of new animation groups
  37555. */
  37556. animationGroups: AnimationGroup[];
  37557. }
  37558. /**
  37559. * Container with a set of assets that can be added or removed from a scene.
  37560. */
  37561. export class AssetContainer extends AbstractScene {
  37562. private _wasAddedToScene;
  37563. /**
  37564. * The scene the AssetContainer belongs to.
  37565. */
  37566. scene: Scene;
  37567. /**
  37568. * Instantiates an AssetContainer.
  37569. * @param scene The scene the AssetContainer belongs to.
  37570. */
  37571. constructor(scene: Scene);
  37572. /**
  37573. * Instantiate or clone all meshes and add the new ones to the scene.
  37574. * Skeletons and animation groups will all be cloned
  37575. * @param nameFunction defines an optional function used to get new names for clones
  37576. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37577. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37578. */
  37579. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37580. /**
  37581. * Adds all the assets from the container to the scene.
  37582. */
  37583. addAllToScene(): void;
  37584. /**
  37585. * Removes all the assets in the container from the scene
  37586. */
  37587. removeAllFromScene(): void;
  37588. /**
  37589. * Disposes all the assets in the container
  37590. */
  37591. dispose(): void;
  37592. private _moveAssets;
  37593. /**
  37594. * Removes all the assets contained in the scene and adds them to the container.
  37595. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37596. */
  37597. moveAllFromScene(keepAssets?: KeepAssets): void;
  37598. /**
  37599. * 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.
  37600. * @returns the root mesh
  37601. */
  37602. createRootMesh(): Mesh;
  37603. /**
  37604. * Merge animations (direct and animation groups) from this asset container into a scene
  37605. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37606. * @param animatables set of animatables to retarget to a node from the scene
  37607. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37608. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37609. */
  37610. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37611. }
  37612. }
  37613. declare module BABYLON {
  37614. /**
  37615. * Defines how the parser contract is defined.
  37616. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37617. */
  37618. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37619. /**
  37620. * Defines how the individual parser contract is defined.
  37621. * These parser can parse an individual asset
  37622. */
  37623. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37624. /**
  37625. * Base class of the scene acting as a container for the different elements composing a scene.
  37626. * This class is dynamically extended by the different components of the scene increasing
  37627. * flexibility and reducing coupling
  37628. */
  37629. export abstract class AbstractScene {
  37630. /**
  37631. * Stores the list of available parsers in the application.
  37632. */
  37633. private static _BabylonFileParsers;
  37634. /**
  37635. * Stores the list of available individual parsers in the application.
  37636. */
  37637. private static _IndividualBabylonFileParsers;
  37638. /**
  37639. * Adds a parser in the list of available ones
  37640. * @param name Defines the name of the parser
  37641. * @param parser Defines the parser to add
  37642. */
  37643. static AddParser(name: string, parser: BabylonFileParser): void;
  37644. /**
  37645. * Gets a general parser from the list of avaialble ones
  37646. * @param name Defines the name of the parser
  37647. * @returns the requested parser or null
  37648. */
  37649. static GetParser(name: string): Nullable<BabylonFileParser>;
  37650. /**
  37651. * Adds n individual parser in the list of available ones
  37652. * @param name Defines the name of the parser
  37653. * @param parser Defines the parser to add
  37654. */
  37655. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37656. /**
  37657. * Gets an individual parser from the list of avaialble ones
  37658. * @param name Defines the name of the parser
  37659. * @returns the requested parser or null
  37660. */
  37661. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37662. /**
  37663. * Parser json data and populate both a scene and its associated container object
  37664. * @param jsonData Defines the data to parse
  37665. * @param scene Defines the scene to parse the data for
  37666. * @param container Defines the container attached to the parsing sequence
  37667. * @param rootUrl Defines the root url of the data
  37668. */
  37669. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37670. /**
  37671. * Gets the list of root nodes (ie. nodes with no parent)
  37672. */
  37673. rootNodes: Node[];
  37674. /** All of the cameras added to this scene
  37675. * @see http://doc.babylonjs.com/babylon101/cameras
  37676. */
  37677. cameras: Camera[];
  37678. /**
  37679. * All of the lights added to this scene
  37680. * @see http://doc.babylonjs.com/babylon101/lights
  37681. */
  37682. lights: Light[];
  37683. /**
  37684. * All of the (abstract) meshes added to this scene
  37685. */
  37686. meshes: AbstractMesh[];
  37687. /**
  37688. * The list of skeletons added to the scene
  37689. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37690. */
  37691. skeletons: Skeleton[];
  37692. /**
  37693. * All of the particle systems added to this scene
  37694. * @see http://doc.babylonjs.com/babylon101/particles
  37695. */
  37696. particleSystems: IParticleSystem[];
  37697. /**
  37698. * Gets a list of Animations associated with the scene
  37699. */
  37700. animations: Animation[];
  37701. /**
  37702. * All of the animation groups added to this scene
  37703. * @see http://doc.babylonjs.com/how_to/group
  37704. */
  37705. animationGroups: AnimationGroup[];
  37706. /**
  37707. * All of the multi-materials added to this scene
  37708. * @see http://doc.babylonjs.com/how_to/multi_materials
  37709. */
  37710. multiMaterials: MultiMaterial[];
  37711. /**
  37712. * All of the materials added to this scene
  37713. * In the context of a Scene, it is not supposed to be modified manually.
  37714. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37715. * Note also that the order of the Material within the array is not significant and might change.
  37716. * @see http://doc.babylonjs.com/babylon101/materials
  37717. */
  37718. materials: Material[];
  37719. /**
  37720. * The list of morph target managers added to the scene
  37721. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37722. */
  37723. morphTargetManagers: MorphTargetManager[];
  37724. /**
  37725. * The list of geometries used in the scene.
  37726. */
  37727. geometries: Geometry[];
  37728. /**
  37729. * All of the tranform nodes added to this scene
  37730. * In the context of a Scene, it is not supposed to be modified manually.
  37731. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37732. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37733. * @see http://doc.babylonjs.com/how_to/transformnode
  37734. */
  37735. transformNodes: TransformNode[];
  37736. /**
  37737. * ActionManagers available on the scene.
  37738. */
  37739. actionManagers: AbstractActionManager[];
  37740. /**
  37741. * Textures to keep.
  37742. */
  37743. textures: BaseTexture[];
  37744. /**
  37745. * Environment texture for the scene
  37746. */
  37747. environmentTexture: Nullable<BaseTexture>;
  37748. /**
  37749. * @returns all meshes, lights, cameras, transformNodes and bones
  37750. */
  37751. getNodes(): Array<Node>;
  37752. }
  37753. }
  37754. declare module BABYLON {
  37755. /**
  37756. * Interface used to define options for Sound class
  37757. */
  37758. export interface ISoundOptions {
  37759. /**
  37760. * Does the sound autoplay once loaded.
  37761. */
  37762. autoplay?: boolean;
  37763. /**
  37764. * Does the sound loop after it finishes playing once.
  37765. */
  37766. loop?: boolean;
  37767. /**
  37768. * Sound's volume
  37769. */
  37770. volume?: number;
  37771. /**
  37772. * Is it a spatial sound?
  37773. */
  37774. spatialSound?: boolean;
  37775. /**
  37776. * Maximum distance to hear that sound
  37777. */
  37778. maxDistance?: number;
  37779. /**
  37780. * Uses user defined attenuation function
  37781. */
  37782. useCustomAttenuation?: boolean;
  37783. /**
  37784. * Define the roll off factor of spatial sounds.
  37785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37786. */
  37787. rolloffFactor?: number;
  37788. /**
  37789. * Define the reference distance the sound should be heard perfectly.
  37790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37791. */
  37792. refDistance?: number;
  37793. /**
  37794. * Define the distance attenuation model the sound will follow.
  37795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37796. */
  37797. distanceModel?: string;
  37798. /**
  37799. * Defines the playback speed (1 by default)
  37800. */
  37801. playbackRate?: number;
  37802. /**
  37803. * Defines if the sound is from a streaming source
  37804. */
  37805. streaming?: boolean;
  37806. /**
  37807. * Defines an optional length (in seconds) inside the sound file
  37808. */
  37809. length?: number;
  37810. /**
  37811. * Defines an optional offset (in seconds) inside the sound file
  37812. */
  37813. offset?: number;
  37814. /**
  37815. * If true, URLs will not be required to state the audio file codec to use.
  37816. */
  37817. skipCodecCheck?: boolean;
  37818. }
  37819. /**
  37820. * Defines a sound that can be played in the application.
  37821. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37823. */
  37824. export class Sound {
  37825. /**
  37826. * The name of the sound in the scene.
  37827. */
  37828. name: string;
  37829. /**
  37830. * Does the sound autoplay once loaded.
  37831. */
  37832. autoplay: boolean;
  37833. /**
  37834. * Does the sound loop after it finishes playing once.
  37835. */
  37836. loop: boolean;
  37837. /**
  37838. * Does the sound use a custom attenuation curve to simulate the falloff
  37839. * happening when the source gets further away from the camera.
  37840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37841. */
  37842. useCustomAttenuation: boolean;
  37843. /**
  37844. * The sound track id this sound belongs to.
  37845. */
  37846. soundTrackId: number;
  37847. /**
  37848. * Is this sound currently played.
  37849. */
  37850. isPlaying: boolean;
  37851. /**
  37852. * Is this sound currently paused.
  37853. */
  37854. isPaused: boolean;
  37855. /**
  37856. * Does this sound enables spatial sound.
  37857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37858. */
  37859. spatialSound: boolean;
  37860. /**
  37861. * Define the reference distance the sound should be heard perfectly.
  37862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37863. */
  37864. refDistance: number;
  37865. /**
  37866. * Define the roll off factor of spatial sounds.
  37867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37868. */
  37869. rolloffFactor: number;
  37870. /**
  37871. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37873. */
  37874. maxDistance: number;
  37875. /**
  37876. * Define the distance attenuation model the sound will follow.
  37877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37878. */
  37879. distanceModel: string;
  37880. /**
  37881. * @hidden
  37882. * Back Compat
  37883. **/
  37884. onended: () => any;
  37885. /**
  37886. * Observable event when the current playing sound finishes.
  37887. */
  37888. onEndedObservable: Observable<Sound>;
  37889. private _panningModel;
  37890. private _playbackRate;
  37891. private _streaming;
  37892. private _startTime;
  37893. private _startOffset;
  37894. private _position;
  37895. /** @hidden */
  37896. _positionInEmitterSpace: boolean;
  37897. private _localDirection;
  37898. private _volume;
  37899. private _isReadyToPlay;
  37900. private _isDirectional;
  37901. private _readyToPlayCallback;
  37902. private _audioBuffer;
  37903. private _soundSource;
  37904. private _streamingSource;
  37905. private _soundPanner;
  37906. private _soundGain;
  37907. private _inputAudioNode;
  37908. private _outputAudioNode;
  37909. private _coneInnerAngle;
  37910. private _coneOuterAngle;
  37911. private _coneOuterGain;
  37912. private _scene;
  37913. private _connectedTransformNode;
  37914. private _customAttenuationFunction;
  37915. private _registerFunc;
  37916. private _isOutputConnected;
  37917. private _htmlAudioElement;
  37918. private _urlType;
  37919. private _length?;
  37920. private _offset?;
  37921. /** @hidden */
  37922. static _SceneComponentInitialization: (scene: Scene) => void;
  37923. /**
  37924. * Create a sound and attach it to a scene
  37925. * @param name Name of your sound
  37926. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37927. * @param scene defines the scene the sound belongs to
  37928. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37929. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37930. */
  37931. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37932. /**
  37933. * Release the sound and its associated resources
  37934. */
  37935. dispose(): void;
  37936. /**
  37937. * Gets if the sounds is ready to be played or not.
  37938. * @returns true if ready, otherwise false
  37939. */
  37940. isReady(): boolean;
  37941. private _soundLoaded;
  37942. /**
  37943. * Sets the data of the sound from an audiobuffer
  37944. * @param audioBuffer The audioBuffer containing the data
  37945. */
  37946. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37947. /**
  37948. * Updates the current sounds options such as maxdistance, loop...
  37949. * @param options A JSON object containing values named as the object properties
  37950. */
  37951. updateOptions(options: ISoundOptions): void;
  37952. private _createSpatialParameters;
  37953. private _updateSpatialParameters;
  37954. /**
  37955. * Switch the panning model to HRTF:
  37956. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37958. */
  37959. switchPanningModelToHRTF(): void;
  37960. /**
  37961. * Switch the panning model to Equal Power:
  37962. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37964. */
  37965. switchPanningModelToEqualPower(): void;
  37966. private _switchPanningModel;
  37967. /**
  37968. * Connect this sound to a sound track audio node like gain...
  37969. * @param soundTrackAudioNode the sound track audio node to connect to
  37970. */
  37971. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37972. /**
  37973. * Transform this sound into a directional source
  37974. * @param coneInnerAngle Size of the inner cone in degree
  37975. * @param coneOuterAngle Size of the outer cone in degree
  37976. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37977. */
  37978. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37979. /**
  37980. * Gets or sets the inner angle for the directional cone.
  37981. */
  37982. get directionalConeInnerAngle(): number;
  37983. /**
  37984. * Gets or sets the inner angle for the directional cone.
  37985. */
  37986. set directionalConeInnerAngle(value: number);
  37987. /**
  37988. * Gets or sets the outer angle for the directional cone.
  37989. */
  37990. get directionalConeOuterAngle(): number;
  37991. /**
  37992. * Gets or sets the outer angle for the directional cone.
  37993. */
  37994. set directionalConeOuterAngle(value: number);
  37995. /**
  37996. * Sets the position of the emitter if spatial sound is enabled
  37997. * @param newPosition Defines the new posisiton
  37998. */
  37999. setPosition(newPosition: Vector3): void;
  38000. /**
  38001. * Sets the local direction of the emitter if spatial sound is enabled
  38002. * @param newLocalDirection Defines the new local direction
  38003. */
  38004. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38005. private _updateDirection;
  38006. /** @hidden */
  38007. updateDistanceFromListener(): void;
  38008. /**
  38009. * Sets a new custom attenuation function for the sound.
  38010. * @param callback Defines the function used for the attenuation
  38011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38012. */
  38013. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38014. /**
  38015. * Play the sound
  38016. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38017. * @param offset (optional) Start the sound at a specific time in seconds
  38018. * @param length (optional) Sound duration (in seconds)
  38019. */
  38020. play(time?: number, offset?: number, length?: number): void;
  38021. private _onended;
  38022. /**
  38023. * Stop the sound
  38024. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38025. */
  38026. stop(time?: number): void;
  38027. /**
  38028. * Put the sound in pause
  38029. */
  38030. pause(): void;
  38031. /**
  38032. * Sets a dedicated volume for this sounds
  38033. * @param newVolume Define the new volume of the sound
  38034. * @param time Define time for gradual change to new volume
  38035. */
  38036. setVolume(newVolume: number, time?: number): void;
  38037. /**
  38038. * Set the sound play back rate
  38039. * @param newPlaybackRate Define the playback rate the sound should be played at
  38040. */
  38041. setPlaybackRate(newPlaybackRate: number): void;
  38042. /**
  38043. * Gets the volume of the sound.
  38044. * @returns the volume of the sound
  38045. */
  38046. getVolume(): number;
  38047. /**
  38048. * Attach the sound to a dedicated mesh
  38049. * @param transformNode The transform node to connect the sound with
  38050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38051. */
  38052. attachToMesh(transformNode: TransformNode): void;
  38053. /**
  38054. * Detach the sound from the previously attached mesh
  38055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38056. */
  38057. detachFromMesh(): void;
  38058. private _onRegisterAfterWorldMatrixUpdate;
  38059. /**
  38060. * Clone the current sound in the scene.
  38061. * @returns the new sound clone
  38062. */
  38063. clone(): Nullable<Sound>;
  38064. /**
  38065. * Gets the current underlying audio buffer containing the data
  38066. * @returns the audio buffer
  38067. */
  38068. getAudioBuffer(): Nullable<AudioBuffer>;
  38069. /**
  38070. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38071. * @returns the source node
  38072. */
  38073. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38074. /**
  38075. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38076. * @returns the gain node
  38077. */
  38078. getSoundGain(): Nullable<GainNode>;
  38079. /**
  38080. * Serializes the Sound in a JSON representation
  38081. * @returns the JSON representation of the sound
  38082. */
  38083. serialize(): any;
  38084. /**
  38085. * Parse a JSON representation of a sound to innstantiate in a given scene
  38086. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38087. * @param scene Define the scene the new parsed sound should be created in
  38088. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38089. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38090. * @returns the newly parsed sound
  38091. */
  38092. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38093. }
  38094. }
  38095. declare module BABYLON {
  38096. /**
  38097. * This defines an action helpful to play a defined sound on a triggered action.
  38098. */
  38099. export class PlaySoundAction extends Action {
  38100. private _sound;
  38101. /**
  38102. * Instantiate the action
  38103. * @param triggerOptions defines the trigger options
  38104. * @param sound defines the sound to play
  38105. * @param condition defines the trigger related conditions
  38106. */
  38107. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38108. /** @hidden */
  38109. _prepare(): void;
  38110. /**
  38111. * Execute the action and play the sound.
  38112. */
  38113. execute(): void;
  38114. /**
  38115. * Serializes the actions and its related information.
  38116. * @param parent defines the object to serialize in
  38117. * @returns the serialized object
  38118. */
  38119. serialize(parent: any): any;
  38120. }
  38121. /**
  38122. * This defines an action helpful to stop a defined sound on a triggered action.
  38123. */
  38124. export class StopSoundAction extends Action {
  38125. private _sound;
  38126. /**
  38127. * Instantiate the action
  38128. * @param triggerOptions defines the trigger options
  38129. * @param sound defines the sound to stop
  38130. * @param condition defines the trigger related conditions
  38131. */
  38132. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38133. /** @hidden */
  38134. _prepare(): void;
  38135. /**
  38136. * Execute the action and stop the sound.
  38137. */
  38138. execute(): void;
  38139. /**
  38140. * Serializes the actions and its related information.
  38141. * @param parent defines the object to serialize in
  38142. * @returns the serialized object
  38143. */
  38144. serialize(parent: any): any;
  38145. }
  38146. }
  38147. declare module BABYLON {
  38148. /**
  38149. * This defines an action responsible to change the value of a property
  38150. * by interpolating between its current value and the newly set one once triggered.
  38151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38152. */
  38153. export class InterpolateValueAction extends Action {
  38154. /**
  38155. * Defines the path of the property where the value should be interpolated
  38156. */
  38157. propertyPath: string;
  38158. /**
  38159. * Defines the target value at the end of the interpolation.
  38160. */
  38161. value: any;
  38162. /**
  38163. * Defines the time it will take for the property to interpolate to the value.
  38164. */
  38165. duration: number;
  38166. /**
  38167. * Defines if the other scene animations should be stopped when the action has been triggered
  38168. */
  38169. stopOtherAnimations?: boolean;
  38170. /**
  38171. * Defines a callback raised once the interpolation animation has been done.
  38172. */
  38173. onInterpolationDone?: () => void;
  38174. /**
  38175. * Observable triggered once the interpolation animation has been done.
  38176. */
  38177. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38178. private _target;
  38179. private _effectiveTarget;
  38180. private _property;
  38181. /**
  38182. * Instantiate the action
  38183. * @param triggerOptions defines the trigger options
  38184. * @param target defines the object containing the value to interpolate
  38185. * @param propertyPath defines the path to the property in the target object
  38186. * @param value defines the target value at the end of the interpolation
  38187. * @param duration deines the time it will take for the property to interpolate to the value.
  38188. * @param condition defines the trigger related conditions
  38189. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38190. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38191. */
  38192. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38193. /** @hidden */
  38194. _prepare(): void;
  38195. /**
  38196. * Execute the action starts the value interpolation.
  38197. */
  38198. execute(): void;
  38199. /**
  38200. * Serializes the actions and its related information.
  38201. * @param parent defines the object to serialize in
  38202. * @returns the serialized object
  38203. */
  38204. serialize(parent: any): any;
  38205. }
  38206. }
  38207. declare module BABYLON {
  38208. /**
  38209. * Options allowed during the creation of a sound track.
  38210. */
  38211. export interface ISoundTrackOptions {
  38212. /**
  38213. * The volume the sound track should take during creation
  38214. */
  38215. volume?: number;
  38216. /**
  38217. * Define if the sound track is the main sound track of the scene
  38218. */
  38219. mainTrack?: boolean;
  38220. }
  38221. /**
  38222. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38223. * It will be also used in a future release to apply effects on a specific track.
  38224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38225. */
  38226. export class SoundTrack {
  38227. /**
  38228. * The unique identifier of the sound track in the scene.
  38229. */
  38230. id: number;
  38231. /**
  38232. * The list of sounds included in the sound track.
  38233. */
  38234. soundCollection: Array<Sound>;
  38235. private _outputAudioNode;
  38236. private _scene;
  38237. private _connectedAnalyser;
  38238. private _options;
  38239. private _isInitialized;
  38240. /**
  38241. * Creates a new sound track.
  38242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38243. * @param scene Define the scene the sound track belongs to
  38244. * @param options
  38245. */
  38246. constructor(scene: Scene, options?: ISoundTrackOptions);
  38247. private _initializeSoundTrackAudioGraph;
  38248. /**
  38249. * Release the sound track and its associated resources
  38250. */
  38251. dispose(): void;
  38252. /**
  38253. * Adds a sound to this sound track
  38254. * @param sound define the cound to add
  38255. * @ignoreNaming
  38256. */
  38257. AddSound(sound: Sound): void;
  38258. /**
  38259. * Removes a sound to this sound track
  38260. * @param sound define the cound to remove
  38261. * @ignoreNaming
  38262. */
  38263. RemoveSound(sound: Sound): void;
  38264. /**
  38265. * Set a global volume for the full sound track.
  38266. * @param newVolume Define the new volume of the sound track
  38267. */
  38268. setVolume(newVolume: number): void;
  38269. /**
  38270. * Switch the panning model to HRTF:
  38271. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38273. */
  38274. switchPanningModelToHRTF(): void;
  38275. /**
  38276. * Switch the panning model to Equal Power:
  38277. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38279. */
  38280. switchPanningModelToEqualPower(): void;
  38281. /**
  38282. * Connect the sound track to an audio analyser allowing some amazing
  38283. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38285. * @param analyser The analyser to connect to the engine
  38286. */
  38287. connectToAnalyser(analyser: Analyser): void;
  38288. }
  38289. }
  38290. declare module BABYLON {
  38291. interface AbstractScene {
  38292. /**
  38293. * The list of sounds used in the scene.
  38294. */
  38295. sounds: Nullable<Array<Sound>>;
  38296. }
  38297. interface Scene {
  38298. /**
  38299. * @hidden
  38300. * Backing field
  38301. */
  38302. _mainSoundTrack: SoundTrack;
  38303. /**
  38304. * The main sound track played by the scene.
  38305. * It cotains your primary collection of sounds.
  38306. */
  38307. mainSoundTrack: SoundTrack;
  38308. /**
  38309. * The list of sound tracks added to the scene
  38310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38311. */
  38312. soundTracks: Nullable<Array<SoundTrack>>;
  38313. /**
  38314. * Gets a sound using a given name
  38315. * @param name defines the name to search for
  38316. * @return the found sound or null if not found at all.
  38317. */
  38318. getSoundByName(name: string): Nullable<Sound>;
  38319. /**
  38320. * Gets or sets if audio support is enabled
  38321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38322. */
  38323. audioEnabled: boolean;
  38324. /**
  38325. * Gets or sets if audio will be output to headphones
  38326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38327. */
  38328. headphone: boolean;
  38329. /**
  38330. * Gets or sets custom audio listener position provider
  38331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38332. */
  38333. audioListenerPositionProvider: Nullable<() => Vector3>;
  38334. /**
  38335. * Gets or sets a refresh rate when using 3D audio positioning
  38336. */
  38337. audioPositioningRefreshRate: number;
  38338. }
  38339. /**
  38340. * Defines the sound scene component responsible to manage any sounds
  38341. * in a given scene.
  38342. */
  38343. export class AudioSceneComponent implements ISceneSerializableComponent {
  38344. /**
  38345. * The component name helpfull to identify the component in the list of scene components.
  38346. */
  38347. readonly name: string;
  38348. /**
  38349. * The scene the component belongs to.
  38350. */
  38351. scene: Scene;
  38352. private _audioEnabled;
  38353. /**
  38354. * Gets whether audio is enabled or not.
  38355. * Please use related enable/disable method to switch state.
  38356. */
  38357. get audioEnabled(): boolean;
  38358. private _headphone;
  38359. /**
  38360. * Gets whether audio is outputing to headphone or not.
  38361. * Please use the according Switch methods to change output.
  38362. */
  38363. get headphone(): boolean;
  38364. /**
  38365. * Gets or sets a refresh rate when using 3D audio positioning
  38366. */
  38367. audioPositioningRefreshRate: number;
  38368. private _audioListenerPositionProvider;
  38369. /**
  38370. * Gets the current audio listener position provider
  38371. */
  38372. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38373. /**
  38374. * Sets a custom listener position for all sounds in the scene
  38375. * By default, this is the position of the first active camera
  38376. */
  38377. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38378. /**
  38379. * Creates a new instance of the component for the given scene
  38380. * @param scene Defines the scene to register the component in
  38381. */
  38382. constructor(scene: Scene);
  38383. /**
  38384. * Registers the component in a given scene
  38385. */
  38386. register(): void;
  38387. /**
  38388. * Rebuilds the elements related to this component in case of
  38389. * context lost for instance.
  38390. */
  38391. rebuild(): void;
  38392. /**
  38393. * Serializes the component data to the specified json object
  38394. * @param serializationObject The object to serialize to
  38395. */
  38396. serialize(serializationObject: any): void;
  38397. /**
  38398. * Adds all the elements from the container to the scene
  38399. * @param container the container holding the elements
  38400. */
  38401. addFromContainer(container: AbstractScene): void;
  38402. /**
  38403. * Removes all the elements in the container from the scene
  38404. * @param container contains the elements to remove
  38405. * @param dispose if the removed element should be disposed (default: false)
  38406. */
  38407. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38408. /**
  38409. * Disposes the component and the associated ressources.
  38410. */
  38411. dispose(): void;
  38412. /**
  38413. * Disables audio in the associated scene.
  38414. */
  38415. disableAudio(): void;
  38416. /**
  38417. * Enables audio in the associated scene.
  38418. */
  38419. enableAudio(): void;
  38420. /**
  38421. * Switch audio to headphone output.
  38422. */
  38423. switchAudioModeForHeadphones(): void;
  38424. /**
  38425. * Switch audio to normal speakers.
  38426. */
  38427. switchAudioModeForNormalSpeakers(): void;
  38428. private _cachedCameraDirection;
  38429. private _cachedCameraPosition;
  38430. private _lastCheck;
  38431. private _afterRender;
  38432. }
  38433. }
  38434. declare module BABYLON {
  38435. /**
  38436. * Wraps one or more Sound objects and selects one with random weight for playback.
  38437. */
  38438. export class WeightedSound {
  38439. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38440. loop: boolean;
  38441. private _coneInnerAngle;
  38442. private _coneOuterAngle;
  38443. private _volume;
  38444. /** A Sound is currently playing. */
  38445. isPlaying: boolean;
  38446. /** A Sound is currently paused. */
  38447. isPaused: boolean;
  38448. private _sounds;
  38449. private _weights;
  38450. private _currentIndex?;
  38451. /**
  38452. * Creates a new WeightedSound from the list of sounds given.
  38453. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38454. * @param sounds Array of Sounds that will be selected from.
  38455. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38456. */
  38457. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38458. /**
  38459. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38460. */
  38461. get directionalConeInnerAngle(): number;
  38462. /**
  38463. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38464. */
  38465. set directionalConeInnerAngle(value: number);
  38466. /**
  38467. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38468. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38469. */
  38470. get directionalConeOuterAngle(): number;
  38471. /**
  38472. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38473. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38474. */
  38475. set directionalConeOuterAngle(value: number);
  38476. /**
  38477. * Playback volume.
  38478. */
  38479. get volume(): number;
  38480. /**
  38481. * Playback volume.
  38482. */
  38483. set volume(value: number);
  38484. private _onended;
  38485. /**
  38486. * Suspend playback
  38487. */
  38488. pause(): void;
  38489. /**
  38490. * Stop playback
  38491. */
  38492. stop(): void;
  38493. /**
  38494. * Start playback.
  38495. * @param startOffset Position the clip head at a specific time in seconds.
  38496. */
  38497. play(startOffset?: number): void;
  38498. }
  38499. }
  38500. declare module BABYLON {
  38501. /**
  38502. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38504. */
  38505. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38506. /**
  38507. * Gets the name of the behavior.
  38508. */
  38509. get name(): string;
  38510. /**
  38511. * The easing function used by animations
  38512. */
  38513. static EasingFunction: BackEase;
  38514. /**
  38515. * The easing mode used by animations
  38516. */
  38517. static EasingMode: number;
  38518. /**
  38519. * The duration of the animation, in milliseconds
  38520. */
  38521. transitionDuration: number;
  38522. /**
  38523. * Length of the distance animated by the transition when lower radius is reached
  38524. */
  38525. lowerRadiusTransitionRange: number;
  38526. /**
  38527. * Length of the distance animated by the transition when upper radius is reached
  38528. */
  38529. upperRadiusTransitionRange: number;
  38530. private _autoTransitionRange;
  38531. /**
  38532. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38533. */
  38534. get autoTransitionRange(): boolean;
  38535. /**
  38536. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38537. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38538. */
  38539. set autoTransitionRange(value: boolean);
  38540. private _attachedCamera;
  38541. private _onAfterCheckInputsObserver;
  38542. private _onMeshTargetChangedObserver;
  38543. /**
  38544. * Initializes the behavior.
  38545. */
  38546. init(): void;
  38547. /**
  38548. * Attaches the behavior to its arc rotate camera.
  38549. * @param camera Defines the camera to attach the behavior to
  38550. */
  38551. attach(camera: ArcRotateCamera): void;
  38552. /**
  38553. * Detaches the behavior from its current arc rotate camera.
  38554. */
  38555. detach(): void;
  38556. private _radiusIsAnimating;
  38557. private _radiusBounceTransition;
  38558. private _animatables;
  38559. private _cachedWheelPrecision;
  38560. /**
  38561. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38562. * @param radiusLimit The limit to check against.
  38563. * @return Bool to indicate if at limit.
  38564. */
  38565. private _isRadiusAtLimit;
  38566. /**
  38567. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38568. * @param radiusDelta The delta by which to animate to. Can be negative.
  38569. */
  38570. private _applyBoundRadiusAnimation;
  38571. /**
  38572. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38573. */
  38574. protected _clearAnimationLocks(): void;
  38575. /**
  38576. * Stops and removes all animations that have been applied to the camera
  38577. */
  38578. stopAllAnimations(): void;
  38579. }
  38580. }
  38581. declare module BABYLON {
  38582. /**
  38583. * 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.
  38584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38585. */
  38586. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38587. /**
  38588. * Gets the name of the behavior.
  38589. */
  38590. get name(): string;
  38591. private _mode;
  38592. private _radiusScale;
  38593. private _positionScale;
  38594. private _defaultElevation;
  38595. private _elevationReturnTime;
  38596. private _elevationReturnWaitTime;
  38597. private _zoomStopsAnimation;
  38598. private _framingTime;
  38599. /**
  38600. * The easing function used by animations
  38601. */
  38602. static EasingFunction: ExponentialEase;
  38603. /**
  38604. * The easing mode used by animations
  38605. */
  38606. static EasingMode: number;
  38607. /**
  38608. * Sets the current mode used by the behavior
  38609. */
  38610. set mode(mode: number);
  38611. /**
  38612. * Gets current mode used by the behavior.
  38613. */
  38614. get mode(): number;
  38615. /**
  38616. * Sets the scale applied to the radius (1 by default)
  38617. */
  38618. set radiusScale(radius: number);
  38619. /**
  38620. * Gets the scale applied to the radius
  38621. */
  38622. get radiusScale(): number;
  38623. /**
  38624. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38625. */
  38626. set positionScale(scale: number);
  38627. /**
  38628. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38629. */
  38630. get positionScale(): number;
  38631. /**
  38632. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38633. * behaviour is triggered, in radians.
  38634. */
  38635. set defaultElevation(elevation: number);
  38636. /**
  38637. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38638. * behaviour is triggered, in radians.
  38639. */
  38640. get defaultElevation(): number;
  38641. /**
  38642. * Sets the time (in milliseconds) taken to return to the default beta position.
  38643. * Negative value indicates camera should not return to default.
  38644. */
  38645. set elevationReturnTime(speed: number);
  38646. /**
  38647. * Gets the time (in milliseconds) taken to return to the default beta position.
  38648. * Negative value indicates camera should not return to default.
  38649. */
  38650. get elevationReturnTime(): number;
  38651. /**
  38652. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38653. */
  38654. set elevationReturnWaitTime(time: number);
  38655. /**
  38656. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38657. */
  38658. get elevationReturnWaitTime(): number;
  38659. /**
  38660. * Sets the flag that indicates if user zooming should stop animation.
  38661. */
  38662. set zoomStopsAnimation(flag: boolean);
  38663. /**
  38664. * Gets the flag that indicates if user zooming should stop animation.
  38665. */
  38666. get zoomStopsAnimation(): boolean;
  38667. /**
  38668. * Sets the transition time when framing the mesh, in milliseconds
  38669. */
  38670. set framingTime(time: number);
  38671. /**
  38672. * Gets the transition time when framing the mesh, in milliseconds
  38673. */
  38674. get framingTime(): number;
  38675. /**
  38676. * Define if the behavior should automatically change the configured
  38677. * camera limits and sensibilities.
  38678. */
  38679. autoCorrectCameraLimitsAndSensibility: boolean;
  38680. private _onPrePointerObservableObserver;
  38681. private _onAfterCheckInputsObserver;
  38682. private _onMeshTargetChangedObserver;
  38683. private _attachedCamera;
  38684. private _isPointerDown;
  38685. private _lastInteractionTime;
  38686. /**
  38687. * Initializes the behavior.
  38688. */
  38689. init(): void;
  38690. /**
  38691. * Attaches the behavior to its arc rotate camera.
  38692. * @param camera Defines the camera to attach the behavior to
  38693. */
  38694. attach(camera: ArcRotateCamera): void;
  38695. /**
  38696. * Detaches the behavior from its current arc rotate camera.
  38697. */
  38698. detach(): void;
  38699. private _animatables;
  38700. private _betaIsAnimating;
  38701. private _betaTransition;
  38702. private _radiusTransition;
  38703. private _vectorTransition;
  38704. /**
  38705. * Targets the given mesh and updates zoom level accordingly.
  38706. * @param mesh The mesh to target.
  38707. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38708. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38709. */
  38710. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38711. /**
  38712. * Targets the given mesh with its children and updates zoom level accordingly.
  38713. * @param mesh The mesh to target.
  38714. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38715. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38716. */
  38717. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38718. /**
  38719. * Targets the given meshes with their children and updates zoom level accordingly.
  38720. * @param meshes The mesh to target.
  38721. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38722. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38723. */
  38724. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38725. /**
  38726. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38727. * @param minimumWorld Determines the smaller position of the bounding box extend
  38728. * @param maximumWorld Determines the bigger position of the bounding box extend
  38729. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38730. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38731. */
  38732. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38733. /**
  38734. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38735. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38736. * frustum width.
  38737. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38738. * to fully enclose the mesh in the viewing frustum.
  38739. */
  38740. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38741. /**
  38742. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38743. * is automatically returned to its default position (expected to be above ground plane).
  38744. */
  38745. private _maintainCameraAboveGround;
  38746. /**
  38747. * Returns the frustum slope based on the canvas ratio and camera FOV
  38748. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38749. */
  38750. private _getFrustumSlope;
  38751. /**
  38752. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38753. */
  38754. private _clearAnimationLocks;
  38755. /**
  38756. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38757. */
  38758. private _applyUserInteraction;
  38759. /**
  38760. * Stops and removes all animations that have been applied to the camera
  38761. */
  38762. stopAllAnimations(): void;
  38763. /**
  38764. * Gets a value indicating if the user is moving the camera
  38765. */
  38766. get isUserIsMoving(): boolean;
  38767. /**
  38768. * The camera can move all the way towards the mesh.
  38769. */
  38770. static IgnoreBoundsSizeMode: number;
  38771. /**
  38772. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38773. */
  38774. static FitFrustumSidesMode: number;
  38775. }
  38776. }
  38777. declare module BABYLON {
  38778. /**
  38779. * Base class for Camera Pointer Inputs.
  38780. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38781. * for example usage.
  38782. */
  38783. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38784. /**
  38785. * Defines the camera the input is attached to.
  38786. */
  38787. abstract camera: Camera;
  38788. /**
  38789. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38790. */
  38791. protected _altKey: boolean;
  38792. protected _ctrlKey: boolean;
  38793. protected _metaKey: boolean;
  38794. protected _shiftKey: boolean;
  38795. /**
  38796. * Which mouse buttons were pressed at time of last mouse event.
  38797. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38798. */
  38799. protected _buttonsPressed: number;
  38800. /**
  38801. * Defines the buttons associated with the input to handle camera move.
  38802. */
  38803. buttons: number[];
  38804. /**
  38805. * Attach the input controls to a specific dom element to get the input from.
  38806. * @param element Defines the element the controls should be listened from
  38807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38808. */
  38809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38810. /**
  38811. * Detach the current controls from the specified dom element.
  38812. * @param element Defines the element to stop listening the inputs from
  38813. */
  38814. detachControl(element: Nullable<HTMLElement>): void;
  38815. /**
  38816. * Gets the class name of the current input.
  38817. * @returns the class name
  38818. */
  38819. getClassName(): string;
  38820. /**
  38821. * Get the friendly name associated with the input class.
  38822. * @returns the input friendly name
  38823. */
  38824. getSimpleName(): string;
  38825. /**
  38826. * Called on pointer POINTERDOUBLETAP event.
  38827. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38828. */
  38829. protected onDoubleTap(type: string): void;
  38830. /**
  38831. * Called on pointer POINTERMOVE event if only a single touch is active.
  38832. * Override this method to provide functionality.
  38833. */
  38834. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38835. /**
  38836. * Called on pointer POINTERMOVE event if multiple touches are active.
  38837. * Override this method to provide functionality.
  38838. */
  38839. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38840. /**
  38841. * Called on JS contextmenu event.
  38842. * Override this method to provide functionality.
  38843. */
  38844. protected onContextMenu(evt: PointerEvent): void;
  38845. /**
  38846. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38847. * press.
  38848. * Override this method to provide functionality.
  38849. */
  38850. protected onButtonDown(evt: PointerEvent): void;
  38851. /**
  38852. * Called each time a new POINTERUP event occurs. Ie, for each button
  38853. * release.
  38854. * Override this method to provide functionality.
  38855. */
  38856. protected onButtonUp(evt: PointerEvent): void;
  38857. /**
  38858. * Called when window becomes inactive.
  38859. * Override this method to provide functionality.
  38860. */
  38861. protected onLostFocus(): void;
  38862. private _pointerInput;
  38863. private _observer;
  38864. private _onLostFocus;
  38865. private pointA;
  38866. private pointB;
  38867. }
  38868. }
  38869. declare module BABYLON {
  38870. /**
  38871. * Manage the pointers inputs to control an arc rotate camera.
  38872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38873. */
  38874. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38875. /**
  38876. * Defines the camera the input is attached to.
  38877. */
  38878. camera: ArcRotateCamera;
  38879. /**
  38880. * Gets the class name of the current input.
  38881. * @returns the class name
  38882. */
  38883. getClassName(): string;
  38884. /**
  38885. * Defines the buttons associated with the input to handle camera move.
  38886. */
  38887. buttons: number[];
  38888. /**
  38889. * Defines the pointer angular sensibility along the X axis or how fast is
  38890. * the camera rotating.
  38891. */
  38892. angularSensibilityX: number;
  38893. /**
  38894. * Defines the pointer angular sensibility along the Y axis or how fast is
  38895. * the camera rotating.
  38896. */
  38897. angularSensibilityY: number;
  38898. /**
  38899. * Defines the pointer pinch precision or how fast is the camera zooming.
  38900. */
  38901. pinchPrecision: number;
  38902. /**
  38903. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38904. * from 0.
  38905. * It defines the percentage of current camera.radius to use as delta when
  38906. * pinch zoom is used.
  38907. */
  38908. pinchDeltaPercentage: number;
  38909. /**
  38910. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38911. * that any object in the plane at the camera's target point will scale
  38912. * perfectly with finger motion.
  38913. * Overrides pinchDeltaPercentage and pinchPrecision.
  38914. */
  38915. useNaturalPinchZoom: boolean;
  38916. /**
  38917. * Defines the pointer panning sensibility or how fast is the camera moving.
  38918. */
  38919. panningSensibility: number;
  38920. /**
  38921. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38922. */
  38923. multiTouchPanning: boolean;
  38924. /**
  38925. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38926. * zoom (pinch) through multitouch.
  38927. */
  38928. multiTouchPanAndZoom: boolean;
  38929. /**
  38930. * Revers pinch action direction.
  38931. */
  38932. pinchInwards: boolean;
  38933. private _isPanClick;
  38934. private _twoFingerActivityCount;
  38935. private _isPinching;
  38936. /**
  38937. * Called on pointer POINTERMOVE event if only a single touch is active.
  38938. */
  38939. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38940. /**
  38941. * Called on pointer POINTERDOUBLETAP event.
  38942. */
  38943. protected onDoubleTap(type: string): void;
  38944. /**
  38945. * Called on pointer POINTERMOVE event if multiple touches are active.
  38946. */
  38947. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38948. /**
  38949. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38950. * press.
  38951. */
  38952. protected onButtonDown(evt: PointerEvent): void;
  38953. /**
  38954. * Called each time a new POINTERUP event occurs. Ie, for each button
  38955. * release.
  38956. */
  38957. protected onButtonUp(evt: PointerEvent): void;
  38958. /**
  38959. * Called when window becomes inactive.
  38960. */
  38961. protected onLostFocus(): void;
  38962. }
  38963. }
  38964. declare module BABYLON {
  38965. /**
  38966. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38968. */
  38969. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38970. /**
  38971. * Defines the camera the input is attached to.
  38972. */
  38973. camera: ArcRotateCamera;
  38974. /**
  38975. * Defines the list of key codes associated with the up action (increase alpha)
  38976. */
  38977. keysUp: number[];
  38978. /**
  38979. * Defines the list of key codes associated with the down action (decrease alpha)
  38980. */
  38981. keysDown: number[];
  38982. /**
  38983. * Defines the list of key codes associated with the left action (increase beta)
  38984. */
  38985. keysLeft: number[];
  38986. /**
  38987. * Defines the list of key codes associated with the right action (decrease beta)
  38988. */
  38989. keysRight: number[];
  38990. /**
  38991. * Defines the list of key codes associated with the reset action.
  38992. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38993. */
  38994. keysReset: number[];
  38995. /**
  38996. * Defines the panning sensibility of the inputs.
  38997. * (How fast is the camera panning)
  38998. */
  38999. panningSensibility: number;
  39000. /**
  39001. * Defines the zooming sensibility of the inputs.
  39002. * (How fast is the camera zooming)
  39003. */
  39004. zoomingSensibility: number;
  39005. /**
  39006. * Defines whether maintaining the alt key down switch the movement mode from
  39007. * orientation to zoom.
  39008. */
  39009. useAltToZoom: boolean;
  39010. /**
  39011. * Rotation speed of the camera
  39012. */
  39013. angularSpeed: number;
  39014. private _keys;
  39015. private _ctrlPressed;
  39016. private _altPressed;
  39017. private _onCanvasBlurObserver;
  39018. private _onKeyboardObserver;
  39019. private _engine;
  39020. private _scene;
  39021. /**
  39022. * Attach the input controls to a specific dom element to get the input from.
  39023. * @param element Defines the element the controls should be listened from
  39024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39025. */
  39026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39027. /**
  39028. * Detach the current controls from the specified dom element.
  39029. * @param element Defines the element to stop listening the inputs from
  39030. */
  39031. detachControl(element: Nullable<HTMLElement>): void;
  39032. /**
  39033. * Update the current camera state depending on the inputs that have been used this frame.
  39034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39035. */
  39036. checkInputs(): void;
  39037. /**
  39038. * Gets the class name of the current intput.
  39039. * @returns the class name
  39040. */
  39041. getClassName(): string;
  39042. /**
  39043. * Get the friendly name associated with the input class.
  39044. * @returns the input friendly name
  39045. */
  39046. getSimpleName(): string;
  39047. }
  39048. }
  39049. declare module BABYLON {
  39050. /**
  39051. * Manage the mouse wheel inputs to control an arc rotate camera.
  39052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39053. */
  39054. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39055. /**
  39056. * Defines the camera the input is attached to.
  39057. */
  39058. camera: ArcRotateCamera;
  39059. /**
  39060. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39061. */
  39062. wheelPrecision: number;
  39063. /**
  39064. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39065. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39066. */
  39067. wheelDeltaPercentage: number;
  39068. private _wheel;
  39069. private _observer;
  39070. private computeDeltaFromMouseWheelLegacyEvent;
  39071. /**
  39072. * Attach the input controls to a specific dom element to get the input from.
  39073. * @param element Defines the element the controls should be listened from
  39074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39075. */
  39076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39077. /**
  39078. * Detach the current controls from the specified dom element.
  39079. * @param element Defines the element to stop listening the inputs from
  39080. */
  39081. detachControl(element: Nullable<HTMLElement>): void;
  39082. /**
  39083. * Gets the class name of the current intput.
  39084. * @returns the class name
  39085. */
  39086. getClassName(): string;
  39087. /**
  39088. * Get the friendly name associated with the input class.
  39089. * @returns the input friendly name
  39090. */
  39091. getSimpleName(): string;
  39092. }
  39093. }
  39094. declare module BABYLON {
  39095. /**
  39096. * Default Inputs manager for the ArcRotateCamera.
  39097. * It groups all the default supported inputs for ease of use.
  39098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39099. */
  39100. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39101. /**
  39102. * Instantiates a new ArcRotateCameraInputsManager.
  39103. * @param camera Defines the camera the inputs belong to
  39104. */
  39105. constructor(camera: ArcRotateCamera);
  39106. /**
  39107. * Add mouse wheel input support to the input manager.
  39108. * @returns the current input manager
  39109. */
  39110. addMouseWheel(): ArcRotateCameraInputsManager;
  39111. /**
  39112. * Add pointers input support to the input manager.
  39113. * @returns the current input manager
  39114. */
  39115. addPointers(): ArcRotateCameraInputsManager;
  39116. /**
  39117. * Add keyboard input support to the input manager.
  39118. * @returns the current input manager
  39119. */
  39120. addKeyboard(): ArcRotateCameraInputsManager;
  39121. }
  39122. }
  39123. declare module BABYLON {
  39124. /**
  39125. * This represents an orbital type of camera.
  39126. *
  39127. * 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.
  39128. * 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.
  39129. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39130. */
  39131. export class ArcRotateCamera extends TargetCamera {
  39132. /**
  39133. * Defines the rotation angle of the camera along the longitudinal axis.
  39134. */
  39135. alpha: number;
  39136. /**
  39137. * Defines the rotation angle of the camera along the latitudinal axis.
  39138. */
  39139. beta: number;
  39140. /**
  39141. * Defines the radius of the camera from it s target point.
  39142. */
  39143. radius: number;
  39144. protected _target: Vector3;
  39145. protected _targetHost: Nullable<AbstractMesh>;
  39146. /**
  39147. * Defines the target point of the camera.
  39148. * The camera looks towards it form the radius distance.
  39149. */
  39150. get target(): Vector3;
  39151. set target(value: Vector3);
  39152. /**
  39153. * Define the current local position of the camera in the scene
  39154. */
  39155. get position(): Vector3;
  39156. set position(newPosition: Vector3);
  39157. protected _upVector: Vector3;
  39158. protected _upToYMatrix: Matrix;
  39159. protected _YToUpMatrix: Matrix;
  39160. /**
  39161. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39162. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39163. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39164. */
  39165. set upVector(vec: Vector3);
  39166. get upVector(): Vector3;
  39167. /**
  39168. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39169. */
  39170. setMatUp(): void;
  39171. /**
  39172. * Current inertia value on the longitudinal axis.
  39173. * The bigger this number the longer it will take for the camera to stop.
  39174. */
  39175. inertialAlphaOffset: number;
  39176. /**
  39177. * Current inertia value on the latitudinal axis.
  39178. * The bigger this number the longer it will take for the camera to stop.
  39179. */
  39180. inertialBetaOffset: number;
  39181. /**
  39182. * Current inertia value on the radius axis.
  39183. * The bigger this number the longer it will take for the camera to stop.
  39184. */
  39185. inertialRadiusOffset: number;
  39186. /**
  39187. * Minimum allowed angle on the longitudinal axis.
  39188. * This can help limiting how the Camera is able to move in the scene.
  39189. */
  39190. lowerAlphaLimit: Nullable<number>;
  39191. /**
  39192. * Maximum allowed angle on the longitudinal axis.
  39193. * This can help limiting how the Camera is able to move in the scene.
  39194. */
  39195. upperAlphaLimit: Nullable<number>;
  39196. /**
  39197. * Minimum allowed angle on the latitudinal axis.
  39198. * This can help limiting how the Camera is able to move in the scene.
  39199. */
  39200. lowerBetaLimit: number;
  39201. /**
  39202. * Maximum allowed angle on the latitudinal axis.
  39203. * This can help limiting how the Camera is able to move in the scene.
  39204. */
  39205. upperBetaLimit: number;
  39206. /**
  39207. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39208. * This can help limiting how the Camera is able to move in the scene.
  39209. */
  39210. lowerRadiusLimit: Nullable<number>;
  39211. /**
  39212. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39213. * This can help limiting how the Camera is able to move in the scene.
  39214. */
  39215. upperRadiusLimit: Nullable<number>;
  39216. /**
  39217. * Defines the current inertia value used during panning of the camera along the X axis.
  39218. */
  39219. inertialPanningX: number;
  39220. /**
  39221. * Defines the current inertia value used during panning of the camera along the Y axis.
  39222. */
  39223. inertialPanningY: number;
  39224. /**
  39225. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39226. * Basically if your fingers moves away from more than this distance you will be considered
  39227. * in pinch mode.
  39228. */
  39229. pinchToPanMaxDistance: number;
  39230. /**
  39231. * Defines the maximum distance the camera can pan.
  39232. * This could help keeping the cammera always in your scene.
  39233. */
  39234. panningDistanceLimit: Nullable<number>;
  39235. /**
  39236. * Defines the target of the camera before paning.
  39237. */
  39238. panningOriginTarget: Vector3;
  39239. /**
  39240. * Defines the value of the inertia used during panning.
  39241. * 0 would mean stop inertia and one would mean no decelleration at all.
  39242. */
  39243. panningInertia: number;
  39244. /**
  39245. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39246. */
  39247. get angularSensibilityX(): number;
  39248. set angularSensibilityX(value: number);
  39249. /**
  39250. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39251. */
  39252. get angularSensibilityY(): number;
  39253. set angularSensibilityY(value: number);
  39254. /**
  39255. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39256. */
  39257. get pinchPrecision(): number;
  39258. set pinchPrecision(value: number);
  39259. /**
  39260. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39261. * It will be used instead of pinchDeltaPrecision if different from 0.
  39262. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39263. */
  39264. get pinchDeltaPercentage(): number;
  39265. set pinchDeltaPercentage(value: number);
  39266. /**
  39267. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39268. * and pinch delta percentage.
  39269. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39270. * that any object in the plane at the camera's target point will scale
  39271. * perfectly with finger motion.
  39272. */
  39273. get useNaturalPinchZoom(): boolean;
  39274. set useNaturalPinchZoom(value: boolean);
  39275. /**
  39276. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39277. */
  39278. get panningSensibility(): number;
  39279. set panningSensibility(value: number);
  39280. /**
  39281. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39282. */
  39283. get keysUp(): number[];
  39284. set keysUp(value: number[]);
  39285. /**
  39286. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39287. */
  39288. get keysDown(): number[];
  39289. set keysDown(value: number[]);
  39290. /**
  39291. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39292. */
  39293. get keysLeft(): number[];
  39294. set keysLeft(value: number[]);
  39295. /**
  39296. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39297. */
  39298. get keysRight(): number[];
  39299. set keysRight(value: number[]);
  39300. /**
  39301. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39302. */
  39303. get wheelPrecision(): number;
  39304. set wheelPrecision(value: number);
  39305. /**
  39306. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39307. * It will be used instead of pinchDeltaPrecision if different from 0.
  39308. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39309. */
  39310. get wheelDeltaPercentage(): number;
  39311. set wheelDeltaPercentage(value: number);
  39312. /**
  39313. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39314. */
  39315. zoomOnFactor: number;
  39316. /**
  39317. * Defines a screen offset for the camera position.
  39318. */
  39319. targetScreenOffset: Vector2;
  39320. /**
  39321. * Allows the camera to be completely reversed.
  39322. * If false the camera can not arrive upside down.
  39323. */
  39324. allowUpsideDown: boolean;
  39325. /**
  39326. * Define if double tap/click is used to restore the previously saved state of the camera.
  39327. */
  39328. useInputToRestoreState: boolean;
  39329. /** @hidden */
  39330. _viewMatrix: Matrix;
  39331. /** @hidden */
  39332. _useCtrlForPanning: boolean;
  39333. /** @hidden */
  39334. _panningMouseButton: number;
  39335. /**
  39336. * Defines the input associated to the camera.
  39337. */
  39338. inputs: ArcRotateCameraInputsManager;
  39339. /** @hidden */
  39340. _reset: () => void;
  39341. /**
  39342. * Defines the allowed panning axis.
  39343. */
  39344. panningAxis: Vector3;
  39345. protected _localDirection: Vector3;
  39346. protected _transformedDirection: Vector3;
  39347. private _bouncingBehavior;
  39348. /**
  39349. * Gets the bouncing behavior of the camera if it has been enabled.
  39350. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39351. */
  39352. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39353. /**
  39354. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39355. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39356. */
  39357. get useBouncingBehavior(): boolean;
  39358. set useBouncingBehavior(value: boolean);
  39359. private _framingBehavior;
  39360. /**
  39361. * Gets the framing behavior of the camera if it has been enabled.
  39362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39363. */
  39364. get framingBehavior(): Nullable<FramingBehavior>;
  39365. /**
  39366. * Defines if the framing behavior of the camera is enabled on the camera.
  39367. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39368. */
  39369. get useFramingBehavior(): boolean;
  39370. set useFramingBehavior(value: boolean);
  39371. private _autoRotationBehavior;
  39372. /**
  39373. * Gets the auto rotation behavior of the camera if it has been enabled.
  39374. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39375. */
  39376. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39377. /**
  39378. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39379. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39380. */
  39381. get useAutoRotationBehavior(): boolean;
  39382. set useAutoRotationBehavior(value: boolean);
  39383. /**
  39384. * Observable triggered when the mesh target has been changed on the camera.
  39385. */
  39386. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39387. /**
  39388. * Event raised when the camera is colliding with a mesh.
  39389. */
  39390. onCollide: (collidedMesh: AbstractMesh) => void;
  39391. /**
  39392. * Defines whether the camera should check collision with the objects oh the scene.
  39393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39394. */
  39395. checkCollisions: boolean;
  39396. /**
  39397. * Defines the collision radius of the camera.
  39398. * This simulates a sphere around the camera.
  39399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39400. */
  39401. collisionRadius: Vector3;
  39402. protected _collider: Collider;
  39403. protected _previousPosition: Vector3;
  39404. protected _collisionVelocity: Vector3;
  39405. protected _newPosition: Vector3;
  39406. protected _previousAlpha: number;
  39407. protected _previousBeta: number;
  39408. protected _previousRadius: number;
  39409. protected _collisionTriggered: boolean;
  39410. protected _targetBoundingCenter: Nullable<Vector3>;
  39411. private _computationVector;
  39412. /**
  39413. * Instantiates a new ArcRotateCamera in a given scene
  39414. * @param name Defines the name of the camera
  39415. * @param alpha Defines the camera rotation along the logitudinal axis
  39416. * @param beta Defines the camera rotation along the latitudinal axis
  39417. * @param radius Defines the camera distance from its target
  39418. * @param target Defines the camera target
  39419. * @param scene Defines the scene the camera belongs to
  39420. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39421. */
  39422. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39423. /** @hidden */
  39424. _initCache(): void;
  39425. /** @hidden */
  39426. _updateCache(ignoreParentClass?: boolean): void;
  39427. protected _getTargetPosition(): Vector3;
  39428. private _storedAlpha;
  39429. private _storedBeta;
  39430. private _storedRadius;
  39431. private _storedTarget;
  39432. private _storedTargetScreenOffset;
  39433. /**
  39434. * Stores the current state of the camera (alpha, beta, radius and target)
  39435. * @returns the camera itself
  39436. */
  39437. storeState(): Camera;
  39438. /**
  39439. * @hidden
  39440. * Restored camera state. You must call storeState() first
  39441. */
  39442. _restoreStateValues(): boolean;
  39443. /** @hidden */
  39444. _isSynchronizedViewMatrix(): boolean;
  39445. /**
  39446. * Attached controls to the current camera.
  39447. * @param element Defines the element the controls should be listened from
  39448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39449. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39450. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39451. */
  39452. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39453. /**
  39454. * Detach the current controls from the camera.
  39455. * The camera will stop reacting to inputs.
  39456. * @param element Defines the element to stop listening the inputs from
  39457. */
  39458. detachControl(element: HTMLElement): void;
  39459. /** @hidden */
  39460. _checkInputs(): void;
  39461. protected _checkLimits(): void;
  39462. /**
  39463. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39464. */
  39465. rebuildAnglesAndRadius(): void;
  39466. /**
  39467. * Use a position to define the current camera related information like alpha, beta and radius
  39468. * @param position Defines the position to set the camera at
  39469. */
  39470. setPosition(position: Vector3): void;
  39471. /**
  39472. * Defines the target the camera should look at.
  39473. * This will automatically adapt alpha beta and radius to fit within the new target.
  39474. * @param target Defines the new target as a Vector or a mesh
  39475. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39476. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39477. */
  39478. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39479. /** @hidden */
  39480. _getViewMatrix(): Matrix;
  39481. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39482. /**
  39483. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39484. * @param meshes Defines the mesh to zoom on
  39485. * @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)
  39486. */
  39487. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39488. /**
  39489. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39490. * The target will be changed but the radius
  39491. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39492. * @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)
  39493. */
  39494. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39495. min: Vector3;
  39496. max: Vector3;
  39497. distance: number;
  39498. }, doNotUpdateMaxZ?: boolean): void;
  39499. /**
  39500. * @override
  39501. * Override Camera.createRigCamera
  39502. */
  39503. createRigCamera(name: string, cameraIndex: number): Camera;
  39504. /**
  39505. * @hidden
  39506. * @override
  39507. * Override Camera._updateRigCameras
  39508. */
  39509. _updateRigCameras(): void;
  39510. /**
  39511. * Destroy the camera and release the current resources hold by it.
  39512. */
  39513. dispose(): void;
  39514. /**
  39515. * Gets the current object class name.
  39516. * @return the class name
  39517. */
  39518. getClassName(): string;
  39519. }
  39520. }
  39521. declare module BABYLON {
  39522. /**
  39523. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39525. */
  39526. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39527. /**
  39528. * Gets the name of the behavior.
  39529. */
  39530. get name(): string;
  39531. private _zoomStopsAnimation;
  39532. private _idleRotationSpeed;
  39533. private _idleRotationWaitTime;
  39534. private _idleRotationSpinupTime;
  39535. /**
  39536. * Sets the flag that indicates if user zooming should stop animation.
  39537. */
  39538. set zoomStopsAnimation(flag: boolean);
  39539. /**
  39540. * Gets the flag that indicates if user zooming should stop animation.
  39541. */
  39542. get zoomStopsAnimation(): boolean;
  39543. /**
  39544. * Sets the default speed at which the camera rotates around the model.
  39545. */
  39546. set idleRotationSpeed(speed: number);
  39547. /**
  39548. * Gets the default speed at which the camera rotates around the model.
  39549. */
  39550. get idleRotationSpeed(): number;
  39551. /**
  39552. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39553. */
  39554. set idleRotationWaitTime(time: number);
  39555. /**
  39556. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39557. */
  39558. get idleRotationWaitTime(): number;
  39559. /**
  39560. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39561. */
  39562. set idleRotationSpinupTime(time: number);
  39563. /**
  39564. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39565. */
  39566. get idleRotationSpinupTime(): number;
  39567. /**
  39568. * Gets a value indicating if the camera is currently rotating because of this behavior
  39569. */
  39570. get rotationInProgress(): boolean;
  39571. private _onPrePointerObservableObserver;
  39572. private _onAfterCheckInputsObserver;
  39573. private _attachedCamera;
  39574. private _isPointerDown;
  39575. private _lastFrameTime;
  39576. private _lastInteractionTime;
  39577. private _cameraRotationSpeed;
  39578. /**
  39579. * Initializes the behavior.
  39580. */
  39581. init(): void;
  39582. /**
  39583. * Attaches the behavior to its arc rotate camera.
  39584. * @param camera Defines the camera to attach the behavior to
  39585. */
  39586. attach(camera: ArcRotateCamera): void;
  39587. /**
  39588. * Detaches the behavior from its current arc rotate camera.
  39589. */
  39590. detach(): void;
  39591. /**
  39592. * Returns true if user is scrolling.
  39593. * @return true if user is scrolling.
  39594. */
  39595. private _userIsZooming;
  39596. private _lastFrameRadius;
  39597. private _shouldAnimationStopForInteraction;
  39598. /**
  39599. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39600. */
  39601. private _applyUserInteraction;
  39602. private _userIsMoving;
  39603. }
  39604. }
  39605. declare module BABYLON {
  39606. /**
  39607. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39608. */
  39609. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39610. private ui;
  39611. /**
  39612. * The name of the behavior
  39613. */
  39614. name: string;
  39615. /**
  39616. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39617. */
  39618. distanceAwayFromFace: number;
  39619. /**
  39620. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39621. */
  39622. distanceAwayFromBottomOfFace: number;
  39623. private _faceVectors;
  39624. private _target;
  39625. private _scene;
  39626. private _onRenderObserver;
  39627. private _tmpMatrix;
  39628. private _tmpVector;
  39629. /**
  39630. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39631. * @param ui The transform node that should be attched to the mesh
  39632. */
  39633. constructor(ui: TransformNode);
  39634. /**
  39635. * Initializes the behavior
  39636. */
  39637. init(): void;
  39638. private _closestFace;
  39639. private _zeroVector;
  39640. private _lookAtTmpMatrix;
  39641. private _lookAtToRef;
  39642. /**
  39643. * Attaches the AttachToBoxBehavior to the passed in mesh
  39644. * @param target The mesh that the specified node will be attached to
  39645. */
  39646. attach(target: Mesh): void;
  39647. /**
  39648. * Detaches the behavior from the mesh
  39649. */
  39650. detach(): void;
  39651. }
  39652. }
  39653. declare module BABYLON {
  39654. /**
  39655. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39656. */
  39657. export class FadeInOutBehavior implements Behavior<Mesh> {
  39658. /**
  39659. * Time in milliseconds to delay before fading in (Default: 0)
  39660. */
  39661. delay: number;
  39662. /**
  39663. * Time in milliseconds for the mesh to fade in (Default: 300)
  39664. */
  39665. fadeInTime: number;
  39666. private _millisecondsPerFrame;
  39667. private _hovered;
  39668. private _hoverValue;
  39669. private _ownerNode;
  39670. /**
  39671. * Instatiates the FadeInOutBehavior
  39672. */
  39673. constructor();
  39674. /**
  39675. * The name of the behavior
  39676. */
  39677. get name(): string;
  39678. /**
  39679. * Initializes the behavior
  39680. */
  39681. init(): void;
  39682. /**
  39683. * Attaches the fade behavior on the passed in mesh
  39684. * @param ownerNode The mesh that will be faded in/out once attached
  39685. */
  39686. attach(ownerNode: Mesh): void;
  39687. /**
  39688. * Detaches the behavior from the mesh
  39689. */
  39690. detach(): void;
  39691. /**
  39692. * Triggers the mesh to begin fading in or out
  39693. * @param value if the object should fade in or out (true to fade in)
  39694. */
  39695. fadeIn(value: boolean): void;
  39696. private _update;
  39697. private _setAllVisibility;
  39698. }
  39699. }
  39700. declare module BABYLON {
  39701. /**
  39702. * Class containing a set of static utilities functions for managing Pivots
  39703. * @hidden
  39704. */
  39705. export class PivotTools {
  39706. private static _PivotCached;
  39707. private static _OldPivotPoint;
  39708. private static _PivotTranslation;
  39709. private static _PivotTmpVector;
  39710. /** @hidden */
  39711. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39712. /** @hidden */
  39713. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39714. }
  39715. }
  39716. declare module BABYLON {
  39717. /**
  39718. * Class containing static functions to help procedurally build meshes
  39719. */
  39720. export class PlaneBuilder {
  39721. /**
  39722. * Creates a plane mesh
  39723. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39724. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39725. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39727. * * 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
  39728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39729. * @param name defines the name of the mesh
  39730. * @param options defines the options used to create the mesh
  39731. * @param scene defines the hosting scene
  39732. * @returns the plane mesh
  39733. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39734. */
  39735. static CreatePlane(name: string, options: {
  39736. size?: number;
  39737. width?: number;
  39738. height?: number;
  39739. sideOrientation?: number;
  39740. frontUVs?: Vector4;
  39741. backUVs?: Vector4;
  39742. updatable?: boolean;
  39743. sourcePlane?: Plane;
  39744. }, scene?: Nullable<Scene>): Mesh;
  39745. }
  39746. }
  39747. declare module BABYLON {
  39748. /**
  39749. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39750. */
  39751. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39752. private static _AnyMouseID;
  39753. /**
  39754. * Abstract mesh the behavior is set on
  39755. */
  39756. attachedNode: AbstractMesh;
  39757. private _dragPlane;
  39758. private _scene;
  39759. private _pointerObserver;
  39760. private _beforeRenderObserver;
  39761. private static _planeScene;
  39762. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39763. /**
  39764. * 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)
  39765. */
  39766. maxDragAngle: number;
  39767. /**
  39768. * @hidden
  39769. */
  39770. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39771. /**
  39772. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39773. */
  39774. currentDraggingPointerID: number;
  39775. /**
  39776. * The last position where the pointer hit the drag plane in world space
  39777. */
  39778. lastDragPosition: Vector3;
  39779. /**
  39780. * If the behavior is currently in a dragging state
  39781. */
  39782. dragging: boolean;
  39783. /**
  39784. * 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)
  39785. */
  39786. dragDeltaRatio: number;
  39787. /**
  39788. * If the drag plane orientation should be updated during the dragging (Default: true)
  39789. */
  39790. updateDragPlane: boolean;
  39791. private _debugMode;
  39792. private _moving;
  39793. /**
  39794. * Fires each time the attached mesh is dragged with the pointer
  39795. * * delta between last drag position and current drag position in world space
  39796. * * dragDistance along the drag axis
  39797. * * dragPlaneNormal normal of the current drag plane used during the drag
  39798. * * dragPlanePoint in world space where the drag intersects the drag plane
  39799. */
  39800. onDragObservable: Observable<{
  39801. delta: Vector3;
  39802. dragPlanePoint: Vector3;
  39803. dragPlaneNormal: Vector3;
  39804. dragDistance: number;
  39805. pointerId: number;
  39806. }>;
  39807. /**
  39808. * Fires each time a drag begins (eg. mouse down on mesh)
  39809. */
  39810. onDragStartObservable: Observable<{
  39811. dragPlanePoint: Vector3;
  39812. pointerId: number;
  39813. }>;
  39814. /**
  39815. * Fires each time a drag ends (eg. mouse release after drag)
  39816. */
  39817. onDragEndObservable: Observable<{
  39818. dragPlanePoint: Vector3;
  39819. pointerId: number;
  39820. }>;
  39821. /**
  39822. * If the attached mesh should be moved when dragged
  39823. */
  39824. moveAttached: boolean;
  39825. /**
  39826. * If the drag behavior will react to drag events (Default: true)
  39827. */
  39828. enabled: boolean;
  39829. /**
  39830. * If pointer events should start and release the drag (Default: true)
  39831. */
  39832. startAndReleaseDragOnPointerEvents: boolean;
  39833. /**
  39834. * If camera controls should be detached during the drag
  39835. */
  39836. detachCameraControls: boolean;
  39837. /**
  39838. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39839. */
  39840. useObjectOrientationForDragging: boolean;
  39841. private _options;
  39842. /**
  39843. * Gets the options used by the behavior
  39844. */
  39845. get options(): {
  39846. dragAxis?: Vector3;
  39847. dragPlaneNormal?: Vector3;
  39848. };
  39849. /**
  39850. * Sets the options used by the behavior
  39851. */
  39852. set options(options: {
  39853. dragAxis?: Vector3;
  39854. dragPlaneNormal?: Vector3;
  39855. });
  39856. /**
  39857. * Creates a pointer drag behavior that can be attached to a mesh
  39858. * @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)
  39859. */
  39860. constructor(options?: {
  39861. dragAxis?: Vector3;
  39862. dragPlaneNormal?: Vector3;
  39863. });
  39864. /**
  39865. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39866. */
  39867. validateDrag: (targetPosition: Vector3) => boolean;
  39868. /**
  39869. * The name of the behavior
  39870. */
  39871. get name(): string;
  39872. /**
  39873. * Initializes the behavior
  39874. */
  39875. init(): void;
  39876. private _tmpVector;
  39877. private _alternatePickedPoint;
  39878. private _worldDragAxis;
  39879. private _targetPosition;
  39880. private _attachedElement;
  39881. /**
  39882. * Attaches the drag behavior the passed in mesh
  39883. * @param ownerNode The mesh that will be dragged around once attached
  39884. * @param predicate Predicate to use for pick filtering
  39885. */
  39886. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39887. /**
  39888. * Force relase the drag action by code.
  39889. */
  39890. releaseDrag(): void;
  39891. private _startDragRay;
  39892. private _lastPointerRay;
  39893. /**
  39894. * Simulates the start of a pointer drag event on the behavior
  39895. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39896. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39897. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39898. */
  39899. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39900. private _startDrag;
  39901. private _dragDelta;
  39902. private _moveDrag;
  39903. private _pickWithRayOnDragPlane;
  39904. private _pointA;
  39905. private _pointB;
  39906. private _pointC;
  39907. private _lineA;
  39908. private _lineB;
  39909. private _localAxis;
  39910. private _lookAt;
  39911. private _updateDragPlanePosition;
  39912. /**
  39913. * Detaches the behavior from the mesh
  39914. */
  39915. detach(): void;
  39916. }
  39917. }
  39918. declare module BABYLON {
  39919. /**
  39920. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39921. */
  39922. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39923. private _dragBehaviorA;
  39924. private _dragBehaviorB;
  39925. private _startDistance;
  39926. private _initialScale;
  39927. private _targetScale;
  39928. private _ownerNode;
  39929. private _sceneRenderObserver;
  39930. /**
  39931. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39932. */
  39933. constructor();
  39934. /**
  39935. * The name of the behavior
  39936. */
  39937. get name(): string;
  39938. /**
  39939. * Initializes the behavior
  39940. */
  39941. init(): void;
  39942. private _getCurrentDistance;
  39943. /**
  39944. * Attaches the scale behavior the passed in mesh
  39945. * @param ownerNode The mesh that will be scaled around once attached
  39946. */
  39947. attach(ownerNode: Mesh): void;
  39948. /**
  39949. * Detaches the behavior from the mesh
  39950. */
  39951. detach(): void;
  39952. }
  39953. }
  39954. declare module BABYLON {
  39955. /**
  39956. * 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
  39957. */
  39958. export class SixDofDragBehavior implements Behavior<Mesh> {
  39959. private static _virtualScene;
  39960. private _ownerNode;
  39961. private _sceneRenderObserver;
  39962. private _scene;
  39963. private _targetPosition;
  39964. private _virtualOriginMesh;
  39965. private _virtualDragMesh;
  39966. private _pointerObserver;
  39967. private _moving;
  39968. private _startingOrientation;
  39969. private _attachedElement;
  39970. /**
  39971. * 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)
  39972. */
  39973. private zDragFactor;
  39974. /**
  39975. * If the object should rotate to face the drag origin
  39976. */
  39977. rotateDraggedObject: boolean;
  39978. /**
  39979. * If the behavior is currently in a dragging state
  39980. */
  39981. dragging: boolean;
  39982. /**
  39983. * 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)
  39984. */
  39985. dragDeltaRatio: number;
  39986. /**
  39987. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39988. */
  39989. currentDraggingPointerID: number;
  39990. /**
  39991. * If camera controls should be detached during the drag
  39992. */
  39993. detachCameraControls: boolean;
  39994. /**
  39995. * Fires each time a drag starts
  39996. */
  39997. onDragStartObservable: Observable<{}>;
  39998. /**
  39999. * Fires each time a drag ends (eg. mouse release after drag)
  40000. */
  40001. onDragEndObservable: Observable<{}>;
  40002. /**
  40003. * 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
  40004. */
  40005. constructor();
  40006. /**
  40007. * The name of the behavior
  40008. */
  40009. get name(): string;
  40010. /**
  40011. * Initializes the behavior
  40012. */
  40013. init(): void;
  40014. /**
  40015. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40016. */
  40017. private get _pointerCamera();
  40018. /**
  40019. * Attaches the scale behavior the passed in mesh
  40020. * @param ownerNode The mesh that will be scaled around once attached
  40021. */
  40022. attach(ownerNode: Mesh): void;
  40023. /**
  40024. * Detaches the behavior from the mesh
  40025. */
  40026. detach(): void;
  40027. }
  40028. }
  40029. declare module BABYLON {
  40030. /**
  40031. * Class used to apply inverse kinematics to bones
  40032. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40033. */
  40034. export class BoneIKController {
  40035. private static _tmpVecs;
  40036. private static _tmpQuat;
  40037. private static _tmpMats;
  40038. /**
  40039. * Gets or sets the target mesh
  40040. */
  40041. targetMesh: AbstractMesh;
  40042. /** Gets or sets the mesh used as pole */
  40043. poleTargetMesh: AbstractMesh;
  40044. /**
  40045. * Gets or sets the bone used as pole
  40046. */
  40047. poleTargetBone: Nullable<Bone>;
  40048. /**
  40049. * Gets or sets the target position
  40050. */
  40051. targetPosition: Vector3;
  40052. /**
  40053. * Gets or sets the pole target position
  40054. */
  40055. poleTargetPosition: Vector3;
  40056. /**
  40057. * Gets or sets the pole target local offset
  40058. */
  40059. poleTargetLocalOffset: Vector3;
  40060. /**
  40061. * Gets or sets the pole angle
  40062. */
  40063. poleAngle: number;
  40064. /**
  40065. * Gets or sets the mesh associated with the controller
  40066. */
  40067. mesh: AbstractMesh;
  40068. /**
  40069. * 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)
  40070. */
  40071. slerpAmount: number;
  40072. private _bone1Quat;
  40073. private _bone1Mat;
  40074. private _bone2Ang;
  40075. private _bone1;
  40076. private _bone2;
  40077. private _bone1Length;
  40078. private _bone2Length;
  40079. private _maxAngle;
  40080. private _maxReach;
  40081. private _rightHandedSystem;
  40082. private _bendAxis;
  40083. private _slerping;
  40084. private _adjustRoll;
  40085. /**
  40086. * Gets or sets maximum allowed angle
  40087. */
  40088. get maxAngle(): number;
  40089. set maxAngle(value: number);
  40090. /**
  40091. * Creates a new BoneIKController
  40092. * @param mesh defines the mesh to control
  40093. * @param bone defines the bone to control
  40094. * @param options defines options to set up the controller
  40095. */
  40096. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40097. targetMesh?: AbstractMesh;
  40098. poleTargetMesh?: AbstractMesh;
  40099. poleTargetBone?: Bone;
  40100. poleTargetLocalOffset?: Vector3;
  40101. poleAngle?: number;
  40102. bendAxis?: Vector3;
  40103. maxAngle?: number;
  40104. slerpAmount?: number;
  40105. });
  40106. private _setMaxAngle;
  40107. /**
  40108. * Force the controller to update the bones
  40109. */
  40110. update(): void;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * Class used to make a bone look toward a point in space
  40116. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40117. */
  40118. export class BoneLookController {
  40119. private static _tmpVecs;
  40120. private static _tmpQuat;
  40121. private static _tmpMats;
  40122. /**
  40123. * The target Vector3 that the bone will look at
  40124. */
  40125. target: Vector3;
  40126. /**
  40127. * The mesh that the bone is attached to
  40128. */
  40129. mesh: AbstractMesh;
  40130. /**
  40131. * The bone that will be looking to the target
  40132. */
  40133. bone: Bone;
  40134. /**
  40135. * The up axis of the coordinate system that is used when the bone is rotated
  40136. */
  40137. upAxis: Vector3;
  40138. /**
  40139. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40140. */
  40141. upAxisSpace: Space;
  40142. /**
  40143. * Used to make an adjustment to the yaw of the bone
  40144. */
  40145. adjustYaw: number;
  40146. /**
  40147. * Used to make an adjustment to the pitch of the bone
  40148. */
  40149. adjustPitch: number;
  40150. /**
  40151. * Used to make an adjustment to the roll of the bone
  40152. */
  40153. adjustRoll: number;
  40154. /**
  40155. * 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)
  40156. */
  40157. slerpAmount: number;
  40158. private _minYaw;
  40159. private _maxYaw;
  40160. private _minPitch;
  40161. private _maxPitch;
  40162. private _minYawSin;
  40163. private _minYawCos;
  40164. private _maxYawSin;
  40165. private _maxYawCos;
  40166. private _midYawConstraint;
  40167. private _minPitchTan;
  40168. private _maxPitchTan;
  40169. private _boneQuat;
  40170. private _slerping;
  40171. private _transformYawPitch;
  40172. private _transformYawPitchInv;
  40173. private _firstFrameSkipped;
  40174. private _yawRange;
  40175. private _fowardAxis;
  40176. /**
  40177. * Gets or sets the minimum yaw angle that the bone can look to
  40178. */
  40179. get minYaw(): number;
  40180. set minYaw(value: number);
  40181. /**
  40182. * Gets or sets the maximum yaw angle that the bone can look to
  40183. */
  40184. get maxYaw(): number;
  40185. set maxYaw(value: number);
  40186. /**
  40187. * Gets or sets the minimum pitch angle that the bone can look to
  40188. */
  40189. get minPitch(): number;
  40190. set minPitch(value: number);
  40191. /**
  40192. * Gets or sets the maximum pitch angle that the bone can look to
  40193. */
  40194. get maxPitch(): number;
  40195. set maxPitch(value: number);
  40196. /**
  40197. * Create a BoneLookController
  40198. * @param mesh the mesh that the bone belongs to
  40199. * @param bone the bone that will be looking to the target
  40200. * @param target the target Vector3 to look at
  40201. * @param options optional settings:
  40202. * * maxYaw: the maximum angle the bone will yaw to
  40203. * * minYaw: the minimum angle the bone will yaw to
  40204. * * maxPitch: the maximum angle the bone will pitch to
  40205. * * minPitch: the minimum angle the bone will yaw to
  40206. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40207. * * upAxis: the up axis of the coordinate system
  40208. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40209. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40210. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40211. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40212. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40213. * * adjustRoll: used to make an adjustment to the roll of the bone
  40214. **/
  40215. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40216. maxYaw?: number;
  40217. minYaw?: number;
  40218. maxPitch?: number;
  40219. minPitch?: number;
  40220. slerpAmount?: number;
  40221. upAxis?: Vector3;
  40222. upAxisSpace?: Space;
  40223. yawAxis?: Vector3;
  40224. pitchAxis?: Vector3;
  40225. adjustYaw?: number;
  40226. adjustPitch?: number;
  40227. adjustRoll?: number;
  40228. });
  40229. /**
  40230. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40231. */
  40232. update(): void;
  40233. private _getAngleDiff;
  40234. private _getAngleBetween;
  40235. private _isAngleBetween;
  40236. }
  40237. }
  40238. declare module BABYLON {
  40239. /**
  40240. * Manage the gamepad inputs to control an arc rotate camera.
  40241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40242. */
  40243. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40244. /**
  40245. * Defines the camera the input is attached to.
  40246. */
  40247. camera: ArcRotateCamera;
  40248. /**
  40249. * Defines the gamepad the input is gathering event from.
  40250. */
  40251. gamepad: Nullable<Gamepad>;
  40252. /**
  40253. * Defines the gamepad rotation sensiblity.
  40254. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40255. */
  40256. gamepadRotationSensibility: number;
  40257. /**
  40258. * Defines the gamepad move sensiblity.
  40259. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40260. */
  40261. gamepadMoveSensibility: number;
  40262. private _yAxisScale;
  40263. /**
  40264. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40265. */
  40266. get invertYAxis(): boolean;
  40267. set invertYAxis(value: boolean);
  40268. private _onGamepadConnectedObserver;
  40269. private _onGamepadDisconnectedObserver;
  40270. /**
  40271. * Attach the input controls to a specific dom element to get the input from.
  40272. * @param element Defines the element the controls should be listened from
  40273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40274. */
  40275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40276. /**
  40277. * Detach the current controls from the specified dom element.
  40278. * @param element Defines the element to stop listening the inputs from
  40279. */
  40280. detachControl(element: Nullable<HTMLElement>): void;
  40281. /**
  40282. * Update the current camera state depending on the inputs that have been used this frame.
  40283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40284. */
  40285. checkInputs(): void;
  40286. /**
  40287. * Gets the class name of the current intput.
  40288. * @returns the class name
  40289. */
  40290. getClassName(): string;
  40291. /**
  40292. * Get the friendly name associated with the input class.
  40293. * @returns the input friendly name
  40294. */
  40295. getSimpleName(): string;
  40296. }
  40297. }
  40298. declare module BABYLON {
  40299. interface ArcRotateCameraInputsManager {
  40300. /**
  40301. * Add orientation input support to the input manager.
  40302. * @returns the current input manager
  40303. */
  40304. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40305. }
  40306. /**
  40307. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40309. */
  40310. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40311. /**
  40312. * Defines the camera the input is attached to.
  40313. */
  40314. camera: ArcRotateCamera;
  40315. /**
  40316. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40317. */
  40318. alphaCorrection: number;
  40319. /**
  40320. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40321. */
  40322. gammaCorrection: number;
  40323. private _alpha;
  40324. private _gamma;
  40325. private _dirty;
  40326. private _deviceOrientationHandler;
  40327. /**
  40328. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40329. */
  40330. constructor();
  40331. /**
  40332. * Attach the input controls to a specific dom element to get the input from.
  40333. * @param element Defines the element the controls should be listened from
  40334. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40335. */
  40336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40337. /** @hidden */
  40338. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40339. /**
  40340. * Update the current camera state depending on the inputs that have been used this frame.
  40341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40342. */
  40343. checkInputs(): void;
  40344. /**
  40345. * Detach the current controls from the specified dom element.
  40346. * @param element Defines the element to stop listening the inputs from
  40347. */
  40348. detachControl(element: Nullable<HTMLElement>): void;
  40349. /**
  40350. * Gets the class name of the current intput.
  40351. * @returns the class name
  40352. */
  40353. getClassName(): string;
  40354. /**
  40355. * Get the friendly name associated with the input class.
  40356. * @returns the input friendly name
  40357. */
  40358. getSimpleName(): string;
  40359. }
  40360. }
  40361. declare module BABYLON {
  40362. /**
  40363. * Listen to mouse events to control the camera.
  40364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40365. */
  40366. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40367. /**
  40368. * Defines the camera the input is attached to.
  40369. */
  40370. camera: FlyCamera;
  40371. /**
  40372. * Defines if touch is enabled. (Default is true.)
  40373. */
  40374. touchEnabled: boolean;
  40375. /**
  40376. * Defines the buttons associated with the input to handle camera rotation.
  40377. */
  40378. buttons: number[];
  40379. /**
  40380. * Assign buttons for Yaw control.
  40381. */
  40382. buttonsYaw: number[];
  40383. /**
  40384. * Assign buttons for Pitch control.
  40385. */
  40386. buttonsPitch: number[];
  40387. /**
  40388. * Assign buttons for Roll control.
  40389. */
  40390. buttonsRoll: number[];
  40391. /**
  40392. * Detect if any button is being pressed while mouse is moved.
  40393. * -1 = Mouse locked.
  40394. * 0 = Left button.
  40395. * 1 = Middle Button.
  40396. * 2 = Right Button.
  40397. */
  40398. activeButton: number;
  40399. /**
  40400. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40401. * Higher values reduce its sensitivity.
  40402. */
  40403. angularSensibility: number;
  40404. private _mousemoveCallback;
  40405. private _observer;
  40406. private _rollObserver;
  40407. private previousPosition;
  40408. private noPreventDefault;
  40409. private element;
  40410. /**
  40411. * Listen to mouse events to control the camera.
  40412. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40414. */
  40415. constructor(touchEnabled?: boolean);
  40416. /**
  40417. * Attach the mouse control to the HTML DOM element.
  40418. * @param element Defines the element that listens to the input events.
  40419. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40420. */
  40421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40422. /**
  40423. * Detach the current controls from the specified dom element.
  40424. * @param element Defines the element to stop listening the inputs from
  40425. */
  40426. detachControl(element: Nullable<HTMLElement>): void;
  40427. /**
  40428. * Gets the class name of the current input.
  40429. * @returns the class name.
  40430. */
  40431. getClassName(): string;
  40432. /**
  40433. * Get the friendly name associated with the input class.
  40434. * @returns the input's friendly name.
  40435. */
  40436. getSimpleName(): string;
  40437. private _pointerInput;
  40438. private _onMouseMove;
  40439. /**
  40440. * Rotate camera by mouse offset.
  40441. */
  40442. private rotateCamera;
  40443. }
  40444. }
  40445. declare module BABYLON {
  40446. /**
  40447. * Default Inputs manager for the FlyCamera.
  40448. * It groups all the default supported inputs for ease of use.
  40449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40450. */
  40451. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40452. /**
  40453. * Instantiates a new FlyCameraInputsManager.
  40454. * @param camera Defines the camera the inputs belong to.
  40455. */
  40456. constructor(camera: FlyCamera);
  40457. /**
  40458. * Add keyboard input support to the input manager.
  40459. * @returns the new FlyCameraKeyboardMoveInput().
  40460. */
  40461. addKeyboard(): FlyCameraInputsManager;
  40462. /**
  40463. * Add mouse input support to the input manager.
  40464. * @param touchEnabled Enable touch screen support.
  40465. * @returns the new FlyCameraMouseInput().
  40466. */
  40467. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40468. }
  40469. }
  40470. declare module BABYLON {
  40471. /**
  40472. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40473. * such as in a 3D Space Shooter or a Flight Simulator.
  40474. */
  40475. export class FlyCamera extends TargetCamera {
  40476. /**
  40477. * Define the collision ellipsoid of the camera.
  40478. * This is helpful for simulating a camera body, like a player's body.
  40479. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40480. */
  40481. ellipsoid: Vector3;
  40482. /**
  40483. * Define an offset for the position of the ellipsoid around the camera.
  40484. * This can be helpful if the camera is attached away from the player's body center,
  40485. * such as at its head.
  40486. */
  40487. ellipsoidOffset: Vector3;
  40488. /**
  40489. * Enable or disable collisions of the camera with the rest of the scene objects.
  40490. */
  40491. checkCollisions: boolean;
  40492. /**
  40493. * Enable or disable gravity on the camera.
  40494. */
  40495. applyGravity: boolean;
  40496. /**
  40497. * Define the current direction the camera is moving to.
  40498. */
  40499. cameraDirection: Vector3;
  40500. /**
  40501. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40502. * This overrides and empties cameraRotation.
  40503. */
  40504. rotationQuaternion: Quaternion;
  40505. /**
  40506. * Track Roll to maintain the wanted Rolling when looking around.
  40507. */
  40508. _trackRoll: number;
  40509. /**
  40510. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40511. */
  40512. rollCorrect: number;
  40513. /**
  40514. * Mimic a banked turn, Rolling the camera when Yawing.
  40515. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40516. */
  40517. bankedTurn: boolean;
  40518. /**
  40519. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40520. */
  40521. bankedTurnLimit: number;
  40522. /**
  40523. * Value of 0 disables the banked Roll.
  40524. * Value of 1 is equal to the Yaw angle in radians.
  40525. */
  40526. bankedTurnMultiplier: number;
  40527. /**
  40528. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40529. */
  40530. inputs: FlyCameraInputsManager;
  40531. /**
  40532. * Gets the input sensibility for mouse input.
  40533. * Higher values reduce sensitivity.
  40534. */
  40535. get angularSensibility(): number;
  40536. /**
  40537. * Sets the input sensibility for a mouse input.
  40538. * Higher values reduce sensitivity.
  40539. */
  40540. set angularSensibility(value: number);
  40541. /**
  40542. * Get the keys for camera movement forward.
  40543. */
  40544. get keysForward(): number[];
  40545. /**
  40546. * Set the keys for camera movement forward.
  40547. */
  40548. set keysForward(value: number[]);
  40549. /**
  40550. * Get the keys for camera movement backward.
  40551. */
  40552. get keysBackward(): number[];
  40553. set keysBackward(value: number[]);
  40554. /**
  40555. * Get the keys for camera movement up.
  40556. */
  40557. get keysUp(): number[];
  40558. /**
  40559. * Set the keys for camera movement up.
  40560. */
  40561. set keysUp(value: number[]);
  40562. /**
  40563. * Get the keys for camera movement down.
  40564. */
  40565. get keysDown(): number[];
  40566. /**
  40567. * Set the keys for camera movement down.
  40568. */
  40569. set keysDown(value: number[]);
  40570. /**
  40571. * Get the keys for camera movement left.
  40572. */
  40573. get keysLeft(): number[];
  40574. /**
  40575. * Set the keys for camera movement left.
  40576. */
  40577. set keysLeft(value: number[]);
  40578. /**
  40579. * Set the keys for camera movement right.
  40580. */
  40581. get keysRight(): number[];
  40582. /**
  40583. * Set the keys for camera movement right.
  40584. */
  40585. set keysRight(value: number[]);
  40586. /**
  40587. * Event raised when the camera collides with a mesh in the scene.
  40588. */
  40589. onCollide: (collidedMesh: AbstractMesh) => void;
  40590. private _collider;
  40591. private _needMoveForGravity;
  40592. private _oldPosition;
  40593. private _diffPosition;
  40594. private _newPosition;
  40595. /** @hidden */
  40596. _localDirection: Vector3;
  40597. /** @hidden */
  40598. _transformedDirection: Vector3;
  40599. /**
  40600. * Instantiates a FlyCamera.
  40601. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40602. * such as in a 3D Space Shooter or a Flight Simulator.
  40603. * @param name Define the name of the camera in the scene.
  40604. * @param position Define the starting position of the camera in the scene.
  40605. * @param scene Define the scene the camera belongs to.
  40606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40607. */
  40608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40609. /**
  40610. * Attach a control to the HTML DOM element.
  40611. * @param element Defines the element that listens to the input events.
  40612. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40613. */
  40614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40615. /**
  40616. * Detach a control from the HTML DOM element.
  40617. * The camera will stop reacting to that input.
  40618. * @param element Defines the element that listens to the input events.
  40619. */
  40620. detachControl(element: HTMLElement): void;
  40621. private _collisionMask;
  40622. /**
  40623. * Get the mask that the camera ignores in collision events.
  40624. */
  40625. get collisionMask(): number;
  40626. /**
  40627. * Set the mask that the camera ignores in collision events.
  40628. */
  40629. set collisionMask(mask: number);
  40630. /** @hidden */
  40631. _collideWithWorld(displacement: Vector3): void;
  40632. /** @hidden */
  40633. private _onCollisionPositionChange;
  40634. /** @hidden */
  40635. _checkInputs(): void;
  40636. /** @hidden */
  40637. _decideIfNeedsToMove(): boolean;
  40638. /** @hidden */
  40639. _updatePosition(): void;
  40640. /**
  40641. * Restore the Roll to its target value at the rate specified.
  40642. * @param rate - Higher means slower restoring.
  40643. * @hidden
  40644. */
  40645. restoreRoll(rate: number): void;
  40646. /**
  40647. * Destroy the camera and release the current resources held by it.
  40648. */
  40649. dispose(): void;
  40650. /**
  40651. * Get the current object class name.
  40652. * @returns the class name.
  40653. */
  40654. getClassName(): string;
  40655. }
  40656. }
  40657. declare module BABYLON {
  40658. /**
  40659. * Listen to keyboard events to control the camera.
  40660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40661. */
  40662. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40663. /**
  40664. * Defines the camera the input is attached to.
  40665. */
  40666. camera: FlyCamera;
  40667. /**
  40668. * The list of keyboard keys used to control the forward move of the camera.
  40669. */
  40670. keysForward: number[];
  40671. /**
  40672. * The list of keyboard keys used to control the backward move of the camera.
  40673. */
  40674. keysBackward: number[];
  40675. /**
  40676. * The list of keyboard keys used to control the forward move of the camera.
  40677. */
  40678. keysUp: number[];
  40679. /**
  40680. * The list of keyboard keys used to control the backward move of the camera.
  40681. */
  40682. keysDown: number[];
  40683. /**
  40684. * The list of keyboard keys used to control the right strafe move of the camera.
  40685. */
  40686. keysRight: number[];
  40687. /**
  40688. * The list of keyboard keys used to control the left strafe move of the camera.
  40689. */
  40690. keysLeft: number[];
  40691. private _keys;
  40692. private _onCanvasBlurObserver;
  40693. private _onKeyboardObserver;
  40694. private _engine;
  40695. private _scene;
  40696. /**
  40697. * Attach the input controls to a specific dom element to get the input from.
  40698. * @param element Defines the element the controls should be listened from
  40699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40700. */
  40701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40702. /**
  40703. * Detach the current controls from the specified dom element.
  40704. * @param element Defines the element to stop listening the inputs from
  40705. */
  40706. detachControl(element: Nullable<HTMLElement>): void;
  40707. /**
  40708. * Gets the class name of the current intput.
  40709. * @returns the class name
  40710. */
  40711. getClassName(): string;
  40712. /** @hidden */
  40713. _onLostFocus(e: FocusEvent): void;
  40714. /**
  40715. * Get the friendly name associated with the input class.
  40716. * @returns the input friendly name
  40717. */
  40718. getSimpleName(): string;
  40719. /**
  40720. * Update the current camera state depending on the inputs that have been used this frame.
  40721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40722. */
  40723. checkInputs(): void;
  40724. }
  40725. }
  40726. declare module BABYLON {
  40727. /**
  40728. * Manage the mouse wheel inputs to control a follow camera.
  40729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40730. */
  40731. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40732. /**
  40733. * Defines the camera the input is attached to.
  40734. */
  40735. camera: FollowCamera;
  40736. /**
  40737. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40738. */
  40739. axisControlRadius: boolean;
  40740. /**
  40741. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40742. */
  40743. axisControlHeight: boolean;
  40744. /**
  40745. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40746. */
  40747. axisControlRotation: boolean;
  40748. /**
  40749. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40750. * relation to mouseWheel events.
  40751. */
  40752. wheelPrecision: number;
  40753. /**
  40754. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40755. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40756. */
  40757. wheelDeltaPercentage: number;
  40758. private _wheel;
  40759. private _observer;
  40760. /**
  40761. * Attach the input controls to a specific dom element to get the input from.
  40762. * @param element Defines the element the controls should be listened from
  40763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40764. */
  40765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40766. /**
  40767. * Detach the current controls from the specified dom element.
  40768. * @param element Defines the element to stop listening the inputs from
  40769. */
  40770. detachControl(element: Nullable<HTMLElement>): void;
  40771. /**
  40772. * Gets the class name of the current intput.
  40773. * @returns the class name
  40774. */
  40775. getClassName(): string;
  40776. /**
  40777. * Get the friendly name associated with the input class.
  40778. * @returns the input friendly name
  40779. */
  40780. getSimpleName(): string;
  40781. }
  40782. }
  40783. declare module BABYLON {
  40784. /**
  40785. * Manage the pointers inputs to control an follow camera.
  40786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40787. */
  40788. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40789. /**
  40790. * Defines the camera the input is attached to.
  40791. */
  40792. camera: FollowCamera;
  40793. /**
  40794. * Gets the class name of the current input.
  40795. * @returns the class name
  40796. */
  40797. getClassName(): string;
  40798. /**
  40799. * Defines the pointer angular sensibility along the X axis or how fast is
  40800. * the camera rotating.
  40801. * A negative number will reverse the axis direction.
  40802. */
  40803. angularSensibilityX: number;
  40804. /**
  40805. * Defines the pointer angular sensibility along the Y axis or how fast is
  40806. * the camera rotating.
  40807. * A negative number will reverse the axis direction.
  40808. */
  40809. angularSensibilityY: number;
  40810. /**
  40811. * Defines the pointer pinch precision or how fast is the camera zooming.
  40812. * A negative number will reverse the axis direction.
  40813. */
  40814. pinchPrecision: number;
  40815. /**
  40816. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40817. * from 0.
  40818. * It defines the percentage of current camera.radius to use as delta when
  40819. * pinch zoom is used.
  40820. */
  40821. pinchDeltaPercentage: number;
  40822. /**
  40823. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40824. */
  40825. axisXControlRadius: boolean;
  40826. /**
  40827. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40828. */
  40829. axisXControlHeight: boolean;
  40830. /**
  40831. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40832. */
  40833. axisXControlRotation: boolean;
  40834. /**
  40835. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40836. */
  40837. axisYControlRadius: boolean;
  40838. /**
  40839. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40840. */
  40841. axisYControlHeight: boolean;
  40842. /**
  40843. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40844. */
  40845. axisYControlRotation: boolean;
  40846. /**
  40847. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40848. */
  40849. axisPinchControlRadius: boolean;
  40850. /**
  40851. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40852. */
  40853. axisPinchControlHeight: boolean;
  40854. /**
  40855. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40856. */
  40857. axisPinchControlRotation: boolean;
  40858. /**
  40859. * Log error messages if basic misconfiguration has occurred.
  40860. */
  40861. warningEnable: boolean;
  40862. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40863. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40864. private _warningCounter;
  40865. private _warning;
  40866. }
  40867. }
  40868. declare module BABYLON {
  40869. /**
  40870. * Default Inputs manager for the FollowCamera.
  40871. * It groups all the default supported inputs for ease of use.
  40872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40873. */
  40874. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40875. /**
  40876. * Instantiates a new FollowCameraInputsManager.
  40877. * @param camera Defines the camera the inputs belong to
  40878. */
  40879. constructor(camera: FollowCamera);
  40880. /**
  40881. * Add keyboard input support to the input manager.
  40882. * @returns the current input manager
  40883. */
  40884. addKeyboard(): FollowCameraInputsManager;
  40885. /**
  40886. * Add mouse wheel input support to the input manager.
  40887. * @returns the current input manager
  40888. */
  40889. addMouseWheel(): FollowCameraInputsManager;
  40890. /**
  40891. * Add pointers input support to the input manager.
  40892. * @returns the current input manager
  40893. */
  40894. addPointers(): FollowCameraInputsManager;
  40895. /**
  40896. * Add orientation input support to the input manager.
  40897. * @returns the current input manager
  40898. */
  40899. addVRDeviceOrientation(): FollowCameraInputsManager;
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /**
  40904. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40905. * an arc rotate version arcFollowCamera are available.
  40906. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40907. */
  40908. export class FollowCamera extends TargetCamera {
  40909. /**
  40910. * Distance the follow camera should follow an object at
  40911. */
  40912. radius: number;
  40913. /**
  40914. * Minimum allowed distance of the camera to the axis of rotation
  40915. * (The camera can not get closer).
  40916. * This can help limiting how the Camera is able to move in the scene.
  40917. */
  40918. lowerRadiusLimit: Nullable<number>;
  40919. /**
  40920. * Maximum allowed distance of the camera to the axis of rotation
  40921. * (The camera can not get further).
  40922. * This can help limiting how the Camera is able to move in the scene.
  40923. */
  40924. upperRadiusLimit: Nullable<number>;
  40925. /**
  40926. * Define a rotation offset between the camera and the object it follows
  40927. */
  40928. rotationOffset: number;
  40929. /**
  40930. * Minimum allowed angle to camera position relative to target object.
  40931. * This can help limiting how the Camera is able to move in the scene.
  40932. */
  40933. lowerRotationOffsetLimit: Nullable<number>;
  40934. /**
  40935. * Maximum allowed angle to camera position relative to target object.
  40936. * This can help limiting how the Camera is able to move in the scene.
  40937. */
  40938. upperRotationOffsetLimit: Nullable<number>;
  40939. /**
  40940. * Define a height offset between the camera and the object it follows.
  40941. * It can help following an object from the top (like a car chaing a plane)
  40942. */
  40943. heightOffset: number;
  40944. /**
  40945. * Minimum allowed height of camera position relative to target object.
  40946. * This can help limiting how the Camera is able to move in the scene.
  40947. */
  40948. lowerHeightOffsetLimit: Nullable<number>;
  40949. /**
  40950. * Maximum allowed height of camera position relative to target object.
  40951. * This can help limiting how the Camera is able to move in the scene.
  40952. */
  40953. upperHeightOffsetLimit: Nullable<number>;
  40954. /**
  40955. * Define how fast the camera can accelerate to follow it s target.
  40956. */
  40957. cameraAcceleration: number;
  40958. /**
  40959. * Define the speed limit of the camera following an object.
  40960. */
  40961. maxCameraSpeed: number;
  40962. /**
  40963. * Define the target of the camera.
  40964. */
  40965. lockedTarget: Nullable<AbstractMesh>;
  40966. /**
  40967. * Defines the input associated with the camera.
  40968. */
  40969. inputs: FollowCameraInputsManager;
  40970. /**
  40971. * Instantiates the follow camera.
  40972. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40973. * @param name Define the name of the camera in the scene
  40974. * @param position Define the position of the camera
  40975. * @param scene Define the scene the camera belong to
  40976. * @param lockedTarget Define the target of the camera
  40977. */
  40978. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40979. private _follow;
  40980. /**
  40981. * Attached controls to the current camera.
  40982. * @param element Defines the element the controls should be listened from
  40983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40984. */
  40985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40986. /**
  40987. * Detach the current controls from the camera.
  40988. * The camera will stop reacting to inputs.
  40989. * @param element Defines the element to stop listening the inputs from
  40990. */
  40991. detachControl(element: HTMLElement): void;
  40992. /** @hidden */
  40993. _checkInputs(): void;
  40994. private _checkLimits;
  40995. /**
  40996. * Gets the camera class name.
  40997. * @returns the class name
  40998. */
  40999. getClassName(): string;
  41000. }
  41001. /**
  41002. * Arc Rotate version of the follow camera.
  41003. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41005. */
  41006. export class ArcFollowCamera extends TargetCamera {
  41007. /** The longitudinal angle of the camera */
  41008. alpha: number;
  41009. /** The latitudinal angle of the camera */
  41010. beta: number;
  41011. /** The radius of the camera from its target */
  41012. radius: number;
  41013. /** Define the camera target (the messh it should follow) */
  41014. target: Nullable<AbstractMesh>;
  41015. private _cartesianCoordinates;
  41016. /**
  41017. * Instantiates a new ArcFollowCamera
  41018. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41019. * @param name Define the name of the camera
  41020. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41021. * @param beta Define the rotation angle of the camera around the elevation axis
  41022. * @param radius Define the radius of the camera from its target point
  41023. * @param target Define the target of the camera
  41024. * @param scene Define the scene the camera belongs to
  41025. */
  41026. constructor(name: string,
  41027. /** The longitudinal angle of the camera */
  41028. alpha: number,
  41029. /** The latitudinal angle of the camera */
  41030. beta: number,
  41031. /** The radius of the camera from its target */
  41032. radius: number,
  41033. /** Define the camera target (the messh it should follow) */
  41034. target: Nullable<AbstractMesh>, scene: Scene);
  41035. private _follow;
  41036. /** @hidden */
  41037. _checkInputs(): void;
  41038. /**
  41039. * Returns the class name of the object.
  41040. * It is mostly used internally for serialization purposes.
  41041. */
  41042. getClassName(): string;
  41043. }
  41044. }
  41045. declare module BABYLON {
  41046. /**
  41047. * Manage the keyboard inputs to control the movement of a follow camera.
  41048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41049. */
  41050. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41051. /**
  41052. * Defines the camera the input is attached to.
  41053. */
  41054. camera: FollowCamera;
  41055. /**
  41056. * Defines the list of key codes associated with the up action (increase heightOffset)
  41057. */
  41058. keysHeightOffsetIncr: number[];
  41059. /**
  41060. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41061. */
  41062. keysHeightOffsetDecr: number[];
  41063. /**
  41064. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41065. */
  41066. keysHeightOffsetModifierAlt: boolean;
  41067. /**
  41068. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41069. */
  41070. keysHeightOffsetModifierCtrl: boolean;
  41071. /**
  41072. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41073. */
  41074. keysHeightOffsetModifierShift: boolean;
  41075. /**
  41076. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41077. */
  41078. keysRotationOffsetIncr: number[];
  41079. /**
  41080. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41081. */
  41082. keysRotationOffsetDecr: number[];
  41083. /**
  41084. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41085. */
  41086. keysRotationOffsetModifierAlt: boolean;
  41087. /**
  41088. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41089. */
  41090. keysRotationOffsetModifierCtrl: boolean;
  41091. /**
  41092. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41093. */
  41094. keysRotationOffsetModifierShift: boolean;
  41095. /**
  41096. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41097. */
  41098. keysRadiusIncr: number[];
  41099. /**
  41100. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41101. */
  41102. keysRadiusDecr: number[];
  41103. /**
  41104. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41105. */
  41106. keysRadiusModifierAlt: boolean;
  41107. /**
  41108. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41109. */
  41110. keysRadiusModifierCtrl: boolean;
  41111. /**
  41112. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41113. */
  41114. keysRadiusModifierShift: boolean;
  41115. /**
  41116. * Defines the rate of change of heightOffset.
  41117. */
  41118. heightSensibility: number;
  41119. /**
  41120. * Defines the rate of change of rotationOffset.
  41121. */
  41122. rotationSensibility: number;
  41123. /**
  41124. * Defines the rate of change of radius.
  41125. */
  41126. radiusSensibility: number;
  41127. private _keys;
  41128. private _ctrlPressed;
  41129. private _altPressed;
  41130. private _shiftPressed;
  41131. private _onCanvasBlurObserver;
  41132. private _onKeyboardObserver;
  41133. private _engine;
  41134. private _scene;
  41135. /**
  41136. * Attach the input controls to a specific dom element to get the input from.
  41137. * @param element Defines the element the controls should be listened from
  41138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41139. */
  41140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41141. /**
  41142. * Detach the current controls from the specified dom element.
  41143. * @param element Defines the element to stop listening the inputs from
  41144. */
  41145. detachControl(element: Nullable<HTMLElement>): void;
  41146. /**
  41147. * Update the current camera state depending on the inputs that have been used this frame.
  41148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41149. */
  41150. checkInputs(): void;
  41151. /**
  41152. * Gets the class name of the current input.
  41153. * @returns the class name
  41154. */
  41155. getClassName(): string;
  41156. /**
  41157. * Get the friendly name associated with the input class.
  41158. * @returns the input friendly name
  41159. */
  41160. getSimpleName(): string;
  41161. /**
  41162. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41163. * allow modification of the heightOffset value.
  41164. */
  41165. private _modifierHeightOffset;
  41166. /**
  41167. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41168. * allow modification of the rotationOffset value.
  41169. */
  41170. private _modifierRotationOffset;
  41171. /**
  41172. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41173. * allow modification of the radius value.
  41174. */
  41175. private _modifierRadius;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. interface FreeCameraInputsManager {
  41180. /**
  41181. * @hidden
  41182. */
  41183. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41184. /**
  41185. * Add orientation input support to the input manager.
  41186. * @returns the current input manager
  41187. */
  41188. addDeviceOrientation(): FreeCameraInputsManager;
  41189. }
  41190. /**
  41191. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41192. * Screen rotation is taken into account.
  41193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41194. */
  41195. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41196. private _camera;
  41197. private _screenOrientationAngle;
  41198. private _constantTranform;
  41199. private _screenQuaternion;
  41200. private _alpha;
  41201. private _beta;
  41202. private _gamma;
  41203. /**
  41204. * Can be used to detect if a device orientation sensor is available on a device
  41205. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41206. * @returns a promise that will resolve on orientation change
  41207. */
  41208. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41209. /**
  41210. * @hidden
  41211. */
  41212. _onDeviceOrientationChangedObservable: Observable<void>;
  41213. /**
  41214. * Instantiates a new input
  41215. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41216. */
  41217. constructor();
  41218. /**
  41219. * Define the camera controlled by the input.
  41220. */
  41221. get camera(): FreeCamera;
  41222. set camera(camera: FreeCamera);
  41223. /**
  41224. * Attach the input controls to a specific dom element to get the input from.
  41225. * @param element Defines the element the controls should be listened from
  41226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41227. */
  41228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41229. private _orientationChanged;
  41230. private _deviceOrientation;
  41231. /**
  41232. * Detach the current controls from the specified dom element.
  41233. * @param element Defines the element to stop listening the inputs from
  41234. */
  41235. detachControl(element: Nullable<HTMLElement>): void;
  41236. /**
  41237. * Update the current camera state depending on the inputs that have been used this frame.
  41238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41239. */
  41240. checkInputs(): void;
  41241. /**
  41242. * Gets the class name of the current intput.
  41243. * @returns the class name
  41244. */
  41245. getClassName(): string;
  41246. /**
  41247. * Get the friendly name associated with the input class.
  41248. * @returns the input friendly name
  41249. */
  41250. getSimpleName(): string;
  41251. }
  41252. }
  41253. declare module BABYLON {
  41254. /**
  41255. * Manage the gamepad inputs to control a free camera.
  41256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41257. */
  41258. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41259. /**
  41260. * Define the camera the input is attached to.
  41261. */
  41262. camera: FreeCamera;
  41263. /**
  41264. * Define the Gamepad controlling the input
  41265. */
  41266. gamepad: Nullable<Gamepad>;
  41267. /**
  41268. * Defines the gamepad rotation sensiblity.
  41269. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41270. */
  41271. gamepadAngularSensibility: number;
  41272. /**
  41273. * Defines the gamepad move sensiblity.
  41274. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41275. */
  41276. gamepadMoveSensibility: number;
  41277. private _yAxisScale;
  41278. /**
  41279. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41280. */
  41281. get invertYAxis(): boolean;
  41282. set invertYAxis(value: boolean);
  41283. private _onGamepadConnectedObserver;
  41284. private _onGamepadDisconnectedObserver;
  41285. private _cameraTransform;
  41286. private _deltaTransform;
  41287. private _vector3;
  41288. private _vector2;
  41289. /**
  41290. * Attach the input controls to a specific dom element to get the input from.
  41291. * @param element Defines the element the controls should be listened from
  41292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41293. */
  41294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41295. /**
  41296. * Detach the current controls from the specified dom element.
  41297. * @param element Defines the element to stop listening the inputs from
  41298. */
  41299. detachControl(element: Nullable<HTMLElement>): void;
  41300. /**
  41301. * Update the current camera state depending on the inputs that have been used this frame.
  41302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41303. */
  41304. checkInputs(): void;
  41305. /**
  41306. * Gets the class name of the current intput.
  41307. * @returns the class name
  41308. */
  41309. getClassName(): string;
  41310. /**
  41311. * Get the friendly name associated with the input class.
  41312. * @returns the input friendly name
  41313. */
  41314. getSimpleName(): string;
  41315. }
  41316. }
  41317. declare module BABYLON {
  41318. /**
  41319. * Defines the potential axis of a Joystick
  41320. */
  41321. export enum JoystickAxis {
  41322. /** X axis */
  41323. X = 0,
  41324. /** Y axis */
  41325. Y = 1,
  41326. /** Z axis */
  41327. Z = 2
  41328. }
  41329. /**
  41330. * Class used to define virtual joystick (used in touch mode)
  41331. */
  41332. export class VirtualJoystick {
  41333. /**
  41334. * Gets or sets a boolean indicating that left and right values must be inverted
  41335. */
  41336. reverseLeftRight: boolean;
  41337. /**
  41338. * Gets or sets a boolean indicating that up and down values must be inverted
  41339. */
  41340. reverseUpDown: boolean;
  41341. /**
  41342. * Gets the offset value for the position (ie. the change of the position value)
  41343. */
  41344. deltaPosition: Vector3;
  41345. /**
  41346. * Gets a boolean indicating if the virtual joystick was pressed
  41347. */
  41348. pressed: boolean;
  41349. /**
  41350. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41351. */
  41352. static Canvas: Nullable<HTMLCanvasElement>;
  41353. private static _globalJoystickIndex;
  41354. private static vjCanvasContext;
  41355. private static vjCanvasWidth;
  41356. private static vjCanvasHeight;
  41357. private static halfWidth;
  41358. private _action;
  41359. private _axisTargetedByLeftAndRight;
  41360. private _axisTargetedByUpAndDown;
  41361. private _joystickSensibility;
  41362. private _inversedSensibility;
  41363. private _joystickPointerID;
  41364. private _joystickColor;
  41365. private _joystickPointerPos;
  41366. private _joystickPreviousPointerPos;
  41367. private _joystickPointerStartPos;
  41368. private _deltaJoystickVector;
  41369. private _leftJoystick;
  41370. private _touches;
  41371. private _onPointerDownHandlerRef;
  41372. private _onPointerMoveHandlerRef;
  41373. private _onPointerUpHandlerRef;
  41374. private _onResize;
  41375. /**
  41376. * Creates a new virtual joystick
  41377. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41378. */
  41379. constructor(leftJoystick?: boolean);
  41380. /**
  41381. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41382. * @param newJoystickSensibility defines the new sensibility
  41383. */
  41384. setJoystickSensibility(newJoystickSensibility: number): void;
  41385. private _onPointerDown;
  41386. private _onPointerMove;
  41387. private _onPointerUp;
  41388. /**
  41389. * Change the color of the virtual joystick
  41390. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41391. */
  41392. setJoystickColor(newColor: string): void;
  41393. /**
  41394. * Defines a callback to call when the joystick is touched
  41395. * @param action defines the callback
  41396. */
  41397. setActionOnTouch(action: () => any): void;
  41398. /**
  41399. * Defines which axis you'd like to control for left & right
  41400. * @param axis defines the axis to use
  41401. */
  41402. setAxisForLeftRight(axis: JoystickAxis): void;
  41403. /**
  41404. * Defines which axis you'd like to control for up & down
  41405. * @param axis defines the axis to use
  41406. */
  41407. setAxisForUpDown(axis: JoystickAxis): void;
  41408. private _drawVirtualJoystick;
  41409. /**
  41410. * Release internal HTML canvas
  41411. */
  41412. releaseCanvas(): void;
  41413. }
  41414. }
  41415. declare module BABYLON {
  41416. interface FreeCameraInputsManager {
  41417. /**
  41418. * Add virtual joystick input support to the input manager.
  41419. * @returns the current input manager
  41420. */
  41421. addVirtualJoystick(): FreeCameraInputsManager;
  41422. }
  41423. /**
  41424. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41426. */
  41427. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41428. /**
  41429. * Defines the camera the input is attached to.
  41430. */
  41431. camera: FreeCamera;
  41432. private _leftjoystick;
  41433. private _rightjoystick;
  41434. /**
  41435. * Gets the left stick of the virtual joystick.
  41436. * @returns The virtual Joystick
  41437. */
  41438. getLeftJoystick(): VirtualJoystick;
  41439. /**
  41440. * Gets the right stick of the virtual joystick.
  41441. * @returns The virtual Joystick
  41442. */
  41443. getRightJoystick(): VirtualJoystick;
  41444. /**
  41445. * Update the current camera state depending on the inputs that have been used this frame.
  41446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41447. */
  41448. checkInputs(): void;
  41449. /**
  41450. * Attach the input controls to a specific dom element to get the input from.
  41451. * @param element Defines the element the controls should be listened from
  41452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41453. */
  41454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41455. /**
  41456. * Detach the current controls from the specified dom element.
  41457. * @param element Defines the element to stop listening the inputs from
  41458. */
  41459. detachControl(element: Nullable<HTMLElement>): void;
  41460. /**
  41461. * Gets the class name of the current intput.
  41462. * @returns the class name
  41463. */
  41464. getClassName(): string;
  41465. /**
  41466. * Get the friendly name associated with the input class.
  41467. * @returns the input friendly name
  41468. */
  41469. getSimpleName(): string;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. /**
  41474. * This represents a FPS type of camera controlled by touch.
  41475. * This is like a universal camera minus the Gamepad controls.
  41476. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41477. */
  41478. export class TouchCamera extends FreeCamera {
  41479. /**
  41480. * Defines the touch sensibility for rotation.
  41481. * The higher the faster.
  41482. */
  41483. get touchAngularSensibility(): number;
  41484. set touchAngularSensibility(value: number);
  41485. /**
  41486. * Defines the touch sensibility for move.
  41487. * The higher the faster.
  41488. */
  41489. get touchMoveSensibility(): number;
  41490. set touchMoveSensibility(value: number);
  41491. /**
  41492. * Instantiates a new touch camera.
  41493. * This represents a FPS type of camera controlled by touch.
  41494. * This is like a universal camera minus the Gamepad controls.
  41495. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41496. * @param name Define the name of the camera in the scene
  41497. * @param position Define the start position of the camera in the scene
  41498. * @param scene Define the scene the camera belongs to
  41499. */
  41500. constructor(name: string, position: Vector3, scene: Scene);
  41501. /**
  41502. * Gets the current object class name.
  41503. * @return the class name
  41504. */
  41505. getClassName(): string;
  41506. /** @hidden */
  41507. _setupInputs(): void;
  41508. }
  41509. }
  41510. declare module BABYLON {
  41511. /**
  41512. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41513. * being tilted forward or back and left or right.
  41514. */
  41515. export class DeviceOrientationCamera extends FreeCamera {
  41516. private _initialQuaternion;
  41517. private _quaternionCache;
  41518. private _tmpDragQuaternion;
  41519. private _disablePointerInputWhenUsingDeviceOrientation;
  41520. /**
  41521. * Creates a new device orientation camera
  41522. * @param name The name of the camera
  41523. * @param position The start position camera
  41524. * @param scene The scene the camera belongs to
  41525. */
  41526. constructor(name: string, position: Vector3, scene: Scene);
  41527. /**
  41528. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41529. */
  41530. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41531. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41532. private _dragFactor;
  41533. /**
  41534. * Enabled turning on the y axis when the orientation sensor is active
  41535. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41536. */
  41537. enableHorizontalDragging(dragFactor?: number): void;
  41538. /**
  41539. * Gets the current instance class name ("DeviceOrientationCamera").
  41540. * This helps avoiding instanceof at run time.
  41541. * @returns the class name
  41542. */
  41543. getClassName(): string;
  41544. /**
  41545. * @hidden
  41546. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41547. */
  41548. _checkInputs(): void;
  41549. /**
  41550. * Reset the camera to its default orientation on the specified axis only.
  41551. * @param axis The axis to reset
  41552. */
  41553. resetToCurrentRotation(axis?: Axis): void;
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /**
  41558. * Defines supported buttons for XBox360 compatible gamepads
  41559. */
  41560. export enum Xbox360Button {
  41561. /** A */
  41562. A = 0,
  41563. /** B */
  41564. B = 1,
  41565. /** X */
  41566. X = 2,
  41567. /** Y */
  41568. Y = 3,
  41569. /** Left button */
  41570. LB = 4,
  41571. /** Right button */
  41572. RB = 5,
  41573. /** Back */
  41574. Back = 8,
  41575. /** Start */
  41576. Start = 9,
  41577. /** Left stick */
  41578. LeftStick = 10,
  41579. /** Right stick */
  41580. RightStick = 11
  41581. }
  41582. /** Defines values for XBox360 DPad */
  41583. export enum Xbox360Dpad {
  41584. /** Up */
  41585. Up = 12,
  41586. /** Down */
  41587. Down = 13,
  41588. /** Left */
  41589. Left = 14,
  41590. /** Right */
  41591. Right = 15
  41592. }
  41593. /**
  41594. * Defines a XBox360 gamepad
  41595. */
  41596. export class Xbox360Pad extends Gamepad {
  41597. private _leftTrigger;
  41598. private _rightTrigger;
  41599. private _onlefttriggerchanged;
  41600. private _onrighttriggerchanged;
  41601. private _onbuttondown;
  41602. private _onbuttonup;
  41603. private _ondpaddown;
  41604. private _ondpadup;
  41605. /** Observable raised when a button is pressed */
  41606. onButtonDownObservable: Observable<Xbox360Button>;
  41607. /** Observable raised when a button is released */
  41608. onButtonUpObservable: Observable<Xbox360Button>;
  41609. /** Observable raised when a pad is pressed */
  41610. onPadDownObservable: Observable<Xbox360Dpad>;
  41611. /** Observable raised when a pad is released */
  41612. onPadUpObservable: Observable<Xbox360Dpad>;
  41613. private _buttonA;
  41614. private _buttonB;
  41615. private _buttonX;
  41616. private _buttonY;
  41617. private _buttonBack;
  41618. private _buttonStart;
  41619. private _buttonLB;
  41620. private _buttonRB;
  41621. private _buttonLeftStick;
  41622. private _buttonRightStick;
  41623. private _dPadUp;
  41624. private _dPadDown;
  41625. private _dPadLeft;
  41626. private _dPadRight;
  41627. private _isXboxOnePad;
  41628. /**
  41629. * Creates a new XBox360 gamepad object
  41630. * @param id defines the id of this gamepad
  41631. * @param index defines its index
  41632. * @param gamepad defines the internal HTML gamepad object
  41633. * @param xboxOne defines if it is a XBox One gamepad
  41634. */
  41635. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41636. /**
  41637. * Defines the callback to call when left trigger is pressed
  41638. * @param callback defines the callback to use
  41639. */
  41640. onlefttriggerchanged(callback: (value: number) => void): void;
  41641. /**
  41642. * Defines the callback to call when right trigger is pressed
  41643. * @param callback defines the callback to use
  41644. */
  41645. onrighttriggerchanged(callback: (value: number) => void): void;
  41646. /**
  41647. * Gets the left trigger value
  41648. */
  41649. get leftTrigger(): number;
  41650. /**
  41651. * Sets the left trigger value
  41652. */
  41653. set leftTrigger(newValue: number);
  41654. /**
  41655. * Gets the right trigger value
  41656. */
  41657. get rightTrigger(): number;
  41658. /**
  41659. * Sets the right trigger value
  41660. */
  41661. set rightTrigger(newValue: number);
  41662. /**
  41663. * Defines the callback to call when a button is pressed
  41664. * @param callback defines the callback to use
  41665. */
  41666. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41667. /**
  41668. * Defines the callback to call when a button is released
  41669. * @param callback defines the callback to use
  41670. */
  41671. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41672. /**
  41673. * Defines the callback to call when a pad is pressed
  41674. * @param callback defines the callback to use
  41675. */
  41676. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41677. /**
  41678. * Defines the callback to call when a pad is released
  41679. * @param callback defines the callback to use
  41680. */
  41681. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41682. private _setButtonValue;
  41683. private _setDPadValue;
  41684. /**
  41685. * Gets the value of the `A` button
  41686. */
  41687. get buttonA(): number;
  41688. /**
  41689. * Sets the value of the `A` button
  41690. */
  41691. set buttonA(value: number);
  41692. /**
  41693. * Gets the value of the `B` button
  41694. */
  41695. get buttonB(): number;
  41696. /**
  41697. * Sets the value of the `B` button
  41698. */
  41699. set buttonB(value: number);
  41700. /**
  41701. * Gets the value of the `X` button
  41702. */
  41703. get buttonX(): number;
  41704. /**
  41705. * Sets the value of the `X` button
  41706. */
  41707. set buttonX(value: number);
  41708. /**
  41709. * Gets the value of the `Y` button
  41710. */
  41711. get buttonY(): number;
  41712. /**
  41713. * Sets the value of the `Y` button
  41714. */
  41715. set buttonY(value: number);
  41716. /**
  41717. * Gets the value of the `Start` button
  41718. */
  41719. get buttonStart(): number;
  41720. /**
  41721. * Sets the value of the `Start` button
  41722. */
  41723. set buttonStart(value: number);
  41724. /**
  41725. * Gets the value of the `Back` button
  41726. */
  41727. get buttonBack(): number;
  41728. /**
  41729. * Sets the value of the `Back` button
  41730. */
  41731. set buttonBack(value: number);
  41732. /**
  41733. * Gets the value of the `Left` button
  41734. */
  41735. get buttonLB(): number;
  41736. /**
  41737. * Sets the value of the `Left` button
  41738. */
  41739. set buttonLB(value: number);
  41740. /**
  41741. * Gets the value of the `Right` button
  41742. */
  41743. get buttonRB(): number;
  41744. /**
  41745. * Sets the value of the `Right` button
  41746. */
  41747. set buttonRB(value: number);
  41748. /**
  41749. * Gets the value of the Left joystick
  41750. */
  41751. get buttonLeftStick(): number;
  41752. /**
  41753. * Sets the value of the Left joystick
  41754. */
  41755. set buttonLeftStick(value: number);
  41756. /**
  41757. * Gets the value of the Right joystick
  41758. */
  41759. get buttonRightStick(): number;
  41760. /**
  41761. * Sets the value of the Right joystick
  41762. */
  41763. set buttonRightStick(value: number);
  41764. /**
  41765. * Gets the value of D-pad up
  41766. */
  41767. get dPadUp(): number;
  41768. /**
  41769. * Sets the value of D-pad up
  41770. */
  41771. set dPadUp(value: number);
  41772. /**
  41773. * Gets the value of D-pad down
  41774. */
  41775. get dPadDown(): number;
  41776. /**
  41777. * Sets the value of D-pad down
  41778. */
  41779. set dPadDown(value: number);
  41780. /**
  41781. * Gets the value of D-pad left
  41782. */
  41783. get dPadLeft(): number;
  41784. /**
  41785. * Sets the value of D-pad left
  41786. */
  41787. set dPadLeft(value: number);
  41788. /**
  41789. * Gets the value of D-pad right
  41790. */
  41791. get dPadRight(): number;
  41792. /**
  41793. * Sets the value of D-pad right
  41794. */
  41795. set dPadRight(value: number);
  41796. /**
  41797. * Force the gamepad to synchronize with device values
  41798. */
  41799. update(): void;
  41800. /**
  41801. * Disposes the gamepad
  41802. */
  41803. dispose(): void;
  41804. }
  41805. }
  41806. declare module BABYLON {
  41807. /**
  41808. * Defines supported buttons for DualShock compatible gamepads
  41809. */
  41810. export enum DualShockButton {
  41811. /** Cross */
  41812. Cross = 0,
  41813. /** Circle */
  41814. Circle = 1,
  41815. /** Square */
  41816. Square = 2,
  41817. /** Triangle */
  41818. Triangle = 3,
  41819. /** L1 */
  41820. L1 = 4,
  41821. /** R1 */
  41822. R1 = 5,
  41823. /** Share */
  41824. Share = 8,
  41825. /** Options */
  41826. Options = 9,
  41827. /** Left stick */
  41828. LeftStick = 10,
  41829. /** Right stick */
  41830. RightStick = 11
  41831. }
  41832. /** Defines values for DualShock DPad */
  41833. export enum DualShockDpad {
  41834. /** Up */
  41835. Up = 12,
  41836. /** Down */
  41837. Down = 13,
  41838. /** Left */
  41839. Left = 14,
  41840. /** Right */
  41841. Right = 15
  41842. }
  41843. /**
  41844. * Defines a DualShock gamepad
  41845. */
  41846. export class DualShockPad extends Gamepad {
  41847. private _leftTrigger;
  41848. private _rightTrigger;
  41849. private _onlefttriggerchanged;
  41850. private _onrighttriggerchanged;
  41851. private _onbuttondown;
  41852. private _onbuttonup;
  41853. private _ondpaddown;
  41854. private _ondpadup;
  41855. /** Observable raised when a button is pressed */
  41856. onButtonDownObservable: Observable<DualShockButton>;
  41857. /** Observable raised when a button is released */
  41858. onButtonUpObservable: Observable<DualShockButton>;
  41859. /** Observable raised when a pad is pressed */
  41860. onPadDownObservable: Observable<DualShockDpad>;
  41861. /** Observable raised when a pad is released */
  41862. onPadUpObservable: Observable<DualShockDpad>;
  41863. private _buttonCross;
  41864. private _buttonCircle;
  41865. private _buttonSquare;
  41866. private _buttonTriangle;
  41867. private _buttonShare;
  41868. private _buttonOptions;
  41869. private _buttonL1;
  41870. private _buttonR1;
  41871. private _buttonLeftStick;
  41872. private _buttonRightStick;
  41873. private _dPadUp;
  41874. private _dPadDown;
  41875. private _dPadLeft;
  41876. private _dPadRight;
  41877. /**
  41878. * Creates a new DualShock gamepad object
  41879. * @param id defines the id of this gamepad
  41880. * @param index defines its index
  41881. * @param gamepad defines the internal HTML gamepad object
  41882. */
  41883. constructor(id: string, index: number, gamepad: any);
  41884. /**
  41885. * Defines the callback to call when left trigger is pressed
  41886. * @param callback defines the callback to use
  41887. */
  41888. onlefttriggerchanged(callback: (value: number) => void): void;
  41889. /**
  41890. * Defines the callback to call when right trigger is pressed
  41891. * @param callback defines the callback to use
  41892. */
  41893. onrighttriggerchanged(callback: (value: number) => void): void;
  41894. /**
  41895. * Gets the left trigger value
  41896. */
  41897. get leftTrigger(): number;
  41898. /**
  41899. * Sets the left trigger value
  41900. */
  41901. set leftTrigger(newValue: number);
  41902. /**
  41903. * Gets the right trigger value
  41904. */
  41905. get rightTrigger(): number;
  41906. /**
  41907. * Sets the right trigger value
  41908. */
  41909. set rightTrigger(newValue: number);
  41910. /**
  41911. * Defines the callback to call when a button is pressed
  41912. * @param callback defines the callback to use
  41913. */
  41914. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41915. /**
  41916. * Defines the callback to call when a button is released
  41917. * @param callback defines the callback to use
  41918. */
  41919. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41920. /**
  41921. * Defines the callback to call when a pad is pressed
  41922. * @param callback defines the callback to use
  41923. */
  41924. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41925. /**
  41926. * Defines the callback to call when a pad is released
  41927. * @param callback defines the callback to use
  41928. */
  41929. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41930. private _setButtonValue;
  41931. private _setDPadValue;
  41932. /**
  41933. * Gets the value of the `Cross` button
  41934. */
  41935. get buttonCross(): number;
  41936. /**
  41937. * Sets the value of the `Cross` button
  41938. */
  41939. set buttonCross(value: number);
  41940. /**
  41941. * Gets the value of the `Circle` button
  41942. */
  41943. get buttonCircle(): number;
  41944. /**
  41945. * Sets the value of the `Circle` button
  41946. */
  41947. set buttonCircle(value: number);
  41948. /**
  41949. * Gets the value of the `Square` button
  41950. */
  41951. get buttonSquare(): number;
  41952. /**
  41953. * Sets the value of the `Square` button
  41954. */
  41955. set buttonSquare(value: number);
  41956. /**
  41957. * Gets the value of the `Triangle` button
  41958. */
  41959. get buttonTriangle(): number;
  41960. /**
  41961. * Sets the value of the `Triangle` button
  41962. */
  41963. set buttonTriangle(value: number);
  41964. /**
  41965. * Gets the value of the `Options` button
  41966. */
  41967. get buttonOptions(): number;
  41968. /**
  41969. * Sets the value of the `Options` button
  41970. */
  41971. set buttonOptions(value: number);
  41972. /**
  41973. * Gets the value of the `Share` button
  41974. */
  41975. get buttonShare(): number;
  41976. /**
  41977. * Sets the value of the `Share` button
  41978. */
  41979. set buttonShare(value: number);
  41980. /**
  41981. * Gets the value of the `L1` button
  41982. */
  41983. get buttonL1(): number;
  41984. /**
  41985. * Sets the value of the `L1` button
  41986. */
  41987. set buttonL1(value: number);
  41988. /**
  41989. * Gets the value of the `R1` button
  41990. */
  41991. get buttonR1(): number;
  41992. /**
  41993. * Sets the value of the `R1` button
  41994. */
  41995. set buttonR1(value: number);
  41996. /**
  41997. * Gets the value of the Left joystick
  41998. */
  41999. get buttonLeftStick(): number;
  42000. /**
  42001. * Sets the value of the Left joystick
  42002. */
  42003. set buttonLeftStick(value: number);
  42004. /**
  42005. * Gets the value of the Right joystick
  42006. */
  42007. get buttonRightStick(): number;
  42008. /**
  42009. * Sets the value of the Right joystick
  42010. */
  42011. set buttonRightStick(value: number);
  42012. /**
  42013. * Gets the value of D-pad up
  42014. */
  42015. get dPadUp(): number;
  42016. /**
  42017. * Sets the value of D-pad up
  42018. */
  42019. set dPadUp(value: number);
  42020. /**
  42021. * Gets the value of D-pad down
  42022. */
  42023. get dPadDown(): number;
  42024. /**
  42025. * Sets the value of D-pad down
  42026. */
  42027. set dPadDown(value: number);
  42028. /**
  42029. * Gets the value of D-pad left
  42030. */
  42031. get dPadLeft(): number;
  42032. /**
  42033. * Sets the value of D-pad left
  42034. */
  42035. set dPadLeft(value: number);
  42036. /**
  42037. * Gets the value of D-pad right
  42038. */
  42039. get dPadRight(): number;
  42040. /**
  42041. * Sets the value of D-pad right
  42042. */
  42043. set dPadRight(value: number);
  42044. /**
  42045. * Force the gamepad to synchronize with device values
  42046. */
  42047. update(): void;
  42048. /**
  42049. * Disposes the gamepad
  42050. */
  42051. dispose(): void;
  42052. }
  42053. }
  42054. declare module BABYLON {
  42055. /**
  42056. * Manager for handling gamepads
  42057. */
  42058. export class GamepadManager {
  42059. private _scene?;
  42060. private _babylonGamepads;
  42061. private _oneGamepadConnected;
  42062. /** @hidden */
  42063. _isMonitoring: boolean;
  42064. private _gamepadEventSupported;
  42065. private _gamepadSupport?;
  42066. /**
  42067. * observable to be triggered when the gamepad controller has been connected
  42068. */
  42069. onGamepadConnectedObservable: Observable<Gamepad>;
  42070. /**
  42071. * observable to be triggered when the gamepad controller has been disconnected
  42072. */
  42073. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42074. private _onGamepadConnectedEvent;
  42075. private _onGamepadDisconnectedEvent;
  42076. /**
  42077. * Initializes the gamepad manager
  42078. * @param _scene BabylonJS scene
  42079. */
  42080. constructor(_scene?: Scene | undefined);
  42081. /**
  42082. * The gamepads in the game pad manager
  42083. */
  42084. get gamepads(): Gamepad[];
  42085. /**
  42086. * Get the gamepad controllers based on type
  42087. * @param type The type of gamepad controller
  42088. * @returns Nullable gamepad
  42089. */
  42090. getGamepadByType(type?: number): Nullable<Gamepad>;
  42091. /**
  42092. * Disposes the gamepad manager
  42093. */
  42094. dispose(): void;
  42095. private _addNewGamepad;
  42096. private _startMonitoringGamepads;
  42097. private _stopMonitoringGamepads;
  42098. /** @hidden */
  42099. _checkGamepadsStatus(): void;
  42100. private _updateGamepadObjects;
  42101. }
  42102. }
  42103. declare module BABYLON {
  42104. interface Scene {
  42105. /** @hidden */
  42106. _gamepadManager: Nullable<GamepadManager>;
  42107. /**
  42108. * Gets the gamepad manager associated with the scene
  42109. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42110. */
  42111. gamepadManager: GamepadManager;
  42112. }
  42113. /**
  42114. * Interface representing a free camera inputs manager
  42115. */
  42116. interface FreeCameraInputsManager {
  42117. /**
  42118. * Adds gamepad input support to the FreeCameraInputsManager.
  42119. * @returns the FreeCameraInputsManager
  42120. */
  42121. addGamepad(): FreeCameraInputsManager;
  42122. }
  42123. /**
  42124. * Interface representing an arc rotate camera inputs manager
  42125. */
  42126. interface ArcRotateCameraInputsManager {
  42127. /**
  42128. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42129. * @returns the camera inputs manager
  42130. */
  42131. addGamepad(): ArcRotateCameraInputsManager;
  42132. }
  42133. /**
  42134. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42135. */
  42136. export class GamepadSystemSceneComponent implements ISceneComponent {
  42137. /**
  42138. * The component name helpfull to identify the component in the list of scene components.
  42139. */
  42140. readonly name: string;
  42141. /**
  42142. * The scene the component belongs to.
  42143. */
  42144. scene: Scene;
  42145. /**
  42146. * Creates a new instance of the component for the given scene
  42147. * @param scene Defines the scene to register the component in
  42148. */
  42149. constructor(scene: Scene);
  42150. /**
  42151. * Registers the component in a given scene
  42152. */
  42153. register(): void;
  42154. /**
  42155. * Rebuilds the elements related to this component in case of
  42156. * context lost for instance.
  42157. */
  42158. rebuild(): void;
  42159. /**
  42160. * Disposes the component and the associated ressources
  42161. */
  42162. dispose(): void;
  42163. private _beforeCameraUpdate;
  42164. }
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * 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,
  42169. * which still works and will still be found in many Playgrounds.
  42170. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42171. */
  42172. export class UniversalCamera extends TouchCamera {
  42173. /**
  42174. * Defines the gamepad rotation sensiblity.
  42175. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42176. */
  42177. get gamepadAngularSensibility(): number;
  42178. set gamepadAngularSensibility(value: number);
  42179. /**
  42180. * Defines the gamepad move sensiblity.
  42181. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42182. */
  42183. get gamepadMoveSensibility(): number;
  42184. set gamepadMoveSensibility(value: number);
  42185. /**
  42186. * 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,
  42187. * which still works and will still be found in many Playgrounds.
  42188. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42189. * @param name Define the name of the camera in the scene
  42190. * @param position Define the start position of the camera in the scene
  42191. * @param scene Define the scene the camera belongs to
  42192. */
  42193. constructor(name: string, position: Vector3, scene: Scene);
  42194. /**
  42195. * Gets the current object class name.
  42196. * @return the class name
  42197. */
  42198. getClassName(): string;
  42199. }
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * This represents a FPS type of camera. This is only here for back compat purpose.
  42204. * Please use the UniversalCamera instead as both are identical.
  42205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42206. */
  42207. export class GamepadCamera extends UniversalCamera {
  42208. /**
  42209. * Instantiates a new Gamepad Camera
  42210. * This represents a FPS type of camera. This is only here for back compat purpose.
  42211. * Please use the UniversalCamera instead as both are identical.
  42212. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42213. * @param name Define the name of the camera in the scene
  42214. * @param position Define the start position of the camera in the scene
  42215. * @param scene Define the scene the camera belongs to
  42216. */
  42217. constructor(name: string, position: Vector3, scene: Scene);
  42218. /**
  42219. * Gets the current object class name.
  42220. * @return the class name
  42221. */
  42222. getClassName(): string;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /** @hidden */
  42227. export var passPixelShader: {
  42228. name: string;
  42229. shader: string;
  42230. };
  42231. }
  42232. declare module BABYLON {
  42233. /** @hidden */
  42234. export var passCubePixelShader: {
  42235. name: string;
  42236. shader: string;
  42237. };
  42238. }
  42239. declare module BABYLON {
  42240. /**
  42241. * PassPostProcess which produces an output the same as it's input
  42242. */
  42243. export class PassPostProcess extends PostProcess {
  42244. /**
  42245. * Creates the PassPostProcess
  42246. * @param name The name of the effect.
  42247. * @param options The required width/height ratio to downsize to before computing the render pass.
  42248. * @param camera The camera to apply the render pass to.
  42249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42250. * @param engine The engine which the post process will be applied. (default: current engine)
  42251. * @param reusable If the post process can be reused on the same frame. (default: false)
  42252. * @param textureType The type of texture to be used when performing the post processing.
  42253. * @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)
  42254. */
  42255. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42256. }
  42257. /**
  42258. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42259. */
  42260. export class PassCubePostProcess extends PostProcess {
  42261. private _face;
  42262. /**
  42263. * Gets or sets the cube face to display.
  42264. * * 0 is +X
  42265. * * 1 is -X
  42266. * * 2 is +Y
  42267. * * 3 is -Y
  42268. * * 4 is +Z
  42269. * * 5 is -Z
  42270. */
  42271. get face(): number;
  42272. set face(value: number);
  42273. /**
  42274. * Creates the PassCubePostProcess
  42275. * @param name The name of the effect.
  42276. * @param options The required width/height ratio to downsize to before computing the render pass.
  42277. * @param camera The camera to apply the render pass to.
  42278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42279. * @param engine The engine which the post process will be applied. (default: current engine)
  42280. * @param reusable If the post process can be reused on the same frame. (default: false)
  42281. * @param textureType The type of texture to be used when performing the post processing.
  42282. * @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)
  42283. */
  42284. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42285. }
  42286. }
  42287. declare module BABYLON {
  42288. /** @hidden */
  42289. export var anaglyphPixelShader: {
  42290. name: string;
  42291. shader: string;
  42292. };
  42293. }
  42294. declare module BABYLON {
  42295. /**
  42296. * Postprocess used to generate anaglyphic rendering
  42297. */
  42298. export class AnaglyphPostProcess extends PostProcess {
  42299. private _passedProcess;
  42300. /**
  42301. * Creates a new AnaglyphPostProcess
  42302. * @param name defines postprocess name
  42303. * @param options defines creation options or target ratio scale
  42304. * @param rigCameras defines cameras using this postprocess
  42305. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42306. * @param engine defines hosting engine
  42307. * @param reusable defines if the postprocess will be reused multiple times per frame
  42308. */
  42309. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42310. }
  42311. }
  42312. declare module BABYLON {
  42313. /**
  42314. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42315. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42316. */
  42317. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42318. /**
  42319. * Creates a new AnaglyphArcRotateCamera
  42320. * @param name defines camera name
  42321. * @param alpha defines alpha angle (in radians)
  42322. * @param beta defines beta angle (in radians)
  42323. * @param radius defines radius
  42324. * @param target defines camera target
  42325. * @param interaxialDistance defines distance between each color axis
  42326. * @param scene defines the hosting scene
  42327. */
  42328. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42329. /**
  42330. * Gets camera class name
  42331. * @returns AnaglyphArcRotateCamera
  42332. */
  42333. getClassName(): string;
  42334. }
  42335. }
  42336. declare module BABYLON {
  42337. /**
  42338. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42340. */
  42341. export class AnaglyphFreeCamera extends FreeCamera {
  42342. /**
  42343. * Creates a new AnaglyphFreeCamera
  42344. * @param name defines camera name
  42345. * @param position defines initial position
  42346. * @param interaxialDistance defines distance between each color axis
  42347. * @param scene defines the hosting scene
  42348. */
  42349. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42350. /**
  42351. * Gets camera class name
  42352. * @returns AnaglyphFreeCamera
  42353. */
  42354. getClassName(): string;
  42355. }
  42356. }
  42357. declare module BABYLON {
  42358. /**
  42359. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42360. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42361. */
  42362. export class AnaglyphGamepadCamera extends GamepadCamera {
  42363. /**
  42364. * Creates a new AnaglyphGamepadCamera
  42365. * @param name defines camera name
  42366. * @param position defines initial position
  42367. * @param interaxialDistance defines distance between each color axis
  42368. * @param scene defines the hosting scene
  42369. */
  42370. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42371. /**
  42372. * Gets camera class name
  42373. * @returns AnaglyphGamepadCamera
  42374. */
  42375. getClassName(): string;
  42376. }
  42377. }
  42378. declare module BABYLON {
  42379. /**
  42380. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42381. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42382. */
  42383. export class AnaglyphUniversalCamera extends UniversalCamera {
  42384. /**
  42385. * Creates a new AnaglyphUniversalCamera
  42386. * @param name defines camera name
  42387. * @param position defines initial position
  42388. * @param interaxialDistance defines distance between each color axis
  42389. * @param scene defines the hosting scene
  42390. */
  42391. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42392. /**
  42393. * Gets camera class name
  42394. * @returns AnaglyphUniversalCamera
  42395. */
  42396. getClassName(): string;
  42397. }
  42398. }
  42399. declare module BABYLON {
  42400. /**
  42401. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42402. * @see http://doc.babylonjs.com/features/cameras
  42403. */
  42404. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42405. /**
  42406. * Creates a new StereoscopicArcRotateCamera
  42407. * @param name defines camera name
  42408. * @param alpha defines alpha angle (in radians)
  42409. * @param beta defines beta angle (in radians)
  42410. * @param radius defines radius
  42411. * @param target defines camera target
  42412. * @param interaxialDistance defines distance between each color axis
  42413. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42414. * @param scene defines the hosting scene
  42415. */
  42416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42417. /**
  42418. * Gets camera class name
  42419. * @returns StereoscopicArcRotateCamera
  42420. */
  42421. getClassName(): string;
  42422. }
  42423. }
  42424. declare module BABYLON {
  42425. /**
  42426. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42427. * @see http://doc.babylonjs.com/features/cameras
  42428. */
  42429. export class StereoscopicFreeCamera extends FreeCamera {
  42430. /**
  42431. * Creates a new StereoscopicFreeCamera
  42432. * @param name defines camera name
  42433. * @param position defines initial position
  42434. * @param interaxialDistance defines distance between each color axis
  42435. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42436. * @param scene defines the hosting scene
  42437. */
  42438. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42439. /**
  42440. * Gets camera class name
  42441. * @returns StereoscopicFreeCamera
  42442. */
  42443. getClassName(): string;
  42444. }
  42445. }
  42446. declare module BABYLON {
  42447. /**
  42448. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42449. * @see http://doc.babylonjs.com/features/cameras
  42450. */
  42451. export class StereoscopicGamepadCamera extends GamepadCamera {
  42452. /**
  42453. * Creates a new StereoscopicGamepadCamera
  42454. * @param name defines camera name
  42455. * @param position defines initial position
  42456. * @param interaxialDistance defines distance between each color axis
  42457. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42458. * @param scene defines the hosting scene
  42459. */
  42460. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42461. /**
  42462. * Gets camera class name
  42463. * @returns StereoscopicGamepadCamera
  42464. */
  42465. getClassName(): string;
  42466. }
  42467. }
  42468. declare module BABYLON {
  42469. /**
  42470. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42471. * @see http://doc.babylonjs.com/features/cameras
  42472. */
  42473. export class StereoscopicUniversalCamera extends UniversalCamera {
  42474. /**
  42475. * Creates a new StereoscopicUniversalCamera
  42476. * @param name defines camera name
  42477. * @param position defines initial position
  42478. * @param interaxialDistance defines distance between each color axis
  42479. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42480. * @param scene defines the hosting scene
  42481. */
  42482. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42483. /**
  42484. * Gets camera class name
  42485. * @returns StereoscopicUniversalCamera
  42486. */
  42487. getClassName(): string;
  42488. }
  42489. }
  42490. declare module BABYLON {
  42491. /**
  42492. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42493. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42494. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42495. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42496. */
  42497. export class VirtualJoysticksCamera extends FreeCamera {
  42498. /**
  42499. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42500. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42501. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42502. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42503. * @param name Define the name of the camera in the scene
  42504. * @param position Define the start position of the camera in the scene
  42505. * @param scene Define the scene the camera belongs to
  42506. */
  42507. constructor(name: string, position: Vector3, scene: Scene);
  42508. /**
  42509. * Gets the current object class name.
  42510. * @return the class name
  42511. */
  42512. getClassName(): string;
  42513. }
  42514. }
  42515. declare module BABYLON {
  42516. /**
  42517. * This represents all the required metrics to create a VR camera.
  42518. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42519. */
  42520. export class VRCameraMetrics {
  42521. /**
  42522. * Define the horizontal resolution off the screen.
  42523. */
  42524. hResolution: number;
  42525. /**
  42526. * Define the vertical resolution off the screen.
  42527. */
  42528. vResolution: number;
  42529. /**
  42530. * Define the horizontal screen size.
  42531. */
  42532. hScreenSize: number;
  42533. /**
  42534. * Define the vertical screen size.
  42535. */
  42536. vScreenSize: number;
  42537. /**
  42538. * Define the vertical screen center position.
  42539. */
  42540. vScreenCenter: number;
  42541. /**
  42542. * Define the distance of the eyes to the screen.
  42543. */
  42544. eyeToScreenDistance: number;
  42545. /**
  42546. * Define the distance between both lenses
  42547. */
  42548. lensSeparationDistance: number;
  42549. /**
  42550. * Define the distance between both viewer's eyes.
  42551. */
  42552. interpupillaryDistance: number;
  42553. /**
  42554. * Define the distortion factor of the VR postprocess.
  42555. * Please, touch with care.
  42556. */
  42557. distortionK: number[];
  42558. /**
  42559. * Define the chromatic aberration correction factors for the VR post process.
  42560. */
  42561. chromaAbCorrection: number[];
  42562. /**
  42563. * Define the scale factor of the post process.
  42564. * The smaller the better but the slower.
  42565. */
  42566. postProcessScaleFactor: number;
  42567. /**
  42568. * Define an offset for the lens center.
  42569. */
  42570. lensCenterOffset: number;
  42571. /**
  42572. * Define if the current vr camera should compensate the distortion of the lense or not.
  42573. */
  42574. compensateDistortion: boolean;
  42575. /**
  42576. * Defines if multiview should be enabled when rendering (Default: false)
  42577. */
  42578. multiviewEnabled: boolean;
  42579. /**
  42580. * Gets the rendering aspect ratio based on the provided resolutions.
  42581. */
  42582. get aspectRatio(): number;
  42583. /**
  42584. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42585. */
  42586. get aspectRatioFov(): number;
  42587. /**
  42588. * @hidden
  42589. */
  42590. get leftHMatrix(): Matrix;
  42591. /**
  42592. * @hidden
  42593. */
  42594. get rightHMatrix(): Matrix;
  42595. /**
  42596. * @hidden
  42597. */
  42598. get leftPreViewMatrix(): Matrix;
  42599. /**
  42600. * @hidden
  42601. */
  42602. get rightPreViewMatrix(): Matrix;
  42603. /**
  42604. * Get the default VRMetrics based on the most generic setup.
  42605. * @returns the default vr metrics
  42606. */
  42607. static GetDefault(): VRCameraMetrics;
  42608. }
  42609. }
  42610. declare module BABYLON {
  42611. /** @hidden */
  42612. export var vrDistortionCorrectionPixelShader: {
  42613. name: string;
  42614. shader: string;
  42615. };
  42616. }
  42617. declare module BABYLON {
  42618. /**
  42619. * VRDistortionCorrectionPostProcess used for mobile VR
  42620. */
  42621. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42622. private _isRightEye;
  42623. private _distortionFactors;
  42624. private _postProcessScaleFactor;
  42625. private _lensCenterOffset;
  42626. private _scaleIn;
  42627. private _scaleFactor;
  42628. private _lensCenter;
  42629. /**
  42630. * Initializes the VRDistortionCorrectionPostProcess
  42631. * @param name The name of the effect.
  42632. * @param camera The camera to apply the render pass to.
  42633. * @param isRightEye If this is for the right eye distortion
  42634. * @param vrMetrics All the required metrics for the VR camera
  42635. */
  42636. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42637. }
  42638. }
  42639. declare module BABYLON {
  42640. /**
  42641. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42642. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42643. */
  42644. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42645. /**
  42646. * Creates a new VRDeviceOrientationArcRotateCamera
  42647. * @param name defines camera name
  42648. * @param alpha defines the camera rotation along the logitudinal axis
  42649. * @param beta defines the camera rotation along the latitudinal axis
  42650. * @param radius defines the camera distance from its target
  42651. * @param target defines the camera target
  42652. * @param scene defines the scene the camera belongs to
  42653. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42654. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42655. */
  42656. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42657. /**
  42658. * Gets camera class name
  42659. * @returns VRDeviceOrientationArcRotateCamera
  42660. */
  42661. getClassName(): string;
  42662. }
  42663. }
  42664. declare module BABYLON {
  42665. /**
  42666. * Camera used to simulate VR rendering (based on FreeCamera)
  42667. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42668. */
  42669. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42670. /**
  42671. * Creates a new VRDeviceOrientationFreeCamera
  42672. * @param name defines camera name
  42673. * @param position defines the start position of the camera
  42674. * @param scene defines the scene the camera belongs to
  42675. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42676. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42677. */
  42678. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42679. /**
  42680. * Gets camera class name
  42681. * @returns VRDeviceOrientationFreeCamera
  42682. */
  42683. getClassName(): string;
  42684. }
  42685. }
  42686. declare module BABYLON {
  42687. /**
  42688. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42689. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42690. */
  42691. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42692. /**
  42693. * Creates a new VRDeviceOrientationGamepadCamera
  42694. * @param name defines camera name
  42695. * @param position defines the start position of the camera
  42696. * @param scene defines the scene the camera belongs to
  42697. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42698. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42699. */
  42700. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42701. /**
  42702. * Gets camera class name
  42703. * @returns VRDeviceOrientationGamepadCamera
  42704. */
  42705. getClassName(): string;
  42706. }
  42707. }
  42708. declare module BABYLON {
  42709. /** @hidden */
  42710. export var imageProcessingPixelShader: {
  42711. name: string;
  42712. shader: string;
  42713. };
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * ImageProcessingPostProcess
  42718. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42719. */
  42720. export class ImageProcessingPostProcess extends PostProcess {
  42721. /**
  42722. * Default configuration related to image processing available in the PBR Material.
  42723. */
  42724. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42725. /**
  42726. * Gets the image processing configuration used either in this material.
  42727. */
  42728. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42729. /**
  42730. * Sets the Default image processing configuration used either in the this material.
  42731. *
  42732. * If sets to null, the scene one is in use.
  42733. */
  42734. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42735. /**
  42736. * Keep track of the image processing observer to allow dispose and replace.
  42737. */
  42738. private _imageProcessingObserver;
  42739. /**
  42740. * Attaches a new image processing configuration to the PBR Material.
  42741. * @param configuration
  42742. */
  42743. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42744. /**
  42745. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42746. */
  42747. get colorCurves(): Nullable<ColorCurves>;
  42748. /**
  42749. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42750. */
  42751. set colorCurves(value: Nullable<ColorCurves>);
  42752. /**
  42753. * Gets wether the color curves effect is enabled.
  42754. */
  42755. get colorCurvesEnabled(): boolean;
  42756. /**
  42757. * Sets wether the color curves effect is enabled.
  42758. */
  42759. set colorCurvesEnabled(value: boolean);
  42760. /**
  42761. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42762. */
  42763. get colorGradingTexture(): Nullable<BaseTexture>;
  42764. /**
  42765. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42766. */
  42767. set colorGradingTexture(value: Nullable<BaseTexture>);
  42768. /**
  42769. * Gets wether the color grading effect is enabled.
  42770. */
  42771. get colorGradingEnabled(): boolean;
  42772. /**
  42773. * Gets wether the color grading effect is enabled.
  42774. */
  42775. set colorGradingEnabled(value: boolean);
  42776. /**
  42777. * Gets exposure used in the effect.
  42778. */
  42779. get exposure(): number;
  42780. /**
  42781. * Sets exposure used in the effect.
  42782. */
  42783. set exposure(value: number);
  42784. /**
  42785. * Gets wether tonemapping is enabled or not.
  42786. */
  42787. get toneMappingEnabled(): boolean;
  42788. /**
  42789. * Sets wether tonemapping is enabled or not
  42790. */
  42791. set toneMappingEnabled(value: boolean);
  42792. /**
  42793. * Gets the type of tone mapping effect.
  42794. */
  42795. get toneMappingType(): number;
  42796. /**
  42797. * Sets the type of tone mapping effect.
  42798. */
  42799. set toneMappingType(value: number);
  42800. /**
  42801. * Gets contrast used in the effect.
  42802. */
  42803. get contrast(): number;
  42804. /**
  42805. * Sets contrast used in the effect.
  42806. */
  42807. set contrast(value: number);
  42808. /**
  42809. * Gets Vignette stretch size.
  42810. */
  42811. get vignetteStretch(): number;
  42812. /**
  42813. * Sets Vignette stretch size.
  42814. */
  42815. set vignetteStretch(value: number);
  42816. /**
  42817. * Gets Vignette centre X Offset.
  42818. */
  42819. get vignetteCentreX(): number;
  42820. /**
  42821. * Sets Vignette centre X Offset.
  42822. */
  42823. set vignetteCentreX(value: number);
  42824. /**
  42825. * Gets Vignette centre Y Offset.
  42826. */
  42827. get vignetteCentreY(): number;
  42828. /**
  42829. * Sets Vignette centre Y Offset.
  42830. */
  42831. set vignetteCentreY(value: number);
  42832. /**
  42833. * Gets Vignette weight or intensity of the vignette effect.
  42834. */
  42835. get vignetteWeight(): number;
  42836. /**
  42837. * Sets Vignette weight or intensity of the vignette effect.
  42838. */
  42839. set vignetteWeight(value: number);
  42840. /**
  42841. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42842. * if vignetteEnabled is set to true.
  42843. */
  42844. get vignetteColor(): Color4;
  42845. /**
  42846. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42847. * if vignetteEnabled is set to true.
  42848. */
  42849. set vignetteColor(value: Color4);
  42850. /**
  42851. * Gets Camera field of view used by the Vignette effect.
  42852. */
  42853. get vignetteCameraFov(): number;
  42854. /**
  42855. * Sets Camera field of view used by the Vignette effect.
  42856. */
  42857. set vignetteCameraFov(value: number);
  42858. /**
  42859. * Gets the vignette blend mode allowing different kind of effect.
  42860. */
  42861. get vignetteBlendMode(): number;
  42862. /**
  42863. * Sets the vignette blend mode allowing different kind of effect.
  42864. */
  42865. set vignetteBlendMode(value: number);
  42866. /**
  42867. * Gets wether the vignette effect is enabled.
  42868. */
  42869. get vignetteEnabled(): boolean;
  42870. /**
  42871. * Sets wether the vignette effect is enabled.
  42872. */
  42873. set vignetteEnabled(value: boolean);
  42874. private _fromLinearSpace;
  42875. /**
  42876. * Gets wether the input of the processing is in Gamma or Linear Space.
  42877. */
  42878. get fromLinearSpace(): boolean;
  42879. /**
  42880. * Sets wether the input of the processing is in Gamma or Linear Space.
  42881. */
  42882. set fromLinearSpace(value: boolean);
  42883. /**
  42884. * Defines cache preventing GC.
  42885. */
  42886. private _defines;
  42887. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42888. /**
  42889. * "ImageProcessingPostProcess"
  42890. * @returns "ImageProcessingPostProcess"
  42891. */
  42892. getClassName(): string;
  42893. protected _updateParameters(): void;
  42894. dispose(camera?: Camera): void;
  42895. }
  42896. }
  42897. declare module BABYLON {
  42898. /**
  42899. * Class containing static functions to help procedurally build meshes
  42900. */
  42901. export class GroundBuilder {
  42902. /**
  42903. * Creates a ground mesh
  42904. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42905. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42907. * @param name defines the name of the mesh
  42908. * @param options defines the options used to create the mesh
  42909. * @param scene defines the hosting scene
  42910. * @returns the ground mesh
  42911. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42912. */
  42913. static CreateGround(name: string, options: {
  42914. width?: number;
  42915. height?: number;
  42916. subdivisions?: number;
  42917. subdivisionsX?: number;
  42918. subdivisionsY?: number;
  42919. updatable?: boolean;
  42920. }, scene: any): Mesh;
  42921. /**
  42922. * Creates a tiled ground mesh
  42923. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42924. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42925. * * 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
  42926. * * 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
  42927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42928. * @param name defines the name of the mesh
  42929. * @param options defines the options used to create the mesh
  42930. * @param scene defines the hosting scene
  42931. * @returns the tiled ground mesh
  42932. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42933. */
  42934. static CreateTiledGround(name: string, options: {
  42935. xmin: number;
  42936. zmin: number;
  42937. xmax: number;
  42938. zmax: number;
  42939. subdivisions?: {
  42940. w: number;
  42941. h: number;
  42942. };
  42943. precision?: {
  42944. w: number;
  42945. h: number;
  42946. };
  42947. updatable?: boolean;
  42948. }, scene?: Nullable<Scene>): Mesh;
  42949. /**
  42950. * Creates a ground mesh from a height map
  42951. * * The parameter `url` sets the URL of the height map image resource.
  42952. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42953. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42954. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42955. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42956. * * 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.
  42957. * * 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).
  42958. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42960. * @param name defines the name of the mesh
  42961. * @param url defines the url to the height map
  42962. * @param options defines the options used to create the mesh
  42963. * @param scene defines the hosting scene
  42964. * @returns the ground mesh
  42965. * @see https://doc.babylonjs.com/babylon101/height_map
  42966. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42967. */
  42968. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42969. width?: number;
  42970. height?: number;
  42971. subdivisions?: number;
  42972. minHeight?: number;
  42973. maxHeight?: number;
  42974. colorFilter?: Color3;
  42975. alphaFilter?: number;
  42976. updatable?: boolean;
  42977. onReady?: (mesh: GroundMesh) => void;
  42978. }, scene?: Nullable<Scene>): GroundMesh;
  42979. }
  42980. }
  42981. declare module BABYLON {
  42982. /**
  42983. * Class containing static functions to help procedurally build meshes
  42984. */
  42985. export class TorusBuilder {
  42986. /**
  42987. * Creates a torus mesh
  42988. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42989. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42990. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42992. * * 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
  42993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42994. * @param name defines the name of the mesh
  42995. * @param options defines the options used to create the mesh
  42996. * @param scene defines the hosting scene
  42997. * @returns the torus mesh
  42998. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42999. */
  43000. static CreateTorus(name: string, options: {
  43001. diameter?: number;
  43002. thickness?: number;
  43003. tessellation?: number;
  43004. updatable?: boolean;
  43005. sideOrientation?: number;
  43006. frontUVs?: Vector4;
  43007. backUVs?: Vector4;
  43008. }, scene: any): Mesh;
  43009. }
  43010. }
  43011. declare module BABYLON {
  43012. /**
  43013. * Class containing static functions to help procedurally build meshes
  43014. */
  43015. export class CylinderBuilder {
  43016. /**
  43017. * Creates a cylinder or a cone mesh
  43018. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43019. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43020. * * 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.
  43021. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43022. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43023. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43024. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43025. * * 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).
  43026. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43027. * * 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).
  43028. * * 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
  43029. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43030. * * 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
  43031. * * 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.
  43032. * * If `enclose` is false, a ring surface is one element.
  43033. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43034. * * 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
  43035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43036. * * 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
  43037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43038. * @param name defines the name of the mesh
  43039. * @param options defines the options used to create the mesh
  43040. * @param scene defines the hosting scene
  43041. * @returns the cylinder mesh
  43042. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43043. */
  43044. static CreateCylinder(name: string, options: {
  43045. height?: number;
  43046. diameterTop?: number;
  43047. diameterBottom?: number;
  43048. diameter?: number;
  43049. tessellation?: number;
  43050. subdivisions?: number;
  43051. arc?: number;
  43052. faceColors?: Color4[];
  43053. faceUV?: Vector4[];
  43054. updatable?: boolean;
  43055. hasRings?: boolean;
  43056. enclose?: boolean;
  43057. cap?: number;
  43058. sideOrientation?: number;
  43059. frontUVs?: Vector4;
  43060. backUVs?: Vector4;
  43061. }, scene: any): Mesh;
  43062. }
  43063. }
  43064. declare module BABYLON {
  43065. /**
  43066. * States of the webXR experience
  43067. */
  43068. export enum WebXRState {
  43069. /**
  43070. * Transitioning to being in XR mode
  43071. */
  43072. ENTERING_XR = 0,
  43073. /**
  43074. * Transitioning to non XR mode
  43075. */
  43076. EXITING_XR = 1,
  43077. /**
  43078. * In XR mode and presenting
  43079. */
  43080. IN_XR = 2,
  43081. /**
  43082. * Not entered XR mode
  43083. */
  43084. NOT_IN_XR = 3
  43085. }
  43086. /**
  43087. * Abstraction of the XR render target
  43088. */
  43089. export interface WebXRRenderTarget extends IDisposable {
  43090. /**
  43091. * xrpresent context of the canvas which can be used to display/mirror xr content
  43092. */
  43093. canvasContext: WebGLRenderingContext;
  43094. /**
  43095. * xr layer for the canvas
  43096. */
  43097. xrLayer: Nullable<XRWebGLLayer>;
  43098. /**
  43099. * Initializes the xr layer for the session
  43100. * @param xrSession xr session
  43101. * @returns a promise that will resolve once the XR Layer has been created
  43102. */
  43103. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43104. }
  43105. }
  43106. declare module BABYLON {
  43107. /**
  43108. * COnfiguration object for WebXR output canvas
  43109. */
  43110. export class WebXRManagedOutputCanvasOptions {
  43111. /**
  43112. * An optional canvas in case you wish to create it yourself and provide it here.
  43113. * If not provided, a new canvas will be created
  43114. */
  43115. canvasElement?: HTMLCanvasElement;
  43116. /**
  43117. * Options for this XR Layer output
  43118. */
  43119. canvasOptions?: XRWebGLLayerOptions;
  43120. /**
  43121. * CSS styling for a newly created canvas (if not provided)
  43122. */
  43123. newCanvasCssStyle?: string;
  43124. /**
  43125. * Get the default values of the configuration object
  43126. * @returns default values of this configuration object
  43127. */
  43128. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43129. }
  43130. /**
  43131. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43132. */
  43133. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43134. private _options;
  43135. private _canvas;
  43136. private _engine;
  43137. /**
  43138. * Rendering context of the canvas which can be used to display/mirror xr content
  43139. */
  43140. canvasContext: WebGLRenderingContext;
  43141. /**
  43142. * xr layer for the canvas
  43143. */
  43144. xrLayer: Nullable<XRWebGLLayer>;
  43145. /**
  43146. * Initializes the canvas to be added/removed upon entering/exiting xr
  43147. * @param _xrSessionManager The XR Session manager
  43148. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43149. */
  43150. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43151. /**
  43152. * Disposes of the object
  43153. */
  43154. dispose(): void;
  43155. /**
  43156. * Initializes the xr layer for the session
  43157. * @param xrSession xr session
  43158. * @returns a promise that will resolve once the XR Layer has been created
  43159. */
  43160. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43161. private _addCanvas;
  43162. private _removeCanvas;
  43163. private _setManagedOutputCanvas;
  43164. }
  43165. }
  43166. declare module BABYLON {
  43167. /**
  43168. * Manages an XRSession to work with Babylon's engine
  43169. * @see https://doc.babylonjs.com/how_to/webxr
  43170. */
  43171. export class WebXRSessionManager implements IDisposable {
  43172. /** The scene which the session should be created for */
  43173. scene: Scene;
  43174. private _referenceSpace;
  43175. private _rttProvider;
  43176. private _sessionEnded;
  43177. private _xrNavigator;
  43178. private baseLayer;
  43179. /**
  43180. * The base reference space from which the session started. good if you want to reset your
  43181. * reference space
  43182. */
  43183. baseReferenceSpace: XRReferenceSpace;
  43184. /**
  43185. * Current XR frame
  43186. */
  43187. currentFrame: Nullable<XRFrame>;
  43188. /** WebXR timestamp updated every frame */
  43189. currentTimestamp: number;
  43190. /**
  43191. * Used just in case of a failure to initialize an immersive session.
  43192. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43193. */
  43194. defaultHeightCompensation: number;
  43195. /**
  43196. * Fires every time a new xrFrame arrives which can be used to update the camera
  43197. */
  43198. onXRFrameObservable: Observable<XRFrame>;
  43199. /**
  43200. * Fires when the reference space changed
  43201. */
  43202. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43203. /**
  43204. * Fires when the xr session is ended either by the device or manually done
  43205. */
  43206. onXRSessionEnded: Observable<any>;
  43207. /**
  43208. * Fires when the xr session is ended either by the device or manually done
  43209. */
  43210. onXRSessionInit: Observable<XRSession>;
  43211. /**
  43212. * Underlying xr session
  43213. */
  43214. session: XRSession;
  43215. /**
  43216. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43217. * or get the offset the player is currently at.
  43218. */
  43219. viewerReferenceSpace: XRReferenceSpace;
  43220. /**
  43221. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43222. * @param scene The scene which the session should be created for
  43223. */
  43224. constructor(
  43225. /** The scene which the session should be created for */
  43226. scene: Scene);
  43227. /**
  43228. * The current reference space used in this session. This reference space can constantly change!
  43229. * It is mainly used to offset the camera's position.
  43230. */
  43231. get referenceSpace(): XRReferenceSpace;
  43232. /**
  43233. * Set a new reference space and triggers the observable
  43234. */
  43235. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43236. /**
  43237. * Disposes of the session manager
  43238. */
  43239. dispose(): void;
  43240. /**
  43241. * Stops the xrSession and restores the render loop
  43242. * @returns Promise which resolves after it exits XR
  43243. */
  43244. exitXRAsync(): Promise<void>;
  43245. /**
  43246. * Gets the correct render target texture to be rendered this frame for this eye
  43247. * @param eye the eye for which to get the render target
  43248. * @returns the render target for the specified eye
  43249. */
  43250. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43251. /**
  43252. * Creates a WebXRRenderTarget object for the XR session
  43253. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43254. * @param options optional options to provide when creating a new render target
  43255. * @returns a WebXR render target to which the session can render
  43256. */
  43257. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43258. /**
  43259. * Initializes the manager
  43260. * After initialization enterXR can be called to start an XR session
  43261. * @returns Promise which resolves after it is initialized
  43262. */
  43263. initializeAsync(): Promise<void>;
  43264. /**
  43265. * Initializes an xr session
  43266. * @param xrSessionMode mode to initialize
  43267. * @param xrSessionInit defines optional and required values to pass to the session builder
  43268. * @returns a promise which will resolve once the session has been initialized
  43269. */
  43270. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43271. /**
  43272. * Checks if a session would be supported for the creation options specified
  43273. * @param sessionMode session mode to check if supported eg. immersive-vr
  43274. * @returns A Promise that resolves to true if supported and false if not
  43275. */
  43276. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43277. /**
  43278. * Resets the reference space to the one started the session
  43279. */
  43280. resetReferenceSpace(): void;
  43281. /**
  43282. * Starts rendering to the xr layer
  43283. */
  43284. runXRRenderLoop(): void;
  43285. /**
  43286. * Sets the reference space on the xr session
  43287. * @param referenceSpaceType space to set
  43288. * @returns a promise that will resolve once the reference space has been set
  43289. */
  43290. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43291. /**
  43292. * Updates the render state of the session
  43293. * @param state state to set
  43294. * @returns a promise that resolves once the render state has been updated
  43295. */
  43296. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43297. /**
  43298. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43299. * @param sessionMode defines the session to test
  43300. * @returns a promise with boolean as final value
  43301. */
  43302. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43303. private _createRenderTargetTexture;
  43304. }
  43305. }
  43306. declare module BABYLON {
  43307. /**
  43308. * WebXR Camera which holds the views for the xrSession
  43309. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43310. */
  43311. export class WebXRCamera extends FreeCamera {
  43312. private _xrSessionManager;
  43313. private _firstFrame;
  43314. private _referenceQuaternion;
  43315. private _referencedPosition;
  43316. private _xrInvPositionCache;
  43317. private _xrInvQuaternionCache;
  43318. /**
  43319. * Should position compensation execute on first frame.
  43320. * This is used when copying the position from a native (non XR) camera
  43321. */
  43322. compensateOnFirstFrame: boolean;
  43323. /**
  43324. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43325. * @param name the name of the camera
  43326. * @param scene the scene to add the camera to
  43327. * @param _xrSessionManager a constructed xr session manager
  43328. */
  43329. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43330. /**
  43331. * Return the user's height, unrelated to the current ground.
  43332. * This will be the y position of this camera, when ground level is 0.
  43333. */
  43334. get realWorldHeight(): number;
  43335. /** @hidden */
  43336. _updateForDualEyeDebugging(): void;
  43337. /**
  43338. * Sets this camera's transformation based on a non-vr camera
  43339. * @param otherCamera the non-vr camera to copy the transformation from
  43340. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43341. */
  43342. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43343. /**
  43344. * Gets the current instance class name ("WebXRCamera").
  43345. * @returns the class name
  43346. */
  43347. getClassName(): string;
  43348. private _updateFromXRSession;
  43349. private _updateNumberOfRigCameras;
  43350. private _updateReferenceSpace;
  43351. private _updateReferenceSpaceOffset;
  43352. }
  43353. }
  43354. declare module BABYLON {
  43355. /**
  43356. * Defining the interface required for a (webxr) feature
  43357. */
  43358. export interface IWebXRFeature extends IDisposable {
  43359. /**
  43360. * Is this feature attached
  43361. */
  43362. attached: boolean;
  43363. /**
  43364. * Should auto-attach be disabled?
  43365. */
  43366. disableAutoAttach: boolean;
  43367. /**
  43368. * Attach the feature to the session
  43369. * Will usually be called by the features manager
  43370. *
  43371. * @param force should attachment be forced (even when already attached)
  43372. * @returns true if successful.
  43373. */
  43374. attach(force?: boolean): boolean;
  43375. /**
  43376. * Detach the feature from the session
  43377. * Will usually be called by the features manager
  43378. *
  43379. * @returns true if successful.
  43380. */
  43381. detach(): boolean;
  43382. }
  43383. /**
  43384. * A list of the currently available features without referencing them
  43385. */
  43386. export class WebXRFeatureName {
  43387. /**
  43388. * The name of the anchor system feature
  43389. */
  43390. static ANCHOR_SYSTEM: string;
  43391. /**
  43392. * The name of the background remover feature
  43393. */
  43394. static BACKGROUND_REMOVER: string;
  43395. /**
  43396. * The name of the hit test feature
  43397. */
  43398. static HIT_TEST: string;
  43399. /**
  43400. * physics impostors for xr controllers feature
  43401. */
  43402. static PHYSICS_CONTROLLERS: string;
  43403. /**
  43404. * The name of the plane detection feature
  43405. */
  43406. static PLANE_DETECTION: string;
  43407. /**
  43408. * The name of the pointer selection feature
  43409. */
  43410. static POINTER_SELECTION: string;
  43411. /**
  43412. * The name of the teleportation feature
  43413. */
  43414. static TELEPORTATION: string;
  43415. }
  43416. /**
  43417. * Defining the constructor of a feature. Used to register the modules.
  43418. */
  43419. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43420. /**
  43421. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43422. * It is mainly used in AR sessions.
  43423. *
  43424. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43425. */
  43426. export class WebXRFeaturesManager implements IDisposable {
  43427. private _xrSessionManager;
  43428. private static readonly _AvailableFeatures;
  43429. private _features;
  43430. /**
  43431. * constructs a new features manages.
  43432. *
  43433. * @param _xrSessionManager an instance of WebXRSessionManager
  43434. */
  43435. constructor(_xrSessionManager: WebXRSessionManager);
  43436. /**
  43437. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43438. * Mainly used internally.
  43439. *
  43440. * @param featureName the name of the feature to register
  43441. * @param constructorFunction the function used to construct the module
  43442. * @param version the (babylon) version of the module
  43443. * @param stable is that a stable version of this module
  43444. */
  43445. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43446. /**
  43447. * Returns a constructor of a specific feature.
  43448. *
  43449. * @param featureName the name of the feature to construct
  43450. * @param version the version of the feature to load
  43451. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43452. * @param options optional options provided to the module.
  43453. * @returns a function that, when called, will return a new instance of this feature
  43454. */
  43455. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43456. /**
  43457. * Can be used to return the list of features currently registered
  43458. *
  43459. * @returns an Array of available features
  43460. */
  43461. static GetAvailableFeatures(): string[];
  43462. /**
  43463. * Gets the versions available for a specific feature
  43464. * @param featureName the name of the feature
  43465. * @returns an array with the available versions
  43466. */
  43467. static GetAvailableVersions(featureName: string): string[];
  43468. /**
  43469. * Return the latest unstable version of this feature
  43470. * @param featureName the name of the feature to search
  43471. * @returns the version number. if not found will return -1
  43472. */
  43473. static GetLatestVersionOfFeature(featureName: string): number;
  43474. /**
  43475. * Return the latest stable version of this feature
  43476. * @param featureName the name of the feature to search
  43477. * @returns the version number. if not found will return -1
  43478. */
  43479. static GetStableVersionOfFeature(featureName: string): number;
  43480. /**
  43481. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43482. * Can be used during a session to start a feature
  43483. * @param featureName the name of feature to attach
  43484. */
  43485. attachFeature(featureName: string): void;
  43486. /**
  43487. * Can be used inside a session or when the session ends to detach a specific feature
  43488. * @param featureName the name of the feature to detach
  43489. */
  43490. detachFeature(featureName: string): void;
  43491. /**
  43492. * Used to disable an already-enabled feature
  43493. * The feature will be disposed and will be recreated once enabled.
  43494. * @param featureName the feature to disable
  43495. * @returns true if disable was successful
  43496. */
  43497. disableFeature(featureName: string | {
  43498. Name: string;
  43499. }): boolean;
  43500. /**
  43501. * dispose this features manager
  43502. */
  43503. dispose(): void;
  43504. /**
  43505. * 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.
  43506. * 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.
  43507. *
  43508. * @param featureName the name of the feature to load or the class of the feature
  43509. * @param version optional version to load. if not provided the latest version will be enabled
  43510. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43511. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43512. * @returns a new constructed feature or throws an error if feature not found.
  43513. */
  43514. enableFeature(featureName: string | {
  43515. Name: string;
  43516. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43517. /**
  43518. * get the implementation of an enabled feature.
  43519. * @param featureName the name of the feature to load
  43520. * @returns the feature class, if found
  43521. */
  43522. getEnabledFeature(featureName: string): IWebXRFeature;
  43523. /**
  43524. * Get the list of enabled features
  43525. * @returns an array of enabled features
  43526. */
  43527. getEnabledFeatures(): string[];
  43528. }
  43529. }
  43530. declare module BABYLON {
  43531. /**
  43532. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43533. * @see https://doc.babylonjs.com/how_to/webxr
  43534. */
  43535. export class WebXRExperienceHelper implements IDisposable {
  43536. private scene;
  43537. private _nonVRCamera;
  43538. private _originalSceneAutoClear;
  43539. private _supported;
  43540. /**
  43541. * Camera used to render xr content
  43542. */
  43543. camera: WebXRCamera;
  43544. /** A features manager for this xr session */
  43545. featuresManager: WebXRFeaturesManager;
  43546. /**
  43547. * Observers registered here will be triggered after the camera's initial transformation is set
  43548. * This can be used to set a different ground level or an extra rotation.
  43549. *
  43550. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43551. * to the position set after this observable is done executing.
  43552. */
  43553. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43554. /**
  43555. * Fires when the state of the experience helper has changed
  43556. */
  43557. onStateChangedObservable: Observable<WebXRState>;
  43558. /** Session manager used to keep track of xr session */
  43559. sessionManager: WebXRSessionManager;
  43560. /**
  43561. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43562. */
  43563. state: WebXRState;
  43564. /**
  43565. * Creates a WebXRExperienceHelper
  43566. * @param scene The scene the helper should be created in
  43567. */
  43568. private constructor();
  43569. /**
  43570. * Creates the experience helper
  43571. * @param scene the scene to attach the experience helper to
  43572. * @returns a promise for the experience helper
  43573. */
  43574. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43575. /**
  43576. * Disposes of the experience helper
  43577. */
  43578. dispose(): void;
  43579. /**
  43580. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43581. * @param sessionMode options for the XR session
  43582. * @param referenceSpaceType frame of reference of the XR session
  43583. * @param renderTarget the output canvas that will be used to enter XR mode
  43584. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  43585. * @returns promise that resolves after xr mode has entered
  43586. */
  43587. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  43588. /**
  43589. * Exits XR mode and returns the scene to its original state
  43590. * @returns promise that resolves after xr mode has exited
  43591. */
  43592. exitXRAsync(): Promise<void>;
  43593. private _nonXRToXRCamera;
  43594. private _setState;
  43595. }
  43596. }
  43597. declare module BABYLON {
  43598. /**
  43599. * X-Y values for axes in WebXR
  43600. */
  43601. export interface IWebXRMotionControllerAxesValue {
  43602. /**
  43603. * The value of the x axis
  43604. */
  43605. x: number;
  43606. /**
  43607. * The value of the y-axis
  43608. */
  43609. y: number;
  43610. }
  43611. /**
  43612. * changed / previous values for the values of this component
  43613. */
  43614. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43615. /**
  43616. * current (this frame) value
  43617. */
  43618. current: T;
  43619. /**
  43620. * previous (last change) value
  43621. */
  43622. previous: T;
  43623. }
  43624. /**
  43625. * Represents changes in the component between current frame and last values recorded
  43626. */
  43627. export interface IWebXRMotionControllerComponentChanges {
  43628. /**
  43629. * will be populated with previous and current values if axes changed
  43630. */
  43631. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43632. /**
  43633. * will be populated with previous and current values if pressed changed
  43634. */
  43635. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43636. /**
  43637. * will be populated with previous and current values if touched changed
  43638. */
  43639. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43640. /**
  43641. * will be populated with previous and current values if value changed
  43642. */
  43643. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43644. }
  43645. /**
  43646. * This class represents a single component (for example button or thumbstick) of a motion controller
  43647. */
  43648. export class WebXRControllerComponent implements IDisposable {
  43649. /**
  43650. * the id of this component
  43651. */
  43652. id: string;
  43653. /**
  43654. * the type of the component
  43655. */
  43656. type: MotionControllerComponentType;
  43657. private _buttonIndex;
  43658. private _axesIndices;
  43659. private _axes;
  43660. private _changes;
  43661. private _currentValue;
  43662. private _hasChanges;
  43663. private _pressed;
  43664. private _touched;
  43665. /**
  43666. * button component type
  43667. */
  43668. static BUTTON_TYPE: MotionControllerComponentType;
  43669. /**
  43670. * squeeze component type
  43671. */
  43672. static SQUEEZE_TYPE: MotionControllerComponentType;
  43673. /**
  43674. * Thumbstick component type
  43675. */
  43676. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43677. /**
  43678. * Touchpad component type
  43679. */
  43680. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43681. /**
  43682. * trigger component type
  43683. */
  43684. static TRIGGER_TYPE: MotionControllerComponentType;
  43685. /**
  43686. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43687. * the axes data changes
  43688. */
  43689. onAxisValueChangedObservable: Observable<{
  43690. x: number;
  43691. y: number;
  43692. }>;
  43693. /**
  43694. * Observers registered here will be triggered when the state of a button changes
  43695. * State change is either pressed / touched / value
  43696. */
  43697. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43698. /**
  43699. * Creates a new component for a motion controller.
  43700. * It is created by the motion controller itself
  43701. *
  43702. * @param id the id of this component
  43703. * @param type the type of the component
  43704. * @param _buttonIndex index in the buttons array of the gamepad
  43705. * @param _axesIndices indices of the values in the axes array of the gamepad
  43706. */
  43707. constructor(
  43708. /**
  43709. * the id of this component
  43710. */
  43711. id: string,
  43712. /**
  43713. * the type of the component
  43714. */
  43715. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43716. /**
  43717. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43718. */
  43719. get axes(): IWebXRMotionControllerAxesValue;
  43720. /**
  43721. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43722. */
  43723. get changes(): IWebXRMotionControllerComponentChanges;
  43724. /**
  43725. * Return whether or not the component changed the last frame
  43726. */
  43727. get hasChanges(): boolean;
  43728. /**
  43729. * is the button currently pressed
  43730. */
  43731. get pressed(): boolean;
  43732. /**
  43733. * is the button currently touched
  43734. */
  43735. get touched(): boolean;
  43736. /**
  43737. * Get the current value of this component
  43738. */
  43739. get value(): number;
  43740. /**
  43741. * Dispose this component
  43742. */
  43743. dispose(): void;
  43744. /**
  43745. * Are there axes correlating to this component
  43746. * @return true is axes data is available
  43747. */
  43748. isAxes(): boolean;
  43749. /**
  43750. * Is this component a button (hence - pressable)
  43751. * @returns true if can be pressed
  43752. */
  43753. isButton(): boolean;
  43754. /**
  43755. * update this component using the gamepad object it is in. Called on every frame
  43756. * @param nativeController the native gamepad controller object
  43757. */
  43758. update(nativeController: IMinimalMotionControllerObject): void;
  43759. }
  43760. }
  43761. declare module BABYLON {
  43762. /**
  43763. * Class used to represent data loading progression
  43764. */
  43765. export class SceneLoaderProgressEvent {
  43766. /** defines if data length to load can be evaluated */
  43767. readonly lengthComputable: boolean;
  43768. /** defines the loaded data length */
  43769. readonly loaded: number;
  43770. /** defines the data length to load */
  43771. readonly total: number;
  43772. /**
  43773. * Create a new progress event
  43774. * @param lengthComputable defines if data length to load can be evaluated
  43775. * @param loaded defines the loaded data length
  43776. * @param total defines the data length to load
  43777. */
  43778. constructor(
  43779. /** defines if data length to load can be evaluated */
  43780. lengthComputable: boolean,
  43781. /** defines the loaded data length */
  43782. loaded: number,
  43783. /** defines the data length to load */
  43784. total: number);
  43785. /**
  43786. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43787. * @param event defines the source event
  43788. * @returns a new SceneLoaderProgressEvent
  43789. */
  43790. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43791. }
  43792. /**
  43793. * Interface used by SceneLoader plugins to define supported file extensions
  43794. */
  43795. export interface ISceneLoaderPluginExtensions {
  43796. /**
  43797. * Defines the list of supported extensions
  43798. */
  43799. [extension: string]: {
  43800. isBinary: boolean;
  43801. };
  43802. }
  43803. /**
  43804. * Interface used by SceneLoader plugin factory
  43805. */
  43806. export interface ISceneLoaderPluginFactory {
  43807. /**
  43808. * Defines the name of the factory
  43809. */
  43810. name: string;
  43811. /**
  43812. * Function called to create a new plugin
  43813. * @return the new plugin
  43814. */
  43815. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43816. /**
  43817. * The callback that returns true if the data can be directly loaded.
  43818. * @param data string containing the file data
  43819. * @returns if the data can be loaded directly
  43820. */
  43821. canDirectLoad?(data: string): boolean;
  43822. }
  43823. /**
  43824. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43825. */
  43826. export interface ISceneLoaderPluginBase {
  43827. /**
  43828. * The friendly name of this plugin.
  43829. */
  43830. name: string;
  43831. /**
  43832. * The file extensions supported by this plugin.
  43833. */
  43834. extensions: string | ISceneLoaderPluginExtensions;
  43835. /**
  43836. * The callback called when loading from a url.
  43837. * @param scene scene loading this url
  43838. * @param url url to load
  43839. * @param onSuccess callback called when the file successfully loads
  43840. * @param onProgress callback called while file is loading (if the server supports this mode)
  43841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43842. * @param onError callback called when the file fails to load
  43843. * @returns a file request object
  43844. */
  43845. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43846. /**
  43847. * The callback called when loading from a file object.
  43848. * @param scene scene loading this file
  43849. * @param file defines the file to load
  43850. * @param onSuccess defines the callback to call when data is loaded
  43851. * @param onProgress defines the callback to call during loading process
  43852. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43853. * @param onError defines the callback to call when an error occurs
  43854. * @returns a file request object
  43855. */
  43856. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43857. /**
  43858. * The callback that returns true if the data can be directly loaded.
  43859. * @param data string containing the file data
  43860. * @returns if the data can be loaded directly
  43861. */
  43862. canDirectLoad?(data: string): boolean;
  43863. /**
  43864. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43865. * @param scene scene loading this data
  43866. * @param data string containing the data
  43867. * @returns data to pass to the plugin
  43868. */
  43869. directLoad?(scene: Scene, data: string): any;
  43870. /**
  43871. * The callback that allows custom handling of the root url based on the response url.
  43872. * @param rootUrl the original root url
  43873. * @param responseURL the response url if available
  43874. * @returns the new root url
  43875. */
  43876. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43877. }
  43878. /**
  43879. * Interface used to define a SceneLoader plugin
  43880. */
  43881. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43882. /**
  43883. * Import meshes into a scene.
  43884. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43885. * @param scene The scene to import into
  43886. * @param data The data to import
  43887. * @param rootUrl The root url for scene and resources
  43888. * @param meshes The meshes array to import into
  43889. * @param particleSystems The particle systems array to import into
  43890. * @param skeletons The skeletons array to import into
  43891. * @param onError The callback when import fails
  43892. * @returns True if successful or false otherwise
  43893. */
  43894. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43895. /**
  43896. * Load into a scene.
  43897. * @param scene The scene to load into
  43898. * @param data The data to import
  43899. * @param rootUrl The root url for scene and resources
  43900. * @param onError The callback when import fails
  43901. * @returns True if successful or false otherwise
  43902. */
  43903. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43904. /**
  43905. * Load into an asset container.
  43906. * @param scene The scene to load into
  43907. * @param data The data to import
  43908. * @param rootUrl The root url for scene and resources
  43909. * @param onError The callback when import fails
  43910. * @returns The loaded asset container
  43911. */
  43912. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43913. }
  43914. /**
  43915. * Interface used to define an async SceneLoader plugin
  43916. */
  43917. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43918. /**
  43919. * Import meshes into a scene.
  43920. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43921. * @param scene The scene to import into
  43922. * @param data The data to import
  43923. * @param rootUrl The root url for scene and resources
  43924. * @param onProgress The callback when the load progresses
  43925. * @param fileName Defines the name of the file to load
  43926. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43927. */
  43928. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43929. meshes: AbstractMesh[];
  43930. particleSystems: IParticleSystem[];
  43931. skeletons: Skeleton[];
  43932. animationGroups: AnimationGroup[];
  43933. }>;
  43934. /**
  43935. * Load into a scene.
  43936. * @param scene The scene to load into
  43937. * @param data The data to import
  43938. * @param rootUrl The root url for scene and resources
  43939. * @param onProgress The callback when the load progresses
  43940. * @param fileName Defines the name of the file to load
  43941. * @returns Nothing
  43942. */
  43943. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43944. /**
  43945. * Load into an asset container.
  43946. * @param scene The scene to load into
  43947. * @param data The data to import
  43948. * @param rootUrl The root url for scene and resources
  43949. * @param onProgress The callback when the load progresses
  43950. * @param fileName Defines the name of the file to load
  43951. * @returns The loaded asset container
  43952. */
  43953. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43954. }
  43955. /**
  43956. * Mode that determines how to handle old animation groups before loading new ones.
  43957. */
  43958. export enum SceneLoaderAnimationGroupLoadingMode {
  43959. /**
  43960. * Reset all old animations to initial state then dispose them.
  43961. */
  43962. Clean = 0,
  43963. /**
  43964. * Stop all old animations.
  43965. */
  43966. Stop = 1,
  43967. /**
  43968. * Restart old animations from first frame.
  43969. */
  43970. Sync = 2,
  43971. /**
  43972. * Old animations remains untouched.
  43973. */
  43974. NoSync = 3
  43975. }
  43976. /**
  43977. * Class used to load scene from various file formats using registered plugins
  43978. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43979. */
  43980. export class SceneLoader {
  43981. /**
  43982. * No logging while loading
  43983. */
  43984. static readonly NO_LOGGING: number;
  43985. /**
  43986. * Minimal logging while loading
  43987. */
  43988. static readonly MINIMAL_LOGGING: number;
  43989. /**
  43990. * Summary logging while loading
  43991. */
  43992. static readonly SUMMARY_LOGGING: number;
  43993. /**
  43994. * Detailled logging while loading
  43995. */
  43996. static readonly DETAILED_LOGGING: number;
  43997. /**
  43998. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43999. */
  44000. static get ForceFullSceneLoadingForIncremental(): boolean;
  44001. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44002. /**
  44003. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44004. */
  44005. static get ShowLoadingScreen(): boolean;
  44006. static set ShowLoadingScreen(value: boolean);
  44007. /**
  44008. * Defines the current logging level (while loading the scene)
  44009. * @ignorenaming
  44010. */
  44011. static get loggingLevel(): number;
  44012. static set loggingLevel(value: number);
  44013. /**
  44014. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44015. */
  44016. static get CleanBoneMatrixWeights(): boolean;
  44017. static set CleanBoneMatrixWeights(value: boolean);
  44018. /**
  44019. * Event raised when a plugin is used to load a scene
  44020. */
  44021. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44022. private static _registeredPlugins;
  44023. private static _getDefaultPlugin;
  44024. private static _getPluginForExtension;
  44025. private static _getPluginForDirectLoad;
  44026. private static _getPluginForFilename;
  44027. private static _getDirectLoad;
  44028. private static _loadData;
  44029. private static _getFileInfo;
  44030. /**
  44031. * Gets a plugin that can load the given extension
  44032. * @param extension defines the extension to load
  44033. * @returns a plugin or null if none works
  44034. */
  44035. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44036. /**
  44037. * Gets a boolean indicating that the given extension can be loaded
  44038. * @param extension defines the extension to load
  44039. * @returns true if the extension is supported
  44040. */
  44041. static IsPluginForExtensionAvailable(extension: string): boolean;
  44042. /**
  44043. * Adds a new plugin to the list of registered plugins
  44044. * @param plugin defines the plugin to add
  44045. */
  44046. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44047. /**
  44048. * Import meshes into a scene
  44049. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44050. * @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)
  44051. * @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)
  44052. * @param scene the instance of BABYLON.Scene to append to
  44053. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44054. * @param onProgress a callback with a progress event for each file being loaded
  44055. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44056. * @param pluginExtension the extension used to determine the plugin
  44057. * @returns The loaded plugin
  44058. */
  44059. 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>;
  44060. /**
  44061. * Import meshes into a scene
  44062. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44063. * @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)
  44064. * @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)
  44065. * @param scene the instance of BABYLON.Scene to append to
  44066. * @param onProgress a callback with a progress event for each file being loaded
  44067. * @param pluginExtension the extension used to determine the plugin
  44068. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44069. */
  44070. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44071. meshes: AbstractMesh[];
  44072. particleSystems: IParticleSystem[];
  44073. skeletons: Skeleton[];
  44074. animationGroups: AnimationGroup[];
  44075. }>;
  44076. /**
  44077. * Load a scene
  44078. * @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)
  44079. * @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)
  44080. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44081. * @param onSuccess a callback with the scene when import succeeds
  44082. * @param onProgress a callback with a progress event for each file being loaded
  44083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44084. * @param pluginExtension the extension used to determine the plugin
  44085. * @returns The loaded plugin
  44086. */
  44087. 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>;
  44088. /**
  44089. * Load a scene
  44090. * @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)
  44091. * @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)
  44092. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44093. * @param onProgress a callback with a progress event for each file being loaded
  44094. * @param pluginExtension the extension used to determine the plugin
  44095. * @returns The loaded scene
  44096. */
  44097. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44098. /**
  44099. * Append a scene
  44100. * @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)
  44101. * @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)
  44102. * @param scene is the instance of BABYLON.Scene to append to
  44103. * @param onSuccess a callback with the scene when import succeeds
  44104. * @param onProgress a callback with a progress event for each file being loaded
  44105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44106. * @param pluginExtension the extension used to determine the plugin
  44107. * @returns The loaded plugin
  44108. */
  44109. 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>;
  44110. /**
  44111. * Append a scene
  44112. * @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)
  44113. * @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)
  44114. * @param scene is the instance of BABYLON.Scene to append to
  44115. * @param onProgress a callback with a progress event for each file being loaded
  44116. * @param pluginExtension the extension used to determine the plugin
  44117. * @returns The given scene
  44118. */
  44119. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44120. /**
  44121. * Load a scene into an asset container
  44122. * @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)
  44123. * @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)
  44124. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44125. * @param onSuccess a callback with the scene when import succeeds
  44126. * @param onProgress a callback with a progress event for each file being loaded
  44127. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44128. * @param pluginExtension the extension used to determine the plugin
  44129. * @returns The loaded plugin
  44130. */
  44131. 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>;
  44132. /**
  44133. * Load a scene into an asset container
  44134. * @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)
  44135. * @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)
  44136. * @param scene is the instance of Scene to append to
  44137. * @param onProgress a callback with a progress event for each file being loaded
  44138. * @param pluginExtension the extension used to determine the plugin
  44139. * @returns The loaded asset container
  44140. */
  44141. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44142. /**
  44143. * Import animations from a file into a scene
  44144. * @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)
  44145. * @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)
  44146. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44147. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44148. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44149. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44150. * @param onSuccess a callback with the scene when import succeeds
  44151. * @param onProgress a callback with a progress event for each file being loaded
  44152. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44153. */
  44154. 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;
  44155. /**
  44156. * Import animations from a file into a scene
  44157. * @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)
  44158. * @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)
  44159. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44160. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44161. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44162. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44163. * @param onSuccess a callback with the scene when import succeeds
  44164. * @param onProgress a callback with a progress event for each file being loaded
  44165. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44166. * @returns the updated scene with imported animations
  44167. */
  44168. 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>;
  44169. }
  44170. }
  44171. declare module BABYLON {
  44172. /**
  44173. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44174. */
  44175. export type MotionControllerHandedness = "none" | "left" | "right";
  44176. /**
  44177. * The type of components available in motion controllers.
  44178. * This is not the name of the component.
  44179. */
  44180. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44181. /**
  44182. * The state of a controller component
  44183. */
  44184. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44185. /**
  44186. * The schema of motion controller layout.
  44187. * No object will be initialized using this interface
  44188. * This is used just to define the profile.
  44189. */
  44190. export interface IMotionControllerLayout {
  44191. /**
  44192. * Path to load the assets. Usually relative to the base path
  44193. */
  44194. assetPath: string;
  44195. /**
  44196. * Available components (unsorted)
  44197. */
  44198. components: {
  44199. /**
  44200. * A map of component Ids
  44201. */
  44202. [componentId: string]: {
  44203. /**
  44204. * The type of input the component outputs
  44205. */
  44206. type: MotionControllerComponentType;
  44207. /**
  44208. * The indices of this component in the gamepad object
  44209. */
  44210. gamepadIndices: {
  44211. /**
  44212. * Index of button
  44213. */
  44214. button?: number;
  44215. /**
  44216. * If available, index of x-axis
  44217. */
  44218. xAxis?: number;
  44219. /**
  44220. * If available, index of y-axis
  44221. */
  44222. yAxis?: number;
  44223. };
  44224. /**
  44225. * The mesh's root node name
  44226. */
  44227. rootNodeName: string;
  44228. /**
  44229. * Animation definitions for this model
  44230. */
  44231. visualResponses: {
  44232. [stateKey: string]: {
  44233. /**
  44234. * What property will be animated
  44235. */
  44236. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44237. /**
  44238. * What states influence this visual response
  44239. */
  44240. states: MotionControllerComponentStateType[];
  44241. /**
  44242. * Type of animation - movement or visibility
  44243. */
  44244. valueNodeProperty: "transform" | "visibility";
  44245. /**
  44246. * Base node name to move. Its position will be calculated according to the min and max nodes
  44247. */
  44248. valueNodeName?: string;
  44249. /**
  44250. * Minimum movement node
  44251. */
  44252. minNodeName?: string;
  44253. /**
  44254. * Max movement node
  44255. */
  44256. maxNodeName?: string;
  44257. };
  44258. };
  44259. /**
  44260. * If touch enabled, what is the name of node to display user feedback
  44261. */
  44262. touchPointNodeName?: string;
  44263. };
  44264. };
  44265. /**
  44266. * Is it xr standard mapping or not
  44267. */
  44268. gamepadMapping: "" | "xr-standard";
  44269. /**
  44270. * Base root node of this entire model
  44271. */
  44272. rootNodeName: string;
  44273. /**
  44274. * Defines the main button component id
  44275. */
  44276. selectComponentId: string;
  44277. }
  44278. /**
  44279. * A definition for the layout map in the input profile
  44280. */
  44281. export interface IMotionControllerLayoutMap {
  44282. /**
  44283. * Layouts with handedness type as a key
  44284. */
  44285. [handedness: string]: IMotionControllerLayout;
  44286. }
  44287. /**
  44288. * The XR Input profile schema
  44289. * Profiles can be found here:
  44290. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44291. */
  44292. export interface IMotionControllerProfile {
  44293. /**
  44294. * fallback profiles for this profileId
  44295. */
  44296. fallbackProfileIds: string[];
  44297. /**
  44298. * The layout map, with handedness as key
  44299. */
  44300. layouts: IMotionControllerLayoutMap;
  44301. /**
  44302. * The id of this profile
  44303. * correlates to the profile(s) in the xrInput.profiles array
  44304. */
  44305. profileId: string;
  44306. }
  44307. /**
  44308. * A helper-interface for the 3 meshes needed for controller button animation
  44309. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44310. */
  44311. export interface IMotionControllerButtonMeshMap {
  44312. /**
  44313. * the mesh that defines the pressed value mesh position.
  44314. * This is used to find the max-position of this button
  44315. */
  44316. pressedMesh: AbstractMesh;
  44317. /**
  44318. * the mesh that defines the unpressed value mesh position.
  44319. * This is used to find the min (or initial) position of this button
  44320. */
  44321. unpressedMesh: AbstractMesh;
  44322. /**
  44323. * The mesh that will be changed when value changes
  44324. */
  44325. valueMesh: AbstractMesh;
  44326. }
  44327. /**
  44328. * A helper-interface for the 3 meshes needed for controller axis animation.
  44329. * This will be expanded when touchpad animations are fully supported
  44330. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44331. */
  44332. export interface IMotionControllerMeshMap {
  44333. /**
  44334. * the mesh that defines the maximum value mesh position.
  44335. */
  44336. maxMesh?: AbstractMesh;
  44337. /**
  44338. * the mesh that defines the minimum value mesh position.
  44339. */
  44340. minMesh?: AbstractMesh;
  44341. /**
  44342. * The mesh that will be changed when axis value changes
  44343. */
  44344. valueMesh: AbstractMesh;
  44345. }
  44346. /**
  44347. * The elements needed for change-detection of the gamepad objects in motion controllers
  44348. */
  44349. export interface IMinimalMotionControllerObject {
  44350. /**
  44351. * Available axes of this controller
  44352. */
  44353. axes: number[];
  44354. /**
  44355. * An array of available buttons
  44356. */
  44357. buttons: Array<{
  44358. /**
  44359. * Value of the button/trigger
  44360. */
  44361. value: number;
  44362. /**
  44363. * If the button/trigger is currently touched
  44364. */
  44365. touched: boolean;
  44366. /**
  44367. * If the button/trigger is currently pressed
  44368. */
  44369. pressed: boolean;
  44370. }>;
  44371. /**
  44372. * EXPERIMENTAL haptic support.
  44373. */
  44374. hapticActuators?: Array<{
  44375. pulse: (value: number, duration: number) => Promise<boolean>;
  44376. }>;
  44377. }
  44378. /**
  44379. * An Abstract Motion controller
  44380. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44381. * Each component has an observable to check for changes in value and state
  44382. */
  44383. export abstract class WebXRAbstractMotionController implements IDisposable {
  44384. protected scene: Scene;
  44385. protected layout: IMotionControllerLayout;
  44386. /**
  44387. * The gamepad object correlating to this controller
  44388. */
  44389. gamepadObject: IMinimalMotionControllerObject;
  44390. /**
  44391. * handedness (left/right/none) of this controller
  44392. */
  44393. handedness: MotionControllerHandedness;
  44394. private _initComponent;
  44395. private _modelReady;
  44396. /**
  44397. * A map of components (WebXRControllerComponent) in this motion controller
  44398. * Components have a ComponentType and can also have both button and axis definitions
  44399. */
  44400. readonly components: {
  44401. [id: string]: WebXRControllerComponent;
  44402. };
  44403. /**
  44404. * Disable the model's animation. Can be set at any time.
  44405. */
  44406. disableAnimation: boolean;
  44407. /**
  44408. * Observers registered here will be triggered when the model of this controller is done loading
  44409. */
  44410. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44411. /**
  44412. * The profile id of this motion controller
  44413. */
  44414. abstract profileId: string;
  44415. /**
  44416. * The root mesh of the model. It is null if the model was not yet initialized
  44417. */
  44418. rootMesh: Nullable<AbstractMesh>;
  44419. /**
  44420. * constructs a new abstract motion controller
  44421. * @param scene the scene to which the model of the controller will be added
  44422. * @param layout The profile layout to load
  44423. * @param gamepadObject The gamepad object correlating to this controller
  44424. * @param handedness handedness (left/right/none) of this controller
  44425. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44426. */
  44427. constructor(scene: Scene, layout: IMotionControllerLayout,
  44428. /**
  44429. * The gamepad object correlating to this controller
  44430. */
  44431. gamepadObject: IMinimalMotionControllerObject,
  44432. /**
  44433. * handedness (left/right/none) of this controller
  44434. */
  44435. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44436. /**
  44437. * Dispose this controller, the model mesh and all its components
  44438. */
  44439. dispose(): void;
  44440. /**
  44441. * Returns all components of specific type
  44442. * @param type the type to search for
  44443. * @return an array of components with this type
  44444. */
  44445. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44446. /**
  44447. * get a component based an its component id as defined in layout.components
  44448. * @param id the id of the component
  44449. * @returns the component correlates to the id or undefined if not found
  44450. */
  44451. getComponent(id: string): WebXRControllerComponent;
  44452. /**
  44453. * Get the list of components available in this motion controller
  44454. * @returns an array of strings correlating to available components
  44455. */
  44456. getComponentIds(): string[];
  44457. /**
  44458. * Get the first component of specific type
  44459. * @param type type of component to find
  44460. * @return a controller component or null if not found
  44461. */
  44462. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44463. /**
  44464. * Get the main (Select) component of this controller as defined in the layout
  44465. * @returns the main component of this controller
  44466. */
  44467. getMainComponent(): WebXRControllerComponent;
  44468. /**
  44469. * Loads the model correlating to this controller
  44470. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44471. * @returns A promise fulfilled with the result of the model loading
  44472. */
  44473. loadModel(): Promise<boolean>;
  44474. /**
  44475. * Update this model using the current XRFrame
  44476. * @param xrFrame the current xr frame to use and update the model
  44477. */
  44478. updateFromXRFrame(xrFrame: XRFrame): void;
  44479. /**
  44480. * Backwards compatibility due to a deeply-integrated typo
  44481. */
  44482. get handness(): XREye;
  44483. /**
  44484. * Pulse (vibrate) this controller
  44485. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  44486. * Consecutive calls to this function will cancel the last pulse call
  44487. *
  44488. * @param value the strength of the pulse in 0.0...1.0 range
  44489. * @param duration Duration of the pulse in milliseconds
  44490. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  44491. * @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
  44492. */
  44493. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  44494. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44495. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44496. /**
  44497. * Moves the axis on the controller mesh based on its current state
  44498. * @param axis the index of the axis
  44499. * @param axisValue the value of the axis which determines the meshes new position
  44500. * @hidden
  44501. */
  44502. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44503. /**
  44504. * Update the model itself with the current frame data
  44505. * @param xrFrame the frame to use for updating the model mesh
  44506. */
  44507. protected updateModel(xrFrame: XRFrame): void;
  44508. /**
  44509. * Get the filename and path for this controller's model
  44510. * @returns a map of filename and path
  44511. */
  44512. protected abstract _getFilenameAndPath(): {
  44513. filename: string;
  44514. path: string;
  44515. };
  44516. /**
  44517. * This function is called before the mesh is loaded. It checks for loading constraints.
  44518. * For example, this function can check if the GLB loader is available
  44519. * If this function returns false, the generic controller will be loaded instead
  44520. * @returns Is the client ready to load the mesh
  44521. */
  44522. protected abstract _getModelLoadingConstraints(): boolean;
  44523. /**
  44524. * This function will be called after the model was successfully loaded and can be used
  44525. * for mesh transformations before it is available for the user
  44526. * @param meshes the loaded meshes
  44527. */
  44528. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44529. /**
  44530. * Set the root mesh for this controller. Important for the WebXR controller class
  44531. * @param meshes the loaded meshes
  44532. */
  44533. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44534. /**
  44535. * A function executed each frame that updates the mesh (if needed)
  44536. * @param xrFrame the current xrFrame
  44537. */
  44538. protected abstract _updateModel(xrFrame: XRFrame): void;
  44539. private _getGenericFilenameAndPath;
  44540. private _getGenericParentMesh;
  44541. }
  44542. }
  44543. declare module BABYLON {
  44544. /**
  44545. * A generic trigger-only motion controller for WebXR
  44546. */
  44547. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44548. /**
  44549. * Static version of the profile id of this controller
  44550. */
  44551. static ProfileId: string;
  44552. profileId: string;
  44553. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44554. protected _getFilenameAndPath(): {
  44555. filename: string;
  44556. path: string;
  44557. };
  44558. protected _getModelLoadingConstraints(): boolean;
  44559. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44560. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44561. protected _updateModel(): void;
  44562. }
  44563. }
  44564. declare module BABYLON {
  44565. /**
  44566. * Class containing static functions to help procedurally build meshes
  44567. */
  44568. export class SphereBuilder {
  44569. /**
  44570. * Creates a sphere mesh
  44571. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44572. * * 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`)
  44573. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44574. * * 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
  44575. * * 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)
  44576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44577. * * 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
  44578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44579. * @param name defines the name of the mesh
  44580. * @param options defines the options used to create the mesh
  44581. * @param scene defines the hosting scene
  44582. * @returns the sphere mesh
  44583. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44584. */
  44585. static CreateSphere(name: string, options: {
  44586. segments?: number;
  44587. diameter?: number;
  44588. diameterX?: number;
  44589. diameterY?: number;
  44590. diameterZ?: number;
  44591. arc?: number;
  44592. slice?: number;
  44593. sideOrientation?: number;
  44594. frontUVs?: Vector4;
  44595. backUVs?: Vector4;
  44596. updatable?: boolean;
  44597. }, scene?: Nullable<Scene>): Mesh;
  44598. }
  44599. }
  44600. declare module BABYLON {
  44601. /**
  44602. * A profiled motion controller has its profile loaded from an online repository.
  44603. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44604. */
  44605. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44606. private _repositoryUrl;
  44607. private _buttonMeshMapping;
  44608. private _touchDots;
  44609. /**
  44610. * The profile ID of this controller. Will be populated when the controller initializes.
  44611. */
  44612. profileId: string;
  44613. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44614. dispose(): void;
  44615. protected _getFilenameAndPath(): {
  44616. filename: string;
  44617. path: string;
  44618. };
  44619. protected _getModelLoadingConstraints(): boolean;
  44620. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44621. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44622. protected _updateModel(_xrFrame: XRFrame): void;
  44623. }
  44624. }
  44625. declare module BABYLON {
  44626. /**
  44627. * A construction function type to create a new controller based on an xrInput object
  44628. */
  44629. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44630. /**
  44631. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44632. *
  44633. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44634. * it should be replaced with auto-loaded controllers.
  44635. *
  44636. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44637. */
  44638. export class WebXRMotionControllerManager {
  44639. private static _AvailableControllers;
  44640. private static _Fallbacks;
  44641. private static _ProfileLoadingPromises;
  44642. private static _ProfilesList;
  44643. /**
  44644. * The base URL of the online controller repository. Can be changed at any time.
  44645. */
  44646. static BaseRepositoryUrl: string;
  44647. /**
  44648. * Which repository gets priority - local or online
  44649. */
  44650. static PrioritizeOnlineRepository: boolean;
  44651. /**
  44652. * Use the online repository, or use only locally-defined controllers
  44653. */
  44654. static UseOnlineRepository: boolean;
  44655. /**
  44656. * Clear the cache used for profile loading and reload when requested again
  44657. */
  44658. static ClearProfilesCache(): void;
  44659. /**
  44660. * Register the default fallbacks.
  44661. * This function is called automatically when this file is imported.
  44662. */
  44663. static DefaultFallbacks(): void;
  44664. /**
  44665. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44666. * @param profileId the profile to which a fallback needs to be found
  44667. * @return an array with corresponding fallback profiles
  44668. */
  44669. static FindFallbackWithProfileId(profileId: string): string[];
  44670. /**
  44671. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44672. * The order of search:
  44673. *
  44674. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44675. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44676. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44677. * 4) return the generic trigger controller if none were found
  44678. *
  44679. * @param xrInput the xrInput to which a new controller is initialized
  44680. * @param scene the scene to which the model will be added
  44681. * @param forceProfile force a certain profile for this controller
  44682. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44683. */
  44684. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44685. /**
  44686. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44687. *
  44688. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44689. *
  44690. * @param type the profile type to register
  44691. * @param constructFunction the function to be called when loading this profile
  44692. */
  44693. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44694. /**
  44695. * Register a fallback to a specific profile.
  44696. * @param profileId the profileId that will receive the fallbacks
  44697. * @param fallbacks A list of fallback profiles
  44698. */
  44699. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44700. /**
  44701. * Will update the list of profiles available in the repository
  44702. * @return a promise that resolves to a map of profiles available online
  44703. */
  44704. static UpdateProfilesList(): Promise<{
  44705. [profile: string]: string;
  44706. }>;
  44707. private static _LoadProfileFromRepository;
  44708. private static _LoadProfilesFromAvailableControllers;
  44709. }
  44710. }
  44711. declare module BABYLON {
  44712. /**
  44713. * Configuration options for the WebXR controller creation
  44714. */
  44715. export interface IWebXRControllerOptions {
  44716. /**
  44717. * Should the controller mesh be animated when a user interacts with it
  44718. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44719. */
  44720. disableMotionControllerAnimation?: boolean;
  44721. /**
  44722. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44723. */
  44724. doNotLoadControllerMesh?: boolean;
  44725. /**
  44726. * Force a specific controller type for this controller.
  44727. * This can be used when creating your own profile or when testing different controllers
  44728. */
  44729. forceControllerProfile?: string;
  44730. /**
  44731. * Defines a rendering group ID for meshes that will be loaded.
  44732. * This is for the default controllers only.
  44733. */
  44734. renderingGroupId?: number;
  44735. }
  44736. /**
  44737. * Represents an XR controller
  44738. */
  44739. export class WebXRInputSource {
  44740. private _scene;
  44741. /** The underlying input source for the controller */
  44742. inputSource: XRInputSource;
  44743. private _options;
  44744. private _tmpQuaternion;
  44745. private _tmpVector;
  44746. private _uniqueId;
  44747. /**
  44748. * 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
  44749. */
  44750. grip?: AbstractMesh;
  44751. /**
  44752. * If available, this is the gamepad object related to this controller.
  44753. * Using this object it is possible to get click events and trackpad changes of the
  44754. * webxr controller that is currently being used.
  44755. */
  44756. motionController?: WebXRAbstractMotionController;
  44757. /**
  44758. * Event that fires when the controller is removed/disposed.
  44759. * The object provided as event data is this controller, after associated assets were disposed.
  44760. * uniqueId is still available.
  44761. */
  44762. onDisposeObservable: Observable<WebXRInputSource>;
  44763. /**
  44764. * Will be triggered when the mesh associated with the motion controller is done loading.
  44765. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44766. * A shortened version of controller -> motion controller -> on mesh loaded.
  44767. */
  44768. onMeshLoadedObservable: Observable<AbstractMesh>;
  44769. /**
  44770. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44771. */
  44772. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44773. /**
  44774. * Pointer which can be used to select objects or attach a visible laser to
  44775. */
  44776. pointer: AbstractMesh;
  44777. /**
  44778. * Creates the controller
  44779. * @see https://doc.babylonjs.com/how_to/webxr
  44780. * @param _scene the scene which the controller should be associated to
  44781. * @param inputSource the underlying input source for the controller
  44782. * @param _options options for this controller creation
  44783. */
  44784. constructor(_scene: Scene,
  44785. /** The underlying input source for the controller */
  44786. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44787. /**
  44788. * Get this controllers unique id
  44789. */
  44790. get uniqueId(): string;
  44791. /**
  44792. * Disposes of the object
  44793. */
  44794. dispose(): void;
  44795. /**
  44796. * Gets a world space ray coming from the pointer or grip
  44797. * @param result the resulting ray
  44798. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44799. */
  44800. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44801. /**
  44802. * Updates the controller pose based on the given XRFrame
  44803. * @param xrFrame xr frame to update the pose with
  44804. * @param referenceSpace reference space to use
  44805. */
  44806. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44807. }
  44808. }
  44809. declare module BABYLON {
  44810. /**
  44811. * The schema for initialization options of the XR Input class
  44812. */
  44813. export interface IWebXRInputOptions {
  44814. /**
  44815. * If set to true no model will be automatically loaded
  44816. */
  44817. doNotLoadControllerMeshes?: boolean;
  44818. /**
  44819. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44820. * If not found, the xr input profile data will be used.
  44821. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44822. */
  44823. forceInputProfile?: string;
  44824. /**
  44825. * Do not send a request to the controller repository to load the profile.
  44826. *
  44827. * Instead, use the controllers available in babylon itself.
  44828. */
  44829. disableOnlineControllerRepository?: boolean;
  44830. /**
  44831. * A custom URL for the controllers repository
  44832. */
  44833. customControllersRepositoryURL?: string;
  44834. /**
  44835. * Should the controller model's components not move according to the user input
  44836. */
  44837. disableControllerAnimation?: boolean;
  44838. /**
  44839. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  44840. */
  44841. controllerOptions?: IWebXRControllerOptions;
  44842. }
  44843. /**
  44844. * XR input used to track XR inputs such as controllers/rays
  44845. */
  44846. export class WebXRInput implements IDisposable {
  44847. /**
  44848. * the xr session manager for this session
  44849. */
  44850. xrSessionManager: WebXRSessionManager;
  44851. /**
  44852. * the WebXR camera for this session. Mainly used for teleportation
  44853. */
  44854. xrCamera: WebXRCamera;
  44855. private readonly options;
  44856. /**
  44857. * XR controllers being tracked
  44858. */
  44859. controllers: Array<WebXRInputSource>;
  44860. private _frameObserver;
  44861. private _sessionEndedObserver;
  44862. private _sessionInitObserver;
  44863. /**
  44864. * Event when a controller has been connected/added
  44865. */
  44866. onControllerAddedObservable: Observable<WebXRInputSource>;
  44867. /**
  44868. * Event when a controller has been removed/disconnected
  44869. */
  44870. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44871. /**
  44872. * Initializes the WebXRInput
  44873. * @param xrSessionManager the xr session manager for this session
  44874. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44875. * @param options = initialization options for this xr input
  44876. */
  44877. constructor(
  44878. /**
  44879. * the xr session manager for this session
  44880. */
  44881. xrSessionManager: WebXRSessionManager,
  44882. /**
  44883. * the WebXR camera for this session. Mainly used for teleportation
  44884. */
  44885. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44886. private _onInputSourcesChange;
  44887. private _addAndRemoveControllers;
  44888. /**
  44889. * Disposes of the object
  44890. */
  44891. dispose(): void;
  44892. }
  44893. }
  44894. declare module BABYLON {
  44895. /**
  44896. * This is the base class for all WebXR features.
  44897. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44898. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44899. */
  44900. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44901. protected _xrSessionManager: WebXRSessionManager;
  44902. private _attached;
  44903. private _removeOnDetach;
  44904. /**
  44905. * Should auto-attach be disabled?
  44906. */
  44907. disableAutoAttach: boolean;
  44908. /**
  44909. * Construct a new (abstract) WebXR feature
  44910. * @param _xrSessionManager the xr session manager for this feature
  44911. */
  44912. constructor(_xrSessionManager: WebXRSessionManager);
  44913. /**
  44914. * Is this feature attached
  44915. */
  44916. get attached(): boolean;
  44917. /**
  44918. * attach this feature
  44919. *
  44920. * @param force should attachment be forced (even when already attached)
  44921. * @returns true if successful, false is failed or already attached
  44922. */
  44923. attach(force?: boolean): boolean;
  44924. /**
  44925. * detach this feature.
  44926. *
  44927. * @returns true if successful, false if failed or already detached
  44928. */
  44929. detach(): boolean;
  44930. /**
  44931. * Dispose this feature and all of the resources attached
  44932. */
  44933. dispose(): void;
  44934. /**
  44935. * This is used to register callbacks that will automatically be removed when detach is called.
  44936. * @param observable the observable to which the observer will be attached
  44937. * @param callback the callback to register
  44938. */
  44939. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44940. /**
  44941. * Code in this function will be executed on each xrFrame received from the browser.
  44942. * This function will not execute after the feature is detached.
  44943. * @param _xrFrame the current frame
  44944. */
  44945. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44946. }
  44947. }
  44948. declare module BABYLON {
  44949. /**
  44950. * Renders a layer on top of an existing scene
  44951. */
  44952. export class UtilityLayerRenderer implements IDisposable {
  44953. /** the original scene that will be rendered on top of */
  44954. originalScene: Scene;
  44955. private _pointerCaptures;
  44956. private _lastPointerEvents;
  44957. private static _DefaultUtilityLayer;
  44958. private static _DefaultKeepDepthUtilityLayer;
  44959. private _sharedGizmoLight;
  44960. private _renderCamera;
  44961. /**
  44962. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44963. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44964. * @returns the camera that is used when rendering the utility layer
  44965. */
  44966. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44967. /**
  44968. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44969. * @param cam the camera that should be used when rendering the utility layer
  44970. */
  44971. setRenderCamera(cam: Nullable<Camera>): void;
  44972. /**
  44973. * @hidden
  44974. * Light which used by gizmos to get light shading
  44975. */
  44976. _getSharedGizmoLight(): HemisphericLight;
  44977. /**
  44978. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44979. */
  44980. pickUtilitySceneFirst: boolean;
  44981. /**
  44982. * 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)
  44983. */
  44984. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44985. /**
  44986. * 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)
  44987. */
  44988. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44989. /**
  44990. * The scene that is rendered on top of the original scene
  44991. */
  44992. utilityLayerScene: Scene;
  44993. /**
  44994. * If the utility layer should automatically be rendered on top of existing scene
  44995. */
  44996. shouldRender: boolean;
  44997. /**
  44998. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44999. */
  45000. onlyCheckPointerDownEvents: boolean;
  45001. /**
  45002. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45003. */
  45004. processAllEvents: boolean;
  45005. /**
  45006. * Observable raised when the pointer move from the utility layer scene to the main scene
  45007. */
  45008. onPointerOutObservable: Observable<number>;
  45009. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45010. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45011. private _afterRenderObserver;
  45012. private _sceneDisposeObserver;
  45013. private _originalPointerObserver;
  45014. /**
  45015. * Instantiates a UtilityLayerRenderer
  45016. * @param originalScene the original scene that will be rendered on top of
  45017. * @param handleEvents boolean indicating if the utility layer should handle events
  45018. */
  45019. constructor(
  45020. /** the original scene that will be rendered on top of */
  45021. originalScene: Scene, handleEvents?: boolean);
  45022. private _notifyObservers;
  45023. /**
  45024. * Renders the utility layers scene on top of the original scene
  45025. */
  45026. render(): void;
  45027. /**
  45028. * Disposes of the renderer
  45029. */
  45030. dispose(): void;
  45031. private _updateCamera;
  45032. }
  45033. }
  45034. declare module BABYLON {
  45035. /**
  45036. * Options interface for the pointer selection module
  45037. */
  45038. export interface IWebXRControllerPointerSelectionOptions {
  45039. /**
  45040. * if provided, this scene will be used to render meshes.
  45041. */
  45042. customUtilityLayerScene?: Scene;
  45043. /**
  45044. * 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)
  45045. * If not disabled, the last picked point will be used to execute a pointer up event
  45046. * If disabled, pointer up event will be triggered right after the pointer down event.
  45047. * Used in screen and gaze target ray mode only
  45048. */
  45049. disablePointerUpOnTouchOut: boolean;
  45050. /**
  45051. * For gaze mode (time to select instead of press)
  45052. */
  45053. forceGazeMode: boolean;
  45054. /**
  45055. * 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
  45056. * to start a new countdown to the pointer down event.
  45057. * Defaults to 1.
  45058. */
  45059. gazeModePointerMovedFactor?: number;
  45060. /**
  45061. * Different button type to use instead of the main component
  45062. */
  45063. overrideButtonId?: string;
  45064. /**
  45065. * use this rendering group id for the meshes (optional)
  45066. */
  45067. renderingGroupId?: number;
  45068. /**
  45069. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45070. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45071. * 3000 means 3 seconds between pointing at something and selecting it
  45072. */
  45073. timeToSelect?: number;
  45074. /**
  45075. * Should meshes created here be added to a utility layer or the main scene
  45076. */
  45077. useUtilityLayer?: boolean;
  45078. /**
  45079. * the xr input to use with this pointer selection
  45080. */
  45081. xrInput: WebXRInput;
  45082. }
  45083. /**
  45084. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45085. */
  45086. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45087. private readonly _options;
  45088. private static _idCounter;
  45089. private _attachController;
  45090. private _controllers;
  45091. private _scene;
  45092. private _tmpVectorForPickCompare;
  45093. /**
  45094. * The module's name
  45095. */
  45096. static readonly Name: string;
  45097. /**
  45098. * The (Babylon) version of this module.
  45099. * This is an integer representing the implementation version.
  45100. * This number does not correspond to the WebXR specs version
  45101. */
  45102. static readonly Version: number;
  45103. /**
  45104. * Disable lighting on the laser pointer (so it will always be visible)
  45105. */
  45106. disablePointerLighting: boolean;
  45107. /**
  45108. * Disable lighting on the selection mesh (so it will always be visible)
  45109. */
  45110. disableSelectionMeshLighting: boolean;
  45111. /**
  45112. * Should the laser pointer be displayed
  45113. */
  45114. displayLaserPointer: boolean;
  45115. /**
  45116. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45117. */
  45118. displaySelectionMesh: boolean;
  45119. /**
  45120. * This color will be set to the laser pointer when selection is triggered
  45121. */
  45122. laserPointerPickedColor: Color3;
  45123. /**
  45124. * Default color of the laser pointer
  45125. */
  45126. lasterPointerDefaultColor: Color3;
  45127. /**
  45128. * default color of the selection ring
  45129. */
  45130. selectionMeshDefaultColor: Color3;
  45131. /**
  45132. * This color will be applied to the selection ring when selection is triggered
  45133. */
  45134. selectionMeshPickedColor: Color3;
  45135. /**
  45136. * Optional filter to be used for ray selection. This predicate shares behavior with
  45137. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45138. */
  45139. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45140. /**
  45141. * constructs a new background remover module
  45142. * @param _xrSessionManager the session manager for this module
  45143. * @param _options read-only options to be used in this module
  45144. */
  45145. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45146. /**
  45147. * attach this feature
  45148. * Will usually be called by the features manager
  45149. *
  45150. * @returns true if successful.
  45151. */
  45152. attach(): boolean;
  45153. /**
  45154. * detach this feature.
  45155. * Will usually be called by the features manager
  45156. *
  45157. * @returns true if successful.
  45158. */
  45159. detach(): boolean;
  45160. /**
  45161. * Will get the mesh under a specific pointer.
  45162. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45163. * @param controllerId the controllerId to check
  45164. * @returns The mesh under pointer or null if no mesh is under the pointer
  45165. */
  45166. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45167. /**
  45168. * Get the xr controller that correlates to the pointer id in the pointer event
  45169. *
  45170. * @param id the pointer id to search for
  45171. * @returns the controller that correlates to this id or null if not found
  45172. */
  45173. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45174. protected _onXRFrame(_xrFrame: XRFrame): void;
  45175. private _attachGazeMode;
  45176. private _attachScreenRayMode;
  45177. private _attachTrackedPointerRayMode;
  45178. private _convertNormalToDirectionOfRay;
  45179. private _detachController;
  45180. private _generateNewMeshPair;
  45181. private _pickingMoved;
  45182. private _updatePointerDistance;
  45183. }
  45184. }
  45185. declare module BABYLON {
  45186. /**
  45187. * Button which can be used to enter a different mode of XR
  45188. */
  45189. export class WebXREnterExitUIButton {
  45190. /** button element */
  45191. element: HTMLElement;
  45192. /** XR initialization options for the button */
  45193. sessionMode: XRSessionMode;
  45194. /** Reference space type */
  45195. referenceSpaceType: XRReferenceSpaceType;
  45196. /**
  45197. * Creates a WebXREnterExitUIButton
  45198. * @param element button element
  45199. * @param sessionMode XR initialization session mode
  45200. * @param referenceSpaceType the type of reference space to be used
  45201. */
  45202. constructor(
  45203. /** button element */
  45204. element: HTMLElement,
  45205. /** XR initialization options for the button */
  45206. sessionMode: XRSessionMode,
  45207. /** Reference space type */
  45208. referenceSpaceType: XRReferenceSpaceType);
  45209. /**
  45210. * Extendable function which can be used to update the button's visuals when the state changes
  45211. * @param activeButton the current active button in the UI
  45212. */
  45213. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45214. }
  45215. /**
  45216. * Options to create the webXR UI
  45217. */
  45218. export class WebXREnterExitUIOptions {
  45219. /**
  45220. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45221. */
  45222. customButtons?: Array<WebXREnterExitUIButton>;
  45223. /**
  45224. * A reference space type to use when creating the default button.
  45225. * Default is local-floor
  45226. */
  45227. referenceSpaceType?: XRReferenceSpaceType;
  45228. /**
  45229. * Context to enter xr with
  45230. */
  45231. renderTarget?: Nullable<WebXRRenderTarget>;
  45232. /**
  45233. * A session mode to use when creating the default button.
  45234. * Default is immersive-vr
  45235. */
  45236. sessionMode?: XRSessionMode;
  45237. /**
  45238. * A list of optional features to init the session with
  45239. */
  45240. optionalFeatures?: string[];
  45241. }
  45242. /**
  45243. * UI to allow the user to enter/exit XR mode
  45244. */
  45245. export class WebXREnterExitUI implements IDisposable {
  45246. private scene;
  45247. /** version of the options passed to this UI */
  45248. options: WebXREnterExitUIOptions;
  45249. private _activeButton;
  45250. private _buttons;
  45251. private _overlay;
  45252. /**
  45253. * Fired every time the active button is changed.
  45254. *
  45255. * When xr is entered via a button that launches xr that button will be the callback parameter
  45256. *
  45257. * When exiting xr the callback parameter will be null)
  45258. */
  45259. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45260. /**
  45261. *
  45262. * @param scene babylon scene object to use
  45263. * @param options (read-only) version of the options passed to this UI
  45264. */
  45265. private constructor();
  45266. /**
  45267. * Creates UI to allow the user to enter/exit XR mode
  45268. * @param scene the scene to add the ui to
  45269. * @param helper the xr experience helper to enter/exit xr with
  45270. * @param options options to configure the UI
  45271. * @returns the created ui
  45272. */
  45273. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45274. /**
  45275. * Disposes of the XR UI component
  45276. */
  45277. dispose(): void;
  45278. private _updateButtons;
  45279. }
  45280. }
  45281. declare module BABYLON {
  45282. /**
  45283. * Class containing static functions to help procedurally build meshes
  45284. */
  45285. export class LinesBuilder {
  45286. /**
  45287. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45288. * * 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
  45289. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45290. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45291. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45292. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45293. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45294. * * 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
  45295. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45298. * @param name defines the name of the new line system
  45299. * @param options defines the options used to create the line system
  45300. * @param scene defines the hosting scene
  45301. * @returns a new line system mesh
  45302. */
  45303. static CreateLineSystem(name: string, options: {
  45304. lines: Vector3[][];
  45305. updatable?: boolean;
  45306. instance?: Nullable<LinesMesh>;
  45307. colors?: Nullable<Color4[][]>;
  45308. useVertexAlpha?: boolean;
  45309. }, scene: Nullable<Scene>): LinesMesh;
  45310. /**
  45311. * Creates a line mesh
  45312. * 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
  45313. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45314. * * The parameter `points` is an array successive Vector3
  45315. * * 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
  45316. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45317. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45318. * * When updating an instance, remember that only point positions can change, not the number of points
  45319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45321. * @param name defines the name of the new line system
  45322. * @param options defines the options used to create the line system
  45323. * @param scene defines the hosting scene
  45324. * @returns a new line mesh
  45325. */
  45326. static CreateLines(name: string, options: {
  45327. points: Vector3[];
  45328. updatable?: boolean;
  45329. instance?: Nullable<LinesMesh>;
  45330. colors?: Color4[];
  45331. useVertexAlpha?: boolean;
  45332. }, scene?: Nullable<Scene>): LinesMesh;
  45333. /**
  45334. * Creates a dashed line mesh
  45335. * * 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
  45336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45337. * * The parameter `points` is an array successive Vector3
  45338. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45339. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45340. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45341. * * 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
  45342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45343. * * When updating an instance, remember that only point positions can change, not the number of points
  45344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45345. * @param name defines the name of the mesh
  45346. * @param options defines the options used to create the mesh
  45347. * @param scene defines the hosting scene
  45348. * @returns the dashed line mesh
  45349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45350. */
  45351. static CreateDashedLines(name: string, options: {
  45352. points: Vector3[];
  45353. dashSize?: number;
  45354. gapSize?: number;
  45355. dashNb?: number;
  45356. updatable?: boolean;
  45357. instance?: LinesMesh;
  45358. useVertexAlpha?: boolean;
  45359. }, scene?: Nullable<Scene>): LinesMesh;
  45360. }
  45361. }
  45362. declare module BABYLON {
  45363. /**
  45364. * The options container for the teleportation module
  45365. */
  45366. export interface IWebXRTeleportationOptions {
  45367. /**
  45368. * if provided, this scene will be used to render meshes.
  45369. */
  45370. customUtilityLayerScene?: Scene;
  45371. /**
  45372. * Values to configure the default target mesh
  45373. */
  45374. defaultTargetMeshOptions?: {
  45375. /**
  45376. * Fill color of the teleportation area
  45377. */
  45378. teleportationFillColor?: string;
  45379. /**
  45380. * Border color for the teleportation area
  45381. */
  45382. teleportationBorderColor?: string;
  45383. /**
  45384. * Disable the mesh's animation sequence
  45385. */
  45386. disableAnimation?: boolean;
  45387. /**
  45388. * Disable lighting on the material or the ring and arrow
  45389. */
  45390. disableLighting?: boolean;
  45391. /**
  45392. * Override the default material of the torus and arrow
  45393. */
  45394. torusArrowMaterial?: Material;
  45395. };
  45396. /**
  45397. * A list of meshes to use as floor meshes.
  45398. * Meshes can be added and removed after initializing the feature using the
  45399. * addFloorMesh and removeFloorMesh functions
  45400. * If empty, rotation will still work
  45401. */
  45402. floorMeshes?: AbstractMesh[];
  45403. /**
  45404. * use this rendering group id for the meshes (optional)
  45405. */
  45406. renderingGroupId?: number;
  45407. /**
  45408. * Should teleportation move only to snap points
  45409. */
  45410. snapPointsOnly?: boolean;
  45411. /**
  45412. * An array of points to which the teleportation will snap to.
  45413. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45414. */
  45415. snapPositions?: Vector3[];
  45416. /**
  45417. * How close should the teleportation ray be in order to snap to position.
  45418. * Default to 0.8 units (meters)
  45419. */
  45420. snapToPositionRadius?: number;
  45421. /**
  45422. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45423. * If you want to support rotation, make sure your mesh has a direction indicator.
  45424. *
  45425. * When left untouched, the default mesh will be initialized.
  45426. */
  45427. teleportationTargetMesh?: AbstractMesh;
  45428. /**
  45429. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45430. */
  45431. timeToTeleport?: number;
  45432. /**
  45433. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45434. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45435. */
  45436. useMainComponentOnly?: boolean;
  45437. /**
  45438. * Should meshes created here be added to a utility layer or the main scene
  45439. */
  45440. useUtilityLayer?: boolean;
  45441. /**
  45442. * Babylon XR Input class for controller
  45443. */
  45444. xrInput: WebXRInput;
  45445. }
  45446. /**
  45447. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45448. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45449. * the input of the attached controllers.
  45450. */
  45451. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45452. private _options;
  45453. private _controllers;
  45454. private _currentTeleportationControllerId;
  45455. private _floorMeshes;
  45456. private _quadraticBezierCurve;
  45457. private _selectionFeature;
  45458. private _snapToPositions;
  45459. private _snappedToPoint;
  45460. private _teleportationRingMaterial?;
  45461. private _tmpRay;
  45462. private _tmpVector;
  45463. /**
  45464. * The module's name
  45465. */
  45466. static readonly Name: string;
  45467. /**
  45468. * The (Babylon) version of this module.
  45469. * This is an integer representing the implementation version.
  45470. * This number does not correspond to the webxr specs version
  45471. */
  45472. static readonly Version: number;
  45473. /**
  45474. * Is movement backwards enabled
  45475. */
  45476. backwardsMovementEnabled: boolean;
  45477. /**
  45478. * Distance to travel when moving backwards
  45479. */
  45480. backwardsTeleportationDistance: number;
  45481. /**
  45482. * The distance from the user to the inspection point in the direction of the controller
  45483. * A higher number will allow the user to move further
  45484. * defaults to 5 (meters, in xr units)
  45485. */
  45486. parabolicCheckRadius: number;
  45487. /**
  45488. * Should the module support parabolic ray on top of direct ray
  45489. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45490. * Very helpful when moving between floors / different heights
  45491. */
  45492. parabolicRayEnabled: boolean;
  45493. /**
  45494. * How much rotation should be applied when rotating right and left
  45495. */
  45496. rotationAngle: number;
  45497. /**
  45498. * Is rotation enabled when moving forward?
  45499. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45500. */
  45501. rotationEnabled: boolean;
  45502. /**
  45503. * constructs a new anchor system
  45504. * @param _xrSessionManager an instance of WebXRSessionManager
  45505. * @param _options configuration object for this feature
  45506. */
  45507. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45508. /**
  45509. * Get the snapPointsOnly flag
  45510. */
  45511. get snapPointsOnly(): boolean;
  45512. /**
  45513. * Sets the snapPointsOnly flag
  45514. * @param snapToPoints should teleportation be exclusively to snap points
  45515. */
  45516. set snapPointsOnly(snapToPoints: boolean);
  45517. /**
  45518. * Add a new mesh to the floor meshes array
  45519. * @param mesh the mesh to use as floor mesh
  45520. */
  45521. addFloorMesh(mesh: AbstractMesh): void;
  45522. /**
  45523. * Add a new snap-to point to fix teleportation to this position
  45524. * @param newSnapPoint The new Snap-To point
  45525. */
  45526. addSnapPoint(newSnapPoint: Vector3): void;
  45527. attach(): boolean;
  45528. detach(): boolean;
  45529. dispose(): void;
  45530. /**
  45531. * Remove a mesh from the floor meshes array
  45532. * @param mesh the mesh to remove
  45533. */
  45534. removeFloorMesh(mesh: AbstractMesh): void;
  45535. /**
  45536. * Remove a mesh from the floor meshes array using its name
  45537. * @param name the mesh name to remove
  45538. */
  45539. removeFloorMeshByName(name: string): void;
  45540. /**
  45541. * 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
  45542. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45543. * @returns was the point found and removed or not
  45544. */
  45545. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45546. /**
  45547. * This function sets a selection feature that will be disabled when
  45548. * the forward ray is shown and will be reattached when hidden.
  45549. * This is used to remove the selection rays when moving.
  45550. * @param selectionFeature the feature to disable when forward movement is enabled
  45551. */
  45552. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45553. protected _onXRFrame(_xrFrame: XRFrame): void;
  45554. private _attachController;
  45555. private _createDefaultTargetMesh;
  45556. private _detachController;
  45557. private _findClosestSnapPointWithRadius;
  45558. private _setTargetMeshPosition;
  45559. private _setTargetMeshVisibility;
  45560. private _showParabolicPath;
  45561. private _teleportForward;
  45562. }
  45563. }
  45564. declare module BABYLON {
  45565. /**
  45566. * Options for the default xr helper
  45567. */
  45568. export class WebXRDefaultExperienceOptions {
  45569. /**
  45570. * Enable or disable default UI to enter XR
  45571. */
  45572. disableDefaultUI?: boolean;
  45573. /**
  45574. * Should teleportation not initialize. defaults to false.
  45575. */
  45576. disableTeleportation?: boolean;
  45577. /**
  45578. * Floor meshes that will be used for teleport
  45579. */
  45580. floorMeshes?: Array<AbstractMesh>;
  45581. /**
  45582. * If set to true, the first frame will not be used to reset position
  45583. * The first frame is mainly used when copying transformation from the old camera
  45584. * Mainly used in AR
  45585. */
  45586. ignoreNativeCameraTransformation?: boolean;
  45587. /**
  45588. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45589. */
  45590. inputOptions?: IWebXRInputOptions;
  45591. /**
  45592. * optional configuration for the output canvas
  45593. */
  45594. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45595. /**
  45596. * optional UI options. This can be used among other to change session mode and reference space type
  45597. */
  45598. uiOptions?: WebXREnterExitUIOptions;
  45599. /**
  45600. * When loading teleportation and pointer select, use stable versions instead of latest.
  45601. */
  45602. useStablePlugins?: boolean;
  45603. /**
  45604. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  45605. */
  45606. renderingGroupId?: number;
  45607. /**
  45608. * A list of optional features to init the session with
  45609. * If set to true, all features we support will be added
  45610. */
  45611. optionalFeatures?: boolean | string[];
  45612. }
  45613. /**
  45614. * Default experience which provides a similar setup to the previous webVRExperience
  45615. */
  45616. export class WebXRDefaultExperience {
  45617. /**
  45618. * Base experience
  45619. */
  45620. baseExperience: WebXRExperienceHelper;
  45621. /**
  45622. * Enables ui for entering/exiting xr
  45623. */
  45624. enterExitUI: WebXREnterExitUI;
  45625. /**
  45626. * Input experience extension
  45627. */
  45628. input: WebXRInput;
  45629. /**
  45630. * Enables laser pointer and selection
  45631. */
  45632. pointerSelection: WebXRControllerPointerSelection;
  45633. /**
  45634. * Default target xr should render to
  45635. */
  45636. renderTarget: WebXRRenderTarget;
  45637. /**
  45638. * Enables teleportation
  45639. */
  45640. teleportation: WebXRMotionControllerTeleportation;
  45641. private constructor();
  45642. /**
  45643. * Creates the default xr experience
  45644. * @param scene scene
  45645. * @param options options for basic configuration
  45646. * @returns resulting WebXRDefaultExperience
  45647. */
  45648. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45649. /**
  45650. * DIsposes of the experience helper
  45651. */
  45652. dispose(): void;
  45653. }
  45654. }
  45655. declare module BABYLON {
  45656. /**
  45657. * Options to modify the vr teleportation behavior.
  45658. */
  45659. export interface VRTeleportationOptions {
  45660. /**
  45661. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45662. */
  45663. floorMeshName?: string;
  45664. /**
  45665. * A list of meshes to be used as the teleportation floor. (default: empty)
  45666. */
  45667. floorMeshes?: Mesh[];
  45668. /**
  45669. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45670. */
  45671. teleportationMode?: number;
  45672. /**
  45673. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45674. */
  45675. teleportationTime?: number;
  45676. /**
  45677. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45678. */
  45679. teleportationSpeed?: number;
  45680. /**
  45681. * The easing function used in the animation or null for Linear. (default CircleEase)
  45682. */
  45683. easingFunction?: EasingFunction;
  45684. }
  45685. /**
  45686. * Options to modify the vr experience helper's behavior.
  45687. */
  45688. export interface VRExperienceHelperOptions extends WebVROptions {
  45689. /**
  45690. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45691. */
  45692. createDeviceOrientationCamera?: boolean;
  45693. /**
  45694. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45695. */
  45696. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45697. /**
  45698. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45699. */
  45700. laserToggle?: boolean;
  45701. /**
  45702. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45703. */
  45704. floorMeshes?: Mesh[];
  45705. /**
  45706. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45707. */
  45708. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45709. /**
  45710. * Defines if WebXR should be used instead of WebVR (if available)
  45711. */
  45712. useXR?: boolean;
  45713. }
  45714. /**
  45715. * Event containing information after VR has been entered
  45716. */
  45717. export class OnAfterEnteringVRObservableEvent {
  45718. /**
  45719. * If entering vr was successful
  45720. */
  45721. success: boolean;
  45722. }
  45723. /**
  45724. * Helps to quickly add VR support to an existing scene.
  45725. * See http://doc.babylonjs.com/how_to/webvr_helper
  45726. */
  45727. export class VRExperienceHelper {
  45728. /** Options to modify the vr experience helper's behavior. */
  45729. webVROptions: VRExperienceHelperOptions;
  45730. private _scene;
  45731. private _position;
  45732. private _btnVR;
  45733. private _btnVRDisplayed;
  45734. private _webVRsupported;
  45735. private _webVRready;
  45736. private _webVRrequesting;
  45737. private _webVRpresenting;
  45738. private _hasEnteredVR;
  45739. private _fullscreenVRpresenting;
  45740. private _inputElement;
  45741. private _webVRCamera;
  45742. private _vrDeviceOrientationCamera;
  45743. private _deviceOrientationCamera;
  45744. private _existingCamera;
  45745. private _onKeyDown;
  45746. private _onVrDisplayPresentChange;
  45747. private _onVRDisplayChanged;
  45748. private _onVRRequestPresentStart;
  45749. private _onVRRequestPresentComplete;
  45750. /**
  45751. * 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)
  45752. */
  45753. enableGazeEvenWhenNoPointerLock: boolean;
  45754. /**
  45755. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45756. */
  45757. exitVROnDoubleTap: boolean;
  45758. /**
  45759. * Observable raised right before entering VR.
  45760. */
  45761. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45762. /**
  45763. * Observable raised when entering VR has completed.
  45764. */
  45765. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45766. /**
  45767. * Observable raised when exiting VR.
  45768. */
  45769. onExitingVRObservable: Observable<VRExperienceHelper>;
  45770. /**
  45771. * Observable raised when controller mesh is loaded.
  45772. */
  45773. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45774. /** Return this.onEnteringVRObservable
  45775. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45776. */
  45777. get onEnteringVR(): Observable<VRExperienceHelper>;
  45778. /** Return this.onExitingVRObservable
  45779. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45780. */
  45781. get onExitingVR(): Observable<VRExperienceHelper>;
  45782. /** Return this.onControllerMeshLoadedObservable
  45783. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45784. */
  45785. get onControllerMeshLoaded(): Observable<WebVRController>;
  45786. private _rayLength;
  45787. private _useCustomVRButton;
  45788. private _teleportationRequested;
  45789. private _teleportActive;
  45790. private _floorMeshName;
  45791. private _floorMeshesCollection;
  45792. private _teleportationMode;
  45793. private _teleportationTime;
  45794. private _teleportationSpeed;
  45795. private _teleportationEasing;
  45796. private _rotationAllowed;
  45797. private _teleportBackwardsVector;
  45798. private _teleportationTarget;
  45799. private _isDefaultTeleportationTarget;
  45800. private _postProcessMove;
  45801. private _teleportationFillColor;
  45802. private _teleportationBorderColor;
  45803. private _rotationAngle;
  45804. private _haloCenter;
  45805. private _cameraGazer;
  45806. private _padSensibilityUp;
  45807. private _padSensibilityDown;
  45808. private _leftController;
  45809. private _rightController;
  45810. private _gazeColor;
  45811. private _laserColor;
  45812. private _pickedLaserColor;
  45813. private _pickedGazeColor;
  45814. /**
  45815. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45816. */
  45817. onNewMeshSelected: Observable<AbstractMesh>;
  45818. /**
  45819. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45820. * This observable will provide the mesh and the controller used to select the mesh
  45821. */
  45822. onMeshSelectedWithController: Observable<{
  45823. mesh: AbstractMesh;
  45824. controller: WebVRController;
  45825. }>;
  45826. /**
  45827. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45828. */
  45829. onNewMeshPicked: Observable<PickingInfo>;
  45830. private _circleEase;
  45831. /**
  45832. * Observable raised before camera teleportation
  45833. */
  45834. onBeforeCameraTeleport: Observable<Vector3>;
  45835. /**
  45836. * Observable raised after camera teleportation
  45837. */
  45838. onAfterCameraTeleport: Observable<Vector3>;
  45839. /**
  45840. * Observable raised when current selected mesh gets unselected
  45841. */
  45842. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45843. private _raySelectionPredicate;
  45844. /**
  45845. * To be optionaly changed by user to define custom ray selection
  45846. */
  45847. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45848. /**
  45849. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45850. */
  45851. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45852. /**
  45853. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45854. */
  45855. teleportationEnabled: boolean;
  45856. private _defaultHeight;
  45857. private _teleportationInitialized;
  45858. private _interactionsEnabled;
  45859. private _interactionsRequested;
  45860. private _displayGaze;
  45861. private _displayLaserPointer;
  45862. /**
  45863. * The mesh used to display where the user is going to teleport.
  45864. */
  45865. get teleportationTarget(): Mesh;
  45866. /**
  45867. * Sets the mesh to be used to display where the user is going to teleport.
  45868. */
  45869. set teleportationTarget(value: Mesh);
  45870. /**
  45871. * 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
  45872. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45873. * See http://doc.babylonjs.com/resources/baking_transformations
  45874. */
  45875. get gazeTrackerMesh(): Mesh;
  45876. set gazeTrackerMesh(value: Mesh);
  45877. /**
  45878. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45879. */
  45880. updateGazeTrackerScale: boolean;
  45881. /**
  45882. * If the gaze trackers color should be updated when selecting meshes
  45883. */
  45884. updateGazeTrackerColor: boolean;
  45885. /**
  45886. * If the controller laser color should be updated when selecting meshes
  45887. */
  45888. updateControllerLaserColor: boolean;
  45889. /**
  45890. * The gaze tracking mesh corresponding to the left controller
  45891. */
  45892. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45893. /**
  45894. * The gaze tracking mesh corresponding to the right controller
  45895. */
  45896. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45897. /**
  45898. * If the ray of the gaze should be displayed.
  45899. */
  45900. get displayGaze(): boolean;
  45901. /**
  45902. * Sets if the ray of the gaze should be displayed.
  45903. */
  45904. set displayGaze(value: boolean);
  45905. /**
  45906. * If the ray of the LaserPointer should be displayed.
  45907. */
  45908. get displayLaserPointer(): boolean;
  45909. /**
  45910. * Sets if the ray of the LaserPointer should be displayed.
  45911. */
  45912. set displayLaserPointer(value: boolean);
  45913. /**
  45914. * The deviceOrientationCamera used as the camera when not in VR.
  45915. */
  45916. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45917. /**
  45918. * Based on the current WebVR support, returns the current VR camera used.
  45919. */
  45920. get currentVRCamera(): Nullable<Camera>;
  45921. /**
  45922. * The webVRCamera which is used when in VR.
  45923. */
  45924. get webVRCamera(): WebVRFreeCamera;
  45925. /**
  45926. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45927. */
  45928. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45929. /**
  45930. * The html button that is used to trigger entering into VR.
  45931. */
  45932. get vrButton(): Nullable<HTMLButtonElement>;
  45933. private get _teleportationRequestInitiated();
  45934. /**
  45935. * Defines whether or not Pointer lock should be requested when switching to
  45936. * full screen.
  45937. */
  45938. requestPointerLockOnFullScreen: boolean;
  45939. /**
  45940. * If asking to force XR, this will be populated with the default xr experience
  45941. */
  45942. xr: WebXRDefaultExperience;
  45943. /**
  45944. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45945. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45946. */
  45947. xrTestDone: boolean;
  45948. /**
  45949. * Instantiates a VRExperienceHelper.
  45950. * Helps to quickly add VR support to an existing scene.
  45951. * @param scene The scene the VRExperienceHelper belongs to.
  45952. * @param webVROptions Options to modify the vr experience helper's behavior.
  45953. */
  45954. constructor(scene: Scene,
  45955. /** Options to modify the vr experience helper's behavior. */
  45956. webVROptions?: VRExperienceHelperOptions);
  45957. private completeVRInit;
  45958. private _onDefaultMeshLoaded;
  45959. private _onResize;
  45960. private _onFullscreenChange;
  45961. /**
  45962. * Gets a value indicating if we are currently in VR mode.
  45963. */
  45964. get isInVRMode(): boolean;
  45965. private onVrDisplayPresentChange;
  45966. private onVRDisplayChanged;
  45967. private moveButtonToBottomRight;
  45968. private displayVRButton;
  45969. private updateButtonVisibility;
  45970. private _cachedAngularSensibility;
  45971. /**
  45972. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45973. * Otherwise, will use the fullscreen API.
  45974. */
  45975. enterVR(): void;
  45976. /**
  45977. * Attempt to exit VR, or fullscreen.
  45978. */
  45979. exitVR(): void;
  45980. /**
  45981. * The position of the vr experience helper.
  45982. */
  45983. get position(): Vector3;
  45984. /**
  45985. * Sets the position of the vr experience helper.
  45986. */
  45987. set position(value: Vector3);
  45988. /**
  45989. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45990. */
  45991. enableInteractions(): void;
  45992. private get _noControllerIsActive();
  45993. private beforeRender;
  45994. private _isTeleportationFloor;
  45995. /**
  45996. * Adds a floor mesh to be used for teleportation.
  45997. * @param floorMesh the mesh to be used for teleportation.
  45998. */
  45999. addFloorMesh(floorMesh: Mesh): void;
  46000. /**
  46001. * Removes a floor mesh from being used for teleportation.
  46002. * @param floorMesh the mesh to be removed.
  46003. */
  46004. removeFloorMesh(floorMesh: Mesh): void;
  46005. /**
  46006. * Enables interactions and teleportation using the VR controllers and gaze.
  46007. * @param vrTeleportationOptions options to modify teleportation behavior.
  46008. */
  46009. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46010. private _onNewGamepadConnected;
  46011. private _tryEnableInteractionOnController;
  46012. private _onNewGamepadDisconnected;
  46013. private _enableInteractionOnController;
  46014. private _checkTeleportWithRay;
  46015. private _checkRotate;
  46016. private _checkTeleportBackwards;
  46017. private _enableTeleportationOnController;
  46018. private _createTeleportationCircles;
  46019. private _displayTeleportationTarget;
  46020. private _hideTeleportationTarget;
  46021. private _rotateCamera;
  46022. private _moveTeleportationSelectorTo;
  46023. private _workingVector;
  46024. private _workingQuaternion;
  46025. private _workingMatrix;
  46026. /**
  46027. * Time Constant Teleportation Mode
  46028. */
  46029. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46030. /**
  46031. * Speed Constant Teleportation Mode
  46032. */
  46033. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46034. /**
  46035. * Teleports the users feet to the desired location
  46036. * @param location The location where the user's feet should be placed
  46037. */
  46038. teleportCamera(location: Vector3): void;
  46039. private _convertNormalToDirectionOfRay;
  46040. private _castRayAndSelectObject;
  46041. private _notifySelectedMeshUnselected;
  46042. /**
  46043. * Permanently set new colors for the laser pointer
  46044. * @param color the new laser color
  46045. * @param pickedColor the new laser color when picked mesh detected
  46046. */
  46047. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46048. /**
  46049. * Set lighting enabled / disabled on the laser pointer of both controllers
  46050. * @param enabled should the lighting be enabled on the laser pointer
  46051. */
  46052. setLaserLightingState(enabled?: boolean): void;
  46053. /**
  46054. * Permanently set new colors for the gaze pointer
  46055. * @param color the new gaze color
  46056. * @param pickedColor the new gaze color when picked mesh detected
  46057. */
  46058. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46059. /**
  46060. * Sets the color of the laser ray from the vr controllers.
  46061. * @param color new color for the ray.
  46062. */
  46063. changeLaserColor(color: Color3): void;
  46064. /**
  46065. * Sets the color of the ray from the vr headsets gaze.
  46066. * @param color new color for the ray.
  46067. */
  46068. changeGazeColor(color: Color3): void;
  46069. /**
  46070. * Exits VR and disposes of the vr experience helper
  46071. */
  46072. dispose(): void;
  46073. /**
  46074. * Gets the name of the VRExperienceHelper class
  46075. * @returns "VRExperienceHelper"
  46076. */
  46077. getClassName(): string;
  46078. }
  46079. }
  46080. declare module BABYLON {
  46081. /**
  46082. * Contains an array of blocks representing the octree
  46083. */
  46084. export interface IOctreeContainer<T> {
  46085. /**
  46086. * Blocks within the octree
  46087. */
  46088. blocks: Array<OctreeBlock<T>>;
  46089. }
  46090. /**
  46091. * Class used to store a cell in an octree
  46092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46093. */
  46094. export class OctreeBlock<T> {
  46095. /**
  46096. * Gets the content of the current block
  46097. */
  46098. entries: T[];
  46099. /**
  46100. * Gets the list of block children
  46101. */
  46102. blocks: Array<OctreeBlock<T>>;
  46103. private _depth;
  46104. private _maxDepth;
  46105. private _capacity;
  46106. private _minPoint;
  46107. private _maxPoint;
  46108. private _boundingVectors;
  46109. private _creationFunc;
  46110. /**
  46111. * Creates a new block
  46112. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46113. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46114. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46115. * @param depth defines the current depth of this block in the octree
  46116. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46117. * @param creationFunc defines a callback to call when an element is added to the block
  46118. */
  46119. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46120. /**
  46121. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46122. */
  46123. get capacity(): number;
  46124. /**
  46125. * Gets the minimum vector (in world space) of the block's bounding box
  46126. */
  46127. get minPoint(): Vector3;
  46128. /**
  46129. * Gets the maximum vector (in world space) of the block's bounding box
  46130. */
  46131. get maxPoint(): Vector3;
  46132. /**
  46133. * Add a new element to this block
  46134. * @param entry defines the element to add
  46135. */
  46136. addEntry(entry: T): void;
  46137. /**
  46138. * Remove an element from this block
  46139. * @param entry defines the element to remove
  46140. */
  46141. removeEntry(entry: T): void;
  46142. /**
  46143. * Add an array of elements to this block
  46144. * @param entries defines the array of elements to add
  46145. */
  46146. addEntries(entries: T[]): void;
  46147. /**
  46148. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46149. * @param frustumPlanes defines the frustum planes to test
  46150. * @param selection defines the array to store current content if selection is positive
  46151. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46152. */
  46153. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46154. /**
  46155. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46156. * @param sphereCenter defines the bounding sphere center
  46157. * @param sphereRadius defines the bounding sphere radius
  46158. * @param selection defines the array to store current content if selection is positive
  46159. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46160. */
  46161. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46162. /**
  46163. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46164. * @param ray defines the ray to test with
  46165. * @param selection defines the array to store current content if selection is positive
  46166. */
  46167. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46168. /**
  46169. * Subdivide the content into child blocks (this block will then be empty)
  46170. */
  46171. createInnerBlocks(): void;
  46172. /**
  46173. * @hidden
  46174. */
  46175. 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;
  46176. }
  46177. }
  46178. declare module BABYLON {
  46179. /**
  46180. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46181. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46182. */
  46183. export class Octree<T> {
  46184. /** 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.) */
  46185. maxDepth: number;
  46186. /**
  46187. * Blocks within the octree containing objects
  46188. */
  46189. blocks: Array<OctreeBlock<T>>;
  46190. /**
  46191. * Content stored in the octree
  46192. */
  46193. dynamicContent: T[];
  46194. private _maxBlockCapacity;
  46195. private _selectionContent;
  46196. private _creationFunc;
  46197. /**
  46198. * Creates a octree
  46199. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46200. * @param creationFunc function to be used to instatiate the octree
  46201. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46202. * @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.)
  46203. */
  46204. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46205. /** 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.) */
  46206. maxDepth?: number);
  46207. /**
  46208. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46209. * @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);
  46210. * @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);
  46211. * @param entries meshes to be added to the octree blocks
  46212. */
  46213. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46214. /**
  46215. * Adds a mesh to the octree
  46216. * @param entry Mesh to add to the octree
  46217. */
  46218. addMesh(entry: T): void;
  46219. /**
  46220. * Remove an element from the octree
  46221. * @param entry defines the element to remove
  46222. */
  46223. removeMesh(entry: T): void;
  46224. /**
  46225. * Selects an array of meshes within the frustum
  46226. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46227. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46228. * @returns array of meshes within the frustum
  46229. */
  46230. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46231. /**
  46232. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46233. * @param sphereCenter defines the bounding sphere center
  46234. * @param sphereRadius defines the bounding sphere radius
  46235. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46236. * @returns an array of objects that intersect the sphere
  46237. */
  46238. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46239. /**
  46240. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46241. * @param ray defines the ray to test with
  46242. * @returns array of intersected objects
  46243. */
  46244. intersectsRay(ray: Ray): SmartArray<T>;
  46245. /**
  46246. * Adds a mesh into the octree block if it intersects the block
  46247. */
  46248. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46249. /**
  46250. * Adds a submesh into the octree block if it intersects the block
  46251. */
  46252. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46253. }
  46254. }
  46255. declare module BABYLON {
  46256. interface Scene {
  46257. /**
  46258. * @hidden
  46259. * Backing Filed
  46260. */
  46261. _selectionOctree: Octree<AbstractMesh>;
  46262. /**
  46263. * Gets the octree used to boost mesh selection (picking)
  46264. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46265. */
  46266. selectionOctree: Octree<AbstractMesh>;
  46267. /**
  46268. * Creates or updates the octree used to boost selection (picking)
  46269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46270. * @param maxCapacity defines the maximum capacity per leaf
  46271. * @param maxDepth defines the maximum depth of the octree
  46272. * @returns an octree of AbstractMesh
  46273. */
  46274. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46275. }
  46276. interface AbstractMesh {
  46277. /**
  46278. * @hidden
  46279. * Backing Field
  46280. */
  46281. _submeshesOctree: Octree<SubMesh>;
  46282. /**
  46283. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46284. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46285. * @param maxCapacity defines the maximum size of each block (64 by default)
  46286. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46287. * @returns the new octree
  46288. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46289. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46290. */
  46291. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46292. }
  46293. /**
  46294. * Defines the octree scene component responsible to manage any octrees
  46295. * in a given scene.
  46296. */
  46297. export class OctreeSceneComponent {
  46298. /**
  46299. * The component name help to identify the component in the list of scene components.
  46300. */
  46301. readonly name: string;
  46302. /**
  46303. * The scene the component belongs to.
  46304. */
  46305. scene: Scene;
  46306. /**
  46307. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46308. */
  46309. readonly checksIsEnabled: boolean;
  46310. /**
  46311. * Creates a new instance of the component for the given scene
  46312. * @param scene Defines the scene to register the component in
  46313. */
  46314. constructor(scene: Scene);
  46315. /**
  46316. * Registers the component in a given scene
  46317. */
  46318. register(): void;
  46319. /**
  46320. * Return the list of active meshes
  46321. * @returns the list of active meshes
  46322. */
  46323. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46324. /**
  46325. * Return the list of active sub meshes
  46326. * @param mesh The mesh to get the candidates sub meshes from
  46327. * @returns the list of active sub meshes
  46328. */
  46329. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46330. private _tempRay;
  46331. /**
  46332. * Return the list of sub meshes intersecting with a given local ray
  46333. * @param mesh defines the mesh to find the submesh for
  46334. * @param localRay defines the ray in local space
  46335. * @returns the list of intersecting sub meshes
  46336. */
  46337. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46338. /**
  46339. * Return the list of sub meshes colliding with a collider
  46340. * @param mesh defines the mesh to find the submesh for
  46341. * @param collider defines the collider to evaluate the collision against
  46342. * @returns the list of colliding sub meshes
  46343. */
  46344. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46345. /**
  46346. * Rebuilds the elements related to this component in case of
  46347. * context lost for instance.
  46348. */
  46349. rebuild(): void;
  46350. /**
  46351. * Disposes the component and the associated ressources.
  46352. */
  46353. dispose(): void;
  46354. }
  46355. }
  46356. declare module BABYLON {
  46357. /**
  46358. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46359. */
  46360. export class Gizmo implements IDisposable {
  46361. /** The utility layer the gizmo will be added to */
  46362. gizmoLayer: UtilityLayerRenderer;
  46363. /**
  46364. * The root mesh of the gizmo
  46365. */
  46366. _rootMesh: Mesh;
  46367. private _attachedMesh;
  46368. /**
  46369. * Ratio for the scale of the gizmo (Default: 1)
  46370. */
  46371. scaleRatio: number;
  46372. /**
  46373. * If a custom mesh has been set (Default: false)
  46374. */
  46375. protected _customMeshSet: boolean;
  46376. /**
  46377. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46378. * * When set, interactions will be enabled
  46379. */
  46380. get attachedMesh(): Nullable<AbstractMesh>;
  46381. set attachedMesh(value: Nullable<AbstractMesh>);
  46382. /**
  46383. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46384. * @param mesh The mesh to replace the default mesh of the gizmo
  46385. */
  46386. setCustomMesh(mesh: Mesh): void;
  46387. /**
  46388. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46389. */
  46390. updateGizmoRotationToMatchAttachedMesh: boolean;
  46391. /**
  46392. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46393. */
  46394. updateGizmoPositionToMatchAttachedMesh: boolean;
  46395. /**
  46396. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46397. */
  46398. updateScale: boolean;
  46399. protected _interactionsEnabled: boolean;
  46400. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46401. private _beforeRenderObserver;
  46402. private _tempVector;
  46403. /**
  46404. * Creates a gizmo
  46405. * @param gizmoLayer The utility layer the gizmo will be added to
  46406. */
  46407. constructor(
  46408. /** The utility layer the gizmo will be added to */
  46409. gizmoLayer?: UtilityLayerRenderer);
  46410. /**
  46411. * Updates the gizmo to match the attached mesh's position/rotation
  46412. */
  46413. protected _update(): void;
  46414. /**
  46415. * Disposes of the gizmo
  46416. */
  46417. dispose(): void;
  46418. }
  46419. }
  46420. declare module BABYLON {
  46421. /**
  46422. * Single plane drag gizmo
  46423. */
  46424. export class PlaneDragGizmo extends Gizmo {
  46425. /**
  46426. * Drag behavior responsible for the gizmos dragging interactions
  46427. */
  46428. dragBehavior: PointerDragBehavior;
  46429. private _pointerObserver;
  46430. /**
  46431. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46432. */
  46433. snapDistance: number;
  46434. /**
  46435. * Event that fires each time the gizmo snaps to a new location.
  46436. * * snapDistance is the the change in distance
  46437. */
  46438. onSnapObservable: Observable<{
  46439. snapDistance: number;
  46440. }>;
  46441. private _plane;
  46442. private _coloredMaterial;
  46443. private _hoverMaterial;
  46444. private _isEnabled;
  46445. private _parent;
  46446. /** @hidden */
  46447. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46448. /** @hidden */
  46449. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46450. /**
  46451. * Creates a PlaneDragGizmo
  46452. * @param gizmoLayer The utility layer the gizmo will be added to
  46453. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46454. * @param color The color of the gizmo
  46455. */
  46456. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46457. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46458. /**
  46459. * If the gizmo is enabled
  46460. */
  46461. set isEnabled(value: boolean);
  46462. get isEnabled(): boolean;
  46463. /**
  46464. * Disposes of the gizmo
  46465. */
  46466. dispose(): void;
  46467. }
  46468. }
  46469. declare module BABYLON {
  46470. /**
  46471. * Gizmo that enables dragging a mesh along 3 axis
  46472. */
  46473. export class PositionGizmo extends Gizmo {
  46474. /**
  46475. * Internal gizmo used for interactions on the x axis
  46476. */
  46477. xGizmo: AxisDragGizmo;
  46478. /**
  46479. * Internal gizmo used for interactions on the y axis
  46480. */
  46481. yGizmo: AxisDragGizmo;
  46482. /**
  46483. * Internal gizmo used for interactions on the z axis
  46484. */
  46485. zGizmo: AxisDragGizmo;
  46486. /**
  46487. * Internal gizmo used for interactions on the yz plane
  46488. */
  46489. xPlaneGizmo: PlaneDragGizmo;
  46490. /**
  46491. * Internal gizmo used for interactions on the xz plane
  46492. */
  46493. yPlaneGizmo: PlaneDragGizmo;
  46494. /**
  46495. * Internal gizmo used for interactions on the xy plane
  46496. */
  46497. zPlaneGizmo: PlaneDragGizmo;
  46498. /**
  46499. * private variables
  46500. */
  46501. private _meshAttached;
  46502. private _updateGizmoRotationToMatchAttachedMesh;
  46503. private _snapDistance;
  46504. private _scaleRatio;
  46505. /** Fires an event when any of it's sub gizmos are dragged */
  46506. onDragStartObservable: Observable<unknown>;
  46507. /** Fires an event when any of it's sub gizmos are released from dragging */
  46508. onDragEndObservable: Observable<unknown>;
  46509. /**
  46510. * If set to true, planar drag is enabled
  46511. */
  46512. private _planarGizmoEnabled;
  46513. get attachedMesh(): Nullable<AbstractMesh>;
  46514. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46515. /**
  46516. * Creates a PositionGizmo
  46517. * @param gizmoLayer The utility layer the gizmo will be added to
  46518. */
  46519. constructor(gizmoLayer?: UtilityLayerRenderer);
  46520. /**
  46521. * If the planar drag gizmo is enabled
  46522. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46523. */
  46524. set planarGizmoEnabled(value: boolean);
  46525. get planarGizmoEnabled(): boolean;
  46526. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46527. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46528. /**
  46529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46530. */
  46531. set snapDistance(value: number);
  46532. get snapDistance(): number;
  46533. /**
  46534. * Ratio for the scale of the gizmo (Default: 1)
  46535. */
  46536. set scaleRatio(value: number);
  46537. get scaleRatio(): number;
  46538. /**
  46539. * Disposes of the gizmo
  46540. */
  46541. dispose(): void;
  46542. /**
  46543. * CustomMeshes are not supported by this gizmo
  46544. * @param mesh The mesh to replace the default mesh of the gizmo
  46545. */
  46546. setCustomMesh(mesh: Mesh): void;
  46547. }
  46548. }
  46549. declare module BABYLON {
  46550. /**
  46551. * Single axis drag gizmo
  46552. */
  46553. export class AxisDragGizmo extends Gizmo {
  46554. /**
  46555. * Drag behavior responsible for the gizmos dragging interactions
  46556. */
  46557. dragBehavior: PointerDragBehavior;
  46558. private _pointerObserver;
  46559. /**
  46560. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46561. */
  46562. snapDistance: number;
  46563. /**
  46564. * Event that fires each time the gizmo snaps to a new location.
  46565. * * snapDistance is the the change in distance
  46566. */
  46567. onSnapObservable: Observable<{
  46568. snapDistance: number;
  46569. }>;
  46570. private _isEnabled;
  46571. private _parent;
  46572. private _arrow;
  46573. private _coloredMaterial;
  46574. private _hoverMaterial;
  46575. /** @hidden */
  46576. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46577. /** @hidden */
  46578. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46579. /**
  46580. * Creates an AxisDragGizmo
  46581. * @param gizmoLayer The utility layer the gizmo will be added to
  46582. * @param dragAxis The axis which the gizmo will be able to drag on
  46583. * @param color The color of the gizmo
  46584. */
  46585. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46586. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46587. /**
  46588. * If the gizmo is enabled
  46589. */
  46590. set isEnabled(value: boolean);
  46591. get isEnabled(): boolean;
  46592. /**
  46593. * Disposes of the gizmo
  46594. */
  46595. dispose(): void;
  46596. }
  46597. }
  46598. declare module BABYLON.Debug {
  46599. /**
  46600. * The Axes viewer will show 3 axes in a specific point in space
  46601. */
  46602. export class AxesViewer {
  46603. private _xAxis;
  46604. private _yAxis;
  46605. private _zAxis;
  46606. private _scaleLinesFactor;
  46607. private _instanced;
  46608. /**
  46609. * Gets the hosting scene
  46610. */
  46611. scene: Scene;
  46612. /**
  46613. * Gets or sets a number used to scale line length
  46614. */
  46615. scaleLines: number;
  46616. /** Gets the node hierarchy used to render x-axis */
  46617. get xAxis(): TransformNode;
  46618. /** Gets the node hierarchy used to render y-axis */
  46619. get yAxis(): TransformNode;
  46620. /** Gets the node hierarchy used to render z-axis */
  46621. get zAxis(): TransformNode;
  46622. /**
  46623. * Creates a new AxesViewer
  46624. * @param scene defines the hosting scene
  46625. * @param scaleLines defines a number used to scale line length (1 by default)
  46626. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46627. * @param xAxis defines the node hierarchy used to render the x-axis
  46628. * @param yAxis defines the node hierarchy used to render the y-axis
  46629. * @param zAxis defines the node hierarchy used to render the z-axis
  46630. */
  46631. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46632. /**
  46633. * Force the viewer to update
  46634. * @param position defines the position of the viewer
  46635. * @param xaxis defines the x axis of the viewer
  46636. * @param yaxis defines the y axis of the viewer
  46637. * @param zaxis defines the z axis of the viewer
  46638. */
  46639. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46640. /**
  46641. * Creates an instance of this axes viewer.
  46642. * @returns a new axes viewer with instanced meshes
  46643. */
  46644. createInstance(): AxesViewer;
  46645. /** Releases resources */
  46646. dispose(): void;
  46647. private static _SetRenderingGroupId;
  46648. }
  46649. }
  46650. declare module BABYLON.Debug {
  46651. /**
  46652. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46653. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46654. */
  46655. export class BoneAxesViewer extends AxesViewer {
  46656. /**
  46657. * Gets or sets the target mesh where to display the axes viewer
  46658. */
  46659. mesh: Nullable<Mesh>;
  46660. /**
  46661. * Gets or sets the target bone where to display the axes viewer
  46662. */
  46663. bone: Nullable<Bone>;
  46664. /** Gets current position */
  46665. pos: Vector3;
  46666. /** Gets direction of X axis */
  46667. xaxis: Vector3;
  46668. /** Gets direction of Y axis */
  46669. yaxis: Vector3;
  46670. /** Gets direction of Z axis */
  46671. zaxis: Vector3;
  46672. /**
  46673. * Creates a new BoneAxesViewer
  46674. * @param scene defines the hosting scene
  46675. * @param bone defines the target bone
  46676. * @param mesh defines the target mesh
  46677. * @param scaleLines defines a scaling factor for line length (1 by default)
  46678. */
  46679. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46680. /**
  46681. * Force the viewer to update
  46682. */
  46683. update(): void;
  46684. /** Releases resources */
  46685. dispose(): void;
  46686. }
  46687. }
  46688. declare module BABYLON {
  46689. /**
  46690. * Interface used to define scene explorer extensibility option
  46691. */
  46692. export interface IExplorerExtensibilityOption {
  46693. /**
  46694. * Define the option label
  46695. */
  46696. label: string;
  46697. /**
  46698. * Defines the action to execute on click
  46699. */
  46700. action: (entity: any) => void;
  46701. }
  46702. /**
  46703. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46704. */
  46705. export interface IExplorerExtensibilityGroup {
  46706. /**
  46707. * Defines a predicate to test if a given type mut be extended
  46708. */
  46709. predicate: (entity: any) => boolean;
  46710. /**
  46711. * Gets the list of options added to a type
  46712. */
  46713. entries: IExplorerExtensibilityOption[];
  46714. }
  46715. /**
  46716. * Interface used to define the options to use to create the Inspector
  46717. */
  46718. export interface IInspectorOptions {
  46719. /**
  46720. * Display in overlay mode (default: false)
  46721. */
  46722. overlay?: boolean;
  46723. /**
  46724. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46725. */
  46726. globalRoot?: HTMLElement;
  46727. /**
  46728. * Display the Scene explorer
  46729. */
  46730. showExplorer?: boolean;
  46731. /**
  46732. * Display the property inspector
  46733. */
  46734. showInspector?: boolean;
  46735. /**
  46736. * Display in embed mode (both panes on the right)
  46737. */
  46738. embedMode?: boolean;
  46739. /**
  46740. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46741. */
  46742. handleResize?: boolean;
  46743. /**
  46744. * Allow the panes to popup (default: true)
  46745. */
  46746. enablePopup?: boolean;
  46747. /**
  46748. * Allow the panes to be closed by users (default: true)
  46749. */
  46750. enableClose?: boolean;
  46751. /**
  46752. * Optional list of extensibility entries
  46753. */
  46754. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46755. /**
  46756. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46757. */
  46758. inspectorURL?: string;
  46759. /**
  46760. * Optional initial tab (default to DebugLayerTab.Properties)
  46761. */
  46762. initialTab?: DebugLayerTab;
  46763. }
  46764. interface Scene {
  46765. /**
  46766. * @hidden
  46767. * Backing field
  46768. */
  46769. _debugLayer: DebugLayer;
  46770. /**
  46771. * Gets the debug layer (aka Inspector) associated with the scene
  46772. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46773. */
  46774. debugLayer: DebugLayer;
  46775. }
  46776. /**
  46777. * Enum of inspector action tab
  46778. */
  46779. export enum DebugLayerTab {
  46780. /**
  46781. * Properties tag (default)
  46782. */
  46783. Properties = 0,
  46784. /**
  46785. * Debug tab
  46786. */
  46787. Debug = 1,
  46788. /**
  46789. * Statistics tab
  46790. */
  46791. Statistics = 2,
  46792. /**
  46793. * Tools tab
  46794. */
  46795. Tools = 3,
  46796. /**
  46797. * Settings tab
  46798. */
  46799. Settings = 4
  46800. }
  46801. /**
  46802. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46803. * what is happening in your scene
  46804. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46805. */
  46806. export class DebugLayer {
  46807. /**
  46808. * Define the url to get the inspector script from.
  46809. * By default it uses the babylonjs CDN.
  46810. * @ignoreNaming
  46811. */
  46812. static InspectorURL: string;
  46813. private _scene;
  46814. private BJSINSPECTOR;
  46815. private _onPropertyChangedObservable?;
  46816. /**
  46817. * Observable triggered when a property is changed through the inspector.
  46818. */
  46819. get onPropertyChangedObservable(): any;
  46820. /**
  46821. * Instantiates a new debug layer.
  46822. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46823. * what is happening in your scene
  46824. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46825. * @param scene Defines the scene to inspect
  46826. */
  46827. constructor(scene: Scene);
  46828. /** Creates the inspector window. */
  46829. private _createInspector;
  46830. /**
  46831. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46832. * @param entity defines the entity to select
  46833. * @param lineContainerTitle defines the specific block to highlight
  46834. */
  46835. select(entity: any, lineContainerTitle?: string): void;
  46836. /** Get the inspector from bundle or global */
  46837. private _getGlobalInspector;
  46838. /**
  46839. * Get if the inspector is visible or not.
  46840. * @returns true if visible otherwise, false
  46841. */
  46842. isVisible(): boolean;
  46843. /**
  46844. * Hide the inspector and close its window.
  46845. */
  46846. hide(): void;
  46847. /**
  46848. * Update the scene in the inspector
  46849. */
  46850. setAsActiveScene(): void;
  46851. /**
  46852. * Launch the debugLayer.
  46853. * @param config Define the configuration of the inspector
  46854. * @return a promise fulfilled when the debug layer is visible
  46855. */
  46856. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46857. }
  46858. }
  46859. declare module BABYLON {
  46860. /**
  46861. * Class containing static functions to help procedurally build meshes
  46862. */
  46863. export class BoxBuilder {
  46864. /**
  46865. * Creates a box mesh
  46866. * * The parameter `size` sets the size (float) of each box side (default 1)
  46867. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46868. * * 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)
  46869. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46871. * * 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
  46872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46873. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46874. * @param name defines the name of the mesh
  46875. * @param options defines the options used to create the mesh
  46876. * @param scene defines the hosting scene
  46877. * @returns the box mesh
  46878. */
  46879. static CreateBox(name: string, options: {
  46880. size?: number;
  46881. width?: number;
  46882. height?: number;
  46883. depth?: number;
  46884. faceUV?: Vector4[];
  46885. faceColors?: Color4[];
  46886. sideOrientation?: number;
  46887. frontUVs?: Vector4;
  46888. backUVs?: Vector4;
  46889. wrap?: boolean;
  46890. topBaseAt?: number;
  46891. bottomBaseAt?: number;
  46892. updatable?: boolean;
  46893. }, scene?: Nullable<Scene>): Mesh;
  46894. }
  46895. }
  46896. declare module BABYLON.Debug {
  46897. /**
  46898. * Used to show the physics impostor around the specific mesh
  46899. */
  46900. export class PhysicsViewer {
  46901. /** @hidden */
  46902. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46903. /** @hidden */
  46904. protected _meshes: Array<Nullable<AbstractMesh>>;
  46905. /** @hidden */
  46906. protected _scene: Nullable<Scene>;
  46907. /** @hidden */
  46908. protected _numMeshes: number;
  46909. /** @hidden */
  46910. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46911. private _renderFunction;
  46912. private _utilityLayer;
  46913. private _debugBoxMesh;
  46914. private _debugSphereMesh;
  46915. private _debugCylinderMesh;
  46916. private _debugMaterial;
  46917. private _debugMeshMeshes;
  46918. /**
  46919. * Creates a new PhysicsViewer
  46920. * @param scene defines the hosting scene
  46921. */
  46922. constructor(scene: Scene);
  46923. /** @hidden */
  46924. protected _updateDebugMeshes(): void;
  46925. /**
  46926. * Renders a specified physic impostor
  46927. * @param impostor defines the impostor to render
  46928. * @param targetMesh defines the mesh represented by the impostor
  46929. * @returns the new debug mesh used to render the impostor
  46930. */
  46931. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46932. /**
  46933. * Hides a specified physic impostor
  46934. * @param impostor defines the impostor to hide
  46935. */
  46936. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46937. private _getDebugMaterial;
  46938. private _getDebugBoxMesh;
  46939. private _getDebugSphereMesh;
  46940. private _getDebugCylinderMesh;
  46941. private _getDebugMeshMesh;
  46942. private _getDebugMesh;
  46943. /** Releases all resources */
  46944. dispose(): void;
  46945. }
  46946. }
  46947. declare module BABYLON {
  46948. /**
  46949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46950. * in order to better appreciate the issue one might have.
  46951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46952. */
  46953. export class RayHelper {
  46954. /**
  46955. * Defines the ray we are currently tryin to visualize.
  46956. */
  46957. ray: Nullable<Ray>;
  46958. private _renderPoints;
  46959. private _renderLine;
  46960. private _renderFunction;
  46961. private _scene;
  46962. private _updateToMeshFunction;
  46963. private _attachedToMesh;
  46964. private _meshSpaceDirection;
  46965. private _meshSpaceOrigin;
  46966. /**
  46967. * Helper function to create a colored helper in a scene in one line.
  46968. * @param ray Defines the ray we are currently tryin to visualize
  46969. * @param scene Defines the scene the ray is used in
  46970. * @param color Defines the color we want to see the ray in
  46971. * @returns The newly created ray helper.
  46972. */
  46973. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46974. /**
  46975. * Instantiate a new ray helper.
  46976. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46977. * in order to better appreciate the issue one might have.
  46978. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46979. * @param ray Defines the ray we are currently tryin to visualize
  46980. */
  46981. constructor(ray: Ray);
  46982. /**
  46983. * Shows the ray we are willing to debug.
  46984. * @param scene Defines the scene the ray needs to be rendered in
  46985. * @param color Defines the color the ray needs to be rendered in
  46986. */
  46987. show(scene: Scene, color?: Color3): void;
  46988. /**
  46989. * Hides the ray we are debugging.
  46990. */
  46991. hide(): void;
  46992. private _render;
  46993. /**
  46994. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46995. * @param mesh Defines the mesh we want the helper attached to
  46996. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46997. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46998. * @param length Defines the length of the ray
  46999. */
  47000. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47001. /**
  47002. * Detach the ray helper from the mesh it has previously been attached to.
  47003. */
  47004. detachFromMesh(): void;
  47005. private _updateToMesh;
  47006. /**
  47007. * Dispose the helper and release its associated resources.
  47008. */
  47009. dispose(): void;
  47010. }
  47011. }
  47012. declare module BABYLON.Debug {
  47013. /**
  47014. * Class used to render a debug view of a given skeleton
  47015. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47016. */
  47017. export class SkeletonViewer {
  47018. /** defines the skeleton to render */
  47019. skeleton: Skeleton;
  47020. /** defines the mesh attached to the skeleton */
  47021. mesh: AbstractMesh;
  47022. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47023. autoUpdateBonesMatrices: boolean;
  47024. /** defines the rendering group id to use with the viewer */
  47025. renderingGroupId: number;
  47026. /** Gets or sets the color used to render the skeleton */
  47027. color: Color3;
  47028. private _scene;
  47029. private _debugLines;
  47030. private _debugMesh;
  47031. private _isEnabled;
  47032. private _renderFunction;
  47033. private _utilityLayer;
  47034. /**
  47035. * Returns the mesh used to render the bones
  47036. */
  47037. get debugMesh(): Nullable<LinesMesh>;
  47038. /**
  47039. * Creates a new SkeletonViewer
  47040. * @param skeleton defines the skeleton to render
  47041. * @param mesh defines the mesh attached to the skeleton
  47042. * @param scene defines the hosting scene
  47043. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47044. * @param renderingGroupId defines the rendering group id to use with the viewer
  47045. */
  47046. constructor(
  47047. /** defines the skeleton to render */
  47048. skeleton: Skeleton,
  47049. /** defines the mesh attached to the skeleton */
  47050. mesh: AbstractMesh, scene: Scene,
  47051. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47052. autoUpdateBonesMatrices?: boolean,
  47053. /** defines the rendering group id to use with the viewer */
  47054. renderingGroupId?: number);
  47055. /** Gets or sets a boolean indicating if the viewer is enabled */
  47056. set isEnabled(value: boolean);
  47057. get isEnabled(): boolean;
  47058. private _getBonePosition;
  47059. private _getLinesForBonesWithLength;
  47060. private _getLinesForBonesNoLength;
  47061. /** Update the viewer to sync with current skeleton state */
  47062. update(): void;
  47063. /** Release associated resources */
  47064. dispose(): void;
  47065. }
  47066. }
  47067. declare module BABYLON {
  47068. /**
  47069. * This class will take all inputs from Keyboard, Pointer, and
  47070. * any Gamepads and provide a polling system that all devices
  47071. * will use. This class assumes that there will only be one
  47072. * pointer device and one keyboard.
  47073. */
  47074. export class DeviceInputSystem implements IDisposable {
  47075. /** POINTER_DEVICE */
  47076. static readonly POINTER_DEVICE: string;
  47077. /** KEYBOARD_DEVICE */
  47078. static readonly KEYBOARD_DEVICE: string;
  47079. /**
  47080. * Observable to be triggered when a device is connected
  47081. */
  47082. onDeviceConnectedObservable: Observable<string>;
  47083. /**
  47084. * Observable to be triggered when a device is disconnected
  47085. */
  47086. onDeviceDisconnectedObservable: Observable<string>;
  47087. private _inputs;
  47088. private _gamepads;
  47089. private _keyboardActive;
  47090. private _pointerActive;
  47091. private _elementToAttachTo;
  47092. private _keyboardDownEvent;
  47093. private _keyboardUpEvent;
  47094. private _pointerMoveEvent;
  47095. private _pointerDownEvent;
  47096. private _pointerUpEvent;
  47097. private _gamepadConnectedEvent;
  47098. private _gamepadDisconnectedEvent;
  47099. private static _MAX_KEYCODES;
  47100. private static _MAX_POINTER_INPUTS;
  47101. /**
  47102. * Default Constructor
  47103. * @param engine - engine to pull input element from
  47104. */
  47105. constructor(engine: Engine);
  47106. /**
  47107. * Checks for current device input value, given an id and input index
  47108. * @param deviceName Id of connected device
  47109. * @param inputIndex Index of device input
  47110. * @returns Current value of input
  47111. */
  47112. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  47113. /**
  47114. * Dispose of all the eventlisteners and clears the observables
  47115. */
  47116. dispose(): void;
  47117. /**
  47118. * Add device and inputs to device map
  47119. * @param deviceName Assigned name of device (may be SN)
  47120. * @param numberOfInputs Number of input entries to create for given device
  47121. */
  47122. private _registerDevice;
  47123. /**
  47124. * Given a specific device name, remove that device from the device map
  47125. * @param deviceName Name of device to be removed
  47126. */
  47127. private _unregisterDevice;
  47128. /**
  47129. * Handle all actions that come from keyboard interaction
  47130. */
  47131. private _handleKeyActions;
  47132. /**
  47133. * Handle all actions that come from pointer interaction
  47134. */
  47135. private _handlePointerActions;
  47136. /**
  47137. * Handle all actions that come from gamepad interaction
  47138. */
  47139. private _handleGamepadActions;
  47140. /**
  47141. * Update all non-event based devices with each frame
  47142. */
  47143. private _updateDevice;
  47144. }
  47145. }
  47146. declare module BABYLON {
  47147. /**
  47148. * Options to create the null engine
  47149. */
  47150. export class NullEngineOptions {
  47151. /**
  47152. * Render width (Default: 512)
  47153. */
  47154. renderWidth: number;
  47155. /**
  47156. * Render height (Default: 256)
  47157. */
  47158. renderHeight: number;
  47159. /**
  47160. * Texture size (Default: 512)
  47161. */
  47162. textureSize: number;
  47163. /**
  47164. * If delta time between frames should be constant
  47165. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47166. */
  47167. deterministicLockstep: boolean;
  47168. /**
  47169. * Maximum about of steps between frames (Default: 4)
  47170. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47171. */
  47172. lockstepMaxSteps: number;
  47173. }
  47174. /**
  47175. * The null engine class provides support for headless version of babylon.js.
  47176. * This can be used in server side scenario or for testing purposes
  47177. */
  47178. export class NullEngine extends Engine {
  47179. private _options;
  47180. /**
  47181. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47183. * @returns true if engine is in deterministic lock step mode
  47184. */
  47185. isDeterministicLockStep(): boolean;
  47186. /**
  47187. * Gets the max steps when engine is running in deterministic lock step
  47188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47189. * @returns the max steps
  47190. */
  47191. getLockstepMaxSteps(): number;
  47192. /**
  47193. * Gets the current hardware scaling level.
  47194. * By default the hardware scaling level is computed from the window device ratio.
  47195. * 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.
  47196. * @returns a number indicating the current hardware scaling level
  47197. */
  47198. getHardwareScalingLevel(): number;
  47199. constructor(options?: NullEngineOptions);
  47200. /**
  47201. * Creates a vertex buffer
  47202. * @param vertices the data for the vertex buffer
  47203. * @returns the new WebGL static buffer
  47204. */
  47205. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47206. /**
  47207. * Creates a new index buffer
  47208. * @param indices defines the content of the index buffer
  47209. * @param updatable defines if the index buffer must be updatable
  47210. * @returns a new webGL buffer
  47211. */
  47212. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47213. /**
  47214. * Clear the current render buffer or the current render target (if any is set up)
  47215. * @param color defines the color to use
  47216. * @param backBuffer defines if the back buffer must be cleared
  47217. * @param depth defines if the depth buffer must be cleared
  47218. * @param stencil defines if the stencil buffer must be cleared
  47219. */
  47220. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47221. /**
  47222. * Gets the current render width
  47223. * @param useScreen defines if screen size must be used (or the current render target if any)
  47224. * @returns a number defining the current render width
  47225. */
  47226. getRenderWidth(useScreen?: boolean): number;
  47227. /**
  47228. * Gets the current render height
  47229. * @param useScreen defines if screen size must be used (or the current render target if any)
  47230. * @returns a number defining the current render height
  47231. */
  47232. getRenderHeight(useScreen?: boolean): number;
  47233. /**
  47234. * Set the WebGL's viewport
  47235. * @param viewport defines the viewport element to be used
  47236. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47237. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47238. */
  47239. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47240. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47241. /**
  47242. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47243. * @param pipelineContext defines the pipeline context to use
  47244. * @param uniformsNames defines the list of uniform names
  47245. * @returns an array of webGL uniform locations
  47246. */
  47247. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47248. /**
  47249. * Gets the lsit of active attributes for a given webGL program
  47250. * @param pipelineContext defines the pipeline context to use
  47251. * @param attributesNames defines the list of attribute names to get
  47252. * @returns an array of indices indicating the offset of each attribute
  47253. */
  47254. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47255. /**
  47256. * Binds an effect to the webGL context
  47257. * @param effect defines the effect to bind
  47258. */
  47259. bindSamplers(effect: Effect): void;
  47260. /**
  47261. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47262. * @param effect defines the effect to activate
  47263. */
  47264. enableEffect(effect: Effect): void;
  47265. /**
  47266. * Set various states to the webGL context
  47267. * @param culling defines backface culling state
  47268. * @param zOffset defines the value to apply to zOffset (0 by default)
  47269. * @param force defines if states must be applied even if cache is up to date
  47270. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47271. */
  47272. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47273. /**
  47274. * Set the value of an uniform to an array of int32
  47275. * @param uniform defines the webGL uniform location where to store the value
  47276. * @param array defines the array of int32 to store
  47277. */
  47278. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47279. /**
  47280. * Set the value of an uniform to an array of int32 (stored as vec2)
  47281. * @param uniform defines the webGL uniform location where to store the value
  47282. * @param array defines the array of int32 to store
  47283. */
  47284. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47285. /**
  47286. * Set the value of an uniform to an array of int32 (stored as vec3)
  47287. * @param uniform defines the webGL uniform location where to store the value
  47288. * @param array defines the array of int32 to store
  47289. */
  47290. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47291. /**
  47292. * Set the value of an uniform to an array of int32 (stored as vec4)
  47293. * @param uniform defines the webGL uniform location where to store the value
  47294. * @param array defines the array of int32 to store
  47295. */
  47296. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47297. /**
  47298. * Set the value of an uniform to an array of float32
  47299. * @param uniform defines the webGL uniform location where to store the value
  47300. * @param array defines the array of float32 to store
  47301. */
  47302. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47303. /**
  47304. * Set the value of an uniform to an array of float32 (stored as vec2)
  47305. * @param uniform defines the webGL uniform location where to store the value
  47306. * @param array defines the array of float32 to store
  47307. */
  47308. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47309. /**
  47310. * Set the value of an uniform to an array of float32 (stored as vec3)
  47311. * @param uniform defines the webGL uniform location where to store the value
  47312. * @param array defines the array of float32 to store
  47313. */
  47314. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47315. /**
  47316. * Set the value of an uniform to an array of float32 (stored as vec4)
  47317. * @param uniform defines the webGL uniform location where to store the value
  47318. * @param array defines the array of float32 to store
  47319. */
  47320. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47321. /**
  47322. * Set the value of an uniform to an array of number
  47323. * @param uniform defines the webGL uniform location where to store the value
  47324. * @param array defines the array of number to store
  47325. */
  47326. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47327. /**
  47328. * Set the value of an uniform to an array of number (stored as vec2)
  47329. * @param uniform defines the webGL uniform location where to store the value
  47330. * @param array defines the array of number to store
  47331. */
  47332. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47333. /**
  47334. * Set the value of an uniform to an array of number (stored as vec3)
  47335. * @param uniform defines the webGL uniform location where to store the value
  47336. * @param array defines the array of number to store
  47337. */
  47338. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47339. /**
  47340. * Set the value of an uniform to an array of number (stored as vec4)
  47341. * @param uniform defines the webGL uniform location where to store the value
  47342. * @param array defines the array of number to store
  47343. */
  47344. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47345. /**
  47346. * Set the value of an uniform to an array of float32 (stored as matrices)
  47347. * @param uniform defines the webGL uniform location where to store the value
  47348. * @param matrices defines the array of float32 to store
  47349. */
  47350. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47351. /**
  47352. * Set the value of an uniform to a matrix (3x3)
  47353. * @param uniform defines the webGL uniform location where to store the value
  47354. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47355. */
  47356. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47357. /**
  47358. * Set the value of an uniform to a matrix (2x2)
  47359. * @param uniform defines the webGL uniform location where to store the value
  47360. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47361. */
  47362. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47363. /**
  47364. * Set the value of an uniform to a number (float)
  47365. * @param uniform defines the webGL uniform location where to store the value
  47366. * @param value defines the float number to store
  47367. */
  47368. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47369. /**
  47370. * Set the value of an uniform to a vec2
  47371. * @param uniform defines the webGL uniform location where to store the value
  47372. * @param x defines the 1st component of the value
  47373. * @param y defines the 2nd component of the value
  47374. */
  47375. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47376. /**
  47377. * Set the value of an uniform to a vec3
  47378. * @param uniform defines the webGL uniform location where to store the value
  47379. * @param x defines the 1st component of the value
  47380. * @param y defines the 2nd component of the value
  47381. * @param z defines the 3rd component of the value
  47382. */
  47383. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47384. /**
  47385. * Set the value of an uniform to a boolean
  47386. * @param uniform defines the webGL uniform location where to store the value
  47387. * @param bool defines the boolean to store
  47388. */
  47389. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47390. /**
  47391. * Set the value of an uniform to a vec4
  47392. * @param uniform defines the webGL uniform location where to store the value
  47393. * @param x defines the 1st component of the value
  47394. * @param y defines the 2nd component of the value
  47395. * @param z defines the 3rd component of the value
  47396. * @param w defines the 4th component of the value
  47397. */
  47398. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47399. /**
  47400. * Sets the current alpha mode
  47401. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47402. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47404. */
  47405. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47406. /**
  47407. * Bind webGl buffers directly to the webGL context
  47408. * @param vertexBuffers defines the vertex buffer to bind
  47409. * @param indexBuffer defines the index buffer to bind
  47410. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47411. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47412. * @param effect defines the effect associated with the vertex buffer
  47413. */
  47414. bindBuffers(vertexBuffers: {
  47415. [key: string]: VertexBuffer;
  47416. }, indexBuffer: DataBuffer, effect: Effect): void;
  47417. /**
  47418. * Force the entire cache to be cleared
  47419. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47420. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47421. */
  47422. wipeCaches(bruteForce?: boolean): void;
  47423. /**
  47424. * Send a draw order
  47425. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47426. * @param indexStart defines the starting index
  47427. * @param indexCount defines the number of index to draw
  47428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47429. */
  47430. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47431. /**
  47432. * Draw a list of indexed primitives
  47433. * @param fillMode defines the primitive to use
  47434. * @param indexStart defines the starting index
  47435. * @param indexCount defines the number of index to draw
  47436. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47437. */
  47438. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47439. /**
  47440. * Draw a list of unindexed primitives
  47441. * @param fillMode defines the primitive to use
  47442. * @param verticesStart defines the index of first vertex to draw
  47443. * @param verticesCount defines the count of vertices to draw
  47444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47445. */
  47446. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47447. /** @hidden */
  47448. _createTexture(): WebGLTexture;
  47449. /** @hidden */
  47450. _releaseTexture(texture: InternalTexture): void;
  47451. /**
  47452. * Usually called from Texture.ts.
  47453. * Passed information to create a WebGLTexture
  47454. * @param urlArg defines a value which contains one of the following:
  47455. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47456. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47457. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47458. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47459. * @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)
  47460. * @param scene needed for loading to the correct scene
  47461. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47462. * @param onLoad optional callback to be called upon successful completion
  47463. * @param onError optional callback to be called upon failure
  47464. * @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
  47465. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47466. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47467. * @param forcedExtension defines the extension to use to pick the right loader
  47468. * @param mimeType defines an optional mime type
  47469. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47470. */
  47471. 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;
  47472. /**
  47473. * Creates a new render target texture
  47474. * @param size defines the size of the texture
  47475. * @param options defines the options used to create the texture
  47476. * @returns a new render target texture stored in an InternalTexture
  47477. */
  47478. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47479. /**
  47480. * Update the sampling mode of a given texture
  47481. * @param samplingMode defines the required sampling mode
  47482. * @param texture defines the texture to update
  47483. */
  47484. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47485. /**
  47486. * Binds the frame buffer to the specified texture.
  47487. * @param texture The texture to render to or null for the default canvas
  47488. * @param faceIndex The face of the texture to render to in case of cube texture
  47489. * @param requiredWidth The width of the target to render to
  47490. * @param requiredHeight The height of the target to render to
  47491. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47492. * @param lodLevel defines le lod level to bind to the frame buffer
  47493. */
  47494. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47495. /**
  47496. * Unbind the current render target texture from the webGL context
  47497. * @param texture defines the render target texture to unbind
  47498. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47499. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47500. */
  47501. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47502. /**
  47503. * Creates a dynamic vertex buffer
  47504. * @param vertices the data for the dynamic vertex buffer
  47505. * @returns the new WebGL dynamic buffer
  47506. */
  47507. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47508. /**
  47509. * Update the content of a dynamic texture
  47510. * @param texture defines the texture to update
  47511. * @param canvas defines the canvas containing the source
  47512. * @param invertY defines if data must be stored with Y axis inverted
  47513. * @param premulAlpha defines if alpha is stored as premultiplied
  47514. * @param format defines the format of the data
  47515. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47516. */
  47517. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47518. /**
  47519. * Gets a boolean indicating if all created effects are ready
  47520. * @returns true if all effects are ready
  47521. */
  47522. areAllEffectsReady(): boolean;
  47523. /**
  47524. * @hidden
  47525. * Get the current error code of the webGL context
  47526. * @returns the error code
  47527. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47528. */
  47529. getError(): number;
  47530. /** @hidden */
  47531. _getUnpackAlignement(): number;
  47532. /** @hidden */
  47533. _unpackFlipY(value: boolean): void;
  47534. /**
  47535. * Update a dynamic index buffer
  47536. * @param indexBuffer defines the target index buffer
  47537. * @param indices defines the data to update
  47538. * @param offset defines the offset in the target index buffer where update should start
  47539. */
  47540. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47541. /**
  47542. * Updates a dynamic vertex buffer.
  47543. * @param vertexBuffer the vertex buffer to update
  47544. * @param vertices the data used to update the vertex buffer
  47545. * @param byteOffset the byte offset of the data (optional)
  47546. * @param byteLength the byte length of the data (optional)
  47547. */
  47548. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47549. /** @hidden */
  47550. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47551. /** @hidden */
  47552. _bindTexture(channel: number, texture: InternalTexture): void;
  47553. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47554. /**
  47555. * 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
  47556. */
  47557. releaseEffects(): void;
  47558. displayLoadingUI(): void;
  47559. hideLoadingUI(): void;
  47560. /** @hidden */
  47561. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47562. /** @hidden */
  47563. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47564. /** @hidden */
  47565. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47566. /** @hidden */
  47567. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47568. }
  47569. }
  47570. declare module BABYLON {
  47571. /**
  47572. * @hidden
  47573. **/
  47574. export class _TimeToken {
  47575. _startTimeQuery: Nullable<WebGLQuery>;
  47576. _endTimeQuery: Nullable<WebGLQuery>;
  47577. _timeElapsedQuery: Nullable<WebGLQuery>;
  47578. _timeElapsedQueryEnded: boolean;
  47579. }
  47580. }
  47581. declare module BABYLON {
  47582. /** @hidden */
  47583. export class _OcclusionDataStorage {
  47584. /** @hidden */
  47585. occlusionInternalRetryCounter: number;
  47586. /** @hidden */
  47587. isOcclusionQueryInProgress: boolean;
  47588. /** @hidden */
  47589. isOccluded: boolean;
  47590. /** @hidden */
  47591. occlusionRetryCount: number;
  47592. /** @hidden */
  47593. occlusionType: number;
  47594. /** @hidden */
  47595. occlusionQueryAlgorithmType: number;
  47596. }
  47597. interface Engine {
  47598. /**
  47599. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47600. * @return the new query
  47601. */
  47602. createQuery(): WebGLQuery;
  47603. /**
  47604. * Delete and release a webGL query
  47605. * @param query defines the query to delete
  47606. * @return the current engine
  47607. */
  47608. deleteQuery(query: WebGLQuery): Engine;
  47609. /**
  47610. * Check if a given query has resolved and got its value
  47611. * @param query defines the query to check
  47612. * @returns true if the query got its value
  47613. */
  47614. isQueryResultAvailable(query: WebGLQuery): boolean;
  47615. /**
  47616. * Gets the value of a given query
  47617. * @param query defines the query to check
  47618. * @returns the value of the query
  47619. */
  47620. getQueryResult(query: WebGLQuery): number;
  47621. /**
  47622. * Initiates an occlusion query
  47623. * @param algorithmType defines the algorithm to use
  47624. * @param query defines the query to use
  47625. * @returns the current engine
  47626. * @see http://doc.babylonjs.com/features/occlusionquery
  47627. */
  47628. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47629. /**
  47630. * Ends an occlusion query
  47631. * @see http://doc.babylonjs.com/features/occlusionquery
  47632. * @param algorithmType defines the algorithm to use
  47633. * @returns the current engine
  47634. */
  47635. endOcclusionQuery(algorithmType: number): Engine;
  47636. /**
  47637. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47638. * Please note that only one query can be issued at a time
  47639. * @returns a time token used to track the time span
  47640. */
  47641. startTimeQuery(): Nullable<_TimeToken>;
  47642. /**
  47643. * Ends a time query
  47644. * @param token defines the token used to measure the time span
  47645. * @returns the time spent (in ns)
  47646. */
  47647. endTimeQuery(token: _TimeToken): int;
  47648. /** @hidden */
  47649. _currentNonTimestampToken: Nullable<_TimeToken>;
  47650. /** @hidden */
  47651. _createTimeQuery(): WebGLQuery;
  47652. /** @hidden */
  47653. _deleteTimeQuery(query: WebGLQuery): void;
  47654. /** @hidden */
  47655. _getGlAlgorithmType(algorithmType: number): number;
  47656. /** @hidden */
  47657. _getTimeQueryResult(query: WebGLQuery): any;
  47658. /** @hidden */
  47659. _getTimeQueryAvailability(query: WebGLQuery): any;
  47660. }
  47661. interface AbstractMesh {
  47662. /**
  47663. * Backing filed
  47664. * @hidden
  47665. */
  47666. __occlusionDataStorage: _OcclusionDataStorage;
  47667. /**
  47668. * Access property
  47669. * @hidden
  47670. */
  47671. _occlusionDataStorage: _OcclusionDataStorage;
  47672. /**
  47673. * 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.
  47674. * The default value is -1 which means don't break the query and wait till the result
  47675. * @see http://doc.babylonjs.com/features/occlusionquery
  47676. */
  47677. occlusionRetryCount: number;
  47678. /**
  47679. * 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:
  47680. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47681. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47682. * * 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.
  47683. * @see http://doc.babylonjs.com/features/occlusionquery
  47684. */
  47685. occlusionType: number;
  47686. /**
  47687. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47688. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47689. * * 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.
  47690. * @see http://doc.babylonjs.com/features/occlusionquery
  47691. */
  47692. occlusionQueryAlgorithmType: number;
  47693. /**
  47694. * 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
  47695. * @see http://doc.babylonjs.com/features/occlusionquery
  47696. */
  47697. isOccluded: boolean;
  47698. /**
  47699. * Flag to check the progress status of the query
  47700. * @see http://doc.babylonjs.com/features/occlusionquery
  47701. */
  47702. isOcclusionQueryInProgress: boolean;
  47703. }
  47704. }
  47705. declare module BABYLON {
  47706. /** @hidden */
  47707. export var _forceTransformFeedbackToBundle: boolean;
  47708. interface Engine {
  47709. /**
  47710. * Creates a webGL transform feedback object
  47711. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47712. * @returns the webGL transform feedback object
  47713. */
  47714. createTransformFeedback(): WebGLTransformFeedback;
  47715. /**
  47716. * Delete a webGL transform feedback object
  47717. * @param value defines the webGL transform feedback object to delete
  47718. */
  47719. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47720. /**
  47721. * Bind a webGL transform feedback object to the webgl context
  47722. * @param value defines the webGL transform feedback object to bind
  47723. */
  47724. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47725. /**
  47726. * Begins a transform feedback operation
  47727. * @param usePoints defines if points or triangles must be used
  47728. */
  47729. beginTransformFeedback(usePoints: boolean): void;
  47730. /**
  47731. * Ends a transform feedback operation
  47732. */
  47733. endTransformFeedback(): void;
  47734. /**
  47735. * Specify the varyings to use with transform feedback
  47736. * @param program defines the associated webGL program
  47737. * @param value defines the list of strings representing the varying names
  47738. */
  47739. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47740. /**
  47741. * Bind a webGL buffer for a transform feedback operation
  47742. * @param value defines the webGL buffer to bind
  47743. */
  47744. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47745. }
  47746. }
  47747. declare module BABYLON {
  47748. /**
  47749. * Creation options of the multi render target texture.
  47750. */
  47751. export interface IMultiRenderTargetOptions {
  47752. /**
  47753. * Define if the texture needs to create mip maps after render.
  47754. */
  47755. generateMipMaps?: boolean;
  47756. /**
  47757. * Define the types of all the draw buffers we want to create
  47758. */
  47759. types?: number[];
  47760. /**
  47761. * Define the sampling modes of all the draw buffers we want to create
  47762. */
  47763. samplingModes?: number[];
  47764. /**
  47765. * Define if a depth buffer is required
  47766. */
  47767. generateDepthBuffer?: boolean;
  47768. /**
  47769. * Define if a stencil buffer is required
  47770. */
  47771. generateStencilBuffer?: boolean;
  47772. /**
  47773. * Define if a depth texture is required instead of a depth buffer
  47774. */
  47775. generateDepthTexture?: boolean;
  47776. /**
  47777. * Define the number of desired draw buffers
  47778. */
  47779. textureCount?: number;
  47780. /**
  47781. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47782. */
  47783. doNotChangeAspectRatio?: boolean;
  47784. /**
  47785. * Define the default type of the buffers we are creating
  47786. */
  47787. defaultType?: number;
  47788. }
  47789. /**
  47790. * A multi render target, like a render target provides the ability to render to a texture.
  47791. * Unlike the render target, it can render to several draw buffers in one draw.
  47792. * This is specially interesting in deferred rendering or for any effects requiring more than
  47793. * just one color from a single pass.
  47794. */
  47795. export class MultiRenderTarget extends RenderTargetTexture {
  47796. private _internalTextures;
  47797. private _textures;
  47798. private _multiRenderTargetOptions;
  47799. /**
  47800. * Get if draw buffers are currently supported by the used hardware and browser.
  47801. */
  47802. get isSupported(): boolean;
  47803. /**
  47804. * Get the list of textures generated by the multi render target.
  47805. */
  47806. get textures(): Texture[];
  47807. /**
  47808. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47809. */
  47810. get depthTexture(): Texture;
  47811. /**
  47812. * Set the wrapping mode on U of all the textures we are rendering to.
  47813. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47814. */
  47815. set wrapU(wrap: number);
  47816. /**
  47817. * Set the wrapping mode on V of all the textures we are rendering to.
  47818. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47819. */
  47820. set wrapV(wrap: number);
  47821. /**
  47822. * Instantiate a new multi render target texture.
  47823. * A multi render target, like a render target provides the ability to render to a texture.
  47824. * Unlike the render target, it can render to several draw buffers in one draw.
  47825. * This is specially interesting in deferred rendering or for any effects requiring more than
  47826. * just one color from a single pass.
  47827. * @param name Define the name of the texture
  47828. * @param size Define the size of the buffers to render to
  47829. * @param count Define the number of target we are rendering into
  47830. * @param scene Define the scene the texture belongs to
  47831. * @param options Define the options used to create the multi render target
  47832. */
  47833. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47834. /** @hidden */
  47835. _rebuild(): void;
  47836. private _createInternalTextures;
  47837. private _createTextures;
  47838. /**
  47839. * Define the number of samples used if MSAA is enabled.
  47840. */
  47841. get samples(): number;
  47842. set samples(value: number);
  47843. /**
  47844. * Resize all the textures in the multi render target.
  47845. * Be carrefull as it will recreate all the data in the new texture.
  47846. * @param size Define the new size
  47847. */
  47848. resize(size: any): void;
  47849. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47850. /**
  47851. * Dispose the render targets and their associated resources
  47852. */
  47853. dispose(): void;
  47854. /**
  47855. * Release all the underlying texture used as draw buffers.
  47856. */
  47857. releaseInternalTextures(): void;
  47858. }
  47859. }
  47860. declare module BABYLON {
  47861. interface ThinEngine {
  47862. /**
  47863. * Unbind a list of render target textures from the webGL context
  47864. * This is used only when drawBuffer extension or webGL2 are active
  47865. * @param textures defines the render target textures to unbind
  47866. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47867. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47868. */
  47869. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47870. /**
  47871. * Create a multi render target texture
  47872. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47873. * @param size defines the size of the texture
  47874. * @param options defines the creation options
  47875. * @returns the cube texture as an InternalTexture
  47876. */
  47877. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47878. /**
  47879. * Update the sample count for a given multiple render target texture
  47880. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47881. * @param textures defines the textures to update
  47882. * @param samples defines the sample count to set
  47883. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47884. */
  47885. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47886. }
  47887. }
  47888. declare module BABYLON {
  47889. /**
  47890. * Class used to define an additional view for the engine
  47891. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47892. */
  47893. export class EngineView {
  47894. /** Defines the canvas where to render the view */
  47895. target: HTMLCanvasElement;
  47896. /** Defines an optional camera used to render the view (will use active camera else) */
  47897. camera?: Camera;
  47898. }
  47899. interface Engine {
  47900. /**
  47901. * Gets or sets the HTML element to use for attaching events
  47902. */
  47903. inputElement: Nullable<HTMLElement>;
  47904. /**
  47905. * Gets the current engine view
  47906. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47907. */
  47908. activeView: Nullable<EngineView>;
  47909. /** Gets or sets the list of views */
  47910. views: EngineView[];
  47911. /**
  47912. * Register a new child canvas
  47913. * @param canvas defines the canvas to register
  47914. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47915. * @returns the associated view
  47916. */
  47917. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47918. /**
  47919. * Remove a registered child canvas
  47920. * @param canvas defines the canvas to remove
  47921. * @returns the current engine
  47922. */
  47923. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47924. }
  47925. }
  47926. declare module BABYLON {
  47927. interface Engine {
  47928. /** @hidden */
  47929. _excludedCompressedTextures: string[];
  47930. /** @hidden */
  47931. _textureFormatInUse: string;
  47932. /**
  47933. * Gets the list of texture formats supported
  47934. */
  47935. readonly texturesSupported: Array<string>;
  47936. /**
  47937. * Gets the texture format in use
  47938. */
  47939. readonly textureFormatInUse: Nullable<string>;
  47940. /**
  47941. * Set the compressed texture extensions or file names to skip.
  47942. *
  47943. * @param skippedFiles defines the list of those texture files you want to skip
  47944. * Example: [".dds", ".env", "myfile.png"]
  47945. */
  47946. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47947. /**
  47948. * Set the compressed texture format to use, based on the formats you have, and the formats
  47949. * supported by the hardware / browser.
  47950. *
  47951. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47952. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47953. * to API arguments needed to compressed textures. This puts the burden on the container
  47954. * generator to house the arcane code for determining these for current & future formats.
  47955. *
  47956. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47957. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47958. *
  47959. * Note: The result of this call is not taken into account when a texture is base64.
  47960. *
  47961. * @param formatsAvailable defines the list of those format families you have created
  47962. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47963. *
  47964. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47965. * @returns The extension selected.
  47966. */
  47967. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47968. }
  47969. }
  47970. declare module BABYLON {
  47971. /**
  47972. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47973. */
  47974. export interface CubeMapInfo {
  47975. /**
  47976. * The pixel array for the front face.
  47977. * This is stored in format, left to right, up to down format.
  47978. */
  47979. front: Nullable<ArrayBufferView>;
  47980. /**
  47981. * The pixel array for the back face.
  47982. * This is stored in format, left to right, up to down format.
  47983. */
  47984. back: Nullable<ArrayBufferView>;
  47985. /**
  47986. * The pixel array for the left face.
  47987. * This is stored in format, left to right, up to down format.
  47988. */
  47989. left: Nullable<ArrayBufferView>;
  47990. /**
  47991. * The pixel array for the right face.
  47992. * This is stored in format, left to right, up to down format.
  47993. */
  47994. right: Nullable<ArrayBufferView>;
  47995. /**
  47996. * The pixel array for the up face.
  47997. * This is stored in format, left to right, up to down format.
  47998. */
  47999. up: Nullable<ArrayBufferView>;
  48000. /**
  48001. * The pixel array for the down face.
  48002. * This is stored in format, left to right, up to down format.
  48003. */
  48004. down: Nullable<ArrayBufferView>;
  48005. /**
  48006. * The size of the cubemap stored.
  48007. *
  48008. * Each faces will be size * size pixels.
  48009. */
  48010. size: number;
  48011. /**
  48012. * The format of the texture.
  48013. *
  48014. * RGBA, RGB.
  48015. */
  48016. format: number;
  48017. /**
  48018. * The type of the texture data.
  48019. *
  48020. * UNSIGNED_INT, FLOAT.
  48021. */
  48022. type: number;
  48023. /**
  48024. * Specifies whether the texture is in gamma space.
  48025. */
  48026. gammaSpace: boolean;
  48027. }
  48028. /**
  48029. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48030. */
  48031. export class PanoramaToCubeMapTools {
  48032. private static FACE_FRONT;
  48033. private static FACE_BACK;
  48034. private static FACE_RIGHT;
  48035. private static FACE_LEFT;
  48036. private static FACE_DOWN;
  48037. private static FACE_UP;
  48038. /**
  48039. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48040. *
  48041. * @param float32Array The source data.
  48042. * @param inputWidth The width of the input panorama.
  48043. * @param inputHeight The height of the input panorama.
  48044. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48045. * @return The cubemap data
  48046. */
  48047. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48048. private static CreateCubemapTexture;
  48049. private static CalcProjectionSpherical;
  48050. }
  48051. }
  48052. declare module BABYLON {
  48053. /**
  48054. * Helper class dealing with the extraction of spherical polynomial dataArray
  48055. * from a cube map.
  48056. */
  48057. export class CubeMapToSphericalPolynomialTools {
  48058. private static FileFaces;
  48059. /**
  48060. * Converts a texture to the according Spherical Polynomial data.
  48061. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48062. *
  48063. * @param texture The texture to extract the information from.
  48064. * @return The Spherical Polynomial data.
  48065. */
  48066. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48067. /**
  48068. * Converts a cubemap to the according Spherical Polynomial data.
  48069. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48070. *
  48071. * @param cubeInfo The Cube map to extract the information from.
  48072. * @return The Spherical Polynomial data.
  48073. */
  48074. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48075. }
  48076. }
  48077. declare module BABYLON {
  48078. interface BaseTexture {
  48079. /**
  48080. * Get the polynomial representation of the texture data.
  48081. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48082. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48083. */
  48084. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48085. }
  48086. }
  48087. declare module BABYLON {
  48088. /** @hidden */
  48089. export var rgbdEncodePixelShader: {
  48090. name: string;
  48091. shader: string;
  48092. };
  48093. }
  48094. declare module BABYLON {
  48095. /** @hidden */
  48096. export var rgbdDecodePixelShader: {
  48097. name: string;
  48098. shader: string;
  48099. };
  48100. }
  48101. declare module BABYLON {
  48102. /**
  48103. * Raw texture data and descriptor sufficient for WebGL texture upload
  48104. */
  48105. export interface EnvironmentTextureInfo {
  48106. /**
  48107. * Version of the environment map
  48108. */
  48109. version: number;
  48110. /**
  48111. * Width of image
  48112. */
  48113. width: number;
  48114. /**
  48115. * Irradiance information stored in the file.
  48116. */
  48117. irradiance: any;
  48118. /**
  48119. * Specular information stored in the file.
  48120. */
  48121. specular: any;
  48122. }
  48123. /**
  48124. * Defines One Image in the file. It requires only the position in the file
  48125. * as well as the length.
  48126. */
  48127. interface BufferImageData {
  48128. /**
  48129. * Length of the image data.
  48130. */
  48131. length: number;
  48132. /**
  48133. * Position of the data from the null terminator delimiting the end of the JSON.
  48134. */
  48135. position: number;
  48136. }
  48137. /**
  48138. * Defines the specular data enclosed in the file.
  48139. * This corresponds to the version 1 of the data.
  48140. */
  48141. export interface EnvironmentTextureSpecularInfoV1 {
  48142. /**
  48143. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48144. */
  48145. specularDataPosition?: number;
  48146. /**
  48147. * This contains all the images data needed to reconstruct the cubemap.
  48148. */
  48149. mipmaps: Array<BufferImageData>;
  48150. /**
  48151. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48152. */
  48153. lodGenerationScale: number;
  48154. }
  48155. /**
  48156. * Sets of helpers addressing the serialization and deserialization of environment texture
  48157. * stored in a BabylonJS env file.
  48158. * Those files are usually stored as .env files.
  48159. */
  48160. export class EnvironmentTextureTools {
  48161. /**
  48162. * Magic number identifying the env file.
  48163. */
  48164. private static _MagicBytes;
  48165. /**
  48166. * Gets the environment info from an env file.
  48167. * @param data The array buffer containing the .env bytes.
  48168. * @returns the environment file info (the json header) if successfully parsed.
  48169. */
  48170. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48171. /**
  48172. * Creates an environment texture from a loaded cube texture.
  48173. * @param texture defines the cube texture to convert in env file
  48174. * @return a promise containing the environment data if succesfull.
  48175. */
  48176. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48177. /**
  48178. * Creates a JSON representation of the spherical data.
  48179. * @param texture defines the texture containing the polynomials
  48180. * @return the JSON representation of the spherical info
  48181. */
  48182. private static _CreateEnvTextureIrradiance;
  48183. /**
  48184. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48185. * @param data the image data
  48186. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48187. * @return the views described by info providing access to the underlying buffer
  48188. */
  48189. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48190. /**
  48191. * Uploads the texture info contained in the env file to the GPU.
  48192. * @param texture defines the internal texture to upload to
  48193. * @param data defines the data to load
  48194. * @param info defines the texture info retrieved through the GetEnvInfo method
  48195. * @returns a promise
  48196. */
  48197. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48198. private static _OnImageReadyAsync;
  48199. /**
  48200. * Uploads the levels of image data to the GPU.
  48201. * @param texture defines the internal texture to upload to
  48202. * @param imageData defines the array buffer views of image data [mipmap][face]
  48203. * @returns a promise
  48204. */
  48205. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48206. /**
  48207. * Uploads spherical polynomials information to the texture.
  48208. * @param texture defines the texture we are trying to upload the information to
  48209. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48210. */
  48211. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48212. /** @hidden */
  48213. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48214. }
  48215. }
  48216. declare module BABYLON {
  48217. /**
  48218. * Contains position and normal vectors for a vertex
  48219. */
  48220. export class PositionNormalVertex {
  48221. /** the position of the vertex (defaut: 0,0,0) */
  48222. position: Vector3;
  48223. /** the normal of the vertex (defaut: 0,1,0) */
  48224. normal: Vector3;
  48225. /**
  48226. * Creates a PositionNormalVertex
  48227. * @param position the position of the vertex (defaut: 0,0,0)
  48228. * @param normal the normal of the vertex (defaut: 0,1,0)
  48229. */
  48230. constructor(
  48231. /** the position of the vertex (defaut: 0,0,0) */
  48232. position?: Vector3,
  48233. /** the normal of the vertex (defaut: 0,1,0) */
  48234. normal?: Vector3);
  48235. /**
  48236. * Clones the PositionNormalVertex
  48237. * @returns the cloned PositionNormalVertex
  48238. */
  48239. clone(): PositionNormalVertex;
  48240. }
  48241. /**
  48242. * Contains position, normal and uv vectors for a vertex
  48243. */
  48244. export class PositionNormalTextureVertex {
  48245. /** the position of the vertex (defaut: 0,0,0) */
  48246. position: Vector3;
  48247. /** the normal of the vertex (defaut: 0,1,0) */
  48248. normal: Vector3;
  48249. /** the uv of the vertex (default: 0,0) */
  48250. uv: Vector2;
  48251. /**
  48252. * Creates a PositionNormalTextureVertex
  48253. * @param position the position of the vertex (defaut: 0,0,0)
  48254. * @param normal the normal of the vertex (defaut: 0,1,0)
  48255. * @param uv the uv of the vertex (default: 0,0)
  48256. */
  48257. constructor(
  48258. /** the position of the vertex (defaut: 0,0,0) */
  48259. position?: Vector3,
  48260. /** the normal of the vertex (defaut: 0,1,0) */
  48261. normal?: Vector3,
  48262. /** the uv of the vertex (default: 0,0) */
  48263. uv?: Vector2);
  48264. /**
  48265. * Clones the PositionNormalTextureVertex
  48266. * @returns the cloned PositionNormalTextureVertex
  48267. */
  48268. clone(): PositionNormalTextureVertex;
  48269. }
  48270. }
  48271. declare module BABYLON {
  48272. /** @hidden */
  48273. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48274. private _genericAttributeLocation;
  48275. private _varyingLocationCount;
  48276. private _varyingLocationMap;
  48277. private _replacements;
  48278. private _textureCount;
  48279. private _uniforms;
  48280. lineProcessor(line: string): string;
  48281. attributeProcessor(attribute: string): string;
  48282. varyingProcessor(varying: string, isFragment: boolean): string;
  48283. uniformProcessor(uniform: string): string;
  48284. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48285. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48286. }
  48287. }
  48288. declare module BABYLON {
  48289. /**
  48290. * Container for accessors for natively-stored mesh data buffers.
  48291. */
  48292. class NativeDataBuffer extends DataBuffer {
  48293. /**
  48294. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48295. */
  48296. nativeIndexBuffer?: any;
  48297. /**
  48298. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48299. */
  48300. nativeVertexBuffer?: any;
  48301. }
  48302. /** @hidden */
  48303. class NativeTexture extends InternalTexture {
  48304. getInternalTexture(): InternalTexture;
  48305. getViewCount(): number;
  48306. }
  48307. /** @hidden */
  48308. export class NativeEngine extends Engine {
  48309. private readonly _native;
  48310. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48311. private readonly INVALID_HANDLE;
  48312. getHardwareScalingLevel(): number;
  48313. constructor();
  48314. dispose(): void;
  48315. /**
  48316. * Can be used to override the current requestAnimationFrame requester.
  48317. * @hidden
  48318. */
  48319. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48320. /**
  48321. * Override default engine behavior.
  48322. * @param color
  48323. * @param backBuffer
  48324. * @param depth
  48325. * @param stencil
  48326. */
  48327. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48328. /**
  48329. * Gets host document
  48330. * @returns the host document object
  48331. */
  48332. getHostDocument(): Nullable<Document>;
  48333. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48334. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48335. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48336. recordVertexArrayObject(vertexBuffers: {
  48337. [key: string]: VertexBuffer;
  48338. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48339. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48340. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48341. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48342. /**
  48343. * Draw a list of indexed primitives
  48344. * @param fillMode defines the primitive to use
  48345. * @param indexStart defines the starting index
  48346. * @param indexCount defines the number of index to draw
  48347. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48348. */
  48349. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48350. /**
  48351. * Draw a list of unindexed primitives
  48352. * @param fillMode defines the primitive to use
  48353. * @param verticesStart defines the index of first vertex to draw
  48354. * @param verticesCount defines the count of vertices to draw
  48355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48356. */
  48357. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48358. createPipelineContext(): IPipelineContext;
  48359. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48360. /** @hidden */
  48361. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48362. /** @hidden */
  48363. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48364. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48365. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48366. protected _setProgram(program: WebGLProgram): void;
  48367. _releaseEffect(effect: Effect): void;
  48368. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48369. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48370. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48371. bindSamplers(effect: Effect): void;
  48372. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48373. getRenderWidth(useScreen?: boolean): number;
  48374. getRenderHeight(useScreen?: boolean): number;
  48375. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48376. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48377. /**
  48378. * Set the z offset to apply to current rendering
  48379. * @param value defines the offset to apply
  48380. */
  48381. setZOffset(value: number): void;
  48382. /**
  48383. * Gets the current value of the zOffset
  48384. * @returns the current zOffset state
  48385. */
  48386. getZOffset(): number;
  48387. /**
  48388. * Enable or disable depth buffering
  48389. * @param enable defines the state to set
  48390. */
  48391. setDepthBuffer(enable: boolean): void;
  48392. /**
  48393. * Gets a boolean indicating if depth writing is enabled
  48394. * @returns the current depth writing state
  48395. */
  48396. getDepthWrite(): boolean;
  48397. /**
  48398. * Enable or disable depth writing
  48399. * @param enable defines the state to set
  48400. */
  48401. setDepthWrite(enable: boolean): void;
  48402. /**
  48403. * Enable or disable color writing
  48404. * @param enable defines the state to set
  48405. */
  48406. setColorWrite(enable: boolean): void;
  48407. /**
  48408. * Gets a boolean indicating if color writing is enabled
  48409. * @returns the current color writing state
  48410. */
  48411. getColorWrite(): boolean;
  48412. /**
  48413. * Sets alpha constants used by some alpha blending modes
  48414. * @param r defines the red component
  48415. * @param g defines the green component
  48416. * @param b defines the blue component
  48417. * @param a defines the alpha component
  48418. */
  48419. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48420. /**
  48421. * Sets the current alpha mode
  48422. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48423. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48424. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48425. */
  48426. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48427. /**
  48428. * Gets the current alpha mode
  48429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48430. * @returns the current alpha mode
  48431. */
  48432. getAlphaMode(): number;
  48433. setInt(uniform: WebGLUniformLocation, int: number): void;
  48434. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48435. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48436. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48437. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48438. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48439. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48440. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48441. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48442. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48443. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48444. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48445. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48446. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48447. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48448. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48449. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48450. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48451. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48452. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48453. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48454. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48455. wipeCaches(bruteForce?: boolean): void;
  48456. _createTexture(): WebGLTexture;
  48457. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48458. /**
  48459. * Usually called from Texture.ts.
  48460. * Passed information to create a WebGLTexture
  48461. * @param url defines a value which contains one of the following:
  48462. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48463. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48464. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48465. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48466. * @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)
  48467. * @param scene needed for loading to the correct scene
  48468. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48469. * @param onLoad optional callback to be called upon successful completion
  48470. * @param onError optional callback to be called upon failure
  48471. * @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
  48472. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48473. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48474. * @param forcedExtension defines the extension to use to pick the right loader
  48475. * @param mimeType defines an optional mime type
  48476. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48477. */
  48478. 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;
  48479. /**
  48480. * Creates a cube texture
  48481. * @param rootUrl defines the url where the files to load is located
  48482. * @param scene defines the current scene
  48483. * @param files defines the list of files to load (1 per face)
  48484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48485. * @param onLoad defines an optional callback raised when the texture is loaded
  48486. * @param onError defines an optional callback raised if there is an issue to load the texture
  48487. * @param format defines the format of the data
  48488. * @param forcedExtension defines the extension to use to pick the right loader
  48489. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48490. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48491. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48492. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48493. * @returns the cube texture as an InternalTexture
  48494. */
  48495. 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;
  48496. private _getSamplingFilter;
  48497. private static _GetNativeTextureFormat;
  48498. createRenderTargetTexture(size: number | {
  48499. width: number;
  48500. height: number;
  48501. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48502. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48503. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48504. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48505. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48506. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48507. /**
  48508. * Updates a dynamic vertex buffer.
  48509. * @param vertexBuffer the vertex buffer to update
  48510. * @param data the data used to update the vertex buffer
  48511. * @param byteOffset the byte offset of the data (optional)
  48512. * @param byteLength the byte length of the data (optional)
  48513. */
  48514. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48515. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48516. private _updateAnisotropicLevel;
  48517. private _getAddressMode;
  48518. /** @hidden */
  48519. _bindTexture(channel: number, texture: InternalTexture): void;
  48520. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48521. releaseEffects(): void;
  48522. /** @hidden */
  48523. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48524. /** @hidden */
  48525. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48526. /** @hidden */
  48527. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48528. /** @hidden */
  48529. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48530. }
  48531. }
  48532. declare module BABYLON {
  48533. /**
  48534. * Gather the list of clipboard event types as constants.
  48535. */
  48536. export class ClipboardEventTypes {
  48537. /**
  48538. * The clipboard event is fired when a copy command is active (pressed).
  48539. */
  48540. static readonly COPY: number;
  48541. /**
  48542. * The clipboard event is fired when a cut command is active (pressed).
  48543. */
  48544. static readonly CUT: number;
  48545. /**
  48546. * The clipboard event is fired when a paste command is active (pressed).
  48547. */
  48548. static readonly PASTE: number;
  48549. }
  48550. /**
  48551. * This class is used to store clipboard related info for the onClipboardObservable event.
  48552. */
  48553. export class ClipboardInfo {
  48554. /**
  48555. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48556. */
  48557. type: number;
  48558. /**
  48559. * Defines the related dom event
  48560. */
  48561. event: ClipboardEvent;
  48562. /**
  48563. *Creates an instance of ClipboardInfo.
  48564. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48565. * @param event Defines the related dom event
  48566. */
  48567. constructor(
  48568. /**
  48569. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48570. */
  48571. type: number,
  48572. /**
  48573. * Defines the related dom event
  48574. */
  48575. event: ClipboardEvent);
  48576. /**
  48577. * Get the clipboard event's type from the keycode.
  48578. * @param keyCode Defines the keyCode for the current keyboard event.
  48579. * @return {number}
  48580. */
  48581. static GetTypeFromCharacter(keyCode: number): number;
  48582. }
  48583. }
  48584. declare module BABYLON {
  48585. /**
  48586. * Google Daydream controller
  48587. */
  48588. export class DaydreamController extends WebVRController {
  48589. /**
  48590. * Base Url for the controller model.
  48591. */
  48592. static MODEL_BASE_URL: string;
  48593. /**
  48594. * File name for the controller model.
  48595. */
  48596. static MODEL_FILENAME: string;
  48597. /**
  48598. * Gamepad Id prefix used to identify Daydream Controller.
  48599. */
  48600. static readonly GAMEPAD_ID_PREFIX: string;
  48601. /**
  48602. * Creates a new DaydreamController from a gamepad
  48603. * @param vrGamepad the gamepad that the controller should be created from
  48604. */
  48605. constructor(vrGamepad: any);
  48606. /**
  48607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48608. * @param scene scene in which to add meshes
  48609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48610. */
  48611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48612. /**
  48613. * Called once for each button that changed state since the last frame
  48614. * @param buttonIdx Which button index changed
  48615. * @param state New state of the button
  48616. * @param changes Which properties on the state changed since last frame
  48617. */
  48618. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48619. }
  48620. }
  48621. declare module BABYLON {
  48622. /**
  48623. * Gear VR Controller
  48624. */
  48625. export class GearVRController extends WebVRController {
  48626. /**
  48627. * Base Url for the controller model.
  48628. */
  48629. static MODEL_BASE_URL: string;
  48630. /**
  48631. * File name for the controller model.
  48632. */
  48633. static MODEL_FILENAME: string;
  48634. /**
  48635. * Gamepad Id prefix used to identify this controller.
  48636. */
  48637. static readonly GAMEPAD_ID_PREFIX: string;
  48638. private readonly _buttonIndexToObservableNameMap;
  48639. /**
  48640. * Creates a new GearVRController from a gamepad
  48641. * @param vrGamepad the gamepad that the controller should be created from
  48642. */
  48643. constructor(vrGamepad: any);
  48644. /**
  48645. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48646. * @param scene scene in which to add meshes
  48647. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48648. */
  48649. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48650. /**
  48651. * Called once for each button that changed state since the last frame
  48652. * @param buttonIdx Which button index changed
  48653. * @param state New state of the button
  48654. * @param changes Which properties on the state changed since last frame
  48655. */
  48656. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * Generic Controller
  48662. */
  48663. export class GenericController extends WebVRController {
  48664. /**
  48665. * Base Url for the controller model.
  48666. */
  48667. static readonly MODEL_BASE_URL: string;
  48668. /**
  48669. * File name for the controller model.
  48670. */
  48671. static readonly MODEL_FILENAME: string;
  48672. /**
  48673. * Creates a new GenericController from a gamepad
  48674. * @param vrGamepad the gamepad that the controller should be created from
  48675. */
  48676. constructor(vrGamepad: any);
  48677. /**
  48678. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48679. * @param scene scene in which to add meshes
  48680. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48681. */
  48682. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48683. /**
  48684. * Called once for each button that changed state since the last frame
  48685. * @param buttonIdx Which button index changed
  48686. * @param state New state of the button
  48687. * @param changes Which properties on the state changed since last frame
  48688. */
  48689. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48690. }
  48691. }
  48692. declare module BABYLON {
  48693. /**
  48694. * Oculus Touch Controller
  48695. */
  48696. export class OculusTouchController extends WebVRController {
  48697. /**
  48698. * Base Url for the controller model.
  48699. */
  48700. static MODEL_BASE_URL: string;
  48701. /**
  48702. * File name for the left controller model.
  48703. */
  48704. static MODEL_LEFT_FILENAME: string;
  48705. /**
  48706. * File name for the right controller model.
  48707. */
  48708. static MODEL_RIGHT_FILENAME: string;
  48709. /**
  48710. * Base Url for the Quest controller model.
  48711. */
  48712. static QUEST_MODEL_BASE_URL: string;
  48713. /**
  48714. * @hidden
  48715. * If the controllers are running on a device that needs the updated Quest controller models
  48716. */
  48717. static _IsQuest: boolean;
  48718. /**
  48719. * Fired when the secondary trigger on this controller is modified
  48720. */
  48721. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48722. /**
  48723. * Fired when the thumb rest on this controller is modified
  48724. */
  48725. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48726. /**
  48727. * Creates a new OculusTouchController from a gamepad
  48728. * @param vrGamepad the gamepad that the controller should be created from
  48729. */
  48730. constructor(vrGamepad: any);
  48731. /**
  48732. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48733. * @param scene scene in which to add meshes
  48734. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48735. */
  48736. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48737. /**
  48738. * Fired when the A button on this controller is modified
  48739. */
  48740. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48741. /**
  48742. * Fired when the B button on this controller is modified
  48743. */
  48744. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48745. /**
  48746. * Fired when the X button on this controller is modified
  48747. */
  48748. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48749. /**
  48750. * Fired when the Y button on this controller is modified
  48751. */
  48752. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48753. /**
  48754. * Called once for each button that changed state since the last frame
  48755. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48756. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48757. * 2) secondary trigger (same)
  48758. * 3) A (right) X (left), touch, pressed = value
  48759. * 4) B / Y
  48760. * 5) thumb rest
  48761. * @param buttonIdx Which button index changed
  48762. * @param state New state of the button
  48763. * @param changes Which properties on the state changed since last frame
  48764. */
  48765. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48766. }
  48767. }
  48768. declare module BABYLON {
  48769. /**
  48770. * Vive Controller
  48771. */
  48772. export class ViveController extends WebVRController {
  48773. /**
  48774. * Base Url for the controller model.
  48775. */
  48776. static MODEL_BASE_URL: string;
  48777. /**
  48778. * File name for the controller model.
  48779. */
  48780. static MODEL_FILENAME: string;
  48781. /**
  48782. * Creates a new ViveController from a gamepad
  48783. * @param vrGamepad the gamepad that the controller should be created from
  48784. */
  48785. constructor(vrGamepad: any);
  48786. /**
  48787. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48788. * @param scene scene in which to add meshes
  48789. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48790. */
  48791. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48792. /**
  48793. * Fired when the left button on this controller is modified
  48794. */
  48795. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48796. /**
  48797. * Fired when the right button on this controller is modified
  48798. */
  48799. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48800. /**
  48801. * Fired when the menu button on this controller is modified
  48802. */
  48803. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48804. /**
  48805. * Called once for each button that changed state since the last frame
  48806. * Vive mapping:
  48807. * 0: touchpad
  48808. * 1: trigger
  48809. * 2: left AND right buttons
  48810. * 3: menu button
  48811. * @param buttonIdx Which button index changed
  48812. * @param state New state of the button
  48813. * @param changes Which properties on the state changed since last frame
  48814. */
  48815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48816. }
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * Defines the WindowsMotionController object that the state of the windows motion controller
  48821. */
  48822. export class WindowsMotionController extends WebVRController {
  48823. /**
  48824. * The base url used to load the left and right controller models
  48825. */
  48826. static MODEL_BASE_URL: string;
  48827. /**
  48828. * The name of the left controller model file
  48829. */
  48830. static MODEL_LEFT_FILENAME: string;
  48831. /**
  48832. * The name of the right controller model file
  48833. */
  48834. static MODEL_RIGHT_FILENAME: string;
  48835. /**
  48836. * The controller name prefix for this controller type
  48837. */
  48838. static readonly GAMEPAD_ID_PREFIX: string;
  48839. /**
  48840. * The controller id pattern for this controller type
  48841. */
  48842. private static readonly GAMEPAD_ID_PATTERN;
  48843. private _loadedMeshInfo;
  48844. protected readonly _mapping: {
  48845. buttons: string[];
  48846. buttonMeshNames: {
  48847. trigger: string;
  48848. menu: string;
  48849. grip: string;
  48850. thumbstick: string;
  48851. trackpad: string;
  48852. };
  48853. buttonObservableNames: {
  48854. trigger: string;
  48855. menu: string;
  48856. grip: string;
  48857. thumbstick: string;
  48858. trackpad: string;
  48859. };
  48860. axisMeshNames: string[];
  48861. pointingPoseMeshName: string;
  48862. };
  48863. /**
  48864. * Fired when the trackpad on this controller is clicked
  48865. */
  48866. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48867. /**
  48868. * Fired when the trackpad on this controller is modified
  48869. */
  48870. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48871. /**
  48872. * The current x and y values of this controller's trackpad
  48873. */
  48874. trackpad: StickValues;
  48875. /**
  48876. * Creates a new WindowsMotionController from a gamepad
  48877. * @param vrGamepad the gamepad that the controller should be created from
  48878. */
  48879. constructor(vrGamepad: any);
  48880. /**
  48881. * Fired when the trigger on this controller is modified
  48882. */
  48883. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48884. /**
  48885. * Fired when the menu button on this controller is modified
  48886. */
  48887. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48888. /**
  48889. * Fired when the grip button on this controller is modified
  48890. */
  48891. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48892. /**
  48893. * Fired when the thumbstick button on this controller is modified
  48894. */
  48895. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48896. /**
  48897. * Fired when the touchpad button on this controller is modified
  48898. */
  48899. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48900. /**
  48901. * Fired when the touchpad values on this controller are modified
  48902. */
  48903. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48904. protected _updateTrackpad(): void;
  48905. /**
  48906. * Called once per frame by the engine.
  48907. */
  48908. update(): void;
  48909. /**
  48910. * Called once for each button that changed state since the last frame
  48911. * @param buttonIdx Which button index changed
  48912. * @param state New state of the button
  48913. * @param changes Which properties on the state changed since last frame
  48914. */
  48915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48916. /**
  48917. * Moves the buttons on the controller mesh based on their current state
  48918. * @param buttonName the name of the button to move
  48919. * @param buttonValue the value of the button which determines the buttons new position
  48920. */
  48921. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48922. /**
  48923. * Moves the axis on the controller mesh based on its current state
  48924. * @param axis the index of the axis
  48925. * @param axisValue the value of the axis which determines the meshes new position
  48926. * @hidden
  48927. */
  48928. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48929. /**
  48930. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48931. * @param scene scene in which to add meshes
  48932. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48933. */
  48934. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48935. /**
  48936. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48937. * can be transformed by button presses and axes values, based on this._mapping.
  48938. *
  48939. * @param scene scene in which the meshes exist
  48940. * @param meshes list of meshes that make up the controller model to process
  48941. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48942. */
  48943. private processModel;
  48944. private createMeshInfo;
  48945. /**
  48946. * Gets the ray of the controller in the direction the controller is pointing
  48947. * @param length the length the resulting ray should be
  48948. * @returns a ray in the direction the controller is pointing
  48949. */
  48950. getForwardRay(length?: number): Ray;
  48951. /**
  48952. * Disposes of the controller
  48953. */
  48954. dispose(): void;
  48955. }
  48956. /**
  48957. * This class represents a new windows motion controller in XR.
  48958. */
  48959. export class XRWindowsMotionController extends WindowsMotionController {
  48960. /**
  48961. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48962. */
  48963. protected readonly _mapping: {
  48964. buttons: string[];
  48965. buttonMeshNames: {
  48966. trigger: string;
  48967. menu: string;
  48968. grip: string;
  48969. thumbstick: string;
  48970. trackpad: string;
  48971. };
  48972. buttonObservableNames: {
  48973. trigger: string;
  48974. menu: string;
  48975. grip: string;
  48976. thumbstick: string;
  48977. trackpad: string;
  48978. };
  48979. axisMeshNames: string[];
  48980. pointingPoseMeshName: string;
  48981. };
  48982. /**
  48983. * Construct a new XR-Based windows motion controller
  48984. *
  48985. * @param gamepadInfo the gamepad object from the browser
  48986. */
  48987. constructor(gamepadInfo: any);
  48988. /**
  48989. * holds the thumbstick values (X,Y)
  48990. */
  48991. thumbstickValues: StickValues;
  48992. /**
  48993. * Fired when the thumbstick on this controller is clicked
  48994. */
  48995. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48996. /**
  48997. * Fired when the thumbstick on this controller is modified
  48998. */
  48999. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49000. /**
  49001. * Fired when the touchpad button on this controller is modified
  49002. */
  49003. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49004. /**
  49005. * Fired when the touchpad values on this controller are modified
  49006. */
  49007. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49008. /**
  49009. * Fired when the thumbstick button on this controller is modified
  49010. * here to prevent breaking changes
  49011. */
  49012. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49013. /**
  49014. * updating the thumbstick(!) and not the trackpad.
  49015. * This is named this way due to the difference between WebVR and XR and to avoid
  49016. * changing the parent class.
  49017. */
  49018. protected _updateTrackpad(): void;
  49019. /**
  49020. * Disposes the class with joy
  49021. */
  49022. dispose(): void;
  49023. }
  49024. }
  49025. declare module BABYLON {
  49026. /**
  49027. * Class containing static functions to help procedurally build meshes
  49028. */
  49029. export class PolyhedronBuilder {
  49030. /**
  49031. * Creates a polyhedron mesh
  49032. * * 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
  49033. * * The parameter `size` (positive float, default 1) sets the polygon size
  49034. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49035. * * 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`
  49036. * * 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
  49037. * * 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)`)
  49038. * * 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
  49039. * * 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
  49040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49041. * * 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
  49042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49043. * @param name defines the name of the mesh
  49044. * @param options defines the options used to create the mesh
  49045. * @param scene defines the hosting scene
  49046. * @returns the polyhedron mesh
  49047. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49048. */
  49049. static CreatePolyhedron(name: string, options: {
  49050. type?: number;
  49051. size?: number;
  49052. sizeX?: number;
  49053. sizeY?: number;
  49054. sizeZ?: number;
  49055. custom?: any;
  49056. faceUV?: Vector4[];
  49057. faceColors?: Color4[];
  49058. flat?: boolean;
  49059. updatable?: boolean;
  49060. sideOrientation?: number;
  49061. frontUVs?: Vector4;
  49062. backUVs?: Vector4;
  49063. }, scene?: Nullable<Scene>): Mesh;
  49064. }
  49065. }
  49066. declare module BABYLON {
  49067. /**
  49068. * Gizmo that enables scaling a mesh along 3 axis
  49069. */
  49070. export class ScaleGizmo extends Gizmo {
  49071. /**
  49072. * Internal gizmo used for interactions on the x axis
  49073. */
  49074. xGizmo: AxisScaleGizmo;
  49075. /**
  49076. * Internal gizmo used for interactions on the y axis
  49077. */
  49078. yGizmo: AxisScaleGizmo;
  49079. /**
  49080. * Internal gizmo used for interactions on the z axis
  49081. */
  49082. zGizmo: AxisScaleGizmo;
  49083. /**
  49084. * Internal gizmo used to scale all axis equally
  49085. */
  49086. uniformScaleGizmo: AxisScaleGizmo;
  49087. private _meshAttached;
  49088. private _updateGizmoRotationToMatchAttachedMesh;
  49089. private _snapDistance;
  49090. private _scaleRatio;
  49091. private _uniformScalingMesh;
  49092. private _octahedron;
  49093. private _sensitivity;
  49094. /** Fires an event when any of it's sub gizmos are dragged */
  49095. onDragStartObservable: Observable<unknown>;
  49096. /** Fires an event when any of it's sub gizmos are released from dragging */
  49097. onDragEndObservable: Observable<unknown>;
  49098. get attachedMesh(): Nullable<AbstractMesh>;
  49099. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49100. /**
  49101. * Creates a ScaleGizmo
  49102. * @param gizmoLayer The utility layer the gizmo will be added to
  49103. */
  49104. constructor(gizmoLayer?: UtilityLayerRenderer);
  49105. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49106. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49107. /**
  49108. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49109. */
  49110. set snapDistance(value: number);
  49111. get snapDistance(): number;
  49112. /**
  49113. * Ratio for the scale of the gizmo (Default: 1)
  49114. */
  49115. set scaleRatio(value: number);
  49116. get scaleRatio(): number;
  49117. /**
  49118. * Sensitivity factor for dragging (Default: 1)
  49119. */
  49120. set sensitivity(value: number);
  49121. get sensitivity(): number;
  49122. /**
  49123. * Disposes of the gizmo
  49124. */
  49125. dispose(): void;
  49126. }
  49127. }
  49128. declare module BABYLON {
  49129. /**
  49130. * Single axis scale gizmo
  49131. */
  49132. export class AxisScaleGizmo extends Gizmo {
  49133. /**
  49134. * Drag behavior responsible for the gizmos dragging interactions
  49135. */
  49136. dragBehavior: PointerDragBehavior;
  49137. private _pointerObserver;
  49138. /**
  49139. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49140. */
  49141. snapDistance: number;
  49142. /**
  49143. * Event that fires each time the gizmo snaps to a new location.
  49144. * * snapDistance is the the change in distance
  49145. */
  49146. onSnapObservable: Observable<{
  49147. snapDistance: number;
  49148. }>;
  49149. /**
  49150. * If the scaling operation should be done on all axis (default: false)
  49151. */
  49152. uniformScaling: boolean;
  49153. /**
  49154. * Custom sensitivity value for the drag strength
  49155. */
  49156. sensitivity: number;
  49157. private _isEnabled;
  49158. private _parent;
  49159. private _arrow;
  49160. private _coloredMaterial;
  49161. private _hoverMaterial;
  49162. /**
  49163. * Creates an AxisScaleGizmo
  49164. * @param gizmoLayer The utility layer the gizmo will be added to
  49165. * @param dragAxis The axis which the gizmo will be able to scale on
  49166. * @param color The color of the gizmo
  49167. */
  49168. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49169. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49170. /**
  49171. * If the gizmo is enabled
  49172. */
  49173. set isEnabled(value: boolean);
  49174. get isEnabled(): boolean;
  49175. /**
  49176. * Disposes of the gizmo
  49177. */
  49178. dispose(): void;
  49179. /**
  49180. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49181. * @param mesh The mesh to replace the default mesh of the gizmo
  49182. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49183. */
  49184. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49185. }
  49186. }
  49187. declare module BABYLON {
  49188. /**
  49189. * Bounding box gizmo
  49190. */
  49191. export class BoundingBoxGizmo extends Gizmo {
  49192. private _lineBoundingBox;
  49193. private _rotateSpheresParent;
  49194. private _scaleBoxesParent;
  49195. private _boundingDimensions;
  49196. private _renderObserver;
  49197. private _pointerObserver;
  49198. private _scaleDragSpeed;
  49199. private _tmpQuaternion;
  49200. private _tmpVector;
  49201. private _tmpRotationMatrix;
  49202. /**
  49203. * 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)
  49204. */
  49205. ignoreChildren: boolean;
  49206. /**
  49207. * 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)
  49208. */
  49209. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49210. /**
  49211. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49212. */
  49213. rotationSphereSize: number;
  49214. /**
  49215. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49216. */
  49217. scaleBoxSize: number;
  49218. /**
  49219. * 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)
  49220. */
  49221. fixedDragMeshScreenSize: boolean;
  49222. /**
  49223. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49224. */
  49225. fixedDragMeshScreenSizeDistanceFactor: number;
  49226. /**
  49227. * Fired when a rotation sphere or scale box is dragged
  49228. */
  49229. onDragStartObservable: Observable<{}>;
  49230. /**
  49231. * Fired when a scale box is dragged
  49232. */
  49233. onScaleBoxDragObservable: Observable<{}>;
  49234. /**
  49235. * Fired when a scale box drag is ended
  49236. */
  49237. onScaleBoxDragEndObservable: Observable<{}>;
  49238. /**
  49239. * Fired when a rotation sphere is dragged
  49240. */
  49241. onRotationSphereDragObservable: Observable<{}>;
  49242. /**
  49243. * Fired when a rotation sphere drag is ended
  49244. */
  49245. onRotationSphereDragEndObservable: Observable<{}>;
  49246. /**
  49247. * 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)
  49248. */
  49249. scalePivot: Nullable<Vector3>;
  49250. /**
  49251. * Mesh used as a pivot to rotate the attached mesh
  49252. */
  49253. private _anchorMesh;
  49254. private _existingMeshScale;
  49255. private _dragMesh;
  49256. private pointerDragBehavior;
  49257. private coloredMaterial;
  49258. private hoverColoredMaterial;
  49259. /**
  49260. * Sets the color of the bounding box gizmo
  49261. * @param color the color to set
  49262. */
  49263. setColor(color: Color3): void;
  49264. /**
  49265. * Creates an BoundingBoxGizmo
  49266. * @param gizmoLayer The utility layer the gizmo will be added to
  49267. * @param color The color of the gizmo
  49268. */
  49269. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49270. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49271. private _selectNode;
  49272. /**
  49273. * Updates the bounding box information for the Gizmo
  49274. */
  49275. updateBoundingBox(): void;
  49276. private _updateRotationSpheres;
  49277. private _updateScaleBoxes;
  49278. /**
  49279. * Enables rotation on the specified axis and disables rotation on the others
  49280. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49281. */
  49282. setEnabledRotationAxis(axis: string): void;
  49283. /**
  49284. * Enables/disables scaling
  49285. * @param enable if scaling should be enabled
  49286. * @param homogeneousScaling defines if scaling should only be homogeneous
  49287. */
  49288. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49289. private _updateDummy;
  49290. /**
  49291. * Enables a pointer drag behavior on the bounding box of the gizmo
  49292. */
  49293. enableDragBehavior(): void;
  49294. /**
  49295. * Disposes of the gizmo
  49296. */
  49297. dispose(): void;
  49298. /**
  49299. * 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)
  49300. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49301. * @returns the bounding box mesh with the passed in mesh as a child
  49302. */
  49303. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49304. /**
  49305. * CustomMeshes are not supported by this gizmo
  49306. * @param mesh The mesh to replace the default mesh of the gizmo
  49307. */
  49308. setCustomMesh(mesh: Mesh): void;
  49309. }
  49310. }
  49311. declare module BABYLON {
  49312. /**
  49313. * Single plane rotation gizmo
  49314. */
  49315. export class PlaneRotationGizmo extends Gizmo {
  49316. /**
  49317. * Drag behavior responsible for the gizmos dragging interactions
  49318. */
  49319. dragBehavior: PointerDragBehavior;
  49320. private _pointerObserver;
  49321. /**
  49322. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49323. */
  49324. snapDistance: number;
  49325. /**
  49326. * Event that fires each time the gizmo snaps to a new location.
  49327. * * snapDistance is the the change in distance
  49328. */
  49329. onSnapObservable: Observable<{
  49330. snapDistance: number;
  49331. }>;
  49332. private _isEnabled;
  49333. private _parent;
  49334. /**
  49335. * Creates a PlaneRotationGizmo
  49336. * @param gizmoLayer The utility layer the gizmo will be added to
  49337. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49338. * @param color The color of the gizmo
  49339. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49340. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49341. */
  49342. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49344. /**
  49345. * If the gizmo is enabled
  49346. */
  49347. set isEnabled(value: boolean);
  49348. get isEnabled(): boolean;
  49349. /**
  49350. * Disposes of the gizmo
  49351. */
  49352. dispose(): void;
  49353. }
  49354. }
  49355. declare module BABYLON {
  49356. /**
  49357. * Gizmo that enables rotating a mesh along 3 axis
  49358. */
  49359. export class RotationGizmo extends Gizmo {
  49360. /**
  49361. * Internal gizmo used for interactions on the x axis
  49362. */
  49363. xGizmo: PlaneRotationGizmo;
  49364. /**
  49365. * Internal gizmo used for interactions on the y axis
  49366. */
  49367. yGizmo: PlaneRotationGizmo;
  49368. /**
  49369. * Internal gizmo used for interactions on the z axis
  49370. */
  49371. zGizmo: PlaneRotationGizmo;
  49372. /** Fires an event when any of it's sub gizmos are dragged */
  49373. onDragStartObservable: Observable<unknown>;
  49374. /** Fires an event when any of it's sub gizmos are released from dragging */
  49375. onDragEndObservable: Observable<unknown>;
  49376. private _meshAttached;
  49377. get attachedMesh(): Nullable<AbstractMesh>;
  49378. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49379. /**
  49380. * Creates a RotationGizmo
  49381. * @param gizmoLayer The utility layer the gizmo will be added to
  49382. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49383. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49384. */
  49385. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49386. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49387. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49388. /**
  49389. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49390. */
  49391. set snapDistance(value: number);
  49392. get snapDistance(): number;
  49393. /**
  49394. * Ratio for the scale of the gizmo (Default: 1)
  49395. */
  49396. set scaleRatio(value: number);
  49397. get scaleRatio(): number;
  49398. /**
  49399. * Disposes of the gizmo
  49400. */
  49401. dispose(): void;
  49402. /**
  49403. * CustomMeshes are not supported by this gizmo
  49404. * @param mesh The mesh to replace the default mesh of the gizmo
  49405. */
  49406. setCustomMesh(mesh: Mesh): void;
  49407. }
  49408. }
  49409. declare module BABYLON {
  49410. /**
  49411. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49412. */
  49413. export class GizmoManager implements IDisposable {
  49414. private scene;
  49415. /**
  49416. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49417. */
  49418. gizmos: {
  49419. positionGizmo: Nullable<PositionGizmo>;
  49420. rotationGizmo: Nullable<RotationGizmo>;
  49421. scaleGizmo: Nullable<ScaleGizmo>;
  49422. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49423. };
  49424. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49425. clearGizmoOnEmptyPointerEvent: boolean;
  49426. /** Fires an event when the manager is attached to a mesh */
  49427. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49428. private _gizmosEnabled;
  49429. private _pointerObserver;
  49430. private _attachedMesh;
  49431. private _boundingBoxColor;
  49432. private _defaultUtilityLayer;
  49433. private _defaultKeepDepthUtilityLayer;
  49434. /**
  49435. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49436. */
  49437. boundingBoxDragBehavior: SixDofDragBehavior;
  49438. /**
  49439. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49440. */
  49441. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49442. /**
  49443. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49444. */
  49445. usePointerToAttachGizmos: boolean;
  49446. /**
  49447. * Utility layer that the bounding box gizmo belongs to
  49448. */
  49449. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49450. /**
  49451. * Utility layer that all gizmos besides bounding box belong to
  49452. */
  49453. get utilityLayer(): UtilityLayerRenderer;
  49454. /**
  49455. * Instatiates a gizmo manager
  49456. * @param scene the scene to overlay the gizmos on top of
  49457. */
  49458. constructor(scene: Scene);
  49459. /**
  49460. * Attaches a set of gizmos to the specified mesh
  49461. * @param mesh The mesh the gizmo's should be attached to
  49462. */
  49463. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49464. /**
  49465. * If the position gizmo is enabled
  49466. */
  49467. set positionGizmoEnabled(value: boolean);
  49468. get positionGizmoEnabled(): boolean;
  49469. /**
  49470. * If the rotation gizmo is enabled
  49471. */
  49472. set rotationGizmoEnabled(value: boolean);
  49473. get rotationGizmoEnabled(): boolean;
  49474. /**
  49475. * If the scale gizmo is enabled
  49476. */
  49477. set scaleGizmoEnabled(value: boolean);
  49478. get scaleGizmoEnabled(): boolean;
  49479. /**
  49480. * If the boundingBox gizmo is enabled
  49481. */
  49482. set boundingBoxGizmoEnabled(value: boolean);
  49483. get boundingBoxGizmoEnabled(): boolean;
  49484. /**
  49485. * Disposes of the gizmo manager
  49486. */
  49487. dispose(): void;
  49488. }
  49489. }
  49490. declare module BABYLON {
  49491. /**
  49492. * A directional light is defined by a direction (what a surprise!).
  49493. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49494. * 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.
  49495. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49496. */
  49497. export class DirectionalLight extends ShadowLight {
  49498. private _shadowFrustumSize;
  49499. /**
  49500. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49501. */
  49502. get shadowFrustumSize(): number;
  49503. /**
  49504. * Specifies a fix frustum size for the shadow generation.
  49505. */
  49506. set shadowFrustumSize(value: number);
  49507. private _shadowOrthoScale;
  49508. /**
  49509. * Gets the shadow projection scale against the optimal computed one.
  49510. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49511. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49512. */
  49513. get shadowOrthoScale(): number;
  49514. /**
  49515. * Sets the shadow projection scale against the optimal computed one.
  49516. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49517. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49518. */
  49519. set shadowOrthoScale(value: number);
  49520. /**
  49521. * Automatically compute the projection matrix to best fit (including all the casters)
  49522. * on each frame.
  49523. */
  49524. autoUpdateExtends: boolean;
  49525. /**
  49526. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49527. * on each frame. autoUpdateExtends must be set to true for this to work
  49528. */
  49529. autoCalcShadowZBounds: boolean;
  49530. private _orthoLeft;
  49531. private _orthoRight;
  49532. private _orthoTop;
  49533. private _orthoBottom;
  49534. /**
  49535. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49536. * The directional light is emitted from everywhere in the given direction.
  49537. * It can cast shadows.
  49538. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49539. * @param name The friendly name of the light
  49540. * @param direction The direction of the light
  49541. * @param scene The scene the light belongs to
  49542. */
  49543. constructor(name: string, direction: Vector3, scene: Scene);
  49544. /**
  49545. * Returns the string "DirectionalLight".
  49546. * @return The class name
  49547. */
  49548. getClassName(): string;
  49549. /**
  49550. * Returns the integer 1.
  49551. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49552. */
  49553. getTypeID(): number;
  49554. /**
  49555. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49556. * Returns the DirectionalLight Shadow projection matrix.
  49557. */
  49558. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49559. /**
  49560. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49561. * Returns the DirectionalLight Shadow projection matrix.
  49562. */
  49563. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49564. /**
  49565. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49566. * Returns the DirectionalLight Shadow projection matrix.
  49567. */
  49568. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49569. protected _buildUniformLayout(): void;
  49570. /**
  49571. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49572. * @param effect The effect to update
  49573. * @param lightIndex The index of the light in the effect to update
  49574. * @returns The directional light
  49575. */
  49576. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49577. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49578. /**
  49579. * Gets the minZ used for shadow according to both the scene and the light.
  49580. *
  49581. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49582. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49583. * @param activeCamera The camera we are returning the min for
  49584. * @returns the depth min z
  49585. */
  49586. getDepthMinZ(activeCamera: Camera): number;
  49587. /**
  49588. * Gets the maxZ used for shadow according to both the scene and the light.
  49589. *
  49590. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49591. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49592. * @param activeCamera The camera we are returning the max for
  49593. * @returns the depth max z
  49594. */
  49595. getDepthMaxZ(activeCamera: Camera): number;
  49596. /**
  49597. * Prepares the list of defines specific to the light type.
  49598. * @param defines the list of defines
  49599. * @param lightIndex defines the index of the light for the effect
  49600. */
  49601. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49602. }
  49603. }
  49604. declare module BABYLON {
  49605. /**
  49606. * Class containing static functions to help procedurally build meshes
  49607. */
  49608. export class HemisphereBuilder {
  49609. /**
  49610. * Creates a hemisphere mesh
  49611. * @param name defines the name of the mesh
  49612. * @param options defines the options used to create the mesh
  49613. * @param scene defines the hosting scene
  49614. * @returns the hemisphere mesh
  49615. */
  49616. static CreateHemisphere(name: string, options: {
  49617. segments?: number;
  49618. diameter?: number;
  49619. sideOrientation?: number;
  49620. }, scene: any): Mesh;
  49621. }
  49622. }
  49623. declare module BABYLON {
  49624. /**
  49625. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49626. * These values define a cone of light starting from the position, emitting toward the direction.
  49627. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49628. * and the exponent defines the speed of the decay of the light with distance (reach).
  49629. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49630. */
  49631. export class SpotLight extends ShadowLight {
  49632. private _angle;
  49633. private _innerAngle;
  49634. private _cosHalfAngle;
  49635. private _lightAngleScale;
  49636. private _lightAngleOffset;
  49637. /**
  49638. * Gets the cone angle of the spot light in Radians.
  49639. */
  49640. get angle(): number;
  49641. /**
  49642. * Sets the cone angle of the spot light in Radians.
  49643. */
  49644. set angle(value: number);
  49645. /**
  49646. * Only used in gltf falloff mode, this defines the angle where
  49647. * the directional falloff will start before cutting at angle which could be seen
  49648. * as outer angle.
  49649. */
  49650. get innerAngle(): number;
  49651. /**
  49652. * Only used in gltf falloff mode, this defines the angle where
  49653. * the directional falloff will start before cutting at angle which could be seen
  49654. * as outer angle.
  49655. */
  49656. set innerAngle(value: number);
  49657. private _shadowAngleScale;
  49658. /**
  49659. * Allows scaling the angle of the light for shadow generation only.
  49660. */
  49661. get shadowAngleScale(): number;
  49662. /**
  49663. * Allows scaling the angle of the light for shadow generation only.
  49664. */
  49665. set shadowAngleScale(value: number);
  49666. /**
  49667. * The light decay speed with the distance from the emission spot.
  49668. */
  49669. exponent: number;
  49670. private _projectionTextureMatrix;
  49671. /**
  49672. * Allows reading the projecton texture
  49673. */
  49674. get projectionTextureMatrix(): Matrix;
  49675. protected _projectionTextureLightNear: number;
  49676. /**
  49677. * Gets the near clip of the Spotlight for texture projection.
  49678. */
  49679. get projectionTextureLightNear(): number;
  49680. /**
  49681. * Sets the near clip of the Spotlight for texture projection.
  49682. */
  49683. set projectionTextureLightNear(value: number);
  49684. protected _projectionTextureLightFar: number;
  49685. /**
  49686. * Gets the far clip of the Spotlight for texture projection.
  49687. */
  49688. get projectionTextureLightFar(): number;
  49689. /**
  49690. * Sets the far clip of the Spotlight for texture projection.
  49691. */
  49692. set projectionTextureLightFar(value: number);
  49693. protected _projectionTextureUpDirection: Vector3;
  49694. /**
  49695. * Gets the Up vector of the Spotlight for texture projection.
  49696. */
  49697. get projectionTextureUpDirection(): Vector3;
  49698. /**
  49699. * Sets the Up vector of the Spotlight for texture projection.
  49700. */
  49701. set projectionTextureUpDirection(value: Vector3);
  49702. private _projectionTexture;
  49703. /**
  49704. * Gets the projection texture of the light.
  49705. */
  49706. get projectionTexture(): Nullable<BaseTexture>;
  49707. /**
  49708. * Sets the projection texture of the light.
  49709. */
  49710. set projectionTexture(value: Nullable<BaseTexture>);
  49711. private _projectionTextureViewLightDirty;
  49712. private _projectionTextureProjectionLightDirty;
  49713. private _projectionTextureDirty;
  49714. private _projectionTextureViewTargetVector;
  49715. private _projectionTextureViewLightMatrix;
  49716. private _projectionTextureProjectionLightMatrix;
  49717. private _projectionTextureScalingMatrix;
  49718. /**
  49719. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49720. * It can cast shadows.
  49721. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49722. * @param name The light friendly name
  49723. * @param position The position of the spot light in the scene
  49724. * @param direction The direction of the light in the scene
  49725. * @param angle The cone angle of the light in Radians
  49726. * @param exponent The light decay speed with the distance from the emission spot
  49727. * @param scene The scene the lights belongs to
  49728. */
  49729. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49730. /**
  49731. * Returns the string "SpotLight".
  49732. * @returns the class name
  49733. */
  49734. getClassName(): string;
  49735. /**
  49736. * Returns the integer 2.
  49737. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49738. */
  49739. getTypeID(): number;
  49740. /**
  49741. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49742. */
  49743. protected _setDirection(value: Vector3): void;
  49744. /**
  49745. * Overrides the position setter to recompute the projection texture view light Matrix.
  49746. */
  49747. protected _setPosition(value: Vector3): void;
  49748. /**
  49749. * 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.
  49750. * Returns the SpotLight.
  49751. */
  49752. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49753. protected _computeProjectionTextureViewLightMatrix(): void;
  49754. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49755. /**
  49756. * Main function for light texture projection matrix computing.
  49757. */
  49758. protected _computeProjectionTextureMatrix(): void;
  49759. protected _buildUniformLayout(): void;
  49760. private _computeAngleValues;
  49761. /**
  49762. * Sets the passed Effect "effect" with the Light textures.
  49763. * @param effect The effect to update
  49764. * @param lightIndex The index of the light in the effect to update
  49765. * @returns The light
  49766. */
  49767. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49768. /**
  49769. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49770. * @param effect The effect to update
  49771. * @param lightIndex The index of the light in the effect to update
  49772. * @returns The spot light
  49773. */
  49774. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49775. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49776. /**
  49777. * Disposes the light and the associated resources.
  49778. */
  49779. dispose(): void;
  49780. /**
  49781. * Prepares the list of defines specific to the light type.
  49782. * @param defines the list of defines
  49783. * @param lightIndex defines the index of the light for the effect
  49784. */
  49785. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49786. }
  49787. }
  49788. declare module BABYLON {
  49789. /**
  49790. * Gizmo that enables viewing a light
  49791. */
  49792. export class LightGizmo extends Gizmo {
  49793. private _lightMesh;
  49794. private _material;
  49795. private _cachedPosition;
  49796. private _cachedForward;
  49797. private _attachedMeshParent;
  49798. /**
  49799. * Creates a LightGizmo
  49800. * @param gizmoLayer The utility layer the gizmo will be added to
  49801. */
  49802. constructor(gizmoLayer?: UtilityLayerRenderer);
  49803. private _light;
  49804. /**
  49805. * The light that the gizmo is attached to
  49806. */
  49807. set light(light: Nullable<Light>);
  49808. get light(): Nullable<Light>;
  49809. /**
  49810. * Gets the material used to render the light gizmo
  49811. */
  49812. get material(): StandardMaterial;
  49813. /**
  49814. * @hidden
  49815. * Updates the gizmo to match the attached mesh's position/rotation
  49816. */
  49817. protected _update(): void;
  49818. private static _Scale;
  49819. /**
  49820. * Creates the lines for a light mesh
  49821. */
  49822. private static _CreateLightLines;
  49823. /**
  49824. * Disposes of the light gizmo
  49825. */
  49826. dispose(): void;
  49827. private static _CreateHemisphericLightMesh;
  49828. private static _CreatePointLightMesh;
  49829. private static _CreateSpotLightMesh;
  49830. private static _CreateDirectionalLightMesh;
  49831. }
  49832. }
  49833. declare module BABYLON {
  49834. /** @hidden */
  49835. export var backgroundFragmentDeclaration: {
  49836. name: string;
  49837. shader: string;
  49838. };
  49839. }
  49840. declare module BABYLON {
  49841. /** @hidden */
  49842. export var backgroundUboDeclaration: {
  49843. name: string;
  49844. shader: string;
  49845. };
  49846. }
  49847. declare module BABYLON {
  49848. /** @hidden */
  49849. export var backgroundPixelShader: {
  49850. name: string;
  49851. shader: string;
  49852. };
  49853. }
  49854. declare module BABYLON {
  49855. /** @hidden */
  49856. export var backgroundVertexDeclaration: {
  49857. name: string;
  49858. shader: string;
  49859. };
  49860. }
  49861. declare module BABYLON {
  49862. /** @hidden */
  49863. export var backgroundVertexShader: {
  49864. name: string;
  49865. shader: string;
  49866. };
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * Background material used to create an efficient environement around your scene.
  49871. */
  49872. export class BackgroundMaterial extends PushMaterial {
  49873. /**
  49874. * Standard reflectance value at parallel view angle.
  49875. */
  49876. static StandardReflectance0: number;
  49877. /**
  49878. * Standard reflectance value at grazing angle.
  49879. */
  49880. static StandardReflectance90: number;
  49881. protected _primaryColor: Color3;
  49882. /**
  49883. * Key light Color (multiply against the environement texture)
  49884. */
  49885. primaryColor: Color3;
  49886. protected __perceptualColor: Nullable<Color3>;
  49887. /**
  49888. * Experimental Internal Use Only.
  49889. *
  49890. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49891. * This acts as a helper to set the primary color to a more "human friendly" value.
  49892. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49893. * output color as close as possible from the chosen value.
  49894. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49895. * part of lighting setup.)
  49896. */
  49897. get _perceptualColor(): Nullable<Color3>;
  49898. set _perceptualColor(value: Nullable<Color3>);
  49899. protected _primaryColorShadowLevel: float;
  49900. /**
  49901. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49902. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49903. */
  49904. get primaryColorShadowLevel(): float;
  49905. set primaryColorShadowLevel(value: float);
  49906. protected _primaryColorHighlightLevel: float;
  49907. /**
  49908. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49909. * The primary color is used at the level chosen to define what the white area would look.
  49910. */
  49911. get primaryColorHighlightLevel(): float;
  49912. set primaryColorHighlightLevel(value: float);
  49913. protected _reflectionTexture: Nullable<BaseTexture>;
  49914. /**
  49915. * Reflection Texture used in the material.
  49916. * Should be author in a specific way for the best result (refer to the documentation).
  49917. */
  49918. reflectionTexture: Nullable<BaseTexture>;
  49919. protected _reflectionBlur: float;
  49920. /**
  49921. * Reflection Texture level of blur.
  49922. *
  49923. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49924. * texture twice.
  49925. */
  49926. reflectionBlur: float;
  49927. protected _diffuseTexture: Nullable<BaseTexture>;
  49928. /**
  49929. * Diffuse Texture used in the material.
  49930. * Should be author in a specific way for the best result (refer to the documentation).
  49931. */
  49932. diffuseTexture: Nullable<BaseTexture>;
  49933. protected _shadowLights: Nullable<IShadowLight[]>;
  49934. /**
  49935. * Specify the list of lights casting shadow on the material.
  49936. * All scene shadow lights will be included if null.
  49937. */
  49938. shadowLights: Nullable<IShadowLight[]>;
  49939. protected _shadowLevel: float;
  49940. /**
  49941. * Helps adjusting the shadow to a softer level if required.
  49942. * 0 means black shadows and 1 means no shadows.
  49943. */
  49944. shadowLevel: float;
  49945. protected _sceneCenter: Vector3;
  49946. /**
  49947. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49948. * It is usually zero but might be interesting to modify according to your setup.
  49949. */
  49950. sceneCenter: Vector3;
  49951. protected _opacityFresnel: boolean;
  49952. /**
  49953. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49954. * This helps ensuring a nice transition when the camera goes under the ground.
  49955. */
  49956. opacityFresnel: boolean;
  49957. protected _reflectionFresnel: boolean;
  49958. /**
  49959. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49960. * This helps adding a mirror texture on the ground.
  49961. */
  49962. reflectionFresnel: boolean;
  49963. protected _reflectionFalloffDistance: number;
  49964. /**
  49965. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49966. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49967. */
  49968. reflectionFalloffDistance: number;
  49969. protected _reflectionAmount: number;
  49970. /**
  49971. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49972. */
  49973. reflectionAmount: number;
  49974. protected _reflectionReflectance0: number;
  49975. /**
  49976. * This specifies the weight of the reflection at grazing angle.
  49977. */
  49978. reflectionReflectance0: number;
  49979. protected _reflectionReflectance90: number;
  49980. /**
  49981. * This specifies the weight of the reflection at a perpendicular point of view.
  49982. */
  49983. reflectionReflectance90: number;
  49984. /**
  49985. * Sets the reflection reflectance fresnel values according to the default standard
  49986. * empirically know to work well :-)
  49987. */
  49988. set reflectionStandardFresnelWeight(value: number);
  49989. protected _useRGBColor: boolean;
  49990. /**
  49991. * Helps to directly use the maps channels instead of their level.
  49992. */
  49993. useRGBColor: boolean;
  49994. protected _enableNoise: boolean;
  49995. /**
  49996. * This helps reducing the banding effect that could occur on the background.
  49997. */
  49998. enableNoise: boolean;
  49999. /**
  50000. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50001. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50002. * Recommended to be keep at 1.0 except for special cases.
  50003. */
  50004. get fovMultiplier(): number;
  50005. set fovMultiplier(value: number);
  50006. private _fovMultiplier;
  50007. /**
  50008. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50009. */
  50010. useEquirectangularFOV: boolean;
  50011. private _maxSimultaneousLights;
  50012. /**
  50013. * Number of Simultaneous lights allowed on the material.
  50014. */
  50015. maxSimultaneousLights: int;
  50016. /**
  50017. * Default configuration related to image processing available in the Background Material.
  50018. */
  50019. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50020. /**
  50021. * Keep track of the image processing observer to allow dispose and replace.
  50022. */
  50023. private _imageProcessingObserver;
  50024. /**
  50025. * Attaches a new image processing configuration to the PBR Material.
  50026. * @param configuration (if null the scene configuration will be use)
  50027. */
  50028. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50029. /**
  50030. * Gets the image processing configuration used either in this material.
  50031. */
  50032. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50033. /**
  50034. * Sets the Default image processing configuration used either in the this material.
  50035. *
  50036. * If sets to null, the scene one is in use.
  50037. */
  50038. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50039. /**
  50040. * Gets wether the color curves effect is enabled.
  50041. */
  50042. get cameraColorCurvesEnabled(): boolean;
  50043. /**
  50044. * Sets wether the color curves effect is enabled.
  50045. */
  50046. set cameraColorCurvesEnabled(value: boolean);
  50047. /**
  50048. * Gets wether the color grading effect is enabled.
  50049. */
  50050. get cameraColorGradingEnabled(): boolean;
  50051. /**
  50052. * Gets wether the color grading effect is enabled.
  50053. */
  50054. set cameraColorGradingEnabled(value: boolean);
  50055. /**
  50056. * Gets wether tonemapping is enabled or not.
  50057. */
  50058. get cameraToneMappingEnabled(): boolean;
  50059. /**
  50060. * Sets wether tonemapping is enabled or not
  50061. */
  50062. set cameraToneMappingEnabled(value: boolean);
  50063. /**
  50064. * The camera exposure used on this material.
  50065. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50066. * This corresponds to a photographic exposure.
  50067. */
  50068. get cameraExposure(): float;
  50069. /**
  50070. * The camera exposure used on this material.
  50071. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50072. * This corresponds to a photographic exposure.
  50073. */
  50074. set cameraExposure(value: float);
  50075. /**
  50076. * Gets The camera contrast used on this material.
  50077. */
  50078. get cameraContrast(): float;
  50079. /**
  50080. * Sets The camera contrast used on this material.
  50081. */
  50082. set cameraContrast(value: float);
  50083. /**
  50084. * Gets the Color Grading 2D Lookup Texture.
  50085. */
  50086. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50087. /**
  50088. * Sets the Color Grading 2D Lookup Texture.
  50089. */
  50090. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50091. /**
  50092. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50093. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50094. * 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;
  50095. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50096. */
  50097. get cameraColorCurves(): Nullable<ColorCurves>;
  50098. /**
  50099. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50100. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50101. * 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;
  50102. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50103. */
  50104. set cameraColorCurves(value: Nullable<ColorCurves>);
  50105. /**
  50106. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50107. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50108. */
  50109. switchToBGR: boolean;
  50110. private _renderTargets;
  50111. private _reflectionControls;
  50112. private _white;
  50113. private _primaryShadowColor;
  50114. private _primaryHighlightColor;
  50115. /**
  50116. * Instantiates a Background Material in the given scene
  50117. * @param name The friendly name of the material
  50118. * @param scene The scene to add the material to
  50119. */
  50120. constructor(name: string, scene: Scene);
  50121. /**
  50122. * Gets a boolean indicating that current material needs to register RTT
  50123. */
  50124. get hasRenderTargetTextures(): boolean;
  50125. /**
  50126. * The entire material has been created in order to prevent overdraw.
  50127. * @returns false
  50128. */
  50129. needAlphaTesting(): boolean;
  50130. /**
  50131. * The entire material has been created in order to prevent overdraw.
  50132. * @returns true if blending is enable
  50133. */
  50134. needAlphaBlending(): boolean;
  50135. /**
  50136. * Checks wether the material is ready to be rendered for a given mesh.
  50137. * @param mesh The mesh to render
  50138. * @param subMesh The submesh to check against
  50139. * @param useInstances Specify wether or not the material is used with instances
  50140. * @returns true if all the dependencies are ready (Textures, Effects...)
  50141. */
  50142. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50143. /**
  50144. * Compute the primary color according to the chosen perceptual color.
  50145. */
  50146. private _computePrimaryColorFromPerceptualColor;
  50147. /**
  50148. * Compute the highlights and shadow colors according to their chosen levels.
  50149. */
  50150. private _computePrimaryColors;
  50151. /**
  50152. * Build the uniform buffer used in the material.
  50153. */
  50154. buildUniformLayout(): void;
  50155. /**
  50156. * Unbind the material.
  50157. */
  50158. unbind(): void;
  50159. /**
  50160. * Bind only the world matrix to the material.
  50161. * @param world The world matrix to bind.
  50162. */
  50163. bindOnlyWorldMatrix(world: Matrix): void;
  50164. /**
  50165. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50166. * @param world The world matrix to bind.
  50167. * @param subMesh The submesh to bind for.
  50168. */
  50169. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50170. /**
  50171. * Checks to see if a texture is used in the material.
  50172. * @param texture - Base texture to use.
  50173. * @returns - Boolean specifying if a texture is used in the material.
  50174. */
  50175. hasTexture(texture: BaseTexture): boolean;
  50176. /**
  50177. * Dispose the material.
  50178. * @param forceDisposeEffect Force disposal of the associated effect.
  50179. * @param forceDisposeTextures Force disposal of the associated textures.
  50180. */
  50181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50182. /**
  50183. * Clones the material.
  50184. * @param name The cloned name.
  50185. * @returns The cloned material.
  50186. */
  50187. clone(name: string): BackgroundMaterial;
  50188. /**
  50189. * Serializes the current material to its JSON representation.
  50190. * @returns The JSON representation.
  50191. */
  50192. serialize(): any;
  50193. /**
  50194. * Gets the class name of the material
  50195. * @returns "BackgroundMaterial"
  50196. */
  50197. getClassName(): string;
  50198. /**
  50199. * Parse a JSON input to create back a background material.
  50200. * @param source The JSON data to parse
  50201. * @param scene The scene to create the parsed material in
  50202. * @param rootUrl The root url of the assets the material depends upon
  50203. * @returns the instantiated BackgroundMaterial.
  50204. */
  50205. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50206. }
  50207. }
  50208. declare module BABYLON {
  50209. /**
  50210. * Represents the different options available during the creation of
  50211. * a Environment helper.
  50212. *
  50213. * This can control the default ground, skybox and image processing setup of your scene.
  50214. */
  50215. export interface IEnvironmentHelperOptions {
  50216. /**
  50217. * Specifies whether or not to create a ground.
  50218. * True by default.
  50219. */
  50220. createGround: boolean;
  50221. /**
  50222. * Specifies the ground size.
  50223. * 15 by default.
  50224. */
  50225. groundSize: number;
  50226. /**
  50227. * The texture used on the ground for the main color.
  50228. * Comes from the BabylonJS CDN by default.
  50229. *
  50230. * Remarks: Can be either a texture or a url.
  50231. */
  50232. groundTexture: string | BaseTexture;
  50233. /**
  50234. * The color mixed in the ground texture by default.
  50235. * BabylonJS clearColor by default.
  50236. */
  50237. groundColor: Color3;
  50238. /**
  50239. * Specifies the ground opacity.
  50240. * 1 by default.
  50241. */
  50242. groundOpacity: number;
  50243. /**
  50244. * Enables the ground to receive shadows.
  50245. * True by default.
  50246. */
  50247. enableGroundShadow: boolean;
  50248. /**
  50249. * Helps preventing the shadow to be fully black on the ground.
  50250. * 0.5 by default.
  50251. */
  50252. groundShadowLevel: number;
  50253. /**
  50254. * Creates a mirror texture attach to the ground.
  50255. * false by default.
  50256. */
  50257. enableGroundMirror: boolean;
  50258. /**
  50259. * Specifies the ground mirror size ratio.
  50260. * 0.3 by default as the default kernel is 64.
  50261. */
  50262. groundMirrorSizeRatio: number;
  50263. /**
  50264. * Specifies the ground mirror blur kernel size.
  50265. * 64 by default.
  50266. */
  50267. groundMirrorBlurKernel: number;
  50268. /**
  50269. * Specifies the ground mirror visibility amount.
  50270. * 1 by default
  50271. */
  50272. groundMirrorAmount: number;
  50273. /**
  50274. * Specifies the ground mirror reflectance weight.
  50275. * This uses the standard weight of the background material to setup the fresnel effect
  50276. * of the mirror.
  50277. * 1 by default.
  50278. */
  50279. groundMirrorFresnelWeight: number;
  50280. /**
  50281. * Specifies the ground mirror Falloff distance.
  50282. * This can helps reducing the size of the reflection.
  50283. * 0 by Default.
  50284. */
  50285. groundMirrorFallOffDistance: number;
  50286. /**
  50287. * Specifies the ground mirror texture type.
  50288. * Unsigned Int by Default.
  50289. */
  50290. groundMirrorTextureType: number;
  50291. /**
  50292. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50293. * the shown objects.
  50294. */
  50295. groundYBias: number;
  50296. /**
  50297. * Specifies whether or not to create a skybox.
  50298. * True by default.
  50299. */
  50300. createSkybox: boolean;
  50301. /**
  50302. * Specifies the skybox size.
  50303. * 20 by default.
  50304. */
  50305. skyboxSize: number;
  50306. /**
  50307. * The texture used on the skybox for the main color.
  50308. * Comes from the BabylonJS CDN by default.
  50309. *
  50310. * Remarks: Can be either a texture or a url.
  50311. */
  50312. skyboxTexture: string | BaseTexture;
  50313. /**
  50314. * The color mixed in the skybox texture by default.
  50315. * BabylonJS clearColor by default.
  50316. */
  50317. skyboxColor: Color3;
  50318. /**
  50319. * The background rotation around the Y axis of the scene.
  50320. * This helps aligning the key lights of your scene with the background.
  50321. * 0 by default.
  50322. */
  50323. backgroundYRotation: number;
  50324. /**
  50325. * Compute automatically the size of the elements to best fit with the scene.
  50326. */
  50327. sizeAuto: boolean;
  50328. /**
  50329. * Default position of the rootMesh if autoSize is not true.
  50330. */
  50331. rootPosition: Vector3;
  50332. /**
  50333. * Sets up the image processing in the scene.
  50334. * true by default.
  50335. */
  50336. setupImageProcessing: boolean;
  50337. /**
  50338. * The texture used as your environment texture in the scene.
  50339. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50340. *
  50341. * Remarks: Can be either a texture or a url.
  50342. */
  50343. environmentTexture: string | BaseTexture;
  50344. /**
  50345. * The value of the exposure to apply to the scene.
  50346. * 0.6 by default if setupImageProcessing is true.
  50347. */
  50348. cameraExposure: number;
  50349. /**
  50350. * The value of the contrast to apply to the scene.
  50351. * 1.6 by default if setupImageProcessing is true.
  50352. */
  50353. cameraContrast: number;
  50354. /**
  50355. * Specifies whether or not tonemapping should be enabled in the scene.
  50356. * true by default if setupImageProcessing is true.
  50357. */
  50358. toneMappingEnabled: boolean;
  50359. }
  50360. /**
  50361. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50362. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50363. * It also helps with the default setup of your imageProcessing configuration.
  50364. */
  50365. export class EnvironmentHelper {
  50366. /**
  50367. * Default ground texture URL.
  50368. */
  50369. private static _groundTextureCDNUrl;
  50370. /**
  50371. * Default skybox texture URL.
  50372. */
  50373. private static _skyboxTextureCDNUrl;
  50374. /**
  50375. * Default environment texture URL.
  50376. */
  50377. private static _environmentTextureCDNUrl;
  50378. /**
  50379. * Creates the default options for the helper.
  50380. */
  50381. private static _getDefaultOptions;
  50382. private _rootMesh;
  50383. /**
  50384. * Gets the root mesh created by the helper.
  50385. */
  50386. get rootMesh(): Mesh;
  50387. private _skybox;
  50388. /**
  50389. * Gets the skybox created by the helper.
  50390. */
  50391. get skybox(): Nullable<Mesh>;
  50392. private _skyboxTexture;
  50393. /**
  50394. * Gets the skybox texture created by the helper.
  50395. */
  50396. get skyboxTexture(): Nullable<BaseTexture>;
  50397. private _skyboxMaterial;
  50398. /**
  50399. * Gets the skybox material created by the helper.
  50400. */
  50401. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50402. private _ground;
  50403. /**
  50404. * Gets the ground mesh created by the helper.
  50405. */
  50406. get ground(): Nullable<Mesh>;
  50407. private _groundTexture;
  50408. /**
  50409. * Gets the ground texture created by the helper.
  50410. */
  50411. get groundTexture(): Nullable<BaseTexture>;
  50412. private _groundMirror;
  50413. /**
  50414. * Gets the ground mirror created by the helper.
  50415. */
  50416. get groundMirror(): Nullable<MirrorTexture>;
  50417. /**
  50418. * Gets the ground mirror render list to helps pushing the meshes
  50419. * you wish in the ground reflection.
  50420. */
  50421. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50422. private _groundMaterial;
  50423. /**
  50424. * Gets the ground material created by the helper.
  50425. */
  50426. get groundMaterial(): Nullable<BackgroundMaterial>;
  50427. /**
  50428. * Stores the creation options.
  50429. */
  50430. private readonly _scene;
  50431. private _options;
  50432. /**
  50433. * This observable will be notified with any error during the creation of the environment,
  50434. * mainly texture creation errors.
  50435. */
  50436. onErrorObservable: Observable<{
  50437. message?: string;
  50438. exception?: any;
  50439. }>;
  50440. /**
  50441. * constructor
  50442. * @param options Defines the options we want to customize the helper
  50443. * @param scene The scene to add the material to
  50444. */
  50445. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50446. /**
  50447. * Updates the background according to the new options
  50448. * @param options
  50449. */
  50450. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50451. /**
  50452. * Sets the primary color of all the available elements.
  50453. * @param color the main color to affect to the ground and the background
  50454. */
  50455. setMainColor(color: Color3): void;
  50456. /**
  50457. * Setup the image processing according to the specified options.
  50458. */
  50459. private _setupImageProcessing;
  50460. /**
  50461. * Setup the environment texture according to the specified options.
  50462. */
  50463. private _setupEnvironmentTexture;
  50464. /**
  50465. * Setup the background according to the specified options.
  50466. */
  50467. private _setupBackground;
  50468. /**
  50469. * Get the scene sizes according to the setup.
  50470. */
  50471. private _getSceneSize;
  50472. /**
  50473. * Setup the ground according to the specified options.
  50474. */
  50475. private _setupGround;
  50476. /**
  50477. * Setup the ground material according to the specified options.
  50478. */
  50479. private _setupGroundMaterial;
  50480. /**
  50481. * Setup the ground diffuse texture according to the specified options.
  50482. */
  50483. private _setupGroundDiffuseTexture;
  50484. /**
  50485. * Setup the ground mirror texture according to the specified options.
  50486. */
  50487. private _setupGroundMirrorTexture;
  50488. /**
  50489. * Setup the ground to receive the mirror texture.
  50490. */
  50491. private _setupMirrorInGroundMaterial;
  50492. /**
  50493. * Setup the skybox according to the specified options.
  50494. */
  50495. private _setupSkybox;
  50496. /**
  50497. * Setup the skybox material according to the specified options.
  50498. */
  50499. private _setupSkyboxMaterial;
  50500. /**
  50501. * Setup the skybox reflection texture according to the specified options.
  50502. */
  50503. private _setupSkyboxReflectionTexture;
  50504. private _errorHandler;
  50505. /**
  50506. * Dispose all the elements created by the Helper.
  50507. */
  50508. dispose(): void;
  50509. }
  50510. }
  50511. declare module BABYLON {
  50512. /**
  50513. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50514. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50515. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50516. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50517. */
  50518. export class PhotoDome extends TransformNode {
  50519. /**
  50520. * Define the image as a Monoscopic panoramic 360 image.
  50521. */
  50522. static readonly MODE_MONOSCOPIC: number;
  50523. /**
  50524. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50525. */
  50526. static readonly MODE_TOPBOTTOM: number;
  50527. /**
  50528. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50529. */
  50530. static readonly MODE_SIDEBYSIDE: number;
  50531. private _useDirectMapping;
  50532. /**
  50533. * The texture being displayed on the sphere
  50534. */
  50535. protected _photoTexture: Texture;
  50536. /**
  50537. * Gets or sets the texture being displayed on the sphere
  50538. */
  50539. get photoTexture(): Texture;
  50540. set photoTexture(value: Texture);
  50541. /**
  50542. * Observable raised when an error occured while loading the 360 image
  50543. */
  50544. onLoadErrorObservable: Observable<string>;
  50545. /**
  50546. * The skybox material
  50547. */
  50548. protected _material: BackgroundMaterial;
  50549. /**
  50550. * The surface used for the skybox
  50551. */
  50552. protected _mesh: Mesh;
  50553. /**
  50554. * Gets the mesh used for the skybox.
  50555. */
  50556. get mesh(): Mesh;
  50557. /**
  50558. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50559. * Also see the options.resolution property.
  50560. */
  50561. get fovMultiplier(): number;
  50562. set fovMultiplier(value: number);
  50563. private _imageMode;
  50564. /**
  50565. * Gets or set the current video mode for the video. It can be:
  50566. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50567. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50568. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50569. */
  50570. get imageMode(): number;
  50571. set imageMode(value: number);
  50572. /**
  50573. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50574. * @param name Element's name, child elements will append suffixes for their own names.
  50575. * @param urlsOfPhoto defines the url of the photo to display
  50576. * @param options defines an object containing optional or exposed sub element properties
  50577. * @param onError defines a callback called when an error occured while loading the texture
  50578. */
  50579. constructor(name: string, urlOfPhoto: string, options: {
  50580. resolution?: number;
  50581. size?: number;
  50582. useDirectMapping?: boolean;
  50583. faceForward?: boolean;
  50584. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50585. private _onBeforeCameraRenderObserver;
  50586. private _changeImageMode;
  50587. /**
  50588. * Releases resources associated with this node.
  50589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50591. */
  50592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50593. }
  50594. }
  50595. declare module BABYLON {
  50596. /**
  50597. * Class used to host RGBD texture specific utilities
  50598. */
  50599. export class RGBDTextureTools {
  50600. /**
  50601. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50602. * @param texture the texture to expand.
  50603. */
  50604. static ExpandRGBDTexture(texture: Texture): void;
  50605. }
  50606. }
  50607. declare module BABYLON {
  50608. /**
  50609. * Class used to host texture specific utilities
  50610. */
  50611. export class BRDFTextureTools {
  50612. /**
  50613. * Prevents texture cache collision
  50614. */
  50615. private static _instanceNumber;
  50616. /**
  50617. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50618. * @param scene defines the hosting scene
  50619. * @returns the environment BRDF texture
  50620. */
  50621. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50622. private static _environmentBRDFBase64Texture;
  50623. }
  50624. }
  50625. declare module BABYLON {
  50626. /**
  50627. * @hidden
  50628. */
  50629. export interface IMaterialClearCoatDefines {
  50630. CLEARCOAT: boolean;
  50631. CLEARCOAT_DEFAULTIOR: boolean;
  50632. CLEARCOAT_TEXTURE: boolean;
  50633. CLEARCOAT_TEXTUREDIRECTUV: number;
  50634. CLEARCOAT_BUMP: boolean;
  50635. CLEARCOAT_BUMPDIRECTUV: number;
  50636. CLEARCOAT_TINT: boolean;
  50637. CLEARCOAT_TINT_TEXTURE: boolean;
  50638. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50639. /** @hidden */
  50640. _areTexturesDirty: boolean;
  50641. }
  50642. /**
  50643. * Define the code related to the clear coat parameters of the pbr material.
  50644. */
  50645. export class PBRClearCoatConfiguration {
  50646. /**
  50647. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50648. * The default fits with a polyurethane material.
  50649. */
  50650. private static readonly _DefaultIndexOfRefraction;
  50651. private _isEnabled;
  50652. /**
  50653. * Defines if the clear coat is enabled in the material.
  50654. */
  50655. isEnabled: boolean;
  50656. /**
  50657. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50658. */
  50659. intensity: number;
  50660. /**
  50661. * Defines the clear coat layer roughness.
  50662. */
  50663. roughness: number;
  50664. private _indexOfRefraction;
  50665. /**
  50666. * Defines the index of refraction of the clear coat.
  50667. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50668. * The default fits with a polyurethane material.
  50669. * Changing the default value is more performance intensive.
  50670. */
  50671. indexOfRefraction: number;
  50672. private _texture;
  50673. /**
  50674. * Stores the clear coat values in a texture.
  50675. */
  50676. texture: Nullable<BaseTexture>;
  50677. private _bumpTexture;
  50678. /**
  50679. * Define the clear coat specific bump texture.
  50680. */
  50681. bumpTexture: Nullable<BaseTexture>;
  50682. private _isTintEnabled;
  50683. /**
  50684. * Defines if the clear coat tint is enabled in the material.
  50685. */
  50686. isTintEnabled: boolean;
  50687. /**
  50688. * Defines the clear coat tint of the material.
  50689. * This is only use if tint is enabled
  50690. */
  50691. tintColor: Color3;
  50692. /**
  50693. * Defines the distance at which the tint color should be found in the
  50694. * clear coat media.
  50695. * This is only use if tint is enabled
  50696. */
  50697. tintColorAtDistance: number;
  50698. /**
  50699. * Defines the clear coat layer thickness.
  50700. * This is only use if tint is enabled
  50701. */
  50702. tintThickness: number;
  50703. private _tintTexture;
  50704. /**
  50705. * Stores the clear tint values in a texture.
  50706. * rgb is tint
  50707. * a is a thickness factor
  50708. */
  50709. tintTexture: Nullable<BaseTexture>;
  50710. /** @hidden */
  50711. private _internalMarkAllSubMeshesAsTexturesDirty;
  50712. /** @hidden */
  50713. _markAllSubMeshesAsTexturesDirty(): void;
  50714. /**
  50715. * Instantiate a new istance of clear coat configuration.
  50716. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50717. */
  50718. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50719. /**
  50720. * Gets wehter the submesh is ready to be used or not.
  50721. * @param defines the list of "defines" to update.
  50722. * @param scene defines the scene the material belongs to.
  50723. * @param engine defines the engine the material belongs to.
  50724. * @param disableBumpMap defines wether the material disables bump or not.
  50725. * @returns - boolean indicating that the submesh is ready or not.
  50726. */
  50727. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50728. /**
  50729. * Checks to see if a texture is used in the material.
  50730. * @param defines the list of "defines" to update.
  50731. * @param scene defines the scene to the material belongs to.
  50732. */
  50733. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50734. /**
  50735. * Binds the material data.
  50736. * @param uniformBuffer defines the Uniform buffer to fill in.
  50737. * @param scene defines the scene the material belongs to.
  50738. * @param engine defines the engine the material belongs to.
  50739. * @param disableBumpMap defines wether the material disables bump or not.
  50740. * @param isFrozen defines wether the material is frozen or not.
  50741. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50742. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50743. */
  50744. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50745. /**
  50746. * Checks to see if a texture is used in the material.
  50747. * @param texture - Base texture to use.
  50748. * @returns - Boolean specifying if a texture is used in the material.
  50749. */
  50750. hasTexture(texture: BaseTexture): boolean;
  50751. /**
  50752. * Returns an array of the actively used textures.
  50753. * @param activeTextures Array of BaseTextures
  50754. */
  50755. getActiveTextures(activeTextures: BaseTexture[]): void;
  50756. /**
  50757. * Returns the animatable textures.
  50758. * @param animatables Array of animatable textures.
  50759. */
  50760. getAnimatables(animatables: IAnimatable[]): void;
  50761. /**
  50762. * Disposes the resources of the material.
  50763. * @param forceDisposeTextures - Forces the disposal of all textures.
  50764. */
  50765. dispose(forceDisposeTextures?: boolean): void;
  50766. /**
  50767. * Get the current class name of the texture useful for serialization or dynamic coding.
  50768. * @returns "PBRClearCoatConfiguration"
  50769. */
  50770. getClassName(): string;
  50771. /**
  50772. * Add fallbacks to the effect fallbacks list.
  50773. * @param defines defines the Base texture to use.
  50774. * @param fallbacks defines the current fallback list.
  50775. * @param currentRank defines the current fallback rank.
  50776. * @returns the new fallback rank.
  50777. */
  50778. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50779. /**
  50780. * Add the required uniforms to the current list.
  50781. * @param uniforms defines the current uniform list.
  50782. */
  50783. static AddUniforms(uniforms: string[]): void;
  50784. /**
  50785. * Add the required samplers to the current list.
  50786. * @param samplers defines the current sampler list.
  50787. */
  50788. static AddSamplers(samplers: string[]): void;
  50789. /**
  50790. * Add the required uniforms to the current buffer.
  50791. * @param uniformBuffer defines the current uniform buffer.
  50792. */
  50793. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50794. /**
  50795. * Makes a duplicate of the current configuration into another one.
  50796. * @param clearCoatConfiguration define the config where to copy the info
  50797. */
  50798. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50799. /**
  50800. * Serializes this clear coat configuration.
  50801. * @returns - An object with the serialized config.
  50802. */
  50803. serialize(): any;
  50804. /**
  50805. * Parses a anisotropy Configuration from a serialized object.
  50806. * @param source - Serialized object.
  50807. * @param scene Defines the scene we are parsing for
  50808. * @param rootUrl Defines the rootUrl to load from
  50809. */
  50810. parse(source: any, scene: Scene, rootUrl: string): void;
  50811. }
  50812. }
  50813. declare module BABYLON {
  50814. /**
  50815. * @hidden
  50816. */
  50817. export interface IMaterialAnisotropicDefines {
  50818. ANISOTROPIC: boolean;
  50819. ANISOTROPIC_TEXTURE: boolean;
  50820. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50821. MAINUV1: boolean;
  50822. _areTexturesDirty: boolean;
  50823. _needUVs: boolean;
  50824. }
  50825. /**
  50826. * Define the code related to the anisotropic parameters of the pbr material.
  50827. */
  50828. export class PBRAnisotropicConfiguration {
  50829. private _isEnabled;
  50830. /**
  50831. * Defines if the anisotropy is enabled in the material.
  50832. */
  50833. isEnabled: boolean;
  50834. /**
  50835. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50836. */
  50837. intensity: number;
  50838. /**
  50839. * Defines if the effect is along the tangents, bitangents or in between.
  50840. * By default, the effect is "strectching" the highlights along the tangents.
  50841. */
  50842. direction: Vector2;
  50843. private _texture;
  50844. /**
  50845. * Stores the anisotropy values in a texture.
  50846. * rg is direction (like normal from -1 to 1)
  50847. * b is a intensity
  50848. */
  50849. texture: Nullable<BaseTexture>;
  50850. /** @hidden */
  50851. private _internalMarkAllSubMeshesAsTexturesDirty;
  50852. /** @hidden */
  50853. _markAllSubMeshesAsTexturesDirty(): void;
  50854. /**
  50855. * Instantiate a new istance of anisotropy configuration.
  50856. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50857. */
  50858. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50859. /**
  50860. * Specifies that the submesh is ready to be used.
  50861. * @param defines the list of "defines" to update.
  50862. * @param scene defines the scene the material belongs to.
  50863. * @returns - boolean indicating that the submesh is ready or not.
  50864. */
  50865. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50866. /**
  50867. * Checks to see if a texture is used in the material.
  50868. * @param defines the list of "defines" to update.
  50869. * @param mesh the mesh we are preparing the defines for.
  50870. * @param scene defines the scene the material belongs to.
  50871. */
  50872. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50873. /**
  50874. * Binds the material data.
  50875. * @param uniformBuffer defines the Uniform buffer to fill in.
  50876. * @param scene defines the scene the material belongs to.
  50877. * @param isFrozen defines wether the material is frozen or not.
  50878. */
  50879. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50880. /**
  50881. * Checks to see if a texture is used in the material.
  50882. * @param texture - Base texture to use.
  50883. * @returns - Boolean specifying if a texture is used in the material.
  50884. */
  50885. hasTexture(texture: BaseTexture): boolean;
  50886. /**
  50887. * Returns an array of the actively used textures.
  50888. * @param activeTextures Array of BaseTextures
  50889. */
  50890. getActiveTextures(activeTextures: BaseTexture[]): void;
  50891. /**
  50892. * Returns the animatable textures.
  50893. * @param animatables Array of animatable textures.
  50894. */
  50895. getAnimatables(animatables: IAnimatable[]): void;
  50896. /**
  50897. * Disposes the resources of the material.
  50898. * @param forceDisposeTextures - Forces the disposal of all textures.
  50899. */
  50900. dispose(forceDisposeTextures?: boolean): void;
  50901. /**
  50902. * Get the current class name of the texture useful for serialization or dynamic coding.
  50903. * @returns "PBRAnisotropicConfiguration"
  50904. */
  50905. getClassName(): string;
  50906. /**
  50907. * Add fallbacks to the effect fallbacks list.
  50908. * @param defines defines the Base texture to use.
  50909. * @param fallbacks defines the current fallback list.
  50910. * @param currentRank defines the current fallback rank.
  50911. * @returns the new fallback rank.
  50912. */
  50913. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50914. /**
  50915. * Add the required uniforms to the current list.
  50916. * @param uniforms defines the current uniform list.
  50917. */
  50918. static AddUniforms(uniforms: string[]): void;
  50919. /**
  50920. * Add the required uniforms to the current buffer.
  50921. * @param uniformBuffer defines the current uniform buffer.
  50922. */
  50923. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50924. /**
  50925. * Add the required samplers to the current list.
  50926. * @param samplers defines the current sampler list.
  50927. */
  50928. static AddSamplers(samplers: string[]): void;
  50929. /**
  50930. * Makes a duplicate of the current configuration into another one.
  50931. * @param anisotropicConfiguration define the config where to copy the info
  50932. */
  50933. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50934. /**
  50935. * Serializes this anisotropy configuration.
  50936. * @returns - An object with the serialized config.
  50937. */
  50938. serialize(): any;
  50939. /**
  50940. * Parses a anisotropy Configuration from a serialized object.
  50941. * @param source - Serialized object.
  50942. * @param scene Defines the scene we are parsing for
  50943. * @param rootUrl Defines the rootUrl to load from
  50944. */
  50945. parse(source: any, scene: Scene, rootUrl: string): void;
  50946. }
  50947. }
  50948. declare module BABYLON {
  50949. /**
  50950. * @hidden
  50951. */
  50952. export interface IMaterialBRDFDefines {
  50953. BRDF_V_HEIGHT_CORRELATED: boolean;
  50954. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50955. SPHERICAL_HARMONICS: boolean;
  50956. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50957. /** @hidden */
  50958. _areMiscDirty: boolean;
  50959. }
  50960. /**
  50961. * Define the code related to the BRDF parameters of the pbr material.
  50962. */
  50963. export class PBRBRDFConfiguration {
  50964. /**
  50965. * Default value used for the energy conservation.
  50966. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50967. */
  50968. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50969. /**
  50970. * Default value used for the Smith Visibility Height Correlated mode.
  50971. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50972. */
  50973. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50974. /**
  50975. * Default value used for the IBL diffuse part.
  50976. * This can help switching back to the polynomials mode globally which is a tiny bit
  50977. * less GPU intensive at the drawback of a lower quality.
  50978. */
  50979. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50980. /**
  50981. * Default value used for activating energy conservation for the specular workflow.
  50982. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50983. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50984. */
  50985. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50986. private _useEnergyConservation;
  50987. /**
  50988. * Defines if the material uses energy conservation.
  50989. */
  50990. useEnergyConservation: boolean;
  50991. private _useSmithVisibilityHeightCorrelated;
  50992. /**
  50993. * LEGACY Mode set to false
  50994. * Defines if the material uses height smith correlated visibility term.
  50995. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50996. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50997. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50998. * Not relying on height correlated will also disable energy conservation.
  50999. */
  51000. useSmithVisibilityHeightCorrelated: boolean;
  51001. private _useSphericalHarmonics;
  51002. /**
  51003. * LEGACY Mode set to false
  51004. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51005. * diffuse part of the IBL.
  51006. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51007. * to the ground truth.
  51008. */
  51009. useSphericalHarmonics: boolean;
  51010. private _useSpecularGlossinessInputEnergyConservation;
  51011. /**
  51012. * Defines if the material uses energy conservation, when the specular workflow is active.
  51013. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51014. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51015. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51016. */
  51017. useSpecularGlossinessInputEnergyConservation: boolean;
  51018. /** @hidden */
  51019. private _internalMarkAllSubMeshesAsMiscDirty;
  51020. /** @hidden */
  51021. _markAllSubMeshesAsMiscDirty(): void;
  51022. /**
  51023. * Instantiate a new istance of clear coat configuration.
  51024. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51025. */
  51026. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51027. /**
  51028. * Checks to see if a texture is used in the material.
  51029. * @param defines the list of "defines" to update.
  51030. */
  51031. prepareDefines(defines: IMaterialBRDFDefines): void;
  51032. /**
  51033. * Get the current class name of the texture useful for serialization or dynamic coding.
  51034. * @returns "PBRClearCoatConfiguration"
  51035. */
  51036. getClassName(): string;
  51037. /**
  51038. * Makes a duplicate of the current configuration into another one.
  51039. * @param brdfConfiguration define the config where to copy the info
  51040. */
  51041. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51042. /**
  51043. * Serializes this BRDF configuration.
  51044. * @returns - An object with the serialized config.
  51045. */
  51046. serialize(): any;
  51047. /**
  51048. * Parses a anisotropy Configuration from a serialized object.
  51049. * @param source - Serialized object.
  51050. * @param scene Defines the scene we are parsing for
  51051. * @param rootUrl Defines the rootUrl to load from
  51052. */
  51053. parse(source: any, scene: Scene, rootUrl: string): void;
  51054. }
  51055. }
  51056. declare module BABYLON {
  51057. /**
  51058. * @hidden
  51059. */
  51060. export interface IMaterialSheenDefines {
  51061. SHEEN: boolean;
  51062. SHEEN_TEXTURE: boolean;
  51063. SHEEN_TEXTUREDIRECTUV: number;
  51064. SHEEN_LINKWITHALBEDO: boolean;
  51065. SHEEN_ROUGHNESS: boolean;
  51066. SHEEN_ALBEDOSCALING: boolean;
  51067. /** @hidden */
  51068. _areTexturesDirty: boolean;
  51069. }
  51070. /**
  51071. * Define the code related to the Sheen parameters of the pbr material.
  51072. */
  51073. export class PBRSheenConfiguration {
  51074. private _isEnabled;
  51075. /**
  51076. * Defines if the material uses sheen.
  51077. */
  51078. isEnabled: boolean;
  51079. private _linkSheenWithAlbedo;
  51080. /**
  51081. * Defines if the sheen is linked to the sheen color.
  51082. */
  51083. linkSheenWithAlbedo: boolean;
  51084. /**
  51085. * Defines the sheen intensity.
  51086. */
  51087. intensity: number;
  51088. /**
  51089. * Defines the sheen color.
  51090. */
  51091. color: Color3;
  51092. private _texture;
  51093. /**
  51094. * Stores the sheen tint values in a texture.
  51095. * rgb is tint
  51096. * a is a intensity
  51097. */
  51098. texture: Nullable<BaseTexture>;
  51099. private _roughness;
  51100. /**
  51101. * Defines the sheen roughness.
  51102. * It is not taken into account if linkSheenWithAlbedo is true.
  51103. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  51104. */
  51105. roughness: Nullable<number>;
  51106. private _albedoScaling;
  51107. /**
  51108. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  51109. * It allows the strength of the sheen effect to not depend on the base color of the material,
  51110. * making it easier to setup and tweak the effect
  51111. */
  51112. albedoScaling: boolean;
  51113. /** @hidden */
  51114. private _internalMarkAllSubMeshesAsTexturesDirty;
  51115. /** @hidden */
  51116. _markAllSubMeshesAsTexturesDirty(): void;
  51117. /**
  51118. * Instantiate a new istance of clear coat configuration.
  51119. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51120. */
  51121. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51122. /**
  51123. * Specifies that the submesh is ready to be used.
  51124. * @param defines the list of "defines" to update.
  51125. * @param scene defines the scene the material belongs to.
  51126. * @returns - boolean indicating that the submesh is ready or not.
  51127. */
  51128. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51129. /**
  51130. * Checks to see if a texture is used in the material.
  51131. * @param defines the list of "defines" to update.
  51132. * @param scene defines the scene the material belongs to.
  51133. */
  51134. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51135. /**
  51136. * Binds the material data.
  51137. * @param uniformBuffer defines the Uniform buffer to fill in.
  51138. * @param scene defines the scene the material belongs to.
  51139. * @param isFrozen defines wether the material is frozen or not.
  51140. */
  51141. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51142. /**
  51143. * Checks to see if a texture is used in the material.
  51144. * @param texture - Base texture to use.
  51145. * @returns - Boolean specifying if a texture is used in the material.
  51146. */
  51147. hasTexture(texture: BaseTexture): boolean;
  51148. /**
  51149. * Returns an array of the actively used textures.
  51150. * @param activeTextures Array of BaseTextures
  51151. */
  51152. getActiveTextures(activeTextures: BaseTexture[]): void;
  51153. /**
  51154. * Returns the animatable textures.
  51155. * @param animatables Array of animatable textures.
  51156. */
  51157. getAnimatables(animatables: IAnimatable[]): void;
  51158. /**
  51159. * Disposes the resources of the material.
  51160. * @param forceDisposeTextures - Forces the disposal of all textures.
  51161. */
  51162. dispose(forceDisposeTextures?: boolean): void;
  51163. /**
  51164. * Get the current class name of the texture useful for serialization or dynamic coding.
  51165. * @returns "PBRSheenConfiguration"
  51166. */
  51167. getClassName(): string;
  51168. /**
  51169. * Add fallbacks to the effect fallbacks list.
  51170. * @param defines defines the Base texture to use.
  51171. * @param fallbacks defines the current fallback list.
  51172. * @param currentRank defines the current fallback rank.
  51173. * @returns the new fallback rank.
  51174. */
  51175. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51176. /**
  51177. * Add the required uniforms to the current list.
  51178. * @param uniforms defines the current uniform list.
  51179. */
  51180. static AddUniforms(uniforms: string[]): void;
  51181. /**
  51182. * Add the required uniforms to the current buffer.
  51183. * @param uniformBuffer defines the current uniform buffer.
  51184. */
  51185. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51186. /**
  51187. * Add the required samplers to the current list.
  51188. * @param samplers defines the current sampler list.
  51189. */
  51190. static AddSamplers(samplers: string[]): void;
  51191. /**
  51192. * Makes a duplicate of the current configuration into another one.
  51193. * @param sheenConfiguration define the config where to copy the info
  51194. */
  51195. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51196. /**
  51197. * Serializes this BRDF configuration.
  51198. * @returns - An object with the serialized config.
  51199. */
  51200. serialize(): any;
  51201. /**
  51202. * Parses a anisotropy Configuration from a serialized object.
  51203. * @param source - Serialized object.
  51204. * @param scene Defines the scene we are parsing for
  51205. * @param rootUrl Defines the rootUrl to load from
  51206. */
  51207. parse(source: any, scene: Scene, rootUrl: string): void;
  51208. }
  51209. }
  51210. declare module BABYLON {
  51211. /**
  51212. * @hidden
  51213. */
  51214. export interface IMaterialSubSurfaceDefines {
  51215. SUBSURFACE: boolean;
  51216. SS_REFRACTION: boolean;
  51217. SS_TRANSLUCENCY: boolean;
  51218. SS_SCATERRING: boolean;
  51219. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51220. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51221. SS_REFRACTIONMAP_3D: boolean;
  51222. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51223. SS_LODINREFRACTIONALPHA: boolean;
  51224. SS_GAMMAREFRACTION: boolean;
  51225. SS_RGBDREFRACTION: boolean;
  51226. SS_LINEARSPECULARREFRACTION: boolean;
  51227. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51228. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51229. /** @hidden */
  51230. _areTexturesDirty: boolean;
  51231. }
  51232. /**
  51233. * Define the code related to the sub surface parameters of the pbr material.
  51234. */
  51235. export class PBRSubSurfaceConfiguration {
  51236. private _isRefractionEnabled;
  51237. /**
  51238. * Defines if the refraction is enabled in the material.
  51239. */
  51240. isRefractionEnabled: boolean;
  51241. private _isTranslucencyEnabled;
  51242. /**
  51243. * Defines if the translucency is enabled in the material.
  51244. */
  51245. isTranslucencyEnabled: boolean;
  51246. private _isScatteringEnabled;
  51247. /**
  51248. * Defines the refraction intensity of the material.
  51249. * The refraction when enabled replaces the Diffuse part of the material.
  51250. * The intensity helps transitionning between diffuse and refraction.
  51251. */
  51252. refractionIntensity: number;
  51253. /**
  51254. * Defines the translucency intensity of the material.
  51255. * When translucency has been enabled, this defines how much of the "translucency"
  51256. * is addded to the diffuse part of the material.
  51257. */
  51258. translucencyIntensity: number;
  51259. /**
  51260. * Defines the scattering intensity of the material.
  51261. * When scattering has been enabled, this defines how much of the "scattered light"
  51262. * is addded to the diffuse part of the material.
  51263. */
  51264. scatteringIntensity: number;
  51265. private _thicknessTexture;
  51266. /**
  51267. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51268. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51269. * 0 would mean minimumThickness
  51270. * 1 would mean maximumThickness
  51271. * The other channels might be use as a mask to vary the different effects intensity.
  51272. */
  51273. thicknessTexture: Nullable<BaseTexture>;
  51274. private _refractionTexture;
  51275. /**
  51276. * Defines the texture to use for refraction.
  51277. */
  51278. refractionTexture: Nullable<BaseTexture>;
  51279. private _indexOfRefraction;
  51280. /**
  51281. * Defines the index of refraction used in the material.
  51282. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51283. */
  51284. indexOfRefraction: number;
  51285. private _invertRefractionY;
  51286. /**
  51287. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51288. */
  51289. invertRefractionY: boolean;
  51290. private _linkRefractionWithTransparency;
  51291. /**
  51292. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51293. * Materials half opaque for instance using refraction could benefit from this control.
  51294. */
  51295. linkRefractionWithTransparency: boolean;
  51296. /**
  51297. * Defines the minimum thickness stored in the thickness map.
  51298. * If no thickness map is defined, this value will be used to simulate thickness.
  51299. */
  51300. minimumThickness: number;
  51301. /**
  51302. * Defines the maximum thickness stored in the thickness map.
  51303. */
  51304. maximumThickness: number;
  51305. /**
  51306. * Defines the volume tint of the material.
  51307. * This is used for both translucency and scattering.
  51308. */
  51309. tintColor: Color3;
  51310. /**
  51311. * Defines the distance at which the tint color should be found in the media.
  51312. * This is used for refraction only.
  51313. */
  51314. tintColorAtDistance: number;
  51315. /**
  51316. * Defines how far each channel transmit through the media.
  51317. * It is defined as a color to simplify it selection.
  51318. */
  51319. diffusionDistance: Color3;
  51320. private _useMaskFromThicknessTexture;
  51321. /**
  51322. * Stores the intensity of the different subsurface effects in the thickness texture.
  51323. * * the green channel is the translucency intensity.
  51324. * * the blue channel is the scattering intensity.
  51325. * * the alpha channel is the refraction intensity.
  51326. */
  51327. useMaskFromThicknessTexture: boolean;
  51328. /** @hidden */
  51329. private _internalMarkAllSubMeshesAsTexturesDirty;
  51330. /** @hidden */
  51331. _markAllSubMeshesAsTexturesDirty(): void;
  51332. /**
  51333. * Instantiate a new istance of sub surface configuration.
  51334. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51335. */
  51336. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51337. /**
  51338. * Gets wehter the submesh is ready to be used or not.
  51339. * @param defines the list of "defines" to update.
  51340. * @param scene defines the scene the material belongs to.
  51341. * @returns - boolean indicating that the submesh is ready or not.
  51342. */
  51343. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51344. /**
  51345. * Checks to see if a texture is used in the material.
  51346. * @param defines the list of "defines" to update.
  51347. * @param scene defines the scene to the material belongs to.
  51348. */
  51349. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51350. /**
  51351. * Binds the material data.
  51352. * @param uniformBuffer defines the Uniform buffer to fill in.
  51353. * @param scene defines the scene the material belongs to.
  51354. * @param engine defines the engine the material belongs to.
  51355. * @param isFrozen defines wether the material is frozen or not.
  51356. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51357. */
  51358. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51359. /**
  51360. * Unbinds the material from the mesh.
  51361. * @param activeEffect defines the effect that should be unbound from.
  51362. * @returns true if unbound, otherwise false
  51363. */
  51364. unbind(activeEffect: Effect): boolean;
  51365. /**
  51366. * Returns the texture used for refraction or null if none is used.
  51367. * @param scene defines the scene the material belongs to.
  51368. * @returns - Refraction texture if present. If no refraction texture and refraction
  51369. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51370. */
  51371. private _getRefractionTexture;
  51372. /**
  51373. * Returns true if alpha blending should be disabled.
  51374. */
  51375. get disableAlphaBlending(): boolean;
  51376. /**
  51377. * Fills the list of render target textures.
  51378. * @param renderTargets the list of render targets to update
  51379. */
  51380. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51381. /**
  51382. * Checks to see if a texture is used in the material.
  51383. * @param texture - Base texture to use.
  51384. * @returns - Boolean specifying if a texture is used in the material.
  51385. */
  51386. hasTexture(texture: BaseTexture): boolean;
  51387. /**
  51388. * Gets a boolean indicating that current material needs to register RTT
  51389. * @returns true if this uses a render target otherwise false.
  51390. */
  51391. hasRenderTargetTextures(): boolean;
  51392. /**
  51393. * Returns an array of the actively used textures.
  51394. * @param activeTextures Array of BaseTextures
  51395. */
  51396. getActiveTextures(activeTextures: BaseTexture[]): void;
  51397. /**
  51398. * Returns the animatable textures.
  51399. * @param animatables Array of animatable textures.
  51400. */
  51401. getAnimatables(animatables: IAnimatable[]): void;
  51402. /**
  51403. * Disposes the resources of the material.
  51404. * @param forceDisposeTextures - Forces the disposal of all textures.
  51405. */
  51406. dispose(forceDisposeTextures?: boolean): void;
  51407. /**
  51408. * Get the current class name of the texture useful for serialization or dynamic coding.
  51409. * @returns "PBRSubSurfaceConfiguration"
  51410. */
  51411. getClassName(): string;
  51412. /**
  51413. * Add fallbacks to the effect fallbacks list.
  51414. * @param defines defines the Base texture to use.
  51415. * @param fallbacks defines the current fallback list.
  51416. * @param currentRank defines the current fallback rank.
  51417. * @returns the new fallback rank.
  51418. */
  51419. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51420. /**
  51421. * Add the required uniforms to the current list.
  51422. * @param uniforms defines the current uniform list.
  51423. */
  51424. static AddUniforms(uniforms: string[]): void;
  51425. /**
  51426. * Add the required samplers to the current list.
  51427. * @param samplers defines the current sampler list.
  51428. */
  51429. static AddSamplers(samplers: string[]): void;
  51430. /**
  51431. * Add the required uniforms to the current buffer.
  51432. * @param uniformBuffer defines the current uniform buffer.
  51433. */
  51434. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51435. /**
  51436. * Makes a duplicate of the current configuration into another one.
  51437. * @param configuration define the config where to copy the info
  51438. */
  51439. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51440. /**
  51441. * Serializes this Sub Surface configuration.
  51442. * @returns - An object with the serialized config.
  51443. */
  51444. serialize(): any;
  51445. /**
  51446. * Parses a anisotropy Configuration from a serialized object.
  51447. * @param source - Serialized object.
  51448. * @param scene Defines the scene we are parsing for
  51449. * @param rootUrl Defines the rootUrl to load from
  51450. */
  51451. parse(source: any, scene: Scene, rootUrl: string): void;
  51452. }
  51453. }
  51454. declare module BABYLON {
  51455. /** @hidden */
  51456. export var pbrFragmentDeclaration: {
  51457. name: string;
  51458. shader: string;
  51459. };
  51460. }
  51461. declare module BABYLON {
  51462. /** @hidden */
  51463. export var pbrUboDeclaration: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module BABYLON {
  51469. /** @hidden */
  51470. export var pbrFragmentExtraDeclaration: {
  51471. name: string;
  51472. shader: string;
  51473. };
  51474. }
  51475. declare module BABYLON {
  51476. /** @hidden */
  51477. export var pbrFragmentSamplersDeclaration: {
  51478. name: string;
  51479. shader: string;
  51480. };
  51481. }
  51482. declare module BABYLON {
  51483. /** @hidden */
  51484. export var pbrHelperFunctions: {
  51485. name: string;
  51486. shader: string;
  51487. };
  51488. }
  51489. declare module BABYLON {
  51490. /** @hidden */
  51491. export var harmonicsFunctions: {
  51492. name: string;
  51493. shader: string;
  51494. };
  51495. }
  51496. declare module BABYLON {
  51497. /** @hidden */
  51498. export var pbrDirectLightingSetupFunctions: {
  51499. name: string;
  51500. shader: string;
  51501. };
  51502. }
  51503. declare module BABYLON {
  51504. /** @hidden */
  51505. export var pbrDirectLightingFalloffFunctions: {
  51506. name: string;
  51507. shader: string;
  51508. };
  51509. }
  51510. declare module BABYLON {
  51511. /** @hidden */
  51512. export var pbrBRDFFunctions: {
  51513. name: string;
  51514. shader: string;
  51515. };
  51516. }
  51517. declare module BABYLON {
  51518. /** @hidden */
  51519. export var pbrDirectLightingFunctions: {
  51520. name: string;
  51521. shader: string;
  51522. };
  51523. }
  51524. declare module BABYLON {
  51525. /** @hidden */
  51526. export var pbrIBLFunctions: {
  51527. name: string;
  51528. shader: string;
  51529. };
  51530. }
  51531. declare module BABYLON {
  51532. /** @hidden */
  51533. export var pbrBlockAlbedoOpacity: {
  51534. name: string;
  51535. shader: string;
  51536. };
  51537. }
  51538. declare module BABYLON {
  51539. /** @hidden */
  51540. export var pbrBlockReflectivity: {
  51541. name: string;
  51542. shader: string;
  51543. };
  51544. }
  51545. declare module BABYLON {
  51546. /** @hidden */
  51547. export var pbrBlockAmbientOcclusion: {
  51548. name: string;
  51549. shader: string;
  51550. };
  51551. }
  51552. declare module BABYLON {
  51553. /** @hidden */
  51554. export var pbrBlockAlphaFresnel: {
  51555. name: string;
  51556. shader: string;
  51557. };
  51558. }
  51559. declare module BABYLON {
  51560. /** @hidden */
  51561. export var pbrBlockAnisotropic: {
  51562. name: string;
  51563. shader: string;
  51564. };
  51565. }
  51566. declare module BABYLON {
  51567. /** @hidden */
  51568. export var pbrBlockReflection: {
  51569. name: string;
  51570. shader: string;
  51571. };
  51572. }
  51573. declare module BABYLON {
  51574. /** @hidden */
  51575. export var pbrBlockSheen: {
  51576. name: string;
  51577. shader: string;
  51578. };
  51579. }
  51580. declare module BABYLON {
  51581. /** @hidden */
  51582. export var pbrBlockClearcoat: {
  51583. name: string;
  51584. shader: string;
  51585. };
  51586. }
  51587. declare module BABYLON {
  51588. /** @hidden */
  51589. export var pbrBlockSubSurface: {
  51590. name: string;
  51591. shader: string;
  51592. };
  51593. }
  51594. declare module BABYLON {
  51595. /** @hidden */
  51596. export var pbrBlockNormalGeometric: {
  51597. name: string;
  51598. shader: string;
  51599. };
  51600. }
  51601. declare module BABYLON {
  51602. /** @hidden */
  51603. export var pbrBlockNormalFinal: {
  51604. name: string;
  51605. shader: string;
  51606. };
  51607. }
  51608. declare module BABYLON {
  51609. /** @hidden */
  51610. export var pbrBlockGeometryInfo: {
  51611. name: string;
  51612. shader: string;
  51613. };
  51614. }
  51615. declare module BABYLON {
  51616. /** @hidden */
  51617. export var pbrBlockReflectance0: {
  51618. name: string;
  51619. shader: string;
  51620. };
  51621. }
  51622. declare module BABYLON {
  51623. /** @hidden */
  51624. export var pbrBlockReflectance: {
  51625. name: string;
  51626. shader: string;
  51627. };
  51628. }
  51629. declare module BABYLON {
  51630. /** @hidden */
  51631. export var pbrBlockDirectLighting: {
  51632. name: string;
  51633. shader: string;
  51634. };
  51635. }
  51636. declare module BABYLON {
  51637. /** @hidden */
  51638. export var pbrBlockFinalLitComponents: {
  51639. name: string;
  51640. shader: string;
  51641. };
  51642. }
  51643. declare module BABYLON {
  51644. /** @hidden */
  51645. export var pbrBlockFinalUnlitComponents: {
  51646. name: string;
  51647. shader: string;
  51648. };
  51649. }
  51650. declare module BABYLON {
  51651. /** @hidden */
  51652. export var pbrBlockFinalColorComposition: {
  51653. name: string;
  51654. shader: string;
  51655. };
  51656. }
  51657. declare module BABYLON {
  51658. /** @hidden */
  51659. export var pbrBlockImageProcessing: {
  51660. name: string;
  51661. shader: string;
  51662. };
  51663. }
  51664. declare module BABYLON {
  51665. /** @hidden */
  51666. export var pbrDebug: {
  51667. name: string;
  51668. shader: string;
  51669. };
  51670. }
  51671. declare module BABYLON {
  51672. /** @hidden */
  51673. export var pbrPixelShader: {
  51674. name: string;
  51675. shader: string;
  51676. };
  51677. }
  51678. declare module BABYLON {
  51679. /** @hidden */
  51680. export var pbrVertexDeclaration: {
  51681. name: string;
  51682. shader: string;
  51683. };
  51684. }
  51685. declare module BABYLON {
  51686. /** @hidden */
  51687. export var pbrVertexShader: {
  51688. name: string;
  51689. shader: string;
  51690. };
  51691. }
  51692. declare module BABYLON {
  51693. /**
  51694. * Manages the defines for the PBR Material.
  51695. * @hidden
  51696. */
  51697. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51698. PBR: boolean;
  51699. MAINUV1: boolean;
  51700. MAINUV2: boolean;
  51701. UV1: boolean;
  51702. UV2: boolean;
  51703. ALBEDO: boolean;
  51704. GAMMAALBEDO: boolean;
  51705. ALBEDODIRECTUV: number;
  51706. VERTEXCOLOR: boolean;
  51707. AMBIENT: boolean;
  51708. AMBIENTDIRECTUV: number;
  51709. AMBIENTINGRAYSCALE: boolean;
  51710. OPACITY: boolean;
  51711. VERTEXALPHA: boolean;
  51712. OPACITYDIRECTUV: number;
  51713. OPACITYRGB: boolean;
  51714. ALPHATEST: boolean;
  51715. DEPTHPREPASS: boolean;
  51716. ALPHABLEND: boolean;
  51717. ALPHAFROMALBEDO: boolean;
  51718. ALPHATESTVALUE: string;
  51719. SPECULAROVERALPHA: boolean;
  51720. RADIANCEOVERALPHA: boolean;
  51721. ALPHAFRESNEL: boolean;
  51722. LINEARALPHAFRESNEL: boolean;
  51723. PREMULTIPLYALPHA: boolean;
  51724. EMISSIVE: boolean;
  51725. EMISSIVEDIRECTUV: number;
  51726. REFLECTIVITY: boolean;
  51727. REFLECTIVITYDIRECTUV: number;
  51728. SPECULARTERM: boolean;
  51729. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51730. MICROSURFACEAUTOMATIC: boolean;
  51731. LODBASEDMICROSFURACE: boolean;
  51732. MICROSURFACEMAP: boolean;
  51733. MICROSURFACEMAPDIRECTUV: number;
  51734. METALLICWORKFLOW: boolean;
  51735. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51736. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51737. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51738. AOSTOREINMETALMAPRED: boolean;
  51739. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51740. ENVIRONMENTBRDF: boolean;
  51741. ENVIRONMENTBRDF_RGBD: boolean;
  51742. NORMAL: boolean;
  51743. TANGENT: boolean;
  51744. BUMP: boolean;
  51745. BUMPDIRECTUV: number;
  51746. OBJECTSPACE_NORMALMAP: boolean;
  51747. PARALLAX: boolean;
  51748. PARALLAXOCCLUSION: boolean;
  51749. NORMALXYSCALE: boolean;
  51750. LIGHTMAP: boolean;
  51751. LIGHTMAPDIRECTUV: number;
  51752. USELIGHTMAPASSHADOWMAP: boolean;
  51753. GAMMALIGHTMAP: boolean;
  51754. RGBDLIGHTMAP: boolean;
  51755. REFLECTION: boolean;
  51756. REFLECTIONMAP_3D: boolean;
  51757. REFLECTIONMAP_SPHERICAL: boolean;
  51758. REFLECTIONMAP_PLANAR: boolean;
  51759. REFLECTIONMAP_CUBIC: boolean;
  51760. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51761. REFLECTIONMAP_PROJECTION: boolean;
  51762. REFLECTIONMAP_SKYBOX: boolean;
  51763. REFLECTIONMAP_EXPLICIT: boolean;
  51764. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51765. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51766. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51767. INVERTCUBICMAP: boolean;
  51768. USESPHERICALFROMREFLECTIONMAP: boolean;
  51769. USEIRRADIANCEMAP: boolean;
  51770. SPHERICAL_HARMONICS: boolean;
  51771. USESPHERICALINVERTEX: boolean;
  51772. REFLECTIONMAP_OPPOSITEZ: boolean;
  51773. LODINREFLECTIONALPHA: boolean;
  51774. GAMMAREFLECTION: boolean;
  51775. RGBDREFLECTION: boolean;
  51776. LINEARSPECULARREFLECTION: boolean;
  51777. RADIANCEOCCLUSION: boolean;
  51778. HORIZONOCCLUSION: boolean;
  51779. INSTANCES: boolean;
  51780. NUM_BONE_INFLUENCERS: number;
  51781. BonesPerMesh: number;
  51782. BONETEXTURE: boolean;
  51783. NONUNIFORMSCALING: boolean;
  51784. MORPHTARGETS: boolean;
  51785. MORPHTARGETS_NORMAL: boolean;
  51786. MORPHTARGETS_TANGENT: boolean;
  51787. MORPHTARGETS_UV: boolean;
  51788. NUM_MORPH_INFLUENCERS: number;
  51789. IMAGEPROCESSING: boolean;
  51790. VIGNETTE: boolean;
  51791. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51792. VIGNETTEBLENDMODEOPAQUE: boolean;
  51793. TONEMAPPING: boolean;
  51794. TONEMAPPING_ACES: boolean;
  51795. CONTRAST: boolean;
  51796. COLORCURVES: boolean;
  51797. COLORGRADING: boolean;
  51798. COLORGRADING3D: boolean;
  51799. SAMPLER3DGREENDEPTH: boolean;
  51800. SAMPLER3DBGRMAP: boolean;
  51801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51802. EXPOSURE: boolean;
  51803. MULTIVIEW: boolean;
  51804. USEPHYSICALLIGHTFALLOFF: boolean;
  51805. USEGLTFLIGHTFALLOFF: boolean;
  51806. TWOSIDEDLIGHTING: boolean;
  51807. SHADOWFLOAT: boolean;
  51808. CLIPPLANE: boolean;
  51809. CLIPPLANE2: boolean;
  51810. CLIPPLANE3: boolean;
  51811. CLIPPLANE4: boolean;
  51812. CLIPPLANE5: boolean;
  51813. CLIPPLANE6: boolean;
  51814. POINTSIZE: boolean;
  51815. FOG: boolean;
  51816. LOGARITHMICDEPTH: boolean;
  51817. FORCENORMALFORWARD: boolean;
  51818. SPECULARAA: boolean;
  51819. CLEARCOAT: boolean;
  51820. CLEARCOAT_DEFAULTIOR: boolean;
  51821. CLEARCOAT_TEXTURE: boolean;
  51822. CLEARCOAT_TEXTUREDIRECTUV: number;
  51823. CLEARCOAT_BUMP: boolean;
  51824. CLEARCOAT_BUMPDIRECTUV: number;
  51825. CLEARCOAT_TINT: boolean;
  51826. CLEARCOAT_TINT_TEXTURE: boolean;
  51827. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51828. ANISOTROPIC: boolean;
  51829. ANISOTROPIC_TEXTURE: boolean;
  51830. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51831. BRDF_V_HEIGHT_CORRELATED: boolean;
  51832. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51833. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51834. SHEEN: boolean;
  51835. SHEEN_TEXTURE: boolean;
  51836. SHEEN_TEXTUREDIRECTUV: number;
  51837. SHEEN_LINKWITHALBEDO: boolean;
  51838. SHEEN_ROUGHNESS: boolean;
  51839. SHEEN_ALBEDOSCALING: boolean;
  51840. SUBSURFACE: boolean;
  51841. SS_REFRACTION: boolean;
  51842. SS_TRANSLUCENCY: boolean;
  51843. SS_SCATERRING: boolean;
  51844. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51845. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51846. SS_REFRACTIONMAP_3D: boolean;
  51847. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51848. SS_LODINREFRACTIONALPHA: boolean;
  51849. SS_GAMMAREFRACTION: boolean;
  51850. SS_RGBDREFRACTION: boolean;
  51851. SS_LINEARSPECULARREFRACTION: boolean;
  51852. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51853. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51854. UNLIT: boolean;
  51855. DEBUGMODE: number;
  51856. /**
  51857. * Initializes the PBR Material defines.
  51858. */
  51859. constructor();
  51860. /**
  51861. * Resets the PBR Material defines.
  51862. */
  51863. reset(): void;
  51864. }
  51865. /**
  51866. * The Physically based material base class of BJS.
  51867. *
  51868. * This offers the main features of a standard PBR material.
  51869. * For more information, please refer to the documentation :
  51870. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51871. */
  51872. export abstract class PBRBaseMaterial extends PushMaterial {
  51873. /**
  51874. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51875. */
  51876. static readonly PBRMATERIAL_OPAQUE: number;
  51877. /**
  51878. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51879. */
  51880. static readonly PBRMATERIAL_ALPHATEST: number;
  51881. /**
  51882. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51883. */
  51884. static readonly PBRMATERIAL_ALPHABLEND: number;
  51885. /**
  51886. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51887. * They are also discarded below the alpha cutoff threshold to improve performances.
  51888. */
  51889. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51890. /**
  51891. * Defines the default value of how much AO map is occluding the analytical lights
  51892. * (point spot...).
  51893. */
  51894. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51895. /**
  51896. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51897. */
  51898. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51899. /**
  51900. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51901. * to enhance interoperability with other engines.
  51902. */
  51903. static readonly LIGHTFALLOFF_GLTF: number;
  51904. /**
  51905. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51906. * to enhance interoperability with other materials.
  51907. */
  51908. static readonly LIGHTFALLOFF_STANDARD: number;
  51909. /**
  51910. * Intensity of the direct lights e.g. the four lights available in your scene.
  51911. * This impacts both the direct diffuse and specular highlights.
  51912. */
  51913. protected _directIntensity: number;
  51914. /**
  51915. * Intensity of the emissive part of the material.
  51916. * This helps controlling the emissive effect without modifying the emissive color.
  51917. */
  51918. protected _emissiveIntensity: number;
  51919. /**
  51920. * Intensity of the environment e.g. how much the environment will light the object
  51921. * either through harmonics for rough material or through the refelction for shiny ones.
  51922. */
  51923. protected _environmentIntensity: number;
  51924. /**
  51925. * This is a special control allowing the reduction of the specular highlights coming from the
  51926. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51927. */
  51928. protected _specularIntensity: number;
  51929. /**
  51930. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51931. */
  51932. private _lightingInfos;
  51933. /**
  51934. * Debug Control allowing disabling the bump map on this material.
  51935. */
  51936. protected _disableBumpMap: boolean;
  51937. /**
  51938. * AKA Diffuse Texture in standard nomenclature.
  51939. */
  51940. protected _albedoTexture: Nullable<BaseTexture>;
  51941. /**
  51942. * AKA Occlusion Texture in other nomenclature.
  51943. */
  51944. protected _ambientTexture: Nullable<BaseTexture>;
  51945. /**
  51946. * AKA Occlusion Texture Intensity in other nomenclature.
  51947. */
  51948. protected _ambientTextureStrength: number;
  51949. /**
  51950. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51951. * 1 means it completely occludes it
  51952. * 0 mean it has no impact
  51953. */
  51954. protected _ambientTextureImpactOnAnalyticalLights: number;
  51955. /**
  51956. * Stores the alpha values in a texture.
  51957. */
  51958. protected _opacityTexture: Nullable<BaseTexture>;
  51959. /**
  51960. * Stores the reflection values in a texture.
  51961. */
  51962. protected _reflectionTexture: Nullable<BaseTexture>;
  51963. /**
  51964. * Stores the emissive values in a texture.
  51965. */
  51966. protected _emissiveTexture: Nullable<BaseTexture>;
  51967. /**
  51968. * AKA Specular texture in other nomenclature.
  51969. */
  51970. protected _reflectivityTexture: Nullable<BaseTexture>;
  51971. /**
  51972. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51973. */
  51974. protected _metallicTexture: Nullable<BaseTexture>;
  51975. /**
  51976. * Specifies the metallic scalar of the metallic/roughness workflow.
  51977. * Can also be used to scale the metalness values of the metallic texture.
  51978. */
  51979. protected _metallic: Nullable<number>;
  51980. /**
  51981. * Specifies the roughness scalar of the metallic/roughness workflow.
  51982. * Can also be used to scale the roughness values of the metallic texture.
  51983. */
  51984. protected _roughness: Nullable<number>;
  51985. /**
  51986. * Specifies the an F0 factor to help configuring the material F0.
  51987. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51988. * to 0.5 the previously hard coded value stays the same.
  51989. * Can also be used to scale the F0 values of the metallic texture.
  51990. */
  51991. protected _metallicF0Factor: number;
  51992. /**
  51993. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51994. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51995. * your expectation as it multiplies with the texture data.
  51996. */
  51997. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51998. /**
  51999. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52000. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52001. */
  52002. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52003. /**
  52004. * Stores surface normal data used to displace a mesh in a texture.
  52005. */
  52006. protected _bumpTexture: Nullable<BaseTexture>;
  52007. /**
  52008. * Stores the pre-calculated light information of a mesh in a texture.
  52009. */
  52010. protected _lightmapTexture: Nullable<BaseTexture>;
  52011. /**
  52012. * The color of a material in ambient lighting.
  52013. */
  52014. protected _ambientColor: Color3;
  52015. /**
  52016. * AKA Diffuse Color in other nomenclature.
  52017. */
  52018. protected _albedoColor: Color3;
  52019. /**
  52020. * AKA Specular Color in other nomenclature.
  52021. */
  52022. protected _reflectivityColor: Color3;
  52023. /**
  52024. * The color applied when light is reflected from a material.
  52025. */
  52026. protected _reflectionColor: Color3;
  52027. /**
  52028. * The color applied when light is emitted from a material.
  52029. */
  52030. protected _emissiveColor: Color3;
  52031. /**
  52032. * AKA Glossiness in other nomenclature.
  52033. */
  52034. protected _microSurface: number;
  52035. /**
  52036. * Specifies that the material will use the light map as a show map.
  52037. */
  52038. protected _useLightmapAsShadowmap: boolean;
  52039. /**
  52040. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52041. * makes the reflect vector face the model (under horizon).
  52042. */
  52043. protected _useHorizonOcclusion: boolean;
  52044. /**
  52045. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52046. * too much the area relying on ambient texture to define their ambient occlusion.
  52047. */
  52048. protected _useRadianceOcclusion: boolean;
  52049. /**
  52050. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52051. */
  52052. protected _useAlphaFromAlbedoTexture: boolean;
  52053. /**
  52054. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52055. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52056. */
  52057. protected _useSpecularOverAlpha: boolean;
  52058. /**
  52059. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52060. */
  52061. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52062. /**
  52063. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52064. */
  52065. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52066. /**
  52067. * Specifies if the metallic texture contains the roughness information in its green channel.
  52068. */
  52069. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52070. /**
  52071. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52072. */
  52073. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52074. /**
  52075. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52076. */
  52077. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52078. /**
  52079. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52080. */
  52081. protected _useAmbientInGrayScale: boolean;
  52082. /**
  52083. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52084. * The material will try to infer what glossiness each pixel should be.
  52085. */
  52086. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52087. /**
  52088. * Defines the falloff type used in this material.
  52089. * It by default is Physical.
  52090. */
  52091. protected _lightFalloff: number;
  52092. /**
  52093. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52094. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52095. */
  52096. protected _useRadianceOverAlpha: boolean;
  52097. /**
  52098. * Allows using an object space normal map (instead of tangent space).
  52099. */
  52100. protected _useObjectSpaceNormalMap: boolean;
  52101. /**
  52102. * Allows using the bump map in parallax mode.
  52103. */
  52104. protected _useParallax: boolean;
  52105. /**
  52106. * Allows using the bump map in parallax occlusion mode.
  52107. */
  52108. protected _useParallaxOcclusion: boolean;
  52109. /**
  52110. * Controls the scale bias of the parallax mode.
  52111. */
  52112. protected _parallaxScaleBias: number;
  52113. /**
  52114. * If sets to true, disables all the lights affecting the material.
  52115. */
  52116. protected _disableLighting: boolean;
  52117. /**
  52118. * Number of Simultaneous lights allowed on the material.
  52119. */
  52120. protected _maxSimultaneousLights: number;
  52121. /**
  52122. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52123. */
  52124. protected _invertNormalMapX: boolean;
  52125. /**
  52126. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52127. */
  52128. protected _invertNormalMapY: boolean;
  52129. /**
  52130. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52131. */
  52132. protected _twoSidedLighting: boolean;
  52133. /**
  52134. * Defines the alpha limits in alpha test mode.
  52135. */
  52136. protected _alphaCutOff: number;
  52137. /**
  52138. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52139. */
  52140. protected _forceAlphaTest: boolean;
  52141. /**
  52142. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52143. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52144. */
  52145. protected _useAlphaFresnel: boolean;
  52146. /**
  52147. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52148. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52149. */
  52150. protected _useLinearAlphaFresnel: boolean;
  52151. /**
  52152. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52153. * from cos thetav and roughness:
  52154. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52155. */
  52156. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52157. /**
  52158. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52159. */
  52160. protected _forceIrradianceInFragment: boolean;
  52161. /**
  52162. * Force normal to face away from face.
  52163. */
  52164. protected _forceNormalForward: boolean;
  52165. /**
  52166. * Enables specular anti aliasing in the PBR shader.
  52167. * It will both interacts on the Geometry for analytical and IBL lighting.
  52168. * It also prefilter the roughness map based on the bump values.
  52169. */
  52170. protected _enableSpecularAntiAliasing: boolean;
  52171. /**
  52172. * Default configuration related to image processing available in the PBR Material.
  52173. */
  52174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52175. /**
  52176. * Keep track of the image processing observer to allow dispose and replace.
  52177. */
  52178. private _imageProcessingObserver;
  52179. /**
  52180. * Attaches a new image processing configuration to the PBR Material.
  52181. * @param configuration
  52182. */
  52183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52184. /**
  52185. * Stores the available render targets.
  52186. */
  52187. private _renderTargets;
  52188. /**
  52189. * Sets the global ambient color for the material used in lighting calculations.
  52190. */
  52191. private _globalAmbientColor;
  52192. /**
  52193. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52194. */
  52195. private _useLogarithmicDepth;
  52196. /**
  52197. * If set to true, no lighting calculations will be applied.
  52198. */
  52199. private _unlit;
  52200. private _debugMode;
  52201. /**
  52202. * @hidden
  52203. * This is reserved for the inspector.
  52204. * Defines the material debug mode.
  52205. * It helps seeing only some components of the material while troubleshooting.
  52206. */
  52207. debugMode: number;
  52208. /**
  52209. * @hidden
  52210. * This is reserved for the inspector.
  52211. * Specify from where on screen the debug mode should start.
  52212. * The value goes from -1 (full screen) to 1 (not visible)
  52213. * It helps with side by side comparison against the final render
  52214. * This defaults to -1
  52215. */
  52216. private debugLimit;
  52217. /**
  52218. * @hidden
  52219. * This is reserved for the inspector.
  52220. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52221. * You can use the factor to better multiply the final value.
  52222. */
  52223. private debugFactor;
  52224. /**
  52225. * Defines the clear coat layer parameters for the material.
  52226. */
  52227. readonly clearCoat: PBRClearCoatConfiguration;
  52228. /**
  52229. * Defines the anisotropic parameters for the material.
  52230. */
  52231. readonly anisotropy: PBRAnisotropicConfiguration;
  52232. /**
  52233. * Defines the BRDF parameters for the material.
  52234. */
  52235. readonly brdf: PBRBRDFConfiguration;
  52236. /**
  52237. * Defines the Sheen parameters for the material.
  52238. */
  52239. readonly sheen: PBRSheenConfiguration;
  52240. /**
  52241. * Defines the SubSurface parameters for the material.
  52242. */
  52243. readonly subSurface: PBRSubSurfaceConfiguration;
  52244. protected _rebuildInParallel: boolean;
  52245. /**
  52246. * Instantiates a new PBRMaterial instance.
  52247. *
  52248. * @param name The material name
  52249. * @param scene The scene the material will be use in.
  52250. */
  52251. constructor(name: string, scene: Scene);
  52252. /**
  52253. * Gets a boolean indicating that current material needs to register RTT
  52254. */
  52255. get hasRenderTargetTextures(): boolean;
  52256. /**
  52257. * Gets the name of the material class.
  52258. */
  52259. getClassName(): string;
  52260. /**
  52261. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52262. */
  52263. get useLogarithmicDepth(): boolean;
  52264. /**
  52265. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52266. */
  52267. set useLogarithmicDepth(value: boolean);
  52268. /**
  52269. * Returns true if alpha blending should be disabled.
  52270. */
  52271. protected get _disableAlphaBlending(): boolean;
  52272. /**
  52273. * Specifies whether or not this material should be rendered in alpha blend mode.
  52274. */
  52275. needAlphaBlending(): boolean;
  52276. /**
  52277. * Specifies whether or not this material should be rendered in alpha test mode.
  52278. */
  52279. needAlphaTesting(): boolean;
  52280. /**
  52281. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52282. */
  52283. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52284. /**
  52285. * Gets the texture used for the alpha test.
  52286. */
  52287. getAlphaTestTexture(): Nullable<BaseTexture>;
  52288. /**
  52289. * Specifies that the submesh is ready to be used.
  52290. * @param mesh - BJS mesh.
  52291. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52292. * @param useInstances - Specifies that instances should be used.
  52293. * @returns - boolean indicating that the submesh is ready or not.
  52294. */
  52295. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52296. /**
  52297. * Specifies if the material uses metallic roughness workflow.
  52298. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52299. */
  52300. isMetallicWorkflow(): boolean;
  52301. private _prepareEffect;
  52302. private _prepareDefines;
  52303. /**
  52304. * Force shader compilation
  52305. */
  52306. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52307. /**
  52308. * Initializes the uniform buffer layout for the shader.
  52309. */
  52310. buildUniformLayout(): void;
  52311. /**
  52312. * Unbinds the material from the mesh
  52313. */
  52314. unbind(): void;
  52315. /**
  52316. * Binds the submesh data.
  52317. * @param world - The world matrix.
  52318. * @param mesh - The BJS mesh.
  52319. * @param subMesh - A submesh of the BJS mesh.
  52320. */
  52321. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52322. /**
  52323. * Returns the animatable textures.
  52324. * @returns - Array of animatable textures.
  52325. */
  52326. getAnimatables(): IAnimatable[];
  52327. /**
  52328. * Returns the texture used for reflections.
  52329. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52330. */
  52331. private _getReflectionTexture;
  52332. /**
  52333. * Returns an array of the actively used textures.
  52334. * @returns - Array of BaseTextures
  52335. */
  52336. getActiveTextures(): BaseTexture[];
  52337. /**
  52338. * Checks to see if a texture is used in the material.
  52339. * @param texture - Base texture to use.
  52340. * @returns - Boolean specifying if a texture is used in the material.
  52341. */
  52342. hasTexture(texture: BaseTexture): boolean;
  52343. /**
  52344. * Disposes the resources of the material.
  52345. * @param forceDisposeEffect - Forces the disposal of effects.
  52346. * @param forceDisposeTextures - Forces the disposal of all textures.
  52347. */
  52348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52349. }
  52350. }
  52351. declare module BABYLON {
  52352. /**
  52353. * The Physically based material of BJS.
  52354. *
  52355. * This offers the main features of a standard PBR material.
  52356. * For more information, please refer to the documentation :
  52357. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52358. */
  52359. export class PBRMaterial extends PBRBaseMaterial {
  52360. /**
  52361. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52362. */
  52363. static readonly PBRMATERIAL_OPAQUE: number;
  52364. /**
  52365. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52366. */
  52367. static readonly PBRMATERIAL_ALPHATEST: number;
  52368. /**
  52369. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52370. */
  52371. static readonly PBRMATERIAL_ALPHABLEND: number;
  52372. /**
  52373. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52374. * They are also discarded below the alpha cutoff threshold to improve performances.
  52375. */
  52376. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52377. /**
  52378. * Defines the default value of how much AO map is occluding the analytical lights
  52379. * (point spot...).
  52380. */
  52381. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52382. /**
  52383. * Intensity of the direct lights e.g. the four lights available in your scene.
  52384. * This impacts both the direct diffuse and specular highlights.
  52385. */
  52386. directIntensity: number;
  52387. /**
  52388. * Intensity of the emissive part of the material.
  52389. * This helps controlling the emissive effect without modifying the emissive color.
  52390. */
  52391. emissiveIntensity: number;
  52392. /**
  52393. * Intensity of the environment e.g. how much the environment will light the object
  52394. * either through harmonics for rough material or through the refelction for shiny ones.
  52395. */
  52396. environmentIntensity: number;
  52397. /**
  52398. * This is a special control allowing the reduction of the specular highlights coming from the
  52399. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52400. */
  52401. specularIntensity: number;
  52402. /**
  52403. * Debug Control allowing disabling the bump map on this material.
  52404. */
  52405. disableBumpMap: boolean;
  52406. /**
  52407. * AKA Diffuse Texture in standard nomenclature.
  52408. */
  52409. albedoTexture: BaseTexture;
  52410. /**
  52411. * AKA Occlusion Texture in other nomenclature.
  52412. */
  52413. ambientTexture: BaseTexture;
  52414. /**
  52415. * AKA Occlusion Texture Intensity in other nomenclature.
  52416. */
  52417. ambientTextureStrength: number;
  52418. /**
  52419. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52420. * 1 means it completely occludes it
  52421. * 0 mean it has no impact
  52422. */
  52423. ambientTextureImpactOnAnalyticalLights: number;
  52424. /**
  52425. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52426. */
  52427. opacityTexture: BaseTexture;
  52428. /**
  52429. * Stores the reflection values in a texture.
  52430. */
  52431. reflectionTexture: Nullable<BaseTexture>;
  52432. /**
  52433. * Stores the emissive values in a texture.
  52434. */
  52435. emissiveTexture: BaseTexture;
  52436. /**
  52437. * AKA Specular texture in other nomenclature.
  52438. */
  52439. reflectivityTexture: BaseTexture;
  52440. /**
  52441. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52442. */
  52443. metallicTexture: BaseTexture;
  52444. /**
  52445. * Specifies the metallic scalar of the metallic/roughness workflow.
  52446. * Can also be used to scale the metalness values of the metallic texture.
  52447. */
  52448. metallic: Nullable<number>;
  52449. /**
  52450. * Specifies the roughness scalar of the metallic/roughness workflow.
  52451. * Can also be used to scale the roughness values of the metallic texture.
  52452. */
  52453. roughness: Nullable<number>;
  52454. /**
  52455. * Specifies the an F0 factor to help configuring the material F0.
  52456. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52457. * to 0.5 the previously hard coded value stays the same.
  52458. * Can also be used to scale the F0 values of the metallic texture.
  52459. */
  52460. metallicF0Factor: number;
  52461. /**
  52462. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52463. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52464. * your expectation as it multiplies with the texture data.
  52465. */
  52466. useMetallicF0FactorFromMetallicTexture: boolean;
  52467. /**
  52468. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52469. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52470. */
  52471. microSurfaceTexture: BaseTexture;
  52472. /**
  52473. * Stores surface normal data used to displace a mesh in a texture.
  52474. */
  52475. bumpTexture: BaseTexture;
  52476. /**
  52477. * Stores the pre-calculated light information of a mesh in a texture.
  52478. */
  52479. lightmapTexture: BaseTexture;
  52480. /**
  52481. * Stores the refracted light information in a texture.
  52482. */
  52483. get refractionTexture(): Nullable<BaseTexture>;
  52484. set refractionTexture(value: Nullable<BaseTexture>);
  52485. /**
  52486. * The color of a material in ambient lighting.
  52487. */
  52488. ambientColor: Color3;
  52489. /**
  52490. * AKA Diffuse Color in other nomenclature.
  52491. */
  52492. albedoColor: Color3;
  52493. /**
  52494. * AKA Specular Color in other nomenclature.
  52495. */
  52496. reflectivityColor: Color3;
  52497. /**
  52498. * The color reflected from the material.
  52499. */
  52500. reflectionColor: Color3;
  52501. /**
  52502. * The color emitted from the material.
  52503. */
  52504. emissiveColor: Color3;
  52505. /**
  52506. * AKA Glossiness in other nomenclature.
  52507. */
  52508. microSurface: number;
  52509. /**
  52510. * source material index of refraction (IOR)' / 'destination material IOR.
  52511. */
  52512. get indexOfRefraction(): number;
  52513. set indexOfRefraction(value: number);
  52514. /**
  52515. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52516. */
  52517. get invertRefractionY(): boolean;
  52518. set invertRefractionY(value: boolean);
  52519. /**
  52520. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52521. * Materials half opaque for instance using refraction could benefit from this control.
  52522. */
  52523. get linkRefractionWithTransparency(): boolean;
  52524. set linkRefractionWithTransparency(value: boolean);
  52525. /**
  52526. * If true, the light map contains occlusion information instead of lighting info.
  52527. */
  52528. useLightmapAsShadowmap: boolean;
  52529. /**
  52530. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52531. */
  52532. useAlphaFromAlbedoTexture: boolean;
  52533. /**
  52534. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52535. */
  52536. forceAlphaTest: boolean;
  52537. /**
  52538. * Defines the alpha limits in alpha test mode.
  52539. */
  52540. alphaCutOff: number;
  52541. /**
  52542. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52543. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52544. */
  52545. useSpecularOverAlpha: boolean;
  52546. /**
  52547. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52548. */
  52549. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52550. /**
  52551. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52552. */
  52553. useRoughnessFromMetallicTextureAlpha: boolean;
  52554. /**
  52555. * Specifies if the metallic texture contains the roughness information in its green channel.
  52556. */
  52557. useRoughnessFromMetallicTextureGreen: boolean;
  52558. /**
  52559. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52560. */
  52561. useMetallnessFromMetallicTextureBlue: boolean;
  52562. /**
  52563. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52564. */
  52565. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52566. /**
  52567. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52568. */
  52569. useAmbientInGrayScale: boolean;
  52570. /**
  52571. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52572. * The material will try to infer what glossiness each pixel should be.
  52573. */
  52574. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52575. /**
  52576. * BJS is using an harcoded light falloff based on a manually sets up range.
  52577. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52578. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52579. */
  52580. get usePhysicalLightFalloff(): boolean;
  52581. /**
  52582. * BJS is using an harcoded light falloff based on a manually sets up range.
  52583. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52584. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52585. */
  52586. set usePhysicalLightFalloff(value: boolean);
  52587. /**
  52588. * In order to support the falloff compatibility with gltf, a special mode has been added
  52589. * to reproduce the gltf light falloff.
  52590. */
  52591. get useGLTFLightFalloff(): boolean;
  52592. /**
  52593. * In order to support the falloff compatibility with gltf, a special mode has been added
  52594. * to reproduce the gltf light falloff.
  52595. */
  52596. set useGLTFLightFalloff(value: boolean);
  52597. /**
  52598. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52599. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52600. */
  52601. useRadianceOverAlpha: boolean;
  52602. /**
  52603. * Allows using an object space normal map (instead of tangent space).
  52604. */
  52605. useObjectSpaceNormalMap: boolean;
  52606. /**
  52607. * Allows using the bump map in parallax mode.
  52608. */
  52609. useParallax: boolean;
  52610. /**
  52611. * Allows using the bump map in parallax occlusion mode.
  52612. */
  52613. useParallaxOcclusion: boolean;
  52614. /**
  52615. * Controls the scale bias of the parallax mode.
  52616. */
  52617. parallaxScaleBias: number;
  52618. /**
  52619. * If sets to true, disables all the lights affecting the material.
  52620. */
  52621. disableLighting: boolean;
  52622. /**
  52623. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52624. */
  52625. forceIrradianceInFragment: boolean;
  52626. /**
  52627. * Number of Simultaneous lights allowed on the material.
  52628. */
  52629. maxSimultaneousLights: number;
  52630. /**
  52631. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52632. */
  52633. invertNormalMapX: boolean;
  52634. /**
  52635. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52636. */
  52637. invertNormalMapY: boolean;
  52638. /**
  52639. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52640. */
  52641. twoSidedLighting: boolean;
  52642. /**
  52643. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52644. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52645. */
  52646. useAlphaFresnel: boolean;
  52647. /**
  52648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52649. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52650. */
  52651. useLinearAlphaFresnel: boolean;
  52652. /**
  52653. * Let user defines the brdf lookup texture used for IBL.
  52654. * A default 8bit version is embedded but you could point at :
  52655. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52656. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52657. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52658. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52659. */
  52660. environmentBRDFTexture: Nullable<BaseTexture>;
  52661. /**
  52662. * Force normal to face away from face.
  52663. */
  52664. forceNormalForward: boolean;
  52665. /**
  52666. * Enables specular anti aliasing in the PBR shader.
  52667. * It will both interacts on the Geometry for analytical and IBL lighting.
  52668. * It also prefilter the roughness map based on the bump values.
  52669. */
  52670. enableSpecularAntiAliasing: boolean;
  52671. /**
  52672. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52673. * makes the reflect vector face the model (under horizon).
  52674. */
  52675. useHorizonOcclusion: boolean;
  52676. /**
  52677. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52678. * too much the area relying on ambient texture to define their ambient occlusion.
  52679. */
  52680. useRadianceOcclusion: boolean;
  52681. /**
  52682. * If set to true, no lighting calculations will be applied.
  52683. */
  52684. unlit: boolean;
  52685. /**
  52686. * Gets the image processing configuration used either in this material.
  52687. */
  52688. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52689. /**
  52690. * Sets the Default image processing configuration used either in the this material.
  52691. *
  52692. * If sets to null, the scene one is in use.
  52693. */
  52694. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52695. /**
  52696. * Gets wether the color curves effect is enabled.
  52697. */
  52698. get cameraColorCurvesEnabled(): boolean;
  52699. /**
  52700. * Sets wether the color curves effect is enabled.
  52701. */
  52702. set cameraColorCurvesEnabled(value: boolean);
  52703. /**
  52704. * Gets wether the color grading effect is enabled.
  52705. */
  52706. get cameraColorGradingEnabled(): boolean;
  52707. /**
  52708. * Gets wether the color grading effect is enabled.
  52709. */
  52710. set cameraColorGradingEnabled(value: boolean);
  52711. /**
  52712. * Gets wether tonemapping is enabled or not.
  52713. */
  52714. get cameraToneMappingEnabled(): boolean;
  52715. /**
  52716. * Sets wether tonemapping is enabled or not
  52717. */
  52718. set cameraToneMappingEnabled(value: boolean);
  52719. /**
  52720. * The camera exposure used on this material.
  52721. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52722. * This corresponds to a photographic exposure.
  52723. */
  52724. get cameraExposure(): number;
  52725. /**
  52726. * The camera exposure used on this material.
  52727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52728. * This corresponds to a photographic exposure.
  52729. */
  52730. set cameraExposure(value: number);
  52731. /**
  52732. * Gets The camera contrast used on this material.
  52733. */
  52734. get cameraContrast(): number;
  52735. /**
  52736. * Sets The camera contrast used on this material.
  52737. */
  52738. set cameraContrast(value: number);
  52739. /**
  52740. * Gets the Color Grading 2D Lookup Texture.
  52741. */
  52742. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52743. /**
  52744. * Sets the Color Grading 2D Lookup Texture.
  52745. */
  52746. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52747. /**
  52748. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52749. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52750. * 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;
  52751. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52752. */
  52753. get cameraColorCurves(): Nullable<ColorCurves>;
  52754. /**
  52755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52757. * 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;
  52758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52759. */
  52760. set cameraColorCurves(value: Nullable<ColorCurves>);
  52761. /**
  52762. * Instantiates a new PBRMaterial instance.
  52763. *
  52764. * @param name The material name
  52765. * @param scene The scene the material will be use in.
  52766. */
  52767. constructor(name: string, scene: Scene);
  52768. /**
  52769. * Returns the name of this material class.
  52770. */
  52771. getClassName(): string;
  52772. /**
  52773. * Makes a duplicate of the current material.
  52774. * @param name - name to use for the new material.
  52775. */
  52776. clone(name: string): PBRMaterial;
  52777. /**
  52778. * Serializes this PBR Material.
  52779. * @returns - An object with the serialized material.
  52780. */
  52781. serialize(): any;
  52782. /**
  52783. * Parses a PBR Material from a serialized object.
  52784. * @param source - Serialized object.
  52785. * @param scene - BJS scene instance.
  52786. * @param rootUrl - url for the scene object
  52787. * @returns - PBRMaterial
  52788. */
  52789. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52790. }
  52791. }
  52792. declare module BABYLON {
  52793. /**
  52794. * Direct draw surface info
  52795. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52796. */
  52797. export interface DDSInfo {
  52798. /**
  52799. * Width of the texture
  52800. */
  52801. width: number;
  52802. /**
  52803. * Width of the texture
  52804. */
  52805. height: number;
  52806. /**
  52807. * Number of Mipmaps for the texture
  52808. * @see https://en.wikipedia.org/wiki/Mipmap
  52809. */
  52810. mipmapCount: number;
  52811. /**
  52812. * If the textures format is a known fourCC format
  52813. * @see https://www.fourcc.org/
  52814. */
  52815. isFourCC: boolean;
  52816. /**
  52817. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52818. */
  52819. isRGB: boolean;
  52820. /**
  52821. * If the texture is a lumincance format
  52822. */
  52823. isLuminance: boolean;
  52824. /**
  52825. * If this is a cube texture
  52826. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52827. */
  52828. isCube: boolean;
  52829. /**
  52830. * If the texture is a compressed format eg. FOURCC_DXT1
  52831. */
  52832. isCompressed: boolean;
  52833. /**
  52834. * The dxgiFormat of the texture
  52835. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52836. */
  52837. dxgiFormat: number;
  52838. /**
  52839. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52840. */
  52841. textureType: number;
  52842. /**
  52843. * Sphericle polynomial created for the dds texture
  52844. */
  52845. sphericalPolynomial?: SphericalPolynomial;
  52846. }
  52847. /**
  52848. * Class used to provide DDS decompression tools
  52849. */
  52850. export class DDSTools {
  52851. /**
  52852. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52853. */
  52854. static StoreLODInAlphaChannel: boolean;
  52855. /**
  52856. * Gets DDS information from an array buffer
  52857. * @param data defines the array buffer view to read data from
  52858. * @returns the DDS information
  52859. */
  52860. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52861. private static _FloatView;
  52862. private static _Int32View;
  52863. private static _ToHalfFloat;
  52864. private static _FromHalfFloat;
  52865. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52866. private static _GetHalfFloatRGBAArrayBuffer;
  52867. private static _GetFloatRGBAArrayBuffer;
  52868. private static _GetFloatAsUIntRGBAArrayBuffer;
  52869. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52870. private static _GetRGBAArrayBuffer;
  52871. private static _ExtractLongWordOrder;
  52872. private static _GetRGBArrayBuffer;
  52873. private static _GetLuminanceArrayBuffer;
  52874. /**
  52875. * Uploads DDS Levels to a Babylon Texture
  52876. * @hidden
  52877. */
  52878. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52879. }
  52880. interface ThinEngine {
  52881. /**
  52882. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52883. * @param rootUrl defines the url where the file to load is located
  52884. * @param scene defines the current scene
  52885. * @param lodScale defines scale to apply to the mip map selection
  52886. * @param lodOffset defines offset to apply to the mip map selection
  52887. * @param onLoad defines an optional callback raised when the texture is loaded
  52888. * @param onError defines an optional callback raised if there is an issue to load the texture
  52889. * @param format defines the format of the data
  52890. * @param forcedExtension defines the extension to use to pick the right loader
  52891. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52892. * @returns the cube texture as an InternalTexture
  52893. */
  52894. 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;
  52895. }
  52896. }
  52897. declare module BABYLON {
  52898. /**
  52899. * Implementation of the DDS Texture Loader.
  52900. * @hidden
  52901. */
  52902. export class _DDSTextureLoader implements IInternalTextureLoader {
  52903. /**
  52904. * Defines wether the loader supports cascade loading the different faces.
  52905. */
  52906. readonly supportCascades: boolean;
  52907. /**
  52908. * This returns if the loader support the current file information.
  52909. * @param extension defines the file extension of the file being loaded
  52910. * @returns true if the loader can load the specified file
  52911. */
  52912. canLoad(extension: string): boolean;
  52913. /**
  52914. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52915. * @param data contains the texture data
  52916. * @param texture defines the BabylonJS internal texture
  52917. * @param createPolynomials will be true if polynomials have been requested
  52918. * @param onLoad defines the callback to trigger once the texture is ready
  52919. * @param onError defines the callback to trigger in case of error
  52920. */
  52921. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52922. /**
  52923. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52924. * @param data contains the texture data
  52925. * @param texture defines the BabylonJS internal texture
  52926. * @param callback defines the method to call once ready to upload
  52927. */
  52928. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52929. }
  52930. }
  52931. declare module BABYLON {
  52932. /**
  52933. * Implementation of the ENV Texture Loader.
  52934. * @hidden
  52935. */
  52936. export class _ENVTextureLoader implements IInternalTextureLoader {
  52937. /**
  52938. * Defines wether the loader supports cascade loading the different faces.
  52939. */
  52940. readonly supportCascades: boolean;
  52941. /**
  52942. * This returns if the loader support the current file information.
  52943. * @param extension defines the file extension of the file being loaded
  52944. * @returns true if the loader can load the specified file
  52945. */
  52946. canLoad(extension: string): boolean;
  52947. /**
  52948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52949. * @param data contains the texture data
  52950. * @param texture defines the BabylonJS internal texture
  52951. * @param createPolynomials will be true if polynomials have been requested
  52952. * @param onLoad defines the callback to trigger once the texture is ready
  52953. * @param onError defines the callback to trigger in case of error
  52954. */
  52955. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52956. /**
  52957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52958. * @param data contains the texture data
  52959. * @param texture defines the BabylonJS internal texture
  52960. * @param callback defines the method to call once ready to upload
  52961. */
  52962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52963. }
  52964. }
  52965. declare module BABYLON {
  52966. /**
  52967. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52968. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52969. */
  52970. export class KhronosTextureContainer {
  52971. /** contents of the KTX container file */
  52972. data: ArrayBufferView;
  52973. private static HEADER_LEN;
  52974. private static COMPRESSED_2D;
  52975. private static COMPRESSED_3D;
  52976. private static TEX_2D;
  52977. private static TEX_3D;
  52978. /**
  52979. * Gets the openGL type
  52980. */
  52981. glType: number;
  52982. /**
  52983. * Gets the openGL type size
  52984. */
  52985. glTypeSize: number;
  52986. /**
  52987. * Gets the openGL format
  52988. */
  52989. glFormat: number;
  52990. /**
  52991. * Gets the openGL internal format
  52992. */
  52993. glInternalFormat: number;
  52994. /**
  52995. * Gets the base internal format
  52996. */
  52997. glBaseInternalFormat: number;
  52998. /**
  52999. * Gets image width in pixel
  53000. */
  53001. pixelWidth: number;
  53002. /**
  53003. * Gets image height in pixel
  53004. */
  53005. pixelHeight: number;
  53006. /**
  53007. * Gets image depth in pixels
  53008. */
  53009. pixelDepth: number;
  53010. /**
  53011. * Gets the number of array elements
  53012. */
  53013. numberOfArrayElements: number;
  53014. /**
  53015. * Gets the number of faces
  53016. */
  53017. numberOfFaces: number;
  53018. /**
  53019. * Gets the number of mipmap levels
  53020. */
  53021. numberOfMipmapLevels: number;
  53022. /**
  53023. * Gets the bytes of key value data
  53024. */
  53025. bytesOfKeyValueData: number;
  53026. /**
  53027. * Gets the load type
  53028. */
  53029. loadType: number;
  53030. /**
  53031. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53032. */
  53033. isInvalid: boolean;
  53034. /**
  53035. * Creates a new KhronosTextureContainer
  53036. * @param data contents of the KTX container file
  53037. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53038. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53039. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53040. */
  53041. constructor(
  53042. /** contents of the KTX container file */
  53043. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53044. /**
  53045. * Uploads KTX content to a Babylon Texture.
  53046. * It is assumed that the texture has already been created & is currently bound
  53047. * @hidden
  53048. */
  53049. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53050. private _upload2DCompressedLevels;
  53051. /**
  53052. * Checks if the given data starts with a KTX file identifier.
  53053. * @param data the data to check
  53054. * @returns true if the data is a KTX file or false otherwise
  53055. */
  53056. static IsValid(data: ArrayBufferView): boolean;
  53057. }
  53058. }
  53059. declare module BABYLON {
  53060. /**
  53061. * Class for loading KTX2 files
  53062. * !!! Experimental Extension Subject to Changes !!!
  53063. * @hidden
  53064. */
  53065. export class KhronosTextureContainer2 {
  53066. private static _ModulePromise;
  53067. private static _TranscodeFormat;
  53068. constructor(engine: ThinEngine);
  53069. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  53070. private _determineTranscodeFormat;
  53071. /**
  53072. * Checks if the given data starts with a KTX2 file identifier.
  53073. * @param data the data to check
  53074. * @returns true if the data is a KTX2 file or false otherwise
  53075. */
  53076. static IsValid(data: ArrayBufferView): boolean;
  53077. }
  53078. }
  53079. declare module BABYLON {
  53080. /**
  53081. * Implementation of the KTX Texture Loader.
  53082. * @hidden
  53083. */
  53084. export class _KTXTextureLoader implements IInternalTextureLoader {
  53085. /**
  53086. * Defines wether the loader supports cascade loading the different faces.
  53087. */
  53088. readonly supportCascades: boolean;
  53089. /**
  53090. * This returns if the loader support the current file information.
  53091. * @param extension defines the file extension of the file being loaded
  53092. * @returns true if the loader can load the specified file
  53093. */
  53094. canLoad(extension: string): boolean;
  53095. /**
  53096. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  53097. * @param data contains the texture data
  53098. * @param texture defines the BabylonJS internal texture
  53099. * @param createPolynomials will be true if polynomials have been requested
  53100. * @param onLoad defines the callback to trigger once the texture is ready
  53101. * @param onError defines the callback to trigger in case of error
  53102. */
  53103. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53104. /**
  53105. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  53106. * @param data contains the texture data
  53107. * @param texture defines the BabylonJS internal texture
  53108. * @param callback defines the method to call once ready to upload
  53109. */
  53110. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53111. }
  53112. }
  53113. declare module BABYLON {
  53114. /** @hidden */
  53115. export var _forceSceneHelpersToBundle: boolean;
  53116. interface Scene {
  53117. /**
  53118. * Creates a default light for the scene.
  53119. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53120. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53121. */
  53122. createDefaultLight(replace?: boolean): void;
  53123. /**
  53124. * Creates a default camera for the scene.
  53125. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53126. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53127. * @param replace has default false, when true replaces the active camera in the scene
  53128. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53129. */
  53130. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53131. /**
  53132. * Creates a default camera and a default light.
  53133. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53134. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53135. * @param replace has the default false, when true replaces the active camera/light in the scene
  53136. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53137. */
  53138. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53139. /**
  53140. * Creates a new sky box
  53141. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53142. * @param environmentTexture defines the texture to use as environment texture
  53143. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53144. * @param scale defines the overall scale of the skybox
  53145. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53146. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53147. * @returns a new mesh holding the sky box
  53148. */
  53149. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53150. /**
  53151. * Creates a new environment
  53152. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53153. * @param options defines the options you can use to configure the environment
  53154. * @returns the new EnvironmentHelper
  53155. */
  53156. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53157. /**
  53158. * Creates a new VREXperienceHelper
  53159. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53160. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53161. * @returns a new VREXperienceHelper
  53162. */
  53163. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53164. /**
  53165. * Creates a new WebXRDefaultExperience
  53166. * @see http://doc.babylonjs.com/how_to/webxr
  53167. * @param options experience options
  53168. * @returns a promise for a new WebXRDefaultExperience
  53169. */
  53170. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53171. }
  53172. }
  53173. declare module BABYLON {
  53174. /**
  53175. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53176. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53177. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53178. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53179. */
  53180. export class VideoDome extends TransformNode {
  53181. /**
  53182. * Define the video source as a Monoscopic panoramic 360 video.
  53183. */
  53184. static readonly MODE_MONOSCOPIC: number;
  53185. /**
  53186. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53187. */
  53188. static readonly MODE_TOPBOTTOM: number;
  53189. /**
  53190. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53191. */
  53192. static readonly MODE_SIDEBYSIDE: number;
  53193. private _halfDome;
  53194. private _useDirectMapping;
  53195. /**
  53196. * The video texture being displayed on the sphere
  53197. */
  53198. protected _videoTexture: VideoTexture;
  53199. /**
  53200. * Gets the video texture being displayed on the sphere
  53201. */
  53202. get videoTexture(): VideoTexture;
  53203. /**
  53204. * The skybox material
  53205. */
  53206. protected _material: BackgroundMaterial;
  53207. /**
  53208. * The surface used for the skybox
  53209. */
  53210. protected _mesh: Mesh;
  53211. /**
  53212. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53213. */
  53214. private _halfDomeMask;
  53215. /**
  53216. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53217. * Also see the options.resolution property.
  53218. */
  53219. get fovMultiplier(): number;
  53220. set fovMultiplier(value: number);
  53221. private _videoMode;
  53222. /**
  53223. * Gets or set the current video mode for the video. It can be:
  53224. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53225. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53226. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53227. */
  53228. get videoMode(): number;
  53229. set videoMode(value: number);
  53230. /**
  53231. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53232. *
  53233. */
  53234. get halfDome(): boolean;
  53235. /**
  53236. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53237. */
  53238. set halfDome(enabled: boolean);
  53239. /**
  53240. * Oberserver used in Stereoscopic VR Mode.
  53241. */
  53242. private _onBeforeCameraRenderObserver;
  53243. /**
  53244. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53245. * @param name Element's name, child elements will append suffixes for their own names.
  53246. * @param urlsOrVideo defines the url(s) or the video element to use
  53247. * @param options An object containing optional or exposed sub element properties
  53248. */
  53249. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53250. resolution?: number;
  53251. clickToPlay?: boolean;
  53252. autoPlay?: boolean;
  53253. loop?: boolean;
  53254. size?: number;
  53255. poster?: string;
  53256. faceForward?: boolean;
  53257. useDirectMapping?: boolean;
  53258. halfDomeMode?: boolean;
  53259. }, scene: Scene);
  53260. private _changeVideoMode;
  53261. /**
  53262. * Releases resources associated with this node.
  53263. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53264. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53265. */
  53266. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53267. }
  53268. }
  53269. declare module BABYLON {
  53270. /**
  53271. * This class can be used to get instrumentation data from a Babylon engine
  53272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53273. */
  53274. export class EngineInstrumentation implements IDisposable {
  53275. /**
  53276. * Define the instrumented engine.
  53277. */
  53278. engine: Engine;
  53279. private _captureGPUFrameTime;
  53280. private _gpuFrameTimeToken;
  53281. private _gpuFrameTime;
  53282. private _captureShaderCompilationTime;
  53283. private _shaderCompilationTime;
  53284. private _onBeginFrameObserver;
  53285. private _onEndFrameObserver;
  53286. private _onBeforeShaderCompilationObserver;
  53287. private _onAfterShaderCompilationObserver;
  53288. /**
  53289. * Gets the perf counter used for GPU frame time
  53290. */
  53291. get gpuFrameTimeCounter(): PerfCounter;
  53292. /**
  53293. * Gets the GPU frame time capture status
  53294. */
  53295. get captureGPUFrameTime(): boolean;
  53296. /**
  53297. * Enable or disable the GPU frame time capture
  53298. */
  53299. set captureGPUFrameTime(value: boolean);
  53300. /**
  53301. * Gets the perf counter used for shader compilation time
  53302. */
  53303. get shaderCompilationTimeCounter(): PerfCounter;
  53304. /**
  53305. * Gets the shader compilation time capture status
  53306. */
  53307. get captureShaderCompilationTime(): boolean;
  53308. /**
  53309. * Enable or disable the shader compilation time capture
  53310. */
  53311. set captureShaderCompilationTime(value: boolean);
  53312. /**
  53313. * Instantiates a new engine instrumentation.
  53314. * This class can be used to get instrumentation data from a Babylon engine
  53315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53316. * @param engine Defines the engine to instrument
  53317. */
  53318. constructor(
  53319. /**
  53320. * Define the instrumented engine.
  53321. */
  53322. engine: Engine);
  53323. /**
  53324. * Dispose and release associated resources.
  53325. */
  53326. dispose(): void;
  53327. }
  53328. }
  53329. declare module BABYLON {
  53330. /**
  53331. * This class can be used to get instrumentation data from a Babylon engine
  53332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53333. */
  53334. export class SceneInstrumentation implements IDisposable {
  53335. /**
  53336. * Defines the scene to instrument
  53337. */
  53338. scene: Scene;
  53339. private _captureActiveMeshesEvaluationTime;
  53340. private _activeMeshesEvaluationTime;
  53341. private _captureRenderTargetsRenderTime;
  53342. private _renderTargetsRenderTime;
  53343. private _captureFrameTime;
  53344. private _frameTime;
  53345. private _captureRenderTime;
  53346. private _renderTime;
  53347. private _captureInterFrameTime;
  53348. private _interFrameTime;
  53349. private _captureParticlesRenderTime;
  53350. private _particlesRenderTime;
  53351. private _captureSpritesRenderTime;
  53352. private _spritesRenderTime;
  53353. private _capturePhysicsTime;
  53354. private _physicsTime;
  53355. private _captureAnimationsTime;
  53356. private _animationsTime;
  53357. private _captureCameraRenderTime;
  53358. private _cameraRenderTime;
  53359. private _onBeforeActiveMeshesEvaluationObserver;
  53360. private _onAfterActiveMeshesEvaluationObserver;
  53361. private _onBeforeRenderTargetsRenderObserver;
  53362. private _onAfterRenderTargetsRenderObserver;
  53363. private _onAfterRenderObserver;
  53364. private _onBeforeDrawPhaseObserver;
  53365. private _onAfterDrawPhaseObserver;
  53366. private _onBeforeAnimationsObserver;
  53367. private _onBeforeParticlesRenderingObserver;
  53368. private _onAfterParticlesRenderingObserver;
  53369. private _onBeforeSpritesRenderingObserver;
  53370. private _onAfterSpritesRenderingObserver;
  53371. private _onBeforePhysicsObserver;
  53372. private _onAfterPhysicsObserver;
  53373. private _onAfterAnimationsObserver;
  53374. private _onBeforeCameraRenderObserver;
  53375. private _onAfterCameraRenderObserver;
  53376. /**
  53377. * Gets the perf counter used for active meshes evaluation time
  53378. */
  53379. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53380. /**
  53381. * Gets the active meshes evaluation time capture status
  53382. */
  53383. get captureActiveMeshesEvaluationTime(): boolean;
  53384. /**
  53385. * Enable or disable the active meshes evaluation time capture
  53386. */
  53387. set captureActiveMeshesEvaluationTime(value: boolean);
  53388. /**
  53389. * Gets the perf counter used for render targets render time
  53390. */
  53391. get renderTargetsRenderTimeCounter(): PerfCounter;
  53392. /**
  53393. * Gets the render targets render time capture status
  53394. */
  53395. get captureRenderTargetsRenderTime(): boolean;
  53396. /**
  53397. * Enable or disable the render targets render time capture
  53398. */
  53399. set captureRenderTargetsRenderTime(value: boolean);
  53400. /**
  53401. * Gets the perf counter used for particles render time
  53402. */
  53403. get particlesRenderTimeCounter(): PerfCounter;
  53404. /**
  53405. * Gets the particles render time capture status
  53406. */
  53407. get captureParticlesRenderTime(): boolean;
  53408. /**
  53409. * Enable or disable the particles render time capture
  53410. */
  53411. set captureParticlesRenderTime(value: boolean);
  53412. /**
  53413. * Gets the perf counter used for sprites render time
  53414. */
  53415. get spritesRenderTimeCounter(): PerfCounter;
  53416. /**
  53417. * Gets the sprites render time capture status
  53418. */
  53419. get captureSpritesRenderTime(): boolean;
  53420. /**
  53421. * Enable or disable the sprites render time capture
  53422. */
  53423. set captureSpritesRenderTime(value: boolean);
  53424. /**
  53425. * Gets the perf counter used for physics time
  53426. */
  53427. get physicsTimeCounter(): PerfCounter;
  53428. /**
  53429. * Gets the physics time capture status
  53430. */
  53431. get capturePhysicsTime(): boolean;
  53432. /**
  53433. * Enable or disable the physics time capture
  53434. */
  53435. set capturePhysicsTime(value: boolean);
  53436. /**
  53437. * Gets the perf counter used for animations time
  53438. */
  53439. get animationsTimeCounter(): PerfCounter;
  53440. /**
  53441. * Gets the animations time capture status
  53442. */
  53443. get captureAnimationsTime(): boolean;
  53444. /**
  53445. * Enable or disable the animations time capture
  53446. */
  53447. set captureAnimationsTime(value: boolean);
  53448. /**
  53449. * Gets the perf counter used for frame time capture
  53450. */
  53451. get frameTimeCounter(): PerfCounter;
  53452. /**
  53453. * Gets the frame time capture status
  53454. */
  53455. get captureFrameTime(): boolean;
  53456. /**
  53457. * Enable or disable the frame time capture
  53458. */
  53459. set captureFrameTime(value: boolean);
  53460. /**
  53461. * Gets the perf counter used for inter-frames time capture
  53462. */
  53463. get interFrameTimeCounter(): PerfCounter;
  53464. /**
  53465. * Gets the inter-frames time capture status
  53466. */
  53467. get captureInterFrameTime(): boolean;
  53468. /**
  53469. * Enable or disable the inter-frames time capture
  53470. */
  53471. set captureInterFrameTime(value: boolean);
  53472. /**
  53473. * Gets the perf counter used for render time capture
  53474. */
  53475. get renderTimeCounter(): PerfCounter;
  53476. /**
  53477. * Gets the render time capture status
  53478. */
  53479. get captureRenderTime(): boolean;
  53480. /**
  53481. * Enable or disable the render time capture
  53482. */
  53483. set captureRenderTime(value: boolean);
  53484. /**
  53485. * Gets the perf counter used for camera render time capture
  53486. */
  53487. get cameraRenderTimeCounter(): PerfCounter;
  53488. /**
  53489. * Gets the camera render time capture status
  53490. */
  53491. get captureCameraRenderTime(): boolean;
  53492. /**
  53493. * Enable or disable the camera render time capture
  53494. */
  53495. set captureCameraRenderTime(value: boolean);
  53496. /**
  53497. * Gets the perf counter used for draw calls
  53498. */
  53499. get drawCallsCounter(): PerfCounter;
  53500. /**
  53501. * Instantiates a new scene instrumentation.
  53502. * This class can be used to get instrumentation data from a Babylon engine
  53503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53504. * @param scene Defines the scene to instrument
  53505. */
  53506. constructor(
  53507. /**
  53508. * Defines the scene to instrument
  53509. */
  53510. scene: Scene);
  53511. /**
  53512. * Dispose and release associated resources.
  53513. */
  53514. dispose(): void;
  53515. }
  53516. }
  53517. declare module BABYLON {
  53518. /** @hidden */
  53519. export var glowMapGenerationPixelShader: {
  53520. name: string;
  53521. shader: string;
  53522. };
  53523. }
  53524. declare module BABYLON {
  53525. /** @hidden */
  53526. export var glowMapGenerationVertexShader: {
  53527. name: string;
  53528. shader: string;
  53529. };
  53530. }
  53531. declare module BABYLON {
  53532. /**
  53533. * Effect layer options. This helps customizing the behaviour
  53534. * of the effect layer.
  53535. */
  53536. export interface IEffectLayerOptions {
  53537. /**
  53538. * Multiplication factor apply to the canvas size to compute the render target size
  53539. * used to generated the objects (the smaller the faster).
  53540. */
  53541. mainTextureRatio: number;
  53542. /**
  53543. * Enforces a fixed size texture to ensure effect stability across devices.
  53544. */
  53545. mainTextureFixedSize?: number;
  53546. /**
  53547. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53548. */
  53549. alphaBlendingMode: number;
  53550. /**
  53551. * The camera attached to the layer.
  53552. */
  53553. camera: Nullable<Camera>;
  53554. /**
  53555. * The rendering group to draw the layer in.
  53556. */
  53557. renderingGroupId: number;
  53558. }
  53559. /**
  53560. * The effect layer Helps adding post process effect blended with the main pass.
  53561. *
  53562. * This can be for instance use to generate glow or higlight effects on the scene.
  53563. *
  53564. * The effect layer class can not be used directly and is intented to inherited from to be
  53565. * customized per effects.
  53566. */
  53567. export abstract class EffectLayer {
  53568. private _vertexBuffers;
  53569. private _indexBuffer;
  53570. private _cachedDefines;
  53571. private _effectLayerMapGenerationEffect;
  53572. private _effectLayerOptions;
  53573. private _mergeEffect;
  53574. protected _scene: Scene;
  53575. protected _engine: Engine;
  53576. protected _maxSize: number;
  53577. protected _mainTextureDesiredSize: ISize;
  53578. protected _mainTexture: RenderTargetTexture;
  53579. protected _shouldRender: boolean;
  53580. protected _postProcesses: PostProcess[];
  53581. protected _textures: BaseTexture[];
  53582. protected _emissiveTextureAndColor: {
  53583. texture: Nullable<BaseTexture>;
  53584. color: Color4;
  53585. };
  53586. /**
  53587. * The name of the layer
  53588. */
  53589. name: string;
  53590. /**
  53591. * The clear color of the texture used to generate the glow map.
  53592. */
  53593. neutralColor: Color4;
  53594. /**
  53595. * Specifies whether the highlight layer is enabled or not.
  53596. */
  53597. isEnabled: boolean;
  53598. /**
  53599. * Gets the camera attached to the layer.
  53600. */
  53601. get camera(): Nullable<Camera>;
  53602. /**
  53603. * Gets the rendering group id the layer should render in.
  53604. */
  53605. get renderingGroupId(): number;
  53606. set renderingGroupId(renderingGroupId: number);
  53607. /**
  53608. * An event triggered when the effect layer has been disposed.
  53609. */
  53610. onDisposeObservable: Observable<EffectLayer>;
  53611. /**
  53612. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53613. */
  53614. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53615. /**
  53616. * An event triggered when the generated texture is being merged in the scene.
  53617. */
  53618. onBeforeComposeObservable: Observable<EffectLayer>;
  53619. /**
  53620. * An event triggered when the mesh is rendered into the effect render target.
  53621. */
  53622. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53623. /**
  53624. * An event triggered after the mesh has been rendered into the effect render target.
  53625. */
  53626. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53627. /**
  53628. * An event triggered when the generated texture has been merged in the scene.
  53629. */
  53630. onAfterComposeObservable: Observable<EffectLayer>;
  53631. /**
  53632. * An event triggered when the efffect layer changes its size.
  53633. */
  53634. onSizeChangedObservable: Observable<EffectLayer>;
  53635. /** @hidden */
  53636. static _SceneComponentInitialization: (scene: Scene) => void;
  53637. /**
  53638. * Instantiates a new effect Layer and references it in the scene.
  53639. * @param name The name of the layer
  53640. * @param scene The scene to use the layer in
  53641. */
  53642. constructor(
  53643. /** The Friendly of the effect in the scene */
  53644. name: string, scene: Scene);
  53645. /**
  53646. * Get the effect name of the layer.
  53647. * @return The effect name
  53648. */
  53649. abstract getEffectName(): string;
  53650. /**
  53651. * Checks for the readiness of the element composing the layer.
  53652. * @param subMesh the mesh to check for
  53653. * @param useInstances specify whether or not to use instances to render the mesh
  53654. * @return true if ready otherwise, false
  53655. */
  53656. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53657. /**
  53658. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53659. * @returns true if the effect requires stencil during the main canvas render pass.
  53660. */
  53661. abstract needStencil(): boolean;
  53662. /**
  53663. * Create the merge effect. This is the shader use to blit the information back
  53664. * to the main canvas at the end of the scene rendering.
  53665. * @returns The effect containing the shader used to merge the effect on the main canvas
  53666. */
  53667. protected abstract _createMergeEffect(): Effect;
  53668. /**
  53669. * Creates the render target textures and post processes used in the effect layer.
  53670. */
  53671. protected abstract _createTextureAndPostProcesses(): void;
  53672. /**
  53673. * Implementation specific of rendering the generating effect on the main canvas.
  53674. * @param effect The effect used to render through
  53675. */
  53676. protected abstract _internalRender(effect: Effect): void;
  53677. /**
  53678. * Sets the required values for both the emissive texture and and the main color.
  53679. */
  53680. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53681. /**
  53682. * Free any resources and references associated to a mesh.
  53683. * Internal use
  53684. * @param mesh The mesh to free.
  53685. */
  53686. abstract _disposeMesh(mesh: Mesh): void;
  53687. /**
  53688. * Serializes this layer (Glow or Highlight for example)
  53689. * @returns a serialized layer object
  53690. */
  53691. abstract serialize?(): any;
  53692. /**
  53693. * Initializes the effect layer with the required options.
  53694. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53695. */
  53696. protected _init(options: Partial<IEffectLayerOptions>): void;
  53697. /**
  53698. * Generates the index buffer of the full screen quad blending to the main canvas.
  53699. */
  53700. private _generateIndexBuffer;
  53701. /**
  53702. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53703. */
  53704. private _generateVertexBuffer;
  53705. /**
  53706. * Sets the main texture desired size which is the closest power of two
  53707. * of the engine canvas size.
  53708. */
  53709. private _setMainTextureSize;
  53710. /**
  53711. * Creates the main texture for the effect layer.
  53712. */
  53713. protected _createMainTexture(): void;
  53714. /**
  53715. * Adds specific effects defines.
  53716. * @param defines The defines to add specifics to.
  53717. */
  53718. protected _addCustomEffectDefines(defines: string[]): void;
  53719. /**
  53720. * Checks for the readiness of the element composing the layer.
  53721. * @param subMesh the mesh to check for
  53722. * @param useInstances specify whether or not to use instances to render the mesh
  53723. * @param emissiveTexture the associated emissive texture used to generate the glow
  53724. * @return true if ready otherwise, false
  53725. */
  53726. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53727. /**
  53728. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53729. */
  53730. render(): void;
  53731. /**
  53732. * Determine if a given mesh will be used in the current effect.
  53733. * @param mesh mesh to test
  53734. * @returns true if the mesh will be used
  53735. */
  53736. hasMesh(mesh: AbstractMesh): boolean;
  53737. /**
  53738. * Returns true if the layer contains information to display, otherwise false.
  53739. * @returns true if the glow layer should be rendered
  53740. */
  53741. shouldRender(): boolean;
  53742. /**
  53743. * Returns true if the mesh should render, otherwise false.
  53744. * @param mesh The mesh to render
  53745. * @returns true if it should render otherwise false
  53746. */
  53747. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53748. /**
  53749. * Returns true if the mesh can be rendered, otherwise false.
  53750. * @param mesh The mesh to render
  53751. * @param material The material used on the mesh
  53752. * @returns true if it can be rendered otherwise false
  53753. */
  53754. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53755. /**
  53756. * Returns true if the mesh should render, otherwise false.
  53757. * @param mesh The mesh to render
  53758. * @returns true if it should render otherwise false
  53759. */
  53760. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53761. /**
  53762. * Renders the submesh passed in parameter to the generation map.
  53763. */
  53764. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53765. /**
  53766. * Defines whether the current material of the mesh should be use to render the effect.
  53767. * @param mesh defines the current mesh to render
  53768. */
  53769. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53770. /**
  53771. * Rebuild the required buffers.
  53772. * @hidden Internal use only.
  53773. */
  53774. _rebuild(): void;
  53775. /**
  53776. * Dispose only the render target textures and post process.
  53777. */
  53778. private _disposeTextureAndPostProcesses;
  53779. /**
  53780. * Dispose the highlight layer and free resources.
  53781. */
  53782. dispose(): void;
  53783. /**
  53784. * Gets the class name of the effect layer
  53785. * @returns the string with the class name of the effect layer
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Creates an effect layer from parsed effect layer data
  53790. * @param parsedEffectLayer defines effect layer data
  53791. * @param scene defines the current scene
  53792. * @param rootUrl defines the root URL containing the effect layer information
  53793. * @returns a parsed effect Layer
  53794. */
  53795. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53796. }
  53797. }
  53798. declare module BABYLON {
  53799. interface AbstractScene {
  53800. /**
  53801. * The list of effect layers (highlights/glow) added to the scene
  53802. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53803. * @see http://doc.babylonjs.com/how_to/glow_layer
  53804. */
  53805. effectLayers: Array<EffectLayer>;
  53806. /**
  53807. * Removes the given effect layer from this scene.
  53808. * @param toRemove defines the effect layer to remove
  53809. * @returns the index of the removed effect layer
  53810. */
  53811. removeEffectLayer(toRemove: EffectLayer): number;
  53812. /**
  53813. * Adds the given effect layer to this scene
  53814. * @param newEffectLayer defines the effect layer to add
  53815. */
  53816. addEffectLayer(newEffectLayer: EffectLayer): void;
  53817. }
  53818. /**
  53819. * Defines the layer scene component responsible to manage any effect layers
  53820. * in a given scene.
  53821. */
  53822. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53823. /**
  53824. * The component name helpfull to identify the component in the list of scene components.
  53825. */
  53826. readonly name: string;
  53827. /**
  53828. * The scene the component belongs to.
  53829. */
  53830. scene: Scene;
  53831. private _engine;
  53832. private _renderEffects;
  53833. private _needStencil;
  53834. private _previousStencilState;
  53835. /**
  53836. * Creates a new instance of the component for the given scene
  53837. * @param scene Defines the scene to register the component in
  53838. */
  53839. constructor(scene: Scene);
  53840. /**
  53841. * Registers the component in a given scene
  53842. */
  53843. register(): void;
  53844. /**
  53845. * Rebuilds the elements related to this component in case of
  53846. * context lost for instance.
  53847. */
  53848. rebuild(): void;
  53849. /**
  53850. * Serializes the component data to the specified json object
  53851. * @param serializationObject The object to serialize to
  53852. */
  53853. serialize(serializationObject: any): void;
  53854. /**
  53855. * Adds all the elements from the container to the scene
  53856. * @param container the container holding the elements
  53857. */
  53858. addFromContainer(container: AbstractScene): void;
  53859. /**
  53860. * Removes all the elements in the container from the scene
  53861. * @param container contains the elements to remove
  53862. * @param dispose if the removed element should be disposed (default: false)
  53863. */
  53864. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53865. /**
  53866. * Disposes the component and the associated ressources.
  53867. */
  53868. dispose(): void;
  53869. private _isReadyForMesh;
  53870. private _renderMainTexture;
  53871. private _setStencil;
  53872. private _setStencilBack;
  53873. private _draw;
  53874. private _drawCamera;
  53875. private _drawRenderingGroup;
  53876. }
  53877. }
  53878. declare module BABYLON {
  53879. /** @hidden */
  53880. export var glowMapMergePixelShader: {
  53881. name: string;
  53882. shader: string;
  53883. };
  53884. }
  53885. declare module BABYLON {
  53886. /** @hidden */
  53887. export var glowMapMergeVertexShader: {
  53888. name: string;
  53889. shader: string;
  53890. };
  53891. }
  53892. declare module BABYLON {
  53893. interface AbstractScene {
  53894. /**
  53895. * Return a the first highlight layer of the scene with a given name.
  53896. * @param name The name of the highlight layer to look for.
  53897. * @return The highlight layer if found otherwise null.
  53898. */
  53899. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53900. }
  53901. /**
  53902. * Glow layer options. This helps customizing the behaviour
  53903. * of the glow layer.
  53904. */
  53905. export interface IGlowLayerOptions {
  53906. /**
  53907. * Multiplication factor apply to the canvas size to compute the render target size
  53908. * used to generated the glowing objects (the smaller the faster).
  53909. */
  53910. mainTextureRatio: number;
  53911. /**
  53912. * Enforces a fixed size texture to ensure resize independant blur.
  53913. */
  53914. mainTextureFixedSize?: number;
  53915. /**
  53916. * How big is the kernel of the blur texture.
  53917. */
  53918. blurKernelSize: number;
  53919. /**
  53920. * The camera attached to the layer.
  53921. */
  53922. camera: Nullable<Camera>;
  53923. /**
  53924. * Enable MSAA by chosing the number of samples.
  53925. */
  53926. mainTextureSamples?: number;
  53927. /**
  53928. * The rendering group to draw the layer in.
  53929. */
  53930. renderingGroupId: number;
  53931. }
  53932. /**
  53933. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53934. *
  53935. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53936. *
  53937. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53938. */
  53939. export class GlowLayer extends EffectLayer {
  53940. /**
  53941. * Effect Name of the layer.
  53942. */
  53943. static readonly EffectName: string;
  53944. /**
  53945. * The default blur kernel size used for the glow.
  53946. */
  53947. static DefaultBlurKernelSize: number;
  53948. /**
  53949. * The default texture size ratio used for the glow.
  53950. */
  53951. static DefaultTextureRatio: number;
  53952. /**
  53953. * Sets the kernel size of the blur.
  53954. */
  53955. set blurKernelSize(value: number);
  53956. /**
  53957. * Gets the kernel size of the blur.
  53958. */
  53959. get blurKernelSize(): number;
  53960. /**
  53961. * Sets the glow intensity.
  53962. */
  53963. set intensity(value: number);
  53964. /**
  53965. * Gets the glow intensity.
  53966. */
  53967. get intensity(): number;
  53968. private _options;
  53969. private _intensity;
  53970. private _horizontalBlurPostprocess1;
  53971. private _verticalBlurPostprocess1;
  53972. private _horizontalBlurPostprocess2;
  53973. private _verticalBlurPostprocess2;
  53974. private _blurTexture1;
  53975. private _blurTexture2;
  53976. private _postProcesses1;
  53977. private _postProcesses2;
  53978. private _includedOnlyMeshes;
  53979. private _excludedMeshes;
  53980. private _meshesUsingTheirOwnMaterials;
  53981. /**
  53982. * Callback used to let the user override the color selection on a per mesh basis
  53983. */
  53984. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53985. /**
  53986. * Callback used to let the user override the texture selection on a per mesh basis
  53987. */
  53988. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53989. /**
  53990. * Instantiates a new glow Layer and references it to the scene.
  53991. * @param name The name of the layer
  53992. * @param scene The scene to use the layer in
  53993. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53994. */
  53995. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53996. /**
  53997. * Get the effect name of the layer.
  53998. * @return The effect name
  53999. */
  54000. getEffectName(): string;
  54001. /**
  54002. * Create the merge effect. This is the shader use to blit the information back
  54003. * to the main canvas at the end of the scene rendering.
  54004. */
  54005. protected _createMergeEffect(): Effect;
  54006. /**
  54007. * Creates the render target textures and post processes used in the glow layer.
  54008. */
  54009. protected _createTextureAndPostProcesses(): void;
  54010. /**
  54011. * Checks for the readiness of the element composing the layer.
  54012. * @param subMesh the mesh to check for
  54013. * @param useInstances specify wether or not to use instances to render the mesh
  54014. * @param emissiveTexture the associated emissive texture used to generate the glow
  54015. * @return true if ready otherwise, false
  54016. */
  54017. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54018. /**
  54019. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  54020. */
  54021. needStencil(): boolean;
  54022. /**
  54023. * Returns true if the mesh can be rendered, otherwise false.
  54024. * @param mesh The mesh to render
  54025. * @param material The material used on the mesh
  54026. * @returns true if it can be rendered otherwise false
  54027. */
  54028. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54029. /**
  54030. * Implementation specific of rendering the generating effect on the main canvas.
  54031. * @param effect The effect used to render through
  54032. */
  54033. protected _internalRender(effect: Effect): void;
  54034. /**
  54035. * Sets the required values for both the emissive texture and and the main color.
  54036. */
  54037. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54038. /**
  54039. * Returns true if the mesh should render, otherwise false.
  54040. * @param mesh The mesh to render
  54041. * @returns true if it should render otherwise false
  54042. */
  54043. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54044. /**
  54045. * Adds specific effects defines.
  54046. * @param defines The defines to add specifics to.
  54047. */
  54048. protected _addCustomEffectDefines(defines: string[]): void;
  54049. /**
  54050. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54051. * @param mesh The mesh to exclude from the glow layer
  54052. */
  54053. addExcludedMesh(mesh: Mesh): void;
  54054. /**
  54055. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54056. * @param mesh The mesh to remove
  54057. */
  54058. removeExcludedMesh(mesh: Mesh): void;
  54059. /**
  54060. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54061. * @param mesh The mesh to include in the glow layer
  54062. */
  54063. addIncludedOnlyMesh(mesh: Mesh): void;
  54064. /**
  54065. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54066. * @param mesh The mesh to remove
  54067. */
  54068. removeIncludedOnlyMesh(mesh: Mesh): void;
  54069. /**
  54070. * Determine if a given mesh will be used in the glow layer
  54071. * @param mesh The mesh to test
  54072. * @returns true if the mesh will be highlighted by the current glow layer
  54073. */
  54074. hasMesh(mesh: AbstractMesh): boolean;
  54075. /**
  54076. * Defines whether the current material of the mesh should be use to render the effect.
  54077. * @param mesh defines the current mesh to render
  54078. */
  54079. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54080. /**
  54081. * Add a mesh to be rendered through its own material and not with emissive only.
  54082. * @param mesh The mesh for which we need to use its material
  54083. */
  54084. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54085. /**
  54086. * Remove a mesh from being rendered through its own material and not with emissive only.
  54087. * @param mesh The mesh for which we need to not use its material
  54088. */
  54089. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54090. /**
  54091. * Free any resources and references associated to a mesh.
  54092. * Internal use
  54093. * @param mesh The mesh to free.
  54094. * @hidden
  54095. */
  54096. _disposeMesh(mesh: Mesh): void;
  54097. /**
  54098. * Gets the class name of the effect layer
  54099. * @returns the string with the class name of the effect layer
  54100. */
  54101. getClassName(): string;
  54102. /**
  54103. * Serializes this glow layer
  54104. * @returns a serialized glow layer object
  54105. */
  54106. serialize(): any;
  54107. /**
  54108. * Creates a Glow Layer from parsed glow layer data
  54109. * @param parsedGlowLayer defines glow layer data
  54110. * @param scene defines the current scene
  54111. * @param rootUrl defines the root URL containing the glow layer information
  54112. * @returns a parsed Glow Layer
  54113. */
  54114. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /** @hidden */
  54119. export var glowBlurPostProcessPixelShader: {
  54120. name: string;
  54121. shader: string;
  54122. };
  54123. }
  54124. declare module BABYLON {
  54125. interface AbstractScene {
  54126. /**
  54127. * Return a the first highlight layer of the scene with a given name.
  54128. * @param name The name of the highlight layer to look for.
  54129. * @return The highlight layer if found otherwise null.
  54130. */
  54131. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54132. }
  54133. /**
  54134. * Highlight layer options. This helps customizing the behaviour
  54135. * of the highlight layer.
  54136. */
  54137. export interface IHighlightLayerOptions {
  54138. /**
  54139. * Multiplication factor apply to the canvas size to compute the render target size
  54140. * used to generated the glowing objects (the smaller the faster).
  54141. */
  54142. mainTextureRatio: number;
  54143. /**
  54144. * Enforces a fixed size texture to ensure resize independant blur.
  54145. */
  54146. mainTextureFixedSize?: number;
  54147. /**
  54148. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54149. * of the picture to blur (the smaller the faster).
  54150. */
  54151. blurTextureSizeRatio: number;
  54152. /**
  54153. * How big in texel of the blur texture is the vertical blur.
  54154. */
  54155. blurVerticalSize: number;
  54156. /**
  54157. * How big in texel of the blur texture is the horizontal blur.
  54158. */
  54159. blurHorizontalSize: number;
  54160. /**
  54161. * Alpha blending mode used to apply the blur. Default is combine.
  54162. */
  54163. alphaBlendingMode: number;
  54164. /**
  54165. * The camera attached to the layer.
  54166. */
  54167. camera: Nullable<Camera>;
  54168. /**
  54169. * Should we display highlight as a solid stroke?
  54170. */
  54171. isStroke?: boolean;
  54172. /**
  54173. * The rendering group to draw the layer in.
  54174. */
  54175. renderingGroupId: number;
  54176. }
  54177. /**
  54178. * The highlight layer Helps adding a glow effect around a mesh.
  54179. *
  54180. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54181. * glowy meshes to your scene.
  54182. *
  54183. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54184. */
  54185. export class HighlightLayer extends EffectLayer {
  54186. name: string;
  54187. /**
  54188. * Effect Name of the highlight layer.
  54189. */
  54190. static readonly EffectName: string;
  54191. /**
  54192. * The neutral color used during the preparation of the glow effect.
  54193. * This is black by default as the blend operation is a blend operation.
  54194. */
  54195. static NeutralColor: Color4;
  54196. /**
  54197. * Stencil value used for glowing meshes.
  54198. */
  54199. static GlowingMeshStencilReference: number;
  54200. /**
  54201. * Stencil value used for the other meshes in the scene.
  54202. */
  54203. static NormalMeshStencilReference: number;
  54204. /**
  54205. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54206. */
  54207. innerGlow: boolean;
  54208. /**
  54209. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54210. */
  54211. outerGlow: boolean;
  54212. /**
  54213. * Specifies the horizontal size of the blur.
  54214. */
  54215. set blurHorizontalSize(value: number);
  54216. /**
  54217. * Specifies the vertical size of the blur.
  54218. */
  54219. set blurVerticalSize(value: number);
  54220. /**
  54221. * Gets the horizontal size of the blur.
  54222. */
  54223. get blurHorizontalSize(): number;
  54224. /**
  54225. * Gets the vertical size of the blur.
  54226. */
  54227. get blurVerticalSize(): number;
  54228. /**
  54229. * An event triggered when the highlight layer is being blurred.
  54230. */
  54231. onBeforeBlurObservable: Observable<HighlightLayer>;
  54232. /**
  54233. * An event triggered when the highlight layer has been blurred.
  54234. */
  54235. onAfterBlurObservable: Observable<HighlightLayer>;
  54236. private _instanceGlowingMeshStencilReference;
  54237. private _options;
  54238. private _downSamplePostprocess;
  54239. private _horizontalBlurPostprocess;
  54240. private _verticalBlurPostprocess;
  54241. private _blurTexture;
  54242. private _meshes;
  54243. private _excludedMeshes;
  54244. /**
  54245. * Instantiates a new highlight Layer and references it to the scene..
  54246. * @param name The name of the layer
  54247. * @param scene The scene to use the layer in
  54248. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54249. */
  54250. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54251. /**
  54252. * Get the effect name of the layer.
  54253. * @return The effect name
  54254. */
  54255. getEffectName(): string;
  54256. /**
  54257. * Create the merge effect. This is the shader use to blit the information back
  54258. * to the main canvas at the end of the scene rendering.
  54259. */
  54260. protected _createMergeEffect(): Effect;
  54261. /**
  54262. * Creates the render target textures and post processes used in the highlight layer.
  54263. */
  54264. protected _createTextureAndPostProcesses(): void;
  54265. /**
  54266. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54267. */
  54268. needStencil(): boolean;
  54269. /**
  54270. * Checks for the readiness of the element composing the layer.
  54271. * @param subMesh the mesh to check for
  54272. * @param useInstances specify wether or not to use instances to render the mesh
  54273. * @param emissiveTexture the associated emissive texture used to generate the glow
  54274. * @return true if ready otherwise, false
  54275. */
  54276. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54277. /**
  54278. * Implementation specific of rendering the generating effect on the main canvas.
  54279. * @param effect The effect used to render through
  54280. */
  54281. protected _internalRender(effect: Effect): void;
  54282. /**
  54283. * Returns true if the layer contains information to display, otherwise false.
  54284. */
  54285. shouldRender(): boolean;
  54286. /**
  54287. * Returns true if the mesh should render, otherwise false.
  54288. * @param mesh The mesh to render
  54289. * @returns true if it should render otherwise false
  54290. */
  54291. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54292. /**
  54293. * Adds specific effects defines.
  54294. * @param defines The defines to add specifics to.
  54295. */
  54296. protected _addCustomEffectDefines(defines: string[]): void;
  54297. /**
  54298. * Sets the required values for both the emissive texture and and the main color.
  54299. */
  54300. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54301. /**
  54302. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54303. * @param mesh The mesh to exclude from the highlight layer
  54304. */
  54305. addExcludedMesh(mesh: Mesh): void;
  54306. /**
  54307. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54308. * @param mesh The mesh to highlight
  54309. */
  54310. removeExcludedMesh(mesh: Mesh): void;
  54311. /**
  54312. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54313. * @param mesh mesh to test
  54314. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54315. */
  54316. hasMesh(mesh: AbstractMesh): boolean;
  54317. /**
  54318. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54319. * @param mesh The mesh to highlight
  54320. * @param color The color of the highlight
  54321. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54322. */
  54323. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54324. /**
  54325. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54326. * @param mesh The mesh to highlight
  54327. */
  54328. removeMesh(mesh: Mesh): void;
  54329. /**
  54330. * Remove all the meshes currently referenced in the highlight layer
  54331. */
  54332. removeAllMeshes(): void;
  54333. /**
  54334. * Force the stencil to the normal expected value for none glowing parts
  54335. */
  54336. private _defaultStencilReference;
  54337. /**
  54338. * Free any resources and references associated to a mesh.
  54339. * Internal use
  54340. * @param mesh The mesh to free.
  54341. * @hidden
  54342. */
  54343. _disposeMesh(mesh: Mesh): void;
  54344. /**
  54345. * Dispose the highlight layer and free resources.
  54346. */
  54347. dispose(): void;
  54348. /**
  54349. * Gets the class name of the effect layer
  54350. * @returns the string with the class name of the effect layer
  54351. */
  54352. getClassName(): string;
  54353. /**
  54354. * Serializes this Highlight layer
  54355. * @returns a serialized Highlight layer object
  54356. */
  54357. serialize(): any;
  54358. /**
  54359. * Creates a Highlight layer from parsed Highlight layer data
  54360. * @param parsedHightlightLayer defines the Highlight layer data
  54361. * @param scene defines the current scene
  54362. * @param rootUrl defines the root URL containing the Highlight layer information
  54363. * @returns a parsed Highlight layer
  54364. */
  54365. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54366. }
  54367. }
  54368. declare module BABYLON {
  54369. interface AbstractScene {
  54370. /**
  54371. * The list of layers (background and foreground) of the scene
  54372. */
  54373. layers: Array<Layer>;
  54374. }
  54375. /**
  54376. * Defines the layer scene component responsible to manage any layers
  54377. * in a given scene.
  54378. */
  54379. export class LayerSceneComponent implements ISceneComponent {
  54380. /**
  54381. * The component name helpfull to identify the component in the list of scene components.
  54382. */
  54383. readonly name: string;
  54384. /**
  54385. * The scene the component belongs to.
  54386. */
  54387. scene: Scene;
  54388. private _engine;
  54389. /**
  54390. * Creates a new instance of the component for the given scene
  54391. * @param scene Defines the scene to register the component in
  54392. */
  54393. constructor(scene: Scene);
  54394. /**
  54395. * Registers the component in a given scene
  54396. */
  54397. register(): void;
  54398. /**
  54399. * Rebuilds the elements related to this component in case of
  54400. * context lost for instance.
  54401. */
  54402. rebuild(): void;
  54403. /**
  54404. * Disposes the component and the associated ressources.
  54405. */
  54406. dispose(): void;
  54407. private _draw;
  54408. private _drawCameraPredicate;
  54409. private _drawCameraBackground;
  54410. private _drawCameraForeground;
  54411. private _drawRenderTargetPredicate;
  54412. private _drawRenderTargetBackground;
  54413. private _drawRenderTargetForeground;
  54414. /**
  54415. * Adds all the elements from the container to the scene
  54416. * @param container the container holding the elements
  54417. */
  54418. addFromContainer(container: AbstractScene): void;
  54419. /**
  54420. * Removes all the elements in the container from the scene
  54421. * @param container contains the elements to remove
  54422. * @param dispose if the removed element should be disposed (default: false)
  54423. */
  54424. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54425. }
  54426. }
  54427. declare module BABYLON {
  54428. /** @hidden */
  54429. export var layerPixelShader: {
  54430. name: string;
  54431. shader: string;
  54432. };
  54433. }
  54434. declare module BABYLON {
  54435. /** @hidden */
  54436. export var layerVertexShader: {
  54437. name: string;
  54438. shader: string;
  54439. };
  54440. }
  54441. declare module BABYLON {
  54442. /**
  54443. * This represents a full screen 2d layer.
  54444. * This can be useful to display a picture in the background of your scene for instance.
  54445. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54446. */
  54447. export class Layer {
  54448. /**
  54449. * Define the name of the layer.
  54450. */
  54451. name: string;
  54452. /**
  54453. * Define the texture the layer should display.
  54454. */
  54455. texture: Nullable<Texture>;
  54456. /**
  54457. * Is the layer in background or foreground.
  54458. */
  54459. isBackground: boolean;
  54460. /**
  54461. * Define the color of the layer (instead of texture).
  54462. */
  54463. color: Color4;
  54464. /**
  54465. * Define the scale of the layer in order to zoom in out of the texture.
  54466. */
  54467. scale: Vector2;
  54468. /**
  54469. * Define an offset for the layer in order to shift the texture.
  54470. */
  54471. offset: Vector2;
  54472. /**
  54473. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54474. */
  54475. alphaBlendingMode: number;
  54476. /**
  54477. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54478. * Alpha test will not mix with the background color in case of transparency.
  54479. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54480. */
  54481. alphaTest: boolean;
  54482. /**
  54483. * Define a mask to restrict the layer to only some of the scene cameras.
  54484. */
  54485. layerMask: number;
  54486. /**
  54487. * Define the list of render target the layer is visible into.
  54488. */
  54489. renderTargetTextures: RenderTargetTexture[];
  54490. /**
  54491. * Define if the layer is only used in renderTarget or if it also
  54492. * renders in the main frame buffer of the canvas.
  54493. */
  54494. renderOnlyInRenderTargetTextures: boolean;
  54495. private _scene;
  54496. private _vertexBuffers;
  54497. private _indexBuffer;
  54498. private _effect;
  54499. private _previousDefines;
  54500. /**
  54501. * An event triggered when the layer is disposed.
  54502. */
  54503. onDisposeObservable: Observable<Layer>;
  54504. private _onDisposeObserver;
  54505. /**
  54506. * Back compatibility with callback before the onDisposeObservable existed.
  54507. * The set callback will be triggered when the layer has been disposed.
  54508. */
  54509. set onDispose(callback: () => void);
  54510. /**
  54511. * An event triggered before rendering the scene
  54512. */
  54513. onBeforeRenderObservable: Observable<Layer>;
  54514. private _onBeforeRenderObserver;
  54515. /**
  54516. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54517. * The set callback will be triggered just before rendering the layer.
  54518. */
  54519. set onBeforeRender(callback: () => void);
  54520. /**
  54521. * An event triggered after rendering the scene
  54522. */
  54523. onAfterRenderObservable: Observable<Layer>;
  54524. private _onAfterRenderObserver;
  54525. /**
  54526. * Back compatibility with callback before the onAfterRenderObservable existed.
  54527. * The set callback will be triggered just after rendering the layer.
  54528. */
  54529. set onAfterRender(callback: () => void);
  54530. /**
  54531. * Instantiates a new layer.
  54532. * This represents a full screen 2d layer.
  54533. * This can be useful to display a picture in the background of your scene for instance.
  54534. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54535. * @param name Define the name of the layer in the scene
  54536. * @param imgUrl Define the url of the texture to display in the layer
  54537. * @param scene Define the scene the layer belongs to
  54538. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54539. * @param color Defines a color for the layer
  54540. */
  54541. constructor(
  54542. /**
  54543. * Define the name of the layer.
  54544. */
  54545. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54546. private _createIndexBuffer;
  54547. /** @hidden */
  54548. _rebuild(): void;
  54549. /**
  54550. * Renders the layer in the scene.
  54551. */
  54552. render(): void;
  54553. /**
  54554. * Disposes and releases the associated ressources.
  54555. */
  54556. dispose(): void;
  54557. }
  54558. }
  54559. declare module BABYLON {
  54560. /** @hidden */
  54561. export var lensFlarePixelShader: {
  54562. name: string;
  54563. shader: string;
  54564. };
  54565. }
  54566. declare module BABYLON {
  54567. /** @hidden */
  54568. export var lensFlareVertexShader: {
  54569. name: string;
  54570. shader: string;
  54571. };
  54572. }
  54573. declare module BABYLON {
  54574. /**
  54575. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54576. * It is usually composed of several `lensFlare`.
  54577. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54578. */
  54579. export class LensFlareSystem {
  54580. /**
  54581. * Define the name of the lens flare system
  54582. */
  54583. name: string;
  54584. /**
  54585. * List of lens flares used in this system.
  54586. */
  54587. lensFlares: LensFlare[];
  54588. /**
  54589. * Define a limit from the border the lens flare can be visible.
  54590. */
  54591. borderLimit: number;
  54592. /**
  54593. * Define a viewport border we do not want to see the lens flare in.
  54594. */
  54595. viewportBorder: number;
  54596. /**
  54597. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54598. */
  54599. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54600. /**
  54601. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54602. */
  54603. layerMask: number;
  54604. /**
  54605. * Define the id of the lens flare system in the scene.
  54606. * (equal to name by default)
  54607. */
  54608. id: string;
  54609. private _scene;
  54610. private _emitter;
  54611. private _vertexBuffers;
  54612. private _indexBuffer;
  54613. private _effect;
  54614. private _positionX;
  54615. private _positionY;
  54616. private _isEnabled;
  54617. /** @hidden */
  54618. static _SceneComponentInitialization: (scene: Scene) => void;
  54619. /**
  54620. * Instantiates a lens flare system.
  54621. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54622. * It is usually composed of several `lensFlare`.
  54623. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54624. * @param name Define the name of the lens flare system in the scene
  54625. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54626. * @param scene Define the scene the lens flare system belongs to
  54627. */
  54628. constructor(
  54629. /**
  54630. * Define the name of the lens flare system
  54631. */
  54632. name: string, emitter: any, scene: Scene);
  54633. /**
  54634. * Define if the lens flare system is enabled.
  54635. */
  54636. get isEnabled(): boolean;
  54637. set isEnabled(value: boolean);
  54638. /**
  54639. * Get the scene the effects belongs to.
  54640. * @returns the scene holding the lens flare system
  54641. */
  54642. getScene(): Scene;
  54643. /**
  54644. * Get the emitter of the lens flare system.
  54645. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54646. * @returns the emitter of the lens flare system
  54647. */
  54648. getEmitter(): any;
  54649. /**
  54650. * Set the emitter of the lens flare system.
  54651. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54652. * @param newEmitter Define the new emitter of the system
  54653. */
  54654. setEmitter(newEmitter: any): void;
  54655. /**
  54656. * Get the lens flare system emitter position.
  54657. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54658. * @returns the position
  54659. */
  54660. getEmitterPosition(): Vector3;
  54661. /**
  54662. * @hidden
  54663. */
  54664. computeEffectivePosition(globalViewport: Viewport): boolean;
  54665. /** @hidden */
  54666. _isVisible(): boolean;
  54667. /**
  54668. * @hidden
  54669. */
  54670. render(): boolean;
  54671. /**
  54672. * Dispose and release the lens flare with its associated resources.
  54673. */
  54674. dispose(): void;
  54675. /**
  54676. * Parse a lens flare system from a JSON repressentation
  54677. * @param parsedLensFlareSystem Define the JSON to parse
  54678. * @param scene Define the scene the parsed system should be instantiated in
  54679. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54680. * @returns the parsed system
  54681. */
  54682. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54683. /**
  54684. * Serialize the current Lens Flare System into a JSON representation.
  54685. * @returns the serialized JSON
  54686. */
  54687. serialize(): any;
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. /**
  54692. * This represents one of the lens effect in a `lensFlareSystem`.
  54693. * It controls one of the indiviual texture used in the effect.
  54694. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54695. */
  54696. export class LensFlare {
  54697. /**
  54698. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54699. */
  54700. size: number;
  54701. /**
  54702. * 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.
  54703. */
  54704. position: number;
  54705. /**
  54706. * Define the lens color.
  54707. */
  54708. color: Color3;
  54709. /**
  54710. * Define the lens texture.
  54711. */
  54712. texture: Nullable<Texture>;
  54713. /**
  54714. * Define the alpha mode to render this particular lens.
  54715. */
  54716. alphaMode: number;
  54717. private _system;
  54718. /**
  54719. * Creates a new Lens Flare.
  54720. * This represents one of the lens effect in a `lensFlareSystem`.
  54721. * It controls one of the indiviual texture used in the effect.
  54722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54723. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54724. * @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.
  54725. * @param color Define the lens color
  54726. * @param imgUrl Define the lens texture url
  54727. * @param system Define the `lensFlareSystem` this flare is part of
  54728. * @returns The newly created Lens Flare
  54729. */
  54730. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54731. /**
  54732. * Instantiates a new Lens Flare.
  54733. * This represents one of the lens effect in a `lensFlareSystem`.
  54734. * It controls one of the indiviual texture used in the effect.
  54735. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54736. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54737. * @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.
  54738. * @param color Define the lens color
  54739. * @param imgUrl Define the lens texture url
  54740. * @param system Define the `lensFlareSystem` this flare is part of
  54741. */
  54742. constructor(
  54743. /**
  54744. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54745. */
  54746. size: number,
  54747. /**
  54748. * 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.
  54749. */
  54750. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54751. /**
  54752. * Dispose and release the lens flare with its associated resources.
  54753. */
  54754. dispose(): void;
  54755. }
  54756. }
  54757. declare module BABYLON {
  54758. interface AbstractScene {
  54759. /**
  54760. * The list of lens flare system added to the scene
  54761. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54762. */
  54763. lensFlareSystems: Array<LensFlareSystem>;
  54764. /**
  54765. * Removes the given lens flare system from this scene.
  54766. * @param toRemove The lens flare system to remove
  54767. * @returns The index of the removed lens flare system
  54768. */
  54769. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54770. /**
  54771. * Adds the given lens flare system to this scene
  54772. * @param newLensFlareSystem The lens flare system to add
  54773. */
  54774. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54775. /**
  54776. * Gets a lens flare system using its name
  54777. * @param name defines the name to look for
  54778. * @returns the lens flare system or null if not found
  54779. */
  54780. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54781. /**
  54782. * Gets a lens flare system using its id
  54783. * @param id defines the id to look for
  54784. * @returns the lens flare system or null if not found
  54785. */
  54786. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54787. }
  54788. /**
  54789. * Defines the lens flare scene component responsible to manage any lens flares
  54790. * in a given scene.
  54791. */
  54792. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54793. /**
  54794. * The component name helpfull to identify the component in the list of scene components.
  54795. */
  54796. readonly name: string;
  54797. /**
  54798. * The scene the component belongs to.
  54799. */
  54800. scene: Scene;
  54801. /**
  54802. * Creates a new instance of the component for the given scene
  54803. * @param scene Defines the scene to register the component in
  54804. */
  54805. constructor(scene: Scene);
  54806. /**
  54807. * Registers the component in a given scene
  54808. */
  54809. register(): void;
  54810. /**
  54811. * Rebuilds the elements related to this component in case of
  54812. * context lost for instance.
  54813. */
  54814. rebuild(): void;
  54815. /**
  54816. * Adds all the elements from the container to the scene
  54817. * @param container the container holding the elements
  54818. */
  54819. addFromContainer(container: AbstractScene): void;
  54820. /**
  54821. * Removes all the elements in the container from the scene
  54822. * @param container contains the elements to remove
  54823. * @param dispose if the removed element should be disposed (default: false)
  54824. */
  54825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54826. /**
  54827. * Serializes the component data to the specified json object
  54828. * @param serializationObject The object to serialize to
  54829. */
  54830. serialize(serializationObject: any): void;
  54831. /**
  54832. * Disposes the component and the associated ressources.
  54833. */
  54834. dispose(): void;
  54835. private _draw;
  54836. }
  54837. }
  54838. declare module BABYLON {
  54839. /** @hidden */
  54840. export var depthPixelShader: {
  54841. name: string;
  54842. shader: string;
  54843. };
  54844. }
  54845. declare module BABYLON {
  54846. /** @hidden */
  54847. export var depthVertexShader: {
  54848. name: string;
  54849. shader: string;
  54850. };
  54851. }
  54852. declare module BABYLON {
  54853. /**
  54854. * This represents a depth renderer in Babylon.
  54855. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54856. */
  54857. export class DepthRenderer {
  54858. private _scene;
  54859. private _depthMap;
  54860. private _effect;
  54861. private readonly _storeNonLinearDepth;
  54862. private readonly _clearColor;
  54863. /** Get if the depth renderer is using packed depth or not */
  54864. readonly isPacked: boolean;
  54865. private _cachedDefines;
  54866. private _camera;
  54867. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54868. enabled: boolean;
  54869. /**
  54870. * Specifiess that the depth renderer will only be used within
  54871. * the camera it is created for.
  54872. * This can help forcing its rendering during the camera processing.
  54873. */
  54874. useOnlyInActiveCamera: boolean;
  54875. /** @hidden */
  54876. static _SceneComponentInitialization: (scene: Scene) => void;
  54877. /**
  54878. * Instantiates a depth renderer
  54879. * @param scene The scene the renderer belongs to
  54880. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54881. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54882. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54883. */
  54884. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54885. /**
  54886. * Creates the depth rendering effect and checks if the effect is ready.
  54887. * @param subMesh The submesh to be used to render the depth map of
  54888. * @param useInstances If multiple world instances should be used
  54889. * @returns if the depth renderer is ready to render the depth map
  54890. */
  54891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54892. /**
  54893. * Gets the texture which the depth map will be written to.
  54894. * @returns The depth map texture
  54895. */
  54896. getDepthMap(): RenderTargetTexture;
  54897. /**
  54898. * Disposes of the depth renderer.
  54899. */
  54900. dispose(): void;
  54901. }
  54902. }
  54903. declare module BABYLON {
  54904. /** @hidden */
  54905. export var minmaxReduxPixelShader: {
  54906. name: string;
  54907. shader: string;
  54908. };
  54909. }
  54910. declare module BABYLON {
  54911. /**
  54912. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54913. * and maximum values from all values of the texture.
  54914. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54915. * The source values are read from the red channel of the texture.
  54916. */
  54917. export class MinMaxReducer {
  54918. /**
  54919. * Observable triggered when the computation has been performed
  54920. */
  54921. onAfterReductionPerformed: Observable<{
  54922. min: number;
  54923. max: number;
  54924. }>;
  54925. protected _camera: Camera;
  54926. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54927. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54928. protected _postProcessManager: PostProcessManager;
  54929. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54930. protected _forceFullscreenViewport: boolean;
  54931. /**
  54932. * Creates a min/max reducer
  54933. * @param camera The camera to use for the post processes
  54934. */
  54935. constructor(camera: Camera);
  54936. /**
  54937. * Gets the texture used to read the values from.
  54938. */
  54939. get sourceTexture(): Nullable<RenderTargetTexture>;
  54940. /**
  54941. * Sets the source texture to read the values from.
  54942. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54943. * because in such textures '1' value must not be taken into account to compute the maximum
  54944. * as this value is used to clear the texture.
  54945. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54946. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54947. * @param depthRedux Indicates if the texture is a depth texture or not
  54948. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54949. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54950. */
  54951. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54952. /**
  54953. * Defines the refresh rate of the computation.
  54954. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54955. */
  54956. get refreshRate(): number;
  54957. set refreshRate(value: number);
  54958. protected _activated: boolean;
  54959. /**
  54960. * Gets the activation status of the reducer
  54961. */
  54962. get activated(): boolean;
  54963. /**
  54964. * Activates the reduction computation.
  54965. * When activated, the observers registered in onAfterReductionPerformed are
  54966. * called after the compuation is performed
  54967. */
  54968. activate(): void;
  54969. /**
  54970. * Deactivates the reduction computation.
  54971. */
  54972. deactivate(): void;
  54973. /**
  54974. * Disposes the min/max reducer
  54975. * @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.
  54976. */
  54977. dispose(disposeAll?: boolean): void;
  54978. }
  54979. }
  54980. declare module BABYLON {
  54981. /**
  54982. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54983. */
  54984. export class DepthReducer extends MinMaxReducer {
  54985. private _depthRenderer;
  54986. private _depthRendererId;
  54987. /**
  54988. * Gets the depth renderer used for the computation.
  54989. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54990. */
  54991. get depthRenderer(): Nullable<DepthRenderer>;
  54992. /**
  54993. * Creates a depth reducer
  54994. * @param camera The camera used to render the depth texture
  54995. */
  54996. constructor(camera: Camera);
  54997. /**
  54998. * Sets the depth renderer to use to generate the depth map
  54999. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  55000. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  55001. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  55002. */
  55003. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  55004. /** @hidden */
  55005. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  55006. /**
  55007. * Activates the reduction computation.
  55008. * When activated, the observers registered in onAfterReductionPerformed are
  55009. * called after the compuation is performed
  55010. */
  55011. activate(): void;
  55012. /**
  55013. * Deactivates the reduction computation.
  55014. */
  55015. deactivate(): void;
  55016. /**
  55017. * Disposes the depth reducer
  55018. * @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.
  55019. */
  55020. dispose(disposeAll?: boolean): void;
  55021. }
  55022. }
  55023. declare module BABYLON {
  55024. /**
  55025. * A CSM implementation allowing casting shadows on large scenes.
  55026. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55027. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  55028. */
  55029. export class CascadedShadowGenerator extends ShadowGenerator {
  55030. private static readonly frustumCornersNDCSpace;
  55031. /**
  55032. * Name of the CSM class
  55033. */
  55034. static CLASSNAME: string;
  55035. /**
  55036. * Defines the default number of cascades used by the CSM.
  55037. */
  55038. static readonly DEFAULT_CASCADES_COUNT: number;
  55039. /**
  55040. * Defines the minimum number of cascades used by the CSM.
  55041. */
  55042. static readonly MIN_CASCADES_COUNT: number;
  55043. /**
  55044. * Defines the maximum number of cascades used by the CSM.
  55045. */
  55046. static readonly MAX_CASCADES_COUNT: number;
  55047. protected _validateFilter(filter: number): number;
  55048. /**
  55049. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  55050. */
  55051. penumbraDarkness: number;
  55052. private _numCascades;
  55053. /**
  55054. * Gets or set the number of cascades used by the CSM.
  55055. */
  55056. get numCascades(): number;
  55057. set numCascades(value: number);
  55058. /**
  55059. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  55060. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  55061. */
  55062. stabilizeCascades: boolean;
  55063. private _freezeShadowCastersBoundingInfo;
  55064. private _freezeShadowCastersBoundingInfoObservable;
  55065. /**
  55066. * Enables or disables the shadow casters bounding info computation.
  55067. * If your shadow casters don't move, you can disable this feature.
  55068. * If it is enabled, the bounding box computation is done every frame.
  55069. */
  55070. get freezeShadowCastersBoundingInfo(): boolean;
  55071. set freezeShadowCastersBoundingInfo(freeze: boolean);
  55072. private _scbiMin;
  55073. private _scbiMax;
  55074. protected _computeShadowCastersBoundingInfo(): void;
  55075. protected _shadowCastersBoundingInfo: BoundingInfo;
  55076. /**
  55077. * Gets or sets the shadow casters bounding info.
  55078. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  55079. * so that the system won't overwrite the bounds you provide
  55080. */
  55081. get shadowCastersBoundingInfo(): BoundingInfo;
  55082. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  55083. protected _breaksAreDirty: boolean;
  55084. protected _minDistance: number;
  55085. protected _maxDistance: number;
  55086. /**
  55087. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  55088. *
  55089. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  55090. * If you don't know these values, simply leave them to their defaults and don't call this function.
  55091. * @param min minimal distance for the breaks (default to 0.)
  55092. * @param max maximal distance for the breaks (default to 1.)
  55093. */
  55094. setMinMaxDistance(min: number, max: number): void;
  55095. /** Gets the minimal distance used in the cascade break computation */
  55096. get minDistance(): number;
  55097. /** Gets the maximal distance used in the cascade break computation */
  55098. get maxDistance(): number;
  55099. /**
  55100. * Gets the class name of that object
  55101. * @returns "CascadedShadowGenerator"
  55102. */
  55103. getClassName(): string;
  55104. private _cascadeMinExtents;
  55105. private _cascadeMaxExtents;
  55106. /**
  55107. * Gets a cascade minimum extents
  55108. * @param cascadeIndex index of the cascade
  55109. * @returns the minimum cascade extents
  55110. */
  55111. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  55112. /**
  55113. * Gets a cascade maximum extents
  55114. * @param cascadeIndex index of the cascade
  55115. * @returns the maximum cascade extents
  55116. */
  55117. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55118. private _cascades;
  55119. private _currentLayer;
  55120. private _viewSpaceFrustumsZ;
  55121. private _viewMatrices;
  55122. private _projectionMatrices;
  55123. private _transformMatrices;
  55124. private _transformMatricesAsArray;
  55125. private _frustumLengths;
  55126. private _lightSizeUVCorrection;
  55127. private _depthCorrection;
  55128. private _frustumCornersWorldSpace;
  55129. private _frustumCenter;
  55130. private _shadowCameraPos;
  55131. private _shadowMaxZ;
  55132. /**
  55133. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55134. * It defaults to camera.maxZ
  55135. */
  55136. get shadowMaxZ(): number;
  55137. /**
  55138. * Sets the shadow max z distance.
  55139. */
  55140. set shadowMaxZ(value: number);
  55141. protected _debug: boolean;
  55142. /**
  55143. * Gets or sets the debug flag.
  55144. * When enabled, the cascades are materialized by different colors on the screen.
  55145. */
  55146. get debug(): boolean;
  55147. set debug(dbg: boolean);
  55148. private _depthClamp;
  55149. /**
  55150. * Gets or sets the depth clamping value.
  55151. *
  55152. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55153. * to account for the shadow casters far away.
  55154. *
  55155. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55156. */
  55157. get depthClamp(): boolean;
  55158. set depthClamp(value: boolean);
  55159. private _cascadeBlendPercentage;
  55160. /**
  55161. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55162. * It defaults to 0.1 (10% blending).
  55163. */
  55164. get cascadeBlendPercentage(): number;
  55165. set cascadeBlendPercentage(value: number);
  55166. private _lambda;
  55167. /**
  55168. * Gets or set the lambda parameter.
  55169. * This parameter is used to split the camera frustum and create the cascades.
  55170. * 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.
  55171. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55172. */
  55173. get lambda(): number;
  55174. set lambda(value: number);
  55175. /**
  55176. * Gets the view matrix corresponding to a given cascade
  55177. * @param cascadeNum cascade to retrieve the view matrix from
  55178. * @returns the cascade view matrix
  55179. */
  55180. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55181. /**
  55182. * Gets the projection matrix corresponding to a given cascade
  55183. * @param cascadeNum cascade to retrieve the projection matrix from
  55184. * @returns the cascade projection matrix
  55185. */
  55186. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55187. /**
  55188. * Gets the transformation matrix corresponding to a given cascade
  55189. * @param cascadeNum cascade to retrieve the transformation matrix from
  55190. * @returns the cascade transformation matrix
  55191. */
  55192. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55193. private _depthRenderer;
  55194. /**
  55195. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55196. *
  55197. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55198. *
  55199. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55200. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55201. * @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
  55202. */
  55203. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55204. private _depthReducer;
  55205. private _autoCalcDepthBounds;
  55206. /**
  55207. * Gets or sets the autoCalcDepthBounds property.
  55208. *
  55209. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55210. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55211. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55212. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55213. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55214. */
  55215. get autoCalcDepthBounds(): boolean;
  55216. set autoCalcDepthBounds(value: boolean);
  55217. /**
  55218. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55219. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55220. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55221. * for setting the refresh rate on the renderer yourself!
  55222. */
  55223. get autoCalcDepthBoundsRefreshRate(): number;
  55224. set autoCalcDepthBoundsRefreshRate(value: number);
  55225. /**
  55226. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55227. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55228. * you change the camera near/far planes!
  55229. */
  55230. splitFrustum(): void;
  55231. private _splitFrustum;
  55232. private _computeMatrices;
  55233. private _computeFrustumInWorldSpace;
  55234. private _computeCascadeFrustum;
  55235. /**
  55236. * Support test.
  55237. */
  55238. static get IsSupported(): boolean;
  55239. /** @hidden */
  55240. static _SceneComponentInitialization: (scene: Scene) => void;
  55241. /**
  55242. * Creates a Cascaded Shadow Generator object.
  55243. * A ShadowGenerator is the required tool to use the shadows.
  55244. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55245. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55246. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55247. * @param light The directional light object generating the shadows.
  55248. * @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.
  55249. */
  55250. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55251. protected _initializeGenerator(): void;
  55252. protected _createTargetRenderTexture(): void;
  55253. protected _initializeShadowMap(): void;
  55254. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55255. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55256. /**
  55257. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55258. * @param defines Defines of the material we want to update
  55259. * @param lightIndex Index of the light in the enabled light list of the material
  55260. */
  55261. prepareDefines(defines: any, lightIndex: number): void;
  55262. /**
  55263. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55264. * defined in the generator but impacting the effect).
  55265. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55266. * @param effect The effect we are binfing the information for
  55267. */
  55268. bindShadowLight(lightIndex: string, effect: Effect): void;
  55269. /**
  55270. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55271. * (eq to view projection * shadow projection matrices)
  55272. * @returns The transform matrix used to create the shadow map
  55273. */
  55274. getTransformMatrix(): Matrix;
  55275. /**
  55276. * Disposes the ShadowGenerator.
  55277. * Returns nothing.
  55278. */
  55279. dispose(): void;
  55280. /**
  55281. * Serializes the shadow generator setup to a json object.
  55282. * @returns The serialized JSON object
  55283. */
  55284. serialize(): any;
  55285. /**
  55286. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55287. * @param parsedShadowGenerator The JSON object to parse
  55288. * @param scene The scene to create the shadow map for
  55289. * @returns The parsed shadow generator
  55290. */
  55291. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55292. }
  55293. }
  55294. declare module BABYLON {
  55295. /**
  55296. * Defines the shadow generator component responsible to manage any shadow generators
  55297. * in a given scene.
  55298. */
  55299. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55300. /**
  55301. * The component name helpfull to identify the component in the list of scene components.
  55302. */
  55303. readonly name: string;
  55304. /**
  55305. * The scene the component belongs to.
  55306. */
  55307. scene: Scene;
  55308. /**
  55309. * Creates a new instance of the component for the given scene
  55310. * @param scene Defines the scene to register the component in
  55311. */
  55312. constructor(scene: Scene);
  55313. /**
  55314. * Registers the component in a given scene
  55315. */
  55316. register(): void;
  55317. /**
  55318. * Rebuilds the elements related to this component in case of
  55319. * context lost for instance.
  55320. */
  55321. rebuild(): void;
  55322. /**
  55323. * Serializes the component data to the specified json object
  55324. * @param serializationObject The object to serialize to
  55325. */
  55326. serialize(serializationObject: any): void;
  55327. /**
  55328. * Adds all the elements from the container to the scene
  55329. * @param container the container holding the elements
  55330. */
  55331. addFromContainer(container: AbstractScene): void;
  55332. /**
  55333. * Removes all the elements in the container from the scene
  55334. * @param container contains the elements to remove
  55335. * @param dispose if the removed element should be disposed (default: false)
  55336. */
  55337. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55338. /**
  55339. * Rebuilds the elements related to this component in case of
  55340. * context lost for instance.
  55341. */
  55342. dispose(): void;
  55343. private _gatherRenderTargets;
  55344. }
  55345. }
  55346. declare module BABYLON {
  55347. /**
  55348. * A point light is a light defined by an unique point in world space.
  55349. * The light is emitted in every direction from this point.
  55350. * A good example of a point light is a standard light bulb.
  55351. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55352. */
  55353. export class PointLight extends ShadowLight {
  55354. private _shadowAngle;
  55355. /**
  55356. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55357. * This specifies what angle the shadow will use to be created.
  55358. *
  55359. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55360. */
  55361. get shadowAngle(): number;
  55362. /**
  55363. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55364. * This specifies what angle the shadow will use to be created.
  55365. *
  55366. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55367. */
  55368. set shadowAngle(value: number);
  55369. /**
  55370. * Gets the direction if it has been set.
  55371. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55372. */
  55373. get direction(): Vector3;
  55374. /**
  55375. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55376. */
  55377. set direction(value: Vector3);
  55378. /**
  55379. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55380. * A PointLight emits the light in every direction.
  55381. * It can cast shadows.
  55382. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55383. * ```javascript
  55384. * var pointLight = new PointLight("pl", camera.position, scene);
  55385. * ```
  55386. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55387. * @param name The light friendly name
  55388. * @param position The position of the point light in the scene
  55389. * @param scene The scene the lights belongs to
  55390. */
  55391. constructor(name: string, position: Vector3, scene: Scene);
  55392. /**
  55393. * Returns the string "PointLight"
  55394. * @returns the class name
  55395. */
  55396. getClassName(): string;
  55397. /**
  55398. * Returns the integer 0.
  55399. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55400. */
  55401. getTypeID(): number;
  55402. /**
  55403. * Specifies wether or not the shadowmap should be a cube texture.
  55404. * @returns true if the shadowmap needs to be a cube texture.
  55405. */
  55406. needCube(): boolean;
  55407. /**
  55408. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55409. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55410. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55411. */
  55412. getShadowDirection(faceIndex?: number): Vector3;
  55413. /**
  55414. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55415. * - fov = PI / 2
  55416. * - aspect ratio : 1.0
  55417. * - z-near and far equal to the active camera minZ and maxZ.
  55418. * Returns the PointLight.
  55419. */
  55420. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55421. protected _buildUniformLayout(): void;
  55422. /**
  55423. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55424. * @param effect The effect to update
  55425. * @param lightIndex The index of the light in the effect to update
  55426. * @returns The point light
  55427. */
  55428. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55429. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55430. /**
  55431. * Prepares the list of defines specific to the light type.
  55432. * @param defines the list of defines
  55433. * @param lightIndex defines the index of the light for the effect
  55434. */
  55435. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55436. }
  55437. }
  55438. declare module BABYLON {
  55439. /**
  55440. * Header information of HDR texture files.
  55441. */
  55442. export interface HDRInfo {
  55443. /**
  55444. * The height of the texture in pixels.
  55445. */
  55446. height: number;
  55447. /**
  55448. * The width of the texture in pixels.
  55449. */
  55450. width: number;
  55451. /**
  55452. * The index of the beginning of the data in the binary file.
  55453. */
  55454. dataPosition: number;
  55455. }
  55456. /**
  55457. * This groups tools to convert HDR texture to native colors array.
  55458. */
  55459. export class HDRTools {
  55460. private static Ldexp;
  55461. private static Rgbe2float;
  55462. private static readStringLine;
  55463. /**
  55464. * Reads header information from an RGBE texture stored in a native array.
  55465. * More information on this format are available here:
  55466. * https://en.wikipedia.org/wiki/RGBE_image_format
  55467. *
  55468. * @param uint8array The binary file stored in native array.
  55469. * @return The header information.
  55470. */
  55471. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55472. /**
  55473. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55474. * This RGBE texture needs to store the information as a panorama.
  55475. *
  55476. * More information on this format are available here:
  55477. * https://en.wikipedia.org/wiki/RGBE_image_format
  55478. *
  55479. * @param buffer The binary file stored in an array buffer.
  55480. * @param size The expected size of the extracted cubemap.
  55481. * @return The Cube Map information.
  55482. */
  55483. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55484. /**
  55485. * Returns the pixels data extracted from an RGBE texture.
  55486. * This pixels will be stored left to right up to down in the R G B order in one array.
  55487. *
  55488. * More information on this format are available here:
  55489. * https://en.wikipedia.org/wiki/RGBE_image_format
  55490. *
  55491. * @param uint8array The binary file stored in an array buffer.
  55492. * @param hdrInfo The header information of the file.
  55493. * @return The pixels data in RGB right to left up to down order.
  55494. */
  55495. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55496. private static RGBE_ReadPixels_RLE;
  55497. }
  55498. }
  55499. declare module BABYLON {
  55500. /**
  55501. * This represents a texture coming from an HDR input.
  55502. *
  55503. * The only supported format is currently panorama picture stored in RGBE format.
  55504. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55505. */
  55506. export class HDRCubeTexture extends BaseTexture {
  55507. private static _facesMapping;
  55508. private _generateHarmonics;
  55509. private _noMipmap;
  55510. private _textureMatrix;
  55511. private _size;
  55512. private _onLoad;
  55513. private _onError;
  55514. private _engine;
  55515. /**
  55516. * The texture URL.
  55517. */
  55518. url: string;
  55519. /**
  55520. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55521. */
  55522. coordinatesMode: number;
  55523. protected _isBlocking: boolean;
  55524. /**
  55525. * Sets wether or not the texture is blocking during loading.
  55526. */
  55527. set isBlocking(value: boolean);
  55528. /**
  55529. * Gets wether or not the texture is blocking during loading.
  55530. */
  55531. get isBlocking(): boolean;
  55532. protected _rotationY: number;
  55533. /**
  55534. * Sets texture matrix rotation angle around Y axis in radians.
  55535. */
  55536. set rotationY(value: number);
  55537. /**
  55538. * Gets texture matrix rotation angle around Y axis radians.
  55539. */
  55540. get rotationY(): number;
  55541. /**
  55542. * Gets or sets the center of the bounding box associated with the cube texture
  55543. * It must define where the camera used to render the texture was set
  55544. */
  55545. boundingBoxPosition: Vector3;
  55546. private _boundingBoxSize;
  55547. /**
  55548. * Gets or sets the size of the bounding box associated with the cube texture
  55549. * When defined, the cubemap will switch to local mode
  55550. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55551. * @example https://www.babylonjs-playground.com/#RNASML
  55552. */
  55553. set boundingBoxSize(value: Vector3);
  55554. get boundingBoxSize(): Vector3;
  55555. /**
  55556. * Instantiates an HDRTexture from the following parameters.
  55557. *
  55558. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55559. * @param scene The scene the texture will be used in
  55560. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55561. * @param noMipmap Forces to not generate the mipmap if true
  55562. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55563. * @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)
  55564. * @param reserved Reserved flag for internal use.
  55565. */
  55566. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55567. /**
  55568. * Get the current class name of the texture useful for serialization or dynamic coding.
  55569. * @returns "HDRCubeTexture"
  55570. */
  55571. getClassName(): string;
  55572. /**
  55573. * Occurs when the file is raw .hdr file.
  55574. */
  55575. private loadTexture;
  55576. clone(): HDRCubeTexture;
  55577. delayLoad(): void;
  55578. /**
  55579. * Get the texture reflection matrix used to rotate/transform the reflection.
  55580. * @returns the reflection matrix
  55581. */
  55582. getReflectionTextureMatrix(): Matrix;
  55583. /**
  55584. * Set the texture reflection matrix used to rotate/transform the reflection.
  55585. * @param value Define the reflection matrix to set
  55586. */
  55587. setReflectionTextureMatrix(value: Matrix): void;
  55588. /**
  55589. * Parses a JSON representation of an HDR Texture in order to create the texture
  55590. * @param parsedTexture Define the JSON representation
  55591. * @param scene Define the scene the texture should be created in
  55592. * @param rootUrl Define the root url in case we need to load relative dependencies
  55593. * @returns the newly created texture after parsing
  55594. */
  55595. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55596. serialize(): any;
  55597. private static _isScene;
  55598. }
  55599. }
  55600. declare module BABYLON {
  55601. /**
  55602. * Class used to control physics engine
  55603. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55604. */
  55605. export class PhysicsEngine implements IPhysicsEngine {
  55606. private _physicsPlugin;
  55607. /**
  55608. * Global value used to control the smallest number supported by the simulation
  55609. */
  55610. static Epsilon: number;
  55611. private _impostors;
  55612. private _joints;
  55613. private _subTimeStep;
  55614. /**
  55615. * Gets the gravity vector used by the simulation
  55616. */
  55617. gravity: Vector3;
  55618. /**
  55619. * Factory used to create the default physics plugin.
  55620. * @returns The default physics plugin
  55621. */
  55622. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55623. /**
  55624. * Creates a new Physics Engine
  55625. * @param gravity defines the gravity vector used by the simulation
  55626. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55627. */
  55628. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55629. /**
  55630. * Sets the gravity vector used by the simulation
  55631. * @param gravity defines the gravity vector to use
  55632. */
  55633. setGravity(gravity: Vector3): void;
  55634. /**
  55635. * Set the time step of the physics engine.
  55636. * Default is 1/60.
  55637. * To slow it down, enter 1/600 for example.
  55638. * To speed it up, 1/30
  55639. * @param newTimeStep defines the new timestep to apply to this world.
  55640. */
  55641. setTimeStep(newTimeStep?: number): void;
  55642. /**
  55643. * Get the time step of the physics engine.
  55644. * @returns the current time step
  55645. */
  55646. getTimeStep(): number;
  55647. /**
  55648. * Set the sub time step of the physics engine.
  55649. * Default is 0 meaning there is no sub steps
  55650. * To increase physics resolution precision, set a small value (like 1 ms)
  55651. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55652. */
  55653. setSubTimeStep(subTimeStep?: number): void;
  55654. /**
  55655. * Get the sub time step of the physics engine.
  55656. * @returns the current sub time step
  55657. */
  55658. getSubTimeStep(): number;
  55659. /**
  55660. * Release all resources
  55661. */
  55662. dispose(): void;
  55663. /**
  55664. * Gets the name of the current physics plugin
  55665. * @returns the name of the plugin
  55666. */
  55667. getPhysicsPluginName(): string;
  55668. /**
  55669. * Adding a new impostor for the impostor tracking.
  55670. * This will be done by the impostor itself.
  55671. * @param impostor the impostor to add
  55672. */
  55673. addImpostor(impostor: PhysicsImpostor): void;
  55674. /**
  55675. * Remove an impostor from the engine.
  55676. * This impostor and its mesh will not longer be updated by the physics engine.
  55677. * @param impostor the impostor to remove
  55678. */
  55679. removeImpostor(impostor: PhysicsImpostor): void;
  55680. /**
  55681. * Add a joint to the physics engine
  55682. * @param mainImpostor defines the main impostor to which the joint is added.
  55683. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55684. * @param joint defines the joint that will connect both impostors.
  55685. */
  55686. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55687. /**
  55688. * Removes a joint from the simulation
  55689. * @param mainImpostor defines the impostor used with the joint
  55690. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55691. * @param joint defines the joint to remove
  55692. */
  55693. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55694. /**
  55695. * Called by the scene. No need to call it.
  55696. * @param delta defines the timespam between frames
  55697. */
  55698. _step(delta: number): void;
  55699. /**
  55700. * Gets the current plugin used to run the simulation
  55701. * @returns current plugin
  55702. */
  55703. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55704. /**
  55705. * Gets the list of physic impostors
  55706. * @returns an array of PhysicsImpostor
  55707. */
  55708. getImpostors(): Array<PhysicsImpostor>;
  55709. /**
  55710. * Gets the impostor for a physics enabled object
  55711. * @param object defines the object impersonated by the impostor
  55712. * @returns the PhysicsImpostor or null if not found
  55713. */
  55714. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55715. /**
  55716. * Gets the impostor for a physics body object
  55717. * @param body defines physics body used by the impostor
  55718. * @returns the PhysicsImpostor or null if not found
  55719. */
  55720. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55721. /**
  55722. * Does a raycast in the physics world
  55723. * @param from when should the ray start?
  55724. * @param to when should the ray end?
  55725. * @returns PhysicsRaycastResult
  55726. */
  55727. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55728. }
  55729. }
  55730. declare module BABYLON {
  55731. /** @hidden */
  55732. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55733. private _useDeltaForWorldStep;
  55734. world: any;
  55735. name: string;
  55736. private _physicsMaterials;
  55737. private _fixedTimeStep;
  55738. private _cannonRaycastResult;
  55739. private _raycastResult;
  55740. private _physicsBodysToRemoveAfterStep;
  55741. BJSCANNON: any;
  55742. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55743. setGravity(gravity: Vector3): void;
  55744. setTimeStep(timeStep: number): void;
  55745. getTimeStep(): number;
  55746. executeStep(delta: number): void;
  55747. private _removeMarkedPhysicsBodiesFromWorld;
  55748. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55749. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55750. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55751. private _processChildMeshes;
  55752. removePhysicsBody(impostor: PhysicsImpostor): void;
  55753. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55754. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55755. private _addMaterial;
  55756. private _checkWithEpsilon;
  55757. private _createShape;
  55758. private _createHeightmap;
  55759. private _minus90X;
  55760. private _plus90X;
  55761. private _tmpPosition;
  55762. private _tmpDeltaPosition;
  55763. private _tmpUnityRotation;
  55764. private _updatePhysicsBodyTransformation;
  55765. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55766. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55767. isSupported(): boolean;
  55768. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55769. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55770. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55771. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55772. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55773. getBodyMass(impostor: PhysicsImpostor): number;
  55774. getBodyFriction(impostor: PhysicsImpostor): number;
  55775. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55776. getBodyRestitution(impostor: PhysicsImpostor): number;
  55777. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55778. sleepBody(impostor: PhysicsImpostor): void;
  55779. wakeUpBody(impostor: PhysicsImpostor): void;
  55780. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55781. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55783. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55784. getRadius(impostor: PhysicsImpostor): number;
  55785. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55786. dispose(): void;
  55787. private _extendNamespace;
  55788. /**
  55789. * Does a raycast in the physics world
  55790. * @param from when should the ray start?
  55791. * @param to when should the ray end?
  55792. * @returns PhysicsRaycastResult
  55793. */
  55794. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55795. }
  55796. }
  55797. declare module BABYLON {
  55798. /** @hidden */
  55799. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55800. private _useDeltaForWorldStep;
  55801. world: any;
  55802. name: string;
  55803. BJSOIMO: any;
  55804. private _raycastResult;
  55805. private _fixedTimeStep;
  55806. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55807. setGravity(gravity: Vector3): void;
  55808. setTimeStep(timeStep: number): void;
  55809. getTimeStep(): number;
  55810. private _tmpImpostorsArray;
  55811. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55812. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55813. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55814. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55815. private _tmpPositionVector;
  55816. removePhysicsBody(impostor: PhysicsImpostor): void;
  55817. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55818. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55819. isSupported(): boolean;
  55820. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55821. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55822. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55823. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55826. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55827. getBodyMass(impostor: PhysicsImpostor): number;
  55828. getBodyFriction(impostor: PhysicsImpostor): number;
  55829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55830. getBodyRestitution(impostor: PhysicsImpostor): number;
  55831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55832. sleepBody(impostor: PhysicsImpostor): void;
  55833. wakeUpBody(impostor: PhysicsImpostor): void;
  55834. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55835. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55836. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55837. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55838. getRadius(impostor: PhysicsImpostor): number;
  55839. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55840. dispose(): void;
  55841. /**
  55842. * Does a raycast in the physics world
  55843. * @param from when should the ray start?
  55844. * @param to when should the ray end?
  55845. * @returns PhysicsRaycastResult
  55846. */
  55847. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55848. }
  55849. }
  55850. declare module BABYLON {
  55851. /**
  55852. * Class containing static functions to help procedurally build meshes
  55853. */
  55854. export class RibbonBuilder {
  55855. /**
  55856. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55857. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55858. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55859. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55860. * * 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
  55861. * * 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
  55862. * * 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
  55863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55864. * * 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
  55865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55866. * * 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
  55867. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55868. * * 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
  55869. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55871. * @param name defines the name of the mesh
  55872. * @param options defines the options used to create the mesh
  55873. * @param scene defines the hosting scene
  55874. * @returns the ribbon mesh
  55875. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55877. */
  55878. static CreateRibbon(name: string, options: {
  55879. pathArray: Vector3[][];
  55880. closeArray?: boolean;
  55881. closePath?: boolean;
  55882. offset?: number;
  55883. updatable?: boolean;
  55884. sideOrientation?: number;
  55885. frontUVs?: Vector4;
  55886. backUVs?: Vector4;
  55887. instance?: Mesh;
  55888. invertUV?: boolean;
  55889. uvs?: Vector2[];
  55890. colors?: Color4[];
  55891. }, scene?: Nullable<Scene>): Mesh;
  55892. }
  55893. }
  55894. declare module BABYLON {
  55895. /**
  55896. * Class containing static functions to help procedurally build meshes
  55897. */
  55898. export class ShapeBuilder {
  55899. /**
  55900. * 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.
  55901. * * 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.
  55902. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55903. * * 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.
  55904. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55905. * * 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
  55906. * * 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
  55907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55909. * * 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
  55910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55912. * @param name defines the name of the mesh
  55913. * @param options defines the options used to create the mesh
  55914. * @param scene defines the hosting scene
  55915. * @returns the extruded shape mesh
  55916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55918. */
  55919. static ExtrudeShape(name: string, options: {
  55920. shape: Vector3[];
  55921. path: Vector3[];
  55922. scale?: number;
  55923. rotation?: number;
  55924. cap?: number;
  55925. updatable?: boolean;
  55926. sideOrientation?: number;
  55927. frontUVs?: Vector4;
  55928. backUVs?: Vector4;
  55929. instance?: Mesh;
  55930. invertUV?: boolean;
  55931. }, scene?: Nullable<Scene>): Mesh;
  55932. /**
  55933. * Creates an custom extruded shape mesh.
  55934. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55935. * * 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.
  55936. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55937. * * 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
  55938. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55939. * * 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
  55940. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55941. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55942. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55943. * * 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
  55944. * * 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
  55945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55947. * * 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
  55948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55950. * @param name defines the name of the mesh
  55951. * @param options defines the options used to create the mesh
  55952. * @param scene defines the hosting scene
  55953. * @returns the custom extruded shape mesh
  55954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55957. */
  55958. static ExtrudeShapeCustom(name: string, options: {
  55959. shape: Vector3[];
  55960. path: Vector3[];
  55961. scaleFunction?: any;
  55962. rotationFunction?: any;
  55963. ribbonCloseArray?: boolean;
  55964. ribbonClosePath?: boolean;
  55965. cap?: number;
  55966. updatable?: boolean;
  55967. sideOrientation?: number;
  55968. frontUVs?: Vector4;
  55969. backUVs?: Vector4;
  55970. instance?: Mesh;
  55971. invertUV?: boolean;
  55972. }, scene?: Nullable<Scene>): Mesh;
  55973. private static _ExtrudeShapeGeneric;
  55974. }
  55975. }
  55976. declare module BABYLON {
  55977. /**
  55978. * AmmoJS Physics plugin
  55979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55980. * @see https://github.com/kripken/ammo.js/
  55981. */
  55982. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55983. private _useDeltaForWorldStep;
  55984. /**
  55985. * Reference to the Ammo library
  55986. */
  55987. bjsAMMO: any;
  55988. /**
  55989. * Created ammoJS world which physics bodies are added to
  55990. */
  55991. world: any;
  55992. /**
  55993. * Name of the plugin
  55994. */
  55995. name: string;
  55996. private _timeStep;
  55997. private _fixedTimeStep;
  55998. private _maxSteps;
  55999. private _tmpQuaternion;
  56000. private _tmpAmmoTransform;
  56001. private _tmpAmmoQuaternion;
  56002. private _tmpAmmoConcreteContactResultCallback;
  56003. private _collisionConfiguration;
  56004. private _dispatcher;
  56005. private _overlappingPairCache;
  56006. private _solver;
  56007. private _softBodySolver;
  56008. private _tmpAmmoVectorA;
  56009. private _tmpAmmoVectorB;
  56010. private _tmpAmmoVectorC;
  56011. private _tmpAmmoVectorD;
  56012. private _tmpContactCallbackResult;
  56013. private _tmpAmmoVectorRCA;
  56014. private _tmpAmmoVectorRCB;
  56015. private _raycastResult;
  56016. private static readonly DISABLE_COLLISION_FLAG;
  56017. private static readonly KINEMATIC_FLAG;
  56018. private static readonly DISABLE_DEACTIVATION_FLAG;
  56019. /**
  56020. * Initializes the ammoJS plugin
  56021. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56022. * @param ammoInjection can be used to inject your own ammo reference
  56023. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56024. */
  56025. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56026. /**
  56027. * Sets the gravity of the physics world (m/(s^2))
  56028. * @param gravity Gravity to set
  56029. */
  56030. setGravity(gravity: Vector3): void;
  56031. /**
  56032. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56033. * @param timeStep timestep to use in seconds
  56034. */
  56035. setTimeStep(timeStep: number): void;
  56036. /**
  56037. * 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)
  56038. * @param fixedTimeStep fixedTimeStep to use in seconds
  56039. */
  56040. setFixedTimeStep(fixedTimeStep: number): void;
  56041. /**
  56042. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56043. * @param maxSteps the maximum number of steps by the physics engine per frame
  56044. */
  56045. setMaxSteps(maxSteps: number): void;
  56046. /**
  56047. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56048. * @returns the current timestep in seconds
  56049. */
  56050. getTimeStep(): number;
  56051. /**
  56052. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56053. */
  56054. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56055. private _isImpostorInContact;
  56056. private _isImpostorPairInContact;
  56057. private _stepSimulation;
  56058. /**
  56059. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56060. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56061. * After the step the babylon meshes are set to the position of the physics imposters
  56062. * @param delta amount of time to step forward
  56063. * @param impostors array of imposters to update before/after the step
  56064. */
  56065. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56066. /**
  56067. * Update babylon mesh to match physics world object
  56068. * @param impostor imposter to match
  56069. */
  56070. private _afterSoftStep;
  56071. /**
  56072. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56073. * @param impostor imposter to match
  56074. */
  56075. private _ropeStep;
  56076. /**
  56077. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56078. * @param impostor imposter to match
  56079. */
  56080. private _softbodyOrClothStep;
  56081. private _tmpMatrix;
  56082. /**
  56083. * Applies an impulse on the imposter
  56084. * @param impostor imposter to apply impulse to
  56085. * @param force amount of force to be applied to the imposter
  56086. * @param contactPoint the location to apply the impulse on the imposter
  56087. */
  56088. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56089. /**
  56090. * Applies a force on the imposter
  56091. * @param impostor imposter to apply force
  56092. * @param force amount of force to be applied to the imposter
  56093. * @param contactPoint the location to apply the force on the imposter
  56094. */
  56095. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56096. /**
  56097. * Creates a physics body using the plugin
  56098. * @param impostor the imposter to create the physics body on
  56099. */
  56100. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56101. /**
  56102. * Removes the physics body from the imposter and disposes of the body's memory
  56103. * @param impostor imposter to remove the physics body from
  56104. */
  56105. removePhysicsBody(impostor: PhysicsImpostor): void;
  56106. /**
  56107. * Generates a joint
  56108. * @param impostorJoint the imposter joint to create the joint with
  56109. */
  56110. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56111. /**
  56112. * Removes a joint
  56113. * @param impostorJoint the imposter joint to remove the joint from
  56114. */
  56115. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56116. private _addMeshVerts;
  56117. /**
  56118. * Initialise the soft body vertices to match its object's (mesh) vertices
  56119. * Softbody vertices (nodes) are in world space and to match this
  56120. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56121. * @param impostor to create the softbody for
  56122. */
  56123. private _softVertexData;
  56124. /**
  56125. * Create an impostor's soft body
  56126. * @param impostor to create the softbody for
  56127. */
  56128. private _createSoftbody;
  56129. /**
  56130. * Create cloth for an impostor
  56131. * @param impostor to create the softbody for
  56132. */
  56133. private _createCloth;
  56134. /**
  56135. * Create rope for an impostor
  56136. * @param impostor to create the softbody for
  56137. */
  56138. private _createRope;
  56139. /**
  56140. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56141. * @param impostor to create the custom physics shape for
  56142. */
  56143. private _createCustom;
  56144. private _addHullVerts;
  56145. private _createShape;
  56146. /**
  56147. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56148. * @param impostor imposter containing the physics body and babylon object
  56149. */
  56150. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56151. /**
  56152. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56153. * @param impostor imposter containing the physics body and babylon object
  56154. * @param newPosition new position
  56155. * @param newRotation new rotation
  56156. */
  56157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56158. /**
  56159. * If this plugin is supported
  56160. * @returns true if its supported
  56161. */
  56162. isSupported(): boolean;
  56163. /**
  56164. * Sets the linear velocity of the physics body
  56165. * @param impostor imposter to set the velocity on
  56166. * @param velocity velocity to set
  56167. */
  56168. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56169. /**
  56170. * Sets the angular velocity of the physics body
  56171. * @param impostor imposter to set the velocity on
  56172. * @param velocity velocity to set
  56173. */
  56174. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56175. /**
  56176. * gets the linear velocity
  56177. * @param impostor imposter to get linear velocity from
  56178. * @returns linear velocity
  56179. */
  56180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56181. /**
  56182. * gets the angular velocity
  56183. * @param impostor imposter to get angular velocity from
  56184. * @returns angular velocity
  56185. */
  56186. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56187. /**
  56188. * Sets the mass of physics body
  56189. * @param impostor imposter to set the mass on
  56190. * @param mass mass to set
  56191. */
  56192. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56193. /**
  56194. * Gets the mass of the physics body
  56195. * @param impostor imposter to get the mass from
  56196. * @returns mass
  56197. */
  56198. getBodyMass(impostor: PhysicsImpostor): number;
  56199. /**
  56200. * Gets friction of the impostor
  56201. * @param impostor impostor to get friction from
  56202. * @returns friction value
  56203. */
  56204. getBodyFriction(impostor: PhysicsImpostor): number;
  56205. /**
  56206. * Sets friction of the impostor
  56207. * @param impostor impostor to set friction on
  56208. * @param friction friction value
  56209. */
  56210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56211. /**
  56212. * Gets restitution of the impostor
  56213. * @param impostor impostor to get restitution from
  56214. * @returns restitution value
  56215. */
  56216. getBodyRestitution(impostor: PhysicsImpostor): number;
  56217. /**
  56218. * Sets resitution of the impostor
  56219. * @param impostor impostor to set resitution on
  56220. * @param restitution resitution value
  56221. */
  56222. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56223. /**
  56224. * Gets pressure inside the impostor
  56225. * @param impostor impostor to get pressure from
  56226. * @returns pressure value
  56227. */
  56228. getBodyPressure(impostor: PhysicsImpostor): number;
  56229. /**
  56230. * Sets pressure inside a soft body impostor
  56231. * Cloth and rope must remain 0 pressure
  56232. * @param impostor impostor to set pressure on
  56233. * @param pressure pressure value
  56234. */
  56235. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56236. /**
  56237. * Gets stiffness of the impostor
  56238. * @param impostor impostor to get stiffness from
  56239. * @returns pressure value
  56240. */
  56241. getBodyStiffness(impostor: PhysicsImpostor): number;
  56242. /**
  56243. * Sets stiffness of the impostor
  56244. * @param impostor impostor to set stiffness on
  56245. * @param stiffness stiffness value from 0 to 1
  56246. */
  56247. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56248. /**
  56249. * Gets velocityIterations of the impostor
  56250. * @param impostor impostor to get velocity iterations from
  56251. * @returns velocityIterations value
  56252. */
  56253. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56254. /**
  56255. * Sets velocityIterations of the impostor
  56256. * @param impostor impostor to set velocity iterations on
  56257. * @param velocityIterations velocityIterations value
  56258. */
  56259. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56260. /**
  56261. * Gets positionIterations of the impostor
  56262. * @param impostor impostor to get position iterations from
  56263. * @returns positionIterations value
  56264. */
  56265. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56266. /**
  56267. * Sets positionIterations of the impostor
  56268. * @param impostor impostor to set position on
  56269. * @param positionIterations positionIterations value
  56270. */
  56271. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56272. /**
  56273. * Append an anchor to a cloth object
  56274. * @param impostor is the cloth impostor to add anchor to
  56275. * @param otherImpostor is the rigid impostor to anchor to
  56276. * @param width ratio across width from 0 to 1
  56277. * @param height ratio up height from 0 to 1
  56278. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56279. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56280. */
  56281. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56282. /**
  56283. * Append an hook to a rope object
  56284. * @param impostor is the rope impostor to add hook to
  56285. * @param otherImpostor is the rigid impostor to hook to
  56286. * @param length ratio along the rope from 0 to 1
  56287. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56288. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56289. */
  56290. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56291. /**
  56292. * Sleeps the physics body and stops it from being active
  56293. * @param impostor impostor to sleep
  56294. */
  56295. sleepBody(impostor: PhysicsImpostor): void;
  56296. /**
  56297. * Activates the physics body
  56298. * @param impostor impostor to activate
  56299. */
  56300. wakeUpBody(impostor: PhysicsImpostor): void;
  56301. /**
  56302. * Updates the distance parameters of the joint
  56303. * @param joint joint to update
  56304. * @param maxDistance maximum distance of the joint
  56305. * @param minDistance minimum distance of the joint
  56306. */
  56307. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56308. /**
  56309. * Sets a motor on the joint
  56310. * @param joint joint to set motor on
  56311. * @param speed speed of the motor
  56312. * @param maxForce maximum force of the motor
  56313. * @param motorIndex index of the motor
  56314. */
  56315. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56316. /**
  56317. * Sets the motors limit
  56318. * @param joint joint to set limit on
  56319. * @param upperLimit upper limit
  56320. * @param lowerLimit lower limit
  56321. */
  56322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56323. /**
  56324. * Syncs the position and rotation of a mesh with the impostor
  56325. * @param mesh mesh to sync
  56326. * @param impostor impostor to update the mesh with
  56327. */
  56328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56329. /**
  56330. * Gets the radius of the impostor
  56331. * @param impostor impostor to get radius from
  56332. * @returns the radius
  56333. */
  56334. getRadius(impostor: PhysicsImpostor): number;
  56335. /**
  56336. * Gets the box size of the impostor
  56337. * @param impostor impostor to get box size from
  56338. * @param result the resulting box size
  56339. */
  56340. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56341. /**
  56342. * Disposes of the impostor
  56343. */
  56344. dispose(): void;
  56345. /**
  56346. * Does a raycast in the physics world
  56347. * @param from when should the ray start?
  56348. * @param to when should the ray end?
  56349. * @returns PhysicsRaycastResult
  56350. */
  56351. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56352. }
  56353. }
  56354. declare module BABYLON {
  56355. interface AbstractScene {
  56356. /**
  56357. * The list of reflection probes added to the scene
  56358. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56359. */
  56360. reflectionProbes: Array<ReflectionProbe>;
  56361. /**
  56362. * Removes the given reflection probe from this scene.
  56363. * @param toRemove The reflection probe to remove
  56364. * @returns The index of the removed reflection probe
  56365. */
  56366. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56367. /**
  56368. * Adds the given reflection probe to this scene.
  56369. * @param newReflectionProbe The reflection probe to add
  56370. */
  56371. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56372. }
  56373. /**
  56374. * Class used to generate realtime reflection / refraction cube textures
  56375. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56376. */
  56377. export class ReflectionProbe {
  56378. /** defines the name of the probe */
  56379. name: string;
  56380. private _scene;
  56381. private _renderTargetTexture;
  56382. private _projectionMatrix;
  56383. private _viewMatrix;
  56384. private _target;
  56385. private _add;
  56386. private _attachedMesh;
  56387. private _invertYAxis;
  56388. /** Gets or sets probe position (center of the cube map) */
  56389. position: Vector3;
  56390. /**
  56391. * Creates a new reflection probe
  56392. * @param name defines the name of the probe
  56393. * @param size defines the texture resolution (for each face)
  56394. * @param scene defines the hosting scene
  56395. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56396. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56397. */
  56398. constructor(
  56399. /** defines the name of the probe */
  56400. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56401. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56402. get samples(): number;
  56403. set samples(value: number);
  56404. /** Gets or sets the refresh rate to use (on every frame by default) */
  56405. get refreshRate(): number;
  56406. set refreshRate(value: number);
  56407. /**
  56408. * Gets the hosting scene
  56409. * @returns a Scene
  56410. */
  56411. getScene(): Scene;
  56412. /** Gets the internal CubeTexture used to render to */
  56413. get cubeTexture(): RenderTargetTexture;
  56414. /** Gets the list of meshes to render */
  56415. get renderList(): Nullable<AbstractMesh[]>;
  56416. /**
  56417. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56418. * @param mesh defines the mesh to attach to
  56419. */
  56420. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56421. /**
  56422. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56423. * @param renderingGroupId The rendering group id corresponding to its index
  56424. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56425. */
  56426. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56427. /**
  56428. * Clean all associated resources
  56429. */
  56430. dispose(): void;
  56431. /**
  56432. * Converts the reflection probe information to a readable string for debug purpose.
  56433. * @param fullDetails Supports for multiple levels of logging within scene loading
  56434. * @returns the human readable reflection probe info
  56435. */
  56436. toString(fullDetails?: boolean): string;
  56437. /**
  56438. * Get the class name of the relfection probe.
  56439. * @returns "ReflectionProbe"
  56440. */
  56441. getClassName(): string;
  56442. /**
  56443. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56444. * @returns The JSON representation of the texture
  56445. */
  56446. serialize(): any;
  56447. /**
  56448. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56449. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56450. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56451. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56452. * @returns The parsed reflection probe if successful
  56453. */
  56454. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56455. }
  56456. }
  56457. declare module BABYLON {
  56458. /** @hidden */
  56459. export var _BabylonLoaderRegistered: boolean;
  56460. /**
  56461. * Helps setting up some configuration for the babylon file loader.
  56462. */
  56463. export class BabylonFileLoaderConfiguration {
  56464. /**
  56465. * The loader does not allow injecting custom physix engine into the plugins.
  56466. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56467. * So you could set this variable to your engine import to make it work.
  56468. */
  56469. static LoaderInjectedPhysicsEngine: any;
  56470. }
  56471. }
  56472. declare module BABYLON {
  56473. /**
  56474. * The Physically based simple base material of BJS.
  56475. *
  56476. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56477. * It is used as the base class for both the specGloss and metalRough conventions.
  56478. */
  56479. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56480. /**
  56481. * Number of Simultaneous lights allowed on the material.
  56482. */
  56483. maxSimultaneousLights: number;
  56484. /**
  56485. * If sets to true, disables all the lights affecting the material.
  56486. */
  56487. disableLighting: boolean;
  56488. /**
  56489. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56490. */
  56491. environmentTexture: BaseTexture;
  56492. /**
  56493. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56494. */
  56495. invertNormalMapX: boolean;
  56496. /**
  56497. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56498. */
  56499. invertNormalMapY: boolean;
  56500. /**
  56501. * Normal map used in the model.
  56502. */
  56503. normalTexture: BaseTexture;
  56504. /**
  56505. * Emissivie color used to self-illuminate the model.
  56506. */
  56507. emissiveColor: Color3;
  56508. /**
  56509. * Emissivie texture used to self-illuminate the model.
  56510. */
  56511. emissiveTexture: BaseTexture;
  56512. /**
  56513. * Occlusion Channel Strenght.
  56514. */
  56515. occlusionStrength: number;
  56516. /**
  56517. * Occlusion Texture of the material (adding extra occlusion effects).
  56518. */
  56519. occlusionTexture: BaseTexture;
  56520. /**
  56521. * Defines the alpha limits in alpha test mode.
  56522. */
  56523. alphaCutOff: number;
  56524. /**
  56525. * Gets the current double sided mode.
  56526. */
  56527. get doubleSided(): boolean;
  56528. /**
  56529. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56530. */
  56531. set doubleSided(value: boolean);
  56532. /**
  56533. * Stores the pre-calculated light information of a mesh in a texture.
  56534. */
  56535. lightmapTexture: BaseTexture;
  56536. /**
  56537. * If true, the light map contains occlusion information instead of lighting info.
  56538. */
  56539. useLightmapAsShadowmap: boolean;
  56540. /**
  56541. * Instantiates a new PBRMaterial instance.
  56542. *
  56543. * @param name The material name
  56544. * @param scene The scene the material will be use in.
  56545. */
  56546. constructor(name: string, scene: Scene);
  56547. getClassName(): string;
  56548. }
  56549. }
  56550. declare module BABYLON {
  56551. /**
  56552. * The PBR material of BJS following the metal roughness convention.
  56553. *
  56554. * This fits to the PBR convention in the GLTF definition:
  56555. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56556. */
  56557. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56558. /**
  56559. * The base color has two different interpretations depending on the value of metalness.
  56560. * When the material is a metal, the base color is the specific measured reflectance value
  56561. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56562. * of the material.
  56563. */
  56564. baseColor: Color3;
  56565. /**
  56566. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56567. * well as opacity information in the alpha channel.
  56568. */
  56569. baseTexture: BaseTexture;
  56570. /**
  56571. * Specifies the metallic scalar value of the material.
  56572. * Can also be used to scale the metalness values of the metallic texture.
  56573. */
  56574. metallic: number;
  56575. /**
  56576. * Specifies the roughness scalar value of the material.
  56577. * Can also be used to scale the roughness values of the metallic texture.
  56578. */
  56579. roughness: number;
  56580. /**
  56581. * Texture containing both the metallic value in the B channel and the
  56582. * roughness value in the G channel to keep better precision.
  56583. */
  56584. metallicRoughnessTexture: BaseTexture;
  56585. /**
  56586. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56587. *
  56588. * @param name The material name
  56589. * @param scene The scene the material will be use in.
  56590. */
  56591. constructor(name: string, scene: Scene);
  56592. /**
  56593. * Return the currrent class name of the material.
  56594. */
  56595. getClassName(): string;
  56596. /**
  56597. * Makes a duplicate of the current material.
  56598. * @param name - name to use for the new material.
  56599. */
  56600. clone(name: string): PBRMetallicRoughnessMaterial;
  56601. /**
  56602. * Serialize the material to a parsable JSON object.
  56603. */
  56604. serialize(): any;
  56605. /**
  56606. * Parses a JSON object correponding to the serialize function.
  56607. */
  56608. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56609. }
  56610. }
  56611. declare module BABYLON {
  56612. /**
  56613. * The PBR material of BJS following the specular glossiness convention.
  56614. *
  56615. * This fits to the PBR convention in the GLTF definition:
  56616. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56617. */
  56618. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56619. /**
  56620. * Specifies the diffuse color of the material.
  56621. */
  56622. diffuseColor: Color3;
  56623. /**
  56624. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56625. * channel.
  56626. */
  56627. diffuseTexture: BaseTexture;
  56628. /**
  56629. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56630. */
  56631. specularColor: Color3;
  56632. /**
  56633. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56634. */
  56635. glossiness: number;
  56636. /**
  56637. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56638. */
  56639. specularGlossinessTexture: BaseTexture;
  56640. /**
  56641. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56642. *
  56643. * @param name The material name
  56644. * @param scene The scene the material will be use in.
  56645. */
  56646. constructor(name: string, scene: Scene);
  56647. /**
  56648. * Return the currrent class name of the material.
  56649. */
  56650. getClassName(): string;
  56651. /**
  56652. * Makes a duplicate of the current material.
  56653. * @param name - name to use for the new material.
  56654. */
  56655. clone(name: string): PBRSpecularGlossinessMaterial;
  56656. /**
  56657. * Serialize the material to a parsable JSON object.
  56658. */
  56659. serialize(): any;
  56660. /**
  56661. * Parses a JSON object correponding to the serialize function.
  56662. */
  56663. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56664. }
  56665. }
  56666. declare module BABYLON {
  56667. /**
  56668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56669. * It can help converting any input color in a desired output one. This can then be used to create effects
  56670. * from sepia, black and white to sixties or futuristic rendering...
  56671. *
  56672. * The only supported format is currently 3dl.
  56673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56674. */
  56675. export class ColorGradingTexture extends BaseTexture {
  56676. /**
  56677. * The texture URL.
  56678. */
  56679. url: string;
  56680. /**
  56681. * Empty line regex stored for GC.
  56682. */
  56683. private static _noneEmptyLineRegex;
  56684. private _textureMatrix;
  56685. private _engine;
  56686. private _onLoad;
  56687. /**
  56688. * Instantiates a ColorGradingTexture from the following parameters.
  56689. *
  56690. * @param url The location of the color gradind data (currently only supporting 3dl)
  56691. * @param sceneOrEngine The scene or engine the texture will be used in
  56692. * @param onLoad defines a callback triggered when the texture has been loaded
  56693. */
  56694. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56695. /**
  56696. * Fires the onload event from the constructor if requested.
  56697. */
  56698. private _triggerOnLoad;
  56699. /**
  56700. * Returns the texture matrix used in most of the material.
  56701. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56702. */
  56703. getTextureMatrix(): Matrix;
  56704. /**
  56705. * Occurs when the file being loaded is a .3dl LUT file.
  56706. */
  56707. private load3dlTexture;
  56708. /**
  56709. * Starts the loading process of the texture.
  56710. */
  56711. private loadTexture;
  56712. /**
  56713. * Clones the color gradind texture.
  56714. */
  56715. clone(): ColorGradingTexture;
  56716. /**
  56717. * Called during delayed load for textures.
  56718. */
  56719. delayLoad(): void;
  56720. /**
  56721. * Parses a color grading texture serialized by Babylon.
  56722. * @param parsedTexture The texture information being parsedTexture
  56723. * @param scene The scene to load the texture in
  56724. * @param rootUrl The root url of the data assets to load
  56725. * @return A color gradind texture
  56726. */
  56727. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56728. /**
  56729. * Serializes the LUT texture to json format.
  56730. */
  56731. serialize(): any;
  56732. /**
  56733. * Returns true if the passed parameter is a scene object (can be use for typings)
  56734. * @param sceneOrEngine The object to test.
  56735. */
  56736. private static _isScene;
  56737. }
  56738. }
  56739. declare module BABYLON {
  56740. /**
  56741. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56742. */
  56743. export class EquiRectangularCubeTexture extends BaseTexture {
  56744. /** The six faces of the cube. */
  56745. private static _FacesMapping;
  56746. private _noMipmap;
  56747. private _onLoad;
  56748. private _onError;
  56749. /** The size of the cubemap. */
  56750. private _size;
  56751. /** The buffer of the image. */
  56752. private _buffer;
  56753. /** The width of the input image. */
  56754. private _width;
  56755. /** The height of the input image. */
  56756. private _height;
  56757. /** The URL to the image. */
  56758. url: string;
  56759. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56760. coordinatesMode: number;
  56761. /**
  56762. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56763. * @param url The location of the image
  56764. * @param scene The scene the texture will be used in
  56765. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56766. * @param noMipmap Forces to not generate the mipmap if true
  56767. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56768. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56769. * @param onLoad — defines a callback called when texture is loaded
  56770. * @param onError — defines a callback called if there is an error
  56771. */
  56772. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56773. /**
  56774. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56775. */
  56776. private loadImage;
  56777. /**
  56778. * Convert the image buffer into a cubemap and create a CubeTexture.
  56779. */
  56780. private loadTexture;
  56781. /**
  56782. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56783. * @param buffer The ArrayBuffer that should be converted.
  56784. * @returns The buffer as Float32Array.
  56785. */
  56786. private getFloat32ArrayFromArrayBuffer;
  56787. /**
  56788. * Get the current class name of the texture useful for serialization or dynamic coding.
  56789. * @returns "EquiRectangularCubeTexture"
  56790. */
  56791. getClassName(): string;
  56792. /**
  56793. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56794. * @returns A clone of the current EquiRectangularCubeTexture.
  56795. */
  56796. clone(): EquiRectangularCubeTexture;
  56797. }
  56798. }
  56799. declare module BABYLON {
  56800. /**
  56801. * Based on jsTGALoader - Javascript loader for TGA file
  56802. * By Vincent Thibault
  56803. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56804. */
  56805. export class TGATools {
  56806. private static _TYPE_INDEXED;
  56807. private static _TYPE_RGB;
  56808. private static _TYPE_GREY;
  56809. private static _TYPE_RLE_INDEXED;
  56810. private static _TYPE_RLE_RGB;
  56811. private static _TYPE_RLE_GREY;
  56812. private static _ORIGIN_MASK;
  56813. private static _ORIGIN_SHIFT;
  56814. private static _ORIGIN_BL;
  56815. private static _ORIGIN_BR;
  56816. private static _ORIGIN_UL;
  56817. private static _ORIGIN_UR;
  56818. /**
  56819. * Gets the header of a TGA file
  56820. * @param data defines the TGA data
  56821. * @returns the header
  56822. */
  56823. static GetTGAHeader(data: Uint8Array): any;
  56824. /**
  56825. * Uploads TGA content to a Babylon Texture
  56826. * @hidden
  56827. */
  56828. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56829. /** @hidden */
  56830. 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;
  56831. /** @hidden */
  56832. 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;
  56833. /** @hidden */
  56834. 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;
  56835. /** @hidden */
  56836. 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;
  56837. /** @hidden */
  56838. 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;
  56839. /** @hidden */
  56840. 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;
  56841. }
  56842. }
  56843. declare module BABYLON {
  56844. /**
  56845. * Implementation of the TGA Texture Loader.
  56846. * @hidden
  56847. */
  56848. export class _TGATextureLoader implements IInternalTextureLoader {
  56849. /**
  56850. * Defines wether the loader supports cascade loading the different faces.
  56851. */
  56852. readonly supportCascades: boolean;
  56853. /**
  56854. * This returns if the loader support the current file information.
  56855. * @param extension defines the file extension of the file being loaded
  56856. * @returns true if the loader can load the specified file
  56857. */
  56858. canLoad(extension: string): boolean;
  56859. /**
  56860. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56861. * @param data contains the texture data
  56862. * @param texture defines the BabylonJS internal texture
  56863. * @param createPolynomials will be true if polynomials have been requested
  56864. * @param onLoad defines the callback to trigger once the texture is ready
  56865. * @param onError defines the callback to trigger in case of error
  56866. */
  56867. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56868. /**
  56869. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56870. * @param data contains the texture data
  56871. * @param texture defines the BabylonJS internal texture
  56872. * @param callback defines the method to call once ready to upload
  56873. */
  56874. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56875. }
  56876. }
  56877. declare module BABYLON {
  56878. /**
  56879. * Info about the .basis files
  56880. */
  56881. class BasisFileInfo {
  56882. /**
  56883. * If the file has alpha
  56884. */
  56885. hasAlpha: boolean;
  56886. /**
  56887. * Info about each image of the basis file
  56888. */
  56889. images: Array<{
  56890. levels: Array<{
  56891. width: number;
  56892. height: number;
  56893. transcodedPixels: ArrayBufferView;
  56894. }>;
  56895. }>;
  56896. }
  56897. /**
  56898. * Result of transcoding a basis file
  56899. */
  56900. class TranscodeResult {
  56901. /**
  56902. * Info about the .basis file
  56903. */
  56904. fileInfo: BasisFileInfo;
  56905. /**
  56906. * Format to use when loading the file
  56907. */
  56908. format: number;
  56909. }
  56910. /**
  56911. * Configuration options for the Basis transcoder
  56912. */
  56913. export class BasisTranscodeConfiguration {
  56914. /**
  56915. * Supported compression formats used to determine the supported output format of the transcoder
  56916. */
  56917. supportedCompressionFormats?: {
  56918. /**
  56919. * etc1 compression format
  56920. */
  56921. etc1?: boolean;
  56922. /**
  56923. * s3tc compression format
  56924. */
  56925. s3tc?: boolean;
  56926. /**
  56927. * pvrtc compression format
  56928. */
  56929. pvrtc?: boolean;
  56930. /**
  56931. * etc2 compression format
  56932. */
  56933. etc2?: boolean;
  56934. };
  56935. /**
  56936. * If mipmap levels should be loaded for transcoded images (Default: true)
  56937. */
  56938. loadMipmapLevels?: boolean;
  56939. /**
  56940. * Index of a single image to load (Default: all images)
  56941. */
  56942. loadSingleImage?: number;
  56943. }
  56944. /**
  56945. * Used to load .Basis files
  56946. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56947. */
  56948. export class BasisTools {
  56949. private static _IgnoreSupportedFormats;
  56950. /**
  56951. * URL to use when loading the basis transcoder
  56952. */
  56953. static JSModuleURL: string;
  56954. /**
  56955. * URL to use when loading the wasm module for the transcoder
  56956. */
  56957. static WasmModuleURL: string;
  56958. /**
  56959. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56960. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56961. * @returns internal format corresponding to the Basis format
  56962. */
  56963. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56964. private static _WorkerPromise;
  56965. private static _Worker;
  56966. private static _actionId;
  56967. private static _CreateWorkerAsync;
  56968. /**
  56969. * Transcodes a loaded image file to compressed pixel data
  56970. * @param data image data to transcode
  56971. * @param config configuration options for the transcoding
  56972. * @returns a promise resulting in the transcoded image
  56973. */
  56974. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56975. /**
  56976. * Loads a texture from the transcode result
  56977. * @param texture texture load to
  56978. * @param transcodeResult the result of transcoding the basis file to load from
  56979. */
  56980. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56981. }
  56982. }
  56983. declare module BABYLON {
  56984. /**
  56985. * Loader for .basis file format
  56986. */
  56987. export class _BasisTextureLoader implements IInternalTextureLoader {
  56988. /**
  56989. * Defines whether the loader supports cascade loading the different faces.
  56990. */
  56991. readonly supportCascades: boolean;
  56992. /**
  56993. * This returns if the loader support the current file information.
  56994. * @param extension defines the file extension of the file being loaded
  56995. * @returns true if the loader can load the specified file
  56996. */
  56997. canLoad(extension: string): boolean;
  56998. /**
  56999. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57000. * @param data contains the texture data
  57001. * @param texture defines the BabylonJS internal texture
  57002. * @param createPolynomials will be true if polynomials have been requested
  57003. * @param onLoad defines the callback to trigger once the texture is ready
  57004. * @param onError defines the callback to trigger in case of error
  57005. */
  57006. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57007. /**
  57008. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57009. * @param data contains the texture data
  57010. * @param texture defines the BabylonJS internal texture
  57011. * @param callback defines the method to call once ready to upload
  57012. */
  57013. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57014. }
  57015. }
  57016. declare module BABYLON {
  57017. /**
  57018. * 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.
  57019. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57020. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57021. */
  57022. export class CustomProceduralTexture extends ProceduralTexture {
  57023. private _animate;
  57024. private _time;
  57025. private _config;
  57026. private _texturePath;
  57027. /**
  57028. * Instantiates a new Custom Procedural Texture.
  57029. * 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.
  57030. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57031. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57032. * @param name Define the name of the texture
  57033. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57034. * @param size Define the size of the texture to create
  57035. * @param scene Define the scene the texture belongs to
  57036. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57037. * @param generateMipMaps Define if the texture should creates mip maps or not
  57038. */
  57039. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57040. private _loadJson;
  57041. /**
  57042. * Is the texture ready to be used ? (rendered at least once)
  57043. * @returns true if ready, otherwise, false.
  57044. */
  57045. isReady(): boolean;
  57046. /**
  57047. * Render the texture to its associated render target.
  57048. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57049. */
  57050. render(useCameraPostProcess?: boolean): void;
  57051. /**
  57052. * Update the list of dependant textures samplers in the shader.
  57053. */
  57054. updateTextures(): void;
  57055. /**
  57056. * Update the uniform values of the procedural texture in the shader.
  57057. */
  57058. updateShaderUniforms(): void;
  57059. /**
  57060. * Define if the texture animates or not.
  57061. */
  57062. get animate(): boolean;
  57063. set animate(value: boolean);
  57064. }
  57065. }
  57066. declare module BABYLON {
  57067. /** @hidden */
  57068. export var noisePixelShader: {
  57069. name: string;
  57070. shader: string;
  57071. };
  57072. }
  57073. declare module BABYLON {
  57074. /**
  57075. * Class used to generate noise procedural textures
  57076. */
  57077. export class NoiseProceduralTexture extends ProceduralTexture {
  57078. private _time;
  57079. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57080. brightness: number;
  57081. /** Defines the number of octaves to process */
  57082. octaves: number;
  57083. /** Defines the level of persistence (0.8 by default) */
  57084. persistence: number;
  57085. /** Gets or sets animation speed factor (default is 1) */
  57086. animationSpeedFactor: number;
  57087. /**
  57088. * Creates a new NoiseProceduralTexture
  57089. * @param name defines the name fo the texture
  57090. * @param size defines the size of the texture (default is 256)
  57091. * @param scene defines the hosting scene
  57092. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57093. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57094. */
  57095. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57096. private _updateShaderUniforms;
  57097. protected _getDefines(): string;
  57098. /** Generate the current state of the procedural texture */
  57099. render(useCameraPostProcess?: boolean): void;
  57100. /**
  57101. * Serializes this noise procedural texture
  57102. * @returns a serialized noise procedural texture object
  57103. */
  57104. serialize(): any;
  57105. /**
  57106. * Clone the texture.
  57107. * @returns the cloned texture
  57108. */
  57109. clone(): NoiseProceduralTexture;
  57110. /**
  57111. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57112. * @param parsedTexture defines parsed texture data
  57113. * @param scene defines the current scene
  57114. * @param rootUrl defines the root URL containing noise procedural texture information
  57115. * @returns a parsed NoiseProceduralTexture
  57116. */
  57117. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57118. }
  57119. }
  57120. declare module BABYLON {
  57121. /**
  57122. * Raw cube texture where the raw buffers are passed in
  57123. */
  57124. export class RawCubeTexture extends CubeTexture {
  57125. /**
  57126. * Creates a cube texture where the raw buffers are passed in.
  57127. * @param scene defines the scene the texture is attached to
  57128. * @param data defines the array of data to use to create each face
  57129. * @param size defines the size of the textures
  57130. * @param format defines the format of the data
  57131. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57132. * @param generateMipMaps defines if the engine should generate the mip levels
  57133. * @param invertY defines if data must be stored with Y axis inverted
  57134. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57135. * @param compression defines the compression used (null by default)
  57136. */
  57137. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57138. /**
  57139. * Updates the raw cube texture.
  57140. * @param data defines the data to store
  57141. * @param format defines the data format
  57142. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57143. * @param invertY defines if data must be stored with Y axis inverted
  57144. * @param compression defines the compression used (null by default)
  57145. * @param level defines which level of the texture to update
  57146. */
  57147. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57148. /**
  57149. * Updates a raw cube texture with RGBD encoded data.
  57150. * @param data defines the array of data [mipmap][face] to use to create each face
  57151. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57152. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57153. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57154. * @returns a promsie that resolves when the operation is complete
  57155. */
  57156. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57157. /**
  57158. * Clones the raw cube texture.
  57159. * @return a new cube texture
  57160. */
  57161. clone(): CubeTexture;
  57162. /** @hidden */
  57163. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57164. }
  57165. }
  57166. declare module BABYLON {
  57167. /**
  57168. * Class used to store 3D textures containing user data
  57169. */
  57170. export class RawTexture3D extends Texture {
  57171. /** Gets or sets the texture format to use */
  57172. format: number;
  57173. private _engine;
  57174. /**
  57175. * Create a new RawTexture3D
  57176. * @param data defines the data of the texture
  57177. * @param width defines the width of the texture
  57178. * @param height defines the height of the texture
  57179. * @param depth defines the depth of the texture
  57180. * @param format defines the texture format to use
  57181. * @param scene defines the hosting scene
  57182. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57183. * @param invertY defines if texture must be stored with Y axis inverted
  57184. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57185. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57186. */
  57187. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57188. /** Gets or sets the texture format to use */
  57189. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57190. /**
  57191. * Update the texture with new data
  57192. * @param data defines the data to store in the texture
  57193. */
  57194. update(data: ArrayBufferView): void;
  57195. }
  57196. }
  57197. declare module BABYLON {
  57198. /**
  57199. * Class used to store 2D array textures containing user data
  57200. */
  57201. export class RawTexture2DArray extends Texture {
  57202. /** Gets or sets the texture format to use */
  57203. format: number;
  57204. private _engine;
  57205. /**
  57206. * Create a new RawTexture2DArray
  57207. * @param data defines the data of the texture
  57208. * @param width defines the width of the texture
  57209. * @param height defines the height of the texture
  57210. * @param depth defines the number of layers of the texture
  57211. * @param format defines the texture format to use
  57212. * @param scene defines the hosting scene
  57213. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57214. * @param invertY defines if texture must be stored with Y axis inverted
  57215. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57216. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57217. */
  57218. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57219. /** Gets or sets the texture format to use */
  57220. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57221. /**
  57222. * Update the texture with new data
  57223. * @param data defines the data to store in the texture
  57224. */
  57225. update(data: ArrayBufferView): void;
  57226. }
  57227. }
  57228. declare module BABYLON {
  57229. /**
  57230. * Creates a refraction texture used by refraction channel of the standard material.
  57231. * It is like a mirror but to see through a material.
  57232. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57233. */
  57234. export class RefractionTexture extends RenderTargetTexture {
  57235. /**
  57236. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57237. * 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.
  57238. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57239. */
  57240. refractionPlane: Plane;
  57241. /**
  57242. * Define how deep under the surface we should see.
  57243. */
  57244. depth: number;
  57245. /**
  57246. * Creates a refraction texture used by refraction channel of the standard material.
  57247. * It is like a mirror but to see through a material.
  57248. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57249. * @param name Define the texture name
  57250. * @param size Define the size of the underlying texture
  57251. * @param scene Define the scene the refraction belongs to
  57252. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57253. */
  57254. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57255. /**
  57256. * Clone the refraction texture.
  57257. * @returns the cloned texture
  57258. */
  57259. clone(): RefractionTexture;
  57260. /**
  57261. * Serialize the texture to a JSON representation you could use in Parse later on
  57262. * @returns the serialized JSON representation
  57263. */
  57264. serialize(): any;
  57265. }
  57266. }
  57267. declare module BABYLON {
  57268. /**
  57269. * Defines the options related to the creation of an HtmlElementTexture
  57270. */
  57271. export interface IHtmlElementTextureOptions {
  57272. /**
  57273. * Defines wether mip maps should be created or not.
  57274. */
  57275. generateMipMaps?: boolean;
  57276. /**
  57277. * Defines the sampling mode of the texture.
  57278. */
  57279. samplingMode?: number;
  57280. /**
  57281. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57282. */
  57283. engine: Nullable<ThinEngine>;
  57284. /**
  57285. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57286. */
  57287. scene: Nullable<Scene>;
  57288. }
  57289. /**
  57290. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57291. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57292. * is automatically managed.
  57293. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57294. * in your application.
  57295. *
  57296. * As the update is not automatic, you need to call them manually.
  57297. */
  57298. export class HtmlElementTexture extends BaseTexture {
  57299. /**
  57300. * The texture URL.
  57301. */
  57302. element: HTMLVideoElement | HTMLCanvasElement;
  57303. private static readonly DefaultOptions;
  57304. private _textureMatrix;
  57305. private _engine;
  57306. private _isVideo;
  57307. private _generateMipMaps;
  57308. private _samplingMode;
  57309. /**
  57310. * Instantiates a HtmlElementTexture from the following parameters.
  57311. *
  57312. * @param name Defines the name of the texture
  57313. * @param element Defines the video or canvas the texture is filled with
  57314. * @param options Defines the other none mandatory texture creation options
  57315. */
  57316. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57317. private _createInternalTexture;
  57318. /**
  57319. * Returns the texture matrix used in most of the material.
  57320. */
  57321. getTextureMatrix(): Matrix;
  57322. /**
  57323. * Updates the content of the texture.
  57324. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57325. */
  57326. update(invertY?: Nullable<boolean>): void;
  57327. }
  57328. }
  57329. declare module BABYLON {
  57330. /**
  57331. * Defines the basic options interface of a TexturePacker Frame
  57332. */
  57333. export interface ITexturePackerFrame {
  57334. /**
  57335. * The frame ID
  57336. */
  57337. id: number;
  57338. /**
  57339. * The frames Scale
  57340. */
  57341. scale: Vector2;
  57342. /**
  57343. * The Frames offset
  57344. */
  57345. offset: Vector2;
  57346. }
  57347. /**
  57348. * This is a support class for frame Data on texture packer sets.
  57349. */
  57350. export class TexturePackerFrame implements ITexturePackerFrame {
  57351. /**
  57352. * The frame ID
  57353. */
  57354. id: number;
  57355. /**
  57356. * The frames Scale
  57357. */
  57358. scale: Vector2;
  57359. /**
  57360. * The Frames offset
  57361. */
  57362. offset: Vector2;
  57363. /**
  57364. * Initializes a texture package frame.
  57365. * @param id The numerical frame identifier
  57366. * @param scale Scalar Vector2 for UV frame
  57367. * @param offset Vector2 for the frame position in UV units.
  57368. * @returns TexturePackerFrame
  57369. */
  57370. constructor(id: number, scale: Vector2, offset: Vector2);
  57371. }
  57372. }
  57373. declare module BABYLON {
  57374. /**
  57375. * Defines the basic options interface of a TexturePacker
  57376. */
  57377. export interface ITexturePackerOptions {
  57378. /**
  57379. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57380. */
  57381. map?: string[];
  57382. /**
  57383. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57384. */
  57385. uvsIn?: string;
  57386. /**
  57387. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57388. */
  57389. uvsOut?: string;
  57390. /**
  57391. * number representing the layout style. Defaults to LAYOUT_STRIP
  57392. */
  57393. layout?: number;
  57394. /**
  57395. * number of columns if using custom column count layout(2). This defaults to 4.
  57396. */
  57397. colnum?: number;
  57398. /**
  57399. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57400. */
  57401. updateInputMeshes?: boolean;
  57402. /**
  57403. * boolean flag to dispose all the source textures. Defaults to true.
  57404. */
  57405. disposeSources?: boolean;
  57406. /**
  57407. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57408. */
  57409. fillBlanks?: boolean;
  57410. /**
  57411. * string value representing the context fill style color. Defaults to 'black'.
  57412. */
  57413. customFillColor?: string;
  57414. /**
  57415. * Width and Height Value of each Frame in the TexturePacker Sets
  57416. */
  57417. frameSize?: number;
  57418. /**
  57419. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57420. */
  57421. paddingRatio?: number;
  57422. /**
  57423. * Number that declares the fill method for the padding gutter.
  57424. */
  57425. paddingMode?: number;
  57426. /**
  57427. * If in SUBUV_COLOR padding mode what color to use.
  57428. */
  57429. paddingColor?: Color3 | Color4;
  57430. }
  57431. /**
  57432. * Defines the basic interface of a TexturePacker JSON File
  57433. */
  57434. export interface ITexturePackerJSON {
  57435. /**
  57436. * The frame ID
  57437. */
  57438. name: string;
  57439. /**
  57440. * The base64 channel data
  57441. */
  57442. sets: any;
  57443. /**
  57444. * The options of the Packer
  57445. */
  57446. options: ITexturePackerOptions;
  57447. /**
  57448. * The frame data of the Packer
  57449. */
  57450. frames: Array<number>;
  57451. }
  57452. /**
  57453. * This is a support class that generates a series of packed texture sets.
  57454. * @see https://doc.babylonjs.com/babylon101/materials
  57455. */
  57456. export class TexturePacker {
  57457. /** Packer Layout Constant 0 */
  57458. static readonly LAYOUT_STRIP: number;
  57459. /** Packer Layout Constant 1 */
  57460. static readonly LAYOUT_POWER2: number;
  57461. /** Packer Layout Constant 2 */
  57462. static readonly LAYOUT_COLNUM: number;
  57463. /** Packer Layout Constant 0 */
  57464. static readonly SUBUV_WRAP: number;
  57465. /** Packer Layout Constant 1 */
  57466. static readonly SUBUV_EXTEND: number;
  57467. /** Packer Layout Constant 2 */
  57468. static readonly SUBUV_COLOR: number;
  57469. /** The Name of the Texture Package */
  57470. name: string;
  57471. /** The scene scope of the TexturePacker */
  57472. scene: Scene;
  57473. /** The Meshes to target */
  57474. meshes: AbstractMesh[];
  57475. /** Arguments passed with the Constructor */
  57476. options: ITexturePackerOptions;
  57477. /** The promise that is started upon initialization */
  57478. promise: Nullable<Promise<TexturePacker | string>>;
  57479. /** The Container object for the channel sets that are generated */
  57480. sets: object;
  57481. /** The Container array for the frames that are generated */
  57482. frames: TexturePackerFrame[];
  57483. /** The expected number of textures the system is parsing. */
  57484. private _expecting;
  57485. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57486. private _paddingValue;
  57487. /**
  57488. * Initializes a texture package series from an array of meshes or a single mesh.
  57489. * @param name The name of the package
  57490. * @param meshes The target meshes to compose the package from
  57491. * @param options The arguments that texture packer should follow while building.
  57492. * @param scene The scene which the textures are scoped to.
  57493. * @returns TexturePacker
  57494. */
  57495. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57496. /**
  57497. * Starts the package process
  57498. * @param resolve The promises resolution function
  57499. * @returns TexturePacker
  57500. */
  57501. private _createFrames;
  57502. /**
  57503. * Calculates the Size of the Channel Sets
  57504. * @returns Vector2
  57505. */
  57506. private _calculateSize;
  57507. /**
  57508. * Calculates the UV data for the frames.
  57509. * @param baseSize the base frameSize
  57510. * @param padding the base frame padding
  57511. * @param dtSize size of the Dynamic Texture for that channel
  57512. * @param dtUnits is 1/dtSize
  57513. * @param update flag to update the input meshes
  57514. */
  57515. private _calculateMeshUVFrames;
  57516. /**
  57517. * Calculates the frames Offset.
  57518. * @param index of the frame
  57519. * @returns Vector2
  57520. */
  57521. private _getFrameOffset;
  57522. /**
  57523. * Updates a Mesh to the frame data
  57524. * @param mesh that is the target
  57525. * @param frameID or the frame index
  57526. */
  57527. private _updateMeshUV;
  57528. /**
  57529. * Updates a Meshes materials to use the texture packer channels
  57530. * @param m is the mesh to target
  57531. * @param force all channels on the packer to be set.
  57532. */
  57533. private _updateTextureReferences;
  57534. /**
  57535. * Public method to set a Mesh to a frame
  57536. * @param m that is the target
  57537. * @param frameID or the frame index
  57538. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57539. */
  57540. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57541. /**
  57542. * Starts the async promise to compile the texture packer.
  57543. * @returns Promise<void>
  57544. */
  57545. processAsync(): Promise<void>;
  57546. /**
  57547. * Disposes all textures associated with this packer
  57548. */
  57549. dispose(): void;
  57550. /**
  57551. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57552. * @param imageType is the image type to use.
  57553. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57554. */
  57555. download(imageType?: string, quality?: number): void;
  57556. /**
  57557. * Public method to load a texturePacker JSON file.
  57558. * @param data of the JSON file in string format.
  57559. */
  57560. updateFromJSON(data: string): void;
  57561. }
  57562. }
  57563. declare module BABYLON {
  57564. /**
  57565. * Enum used to define the target of a block
  57566. */
  57567. export enum NodeMaterialBlockTargets {
  57568. /** Vertex shader */
  57569. Vertex = 1,
  57570. /** Fragment shader */
  57571. Fragment = 2,
  57572. /** Neutral */
  57573. Neutral = 4,
  57574. /** Vertex and Fragment */
  57575. VertexAndFragment = 3
  57576. }
  57577. }
  57578. declare module BABYLON {
  57579. /**
  57580. * Defines the kind of connection point for node based material
  57581. */
  57582. export enum NodeMaterialBlockConnectionPointTypes {
  57583. /** Float */
  57584. Float = 1,
  57585. /** Int */
  57586. Int = 2,
  57587. /** Vector2 */
  57588. Vector2 = 4,
  57589. /** Vector3 */
  57590. Vector3 = 8,
  57591. /** Vector4 */
  57592. Vector4 = 16,
  57593. /** Color3 */
  57594. Color3 = 32,
  57595. /** Color4 */
  57596. Color4 = 64,
  57597. /** Matrix */
  57598. Matrix = 128,
  57599. /** Custom object */
  57600. Object = 256,
  57601. /** Detect type based on connection */
  57602. AutoDetect = 1024,
  57603. /** Output type that will be defined by input type */
  57604. BasedOnInput = 2048
  57605. }
  57606. }
  57607. declare module BABYLON {
  57608. /**
  57609. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57610. */
  57611. export enum NodeMaterialBlockConnectionPointMode {
  57612. /** Value is an uniform */
  57613. Uniform = 0,
  57614. /** Value is a mesh attribute */
  57615. Attribute = 1,
  57616. /** Value is a varying between vertex and fragment shaders */
  57617. Varying = 2,
  57618. /** Mode is undefined */
  57619. Undefined = 3
  57620. }
  57621. }
  57622. declare module BABYLON {
  57623. /**
  57624. * Enum used to define system values e.g. values automatically provided by the system
  57625. */
  57626. export enum NodeMaterialSystemValues {
  57627. /** World */
  57628. World = 1,
  57629. /** View */
  57630. View = 2,
  57631. /** Projection */
  57632. Projection = 3,
  57633. /** ViewProjection */
  57634. ViewProjection = 4,
  57635. /** WorldView */
  57636. WorldView = 5,
  57637. /** WorldViewProjection */
  57638. WorldViewProjection = 6,
  57639. /** CameraPosition */
  57640. CameraPosition = 7,
  57641. /** Fog Color */
  57642. FogColor = 8,
  57643. /** Delta time */
  57644. DeltaTime = 9
  57645. }
  57646. }
  57647. declare module BABYLON {
  57648. /**
  57649. * Root class for all node material optimizers
  57650. */
  57651. export class NodeMaterialOptimizer {
  57652. /**
  57653. * Function used to optimize a NodeMaterial graph
  57654. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57655. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57656. */
  57657. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. /**
  57662. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57663. */
  57664. export class TransformBlock extends NodeMaterialBlock {
  57665. /**
  57666. * Defines the value to use to complement W value to transform it to a Vector4
  57667. */
  57668. complementW: number;
  57669. /**
  57670. * Defines the value to use to complement z value to transform it to a Vector4
  57671. */
  57672. complementZ: number;
  57673. /**
  57674. * Creates a new TransformBlock
  57675. * @param name defines the block name
  57676. */
  57677. constructor(name: string);
  57678. /**
  57679. * Gets the current class name
  57680. * @returns the class name
  57681. */
  57682. getClassName(): string;
  57683. /**
  57684. * Gets the vector input
  57685. */
  57686. get vector(): NodeMaterialConnectionPoint;
  57687. /**
  57688. * Gets the output component
  57689. */
  57690. get output(): NodeMaterialConnectionPoint;
  57691. /**
  57692. * Gets the xyz output component
  57693. */
  57694. get xyz(): NodeMaterialConnectionPoint;
  57695. /**
  57696. * Gets the matrix transform input
  57697. */
  57698. get transform(): NodeMaterialConnectionPoint;
  57699. protected _buildBlock(state: NodeMaterialBuildState): this;
  57700. serialize(): any;
  57701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57702. protected _dumpPropertiesCode(): string;
  57703. }
  57704. }
  57705. declare module BABYLON {
  57706. /**
  57707. * Block used to output the vertex position
  57708. */
  57709. export class VertexOutputBlock extends NodeMaterialBlock {
  57710. /**
  57711. * Creates a new VertexOutputBlock
  57712. * @param name defines the block name
  57713. */
  57714. constructor(name: string);
  57715. /**
  57716. * Gets the current class name
  57717. * @returns the class name
  57718. */
  57719. getClassName(): string;
  57720. /**
  57721. * Gets the vector input component
  57722. */
  57723. get vector(): NodeMaterialConnectionPoint;
  57724. protected _buildBlock(state: NodeMaterialBuildState): this;
  57725. }
  57726. }
  57727. declare module BABYLON {
  57728. /**
  57729. * Block used to output the final color
  57730. */
  57731. export class FragmentOutputBlock extends NodeMaterialBlock {
  57732. /**
  57733. * Create a new FragmentOutputBlock
  57734. * @param name defines the block name
  57735. */
  57736. constructor(name: string);
  57737. /**
  57738. * Gets the current class name
  57739. * @returns the class name
  57740. */
  57741. getClassName(): string;
  57742. /**
  57743. * Gets the rgba input component
  57744. */
  57745. get rgba(): NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the rgb input component
  57748. */
  57749. get rgb(): NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the a input component
  57752. */
  57753. get a(): NodeMaterialConnectionPoint;
  57754. protected _buildBlock(state: NodeMaterialBuildState): this;
  57755. }
  57756. }
  57757. declare module BABYLON {
  57758. /**
  57759. * Base block used to read a reflection texture from a sampler
  57760. */
  57761. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  57762. /** @hidden */
  57763. _define3DName: string;
  57764. /** @hidden */
  57765. _defineCubicName: string;
  57766. /** @hidden */
  57767. _defineExplicitName: string;
  57768. /** @hidden */
  57769. _defineProjectionName: string;
  57770. /** @hidden */
  57771. _defineLocalCubicName: string;
  57772. /** @hidden */
  57773. _defineSphericalName: string;
  57774. /** @hidden */
  57775. _definePlanarName: string;
  57776. /** @hidden */
  57777. _defineEquirectangularName: string;
  57778. /** @hidden */
  57779. _defineMirroredEquirectangularFixedName: string;
  57780. /** @hidden */
  57781. _defineEquirectangularFixedName: string;
  57782. /** @hidden */
  57783. _defineSkyboxName: string;
  57784. /** @hidden */
  57785. _defineOppositeZ: string;
  57786. /** @hidden */
  57787. _cubeSamplerName: string;
  57788. /** @hidden */
  57789. _2DSamplerName: string;
  57790. protected _positionUVWName: string;
  57791. protected _directionWName: string;
  57792. protected _reflectionVectorName: string;
  57793. /** @hidden */
  57794. _reflectionCoordsName: string;
  57795. /** @hidden */
  57796. _reflectionMatrixName: string;
  57797. protected _reflectionColorName: string;
  57798. /**
  57799. * Gets or sets the texture associated with the node
  57800. */
  57801. texture: Nullable<BaseTexture>;
  57802. /**
  57803. * Create a new ReflectionTextureBaseBlock
  57804. * @param name defines the block name
  57805. */
  57806. constructor(name: string);
  57807. /**
  57808. * Gets the current class name
  57809. * @returns the class name
  57810. */
  57811. getClassName(): string;
  57812. /**
  57813. * Gets the world position input component
  57814. */
  57815. abstract get position(): NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the world position input component
  57818. */
  57819. abstract get worldPosition(): NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the world normal input component
  57822. */
  57823. abstract get worldNormal(): NodeMaterialConnectionPoint;
  57824. /**
  57825. * Gets the world input component
  57826. */
  57827. abstract get world(): NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the camera (or eye) position component
  57830. */
  57831. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  57832. /**
  57833. * Gets the view input component
  57834. */
  57835. abstract get view(): NodeMaterialConnectionPoint;
  57836. protected _getTexture(): Nullable<BaseTexture>;
  57837. autoConfigure(material: NodeMaterial): void;
  57838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57839. isReady(): boolean;
  57840. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57841. /**
  57842. * Gets the code to inject in the vertex shader
  57843. * @param state current state of the node material building
  57844. * @returns the shader code
  57845. */
  57846. handleVertexSide(state: NodeMaterialBuildState): string;
  57847. /**
  57848. * Handles the inits for the fragment code path
  57849. * @param state node material build state
  57850. */
  57851. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  57852. /**
  57853. * Generates the reflection coords code for the fragment code path
  57854. * @param worldNormalVarName name of the world normal variable
  57855. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  57856. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  57857. * @returns the shader code
  57858. */
  57859. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  57860. /**
  57861. * Generates the reflection color code for the fragment code path
  57862. * @param lodVarName name of the lod variable
  57863. * @param swizzleLookupTexture swizzle to use for the final color variable
  57864. * @returns the shader code
  57865. */
  57866. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  57867. /**
  57868. * Generates the code corresponding to the connected output points
  57869. * @param state node material build state
  57870. * @param varName name of the variable to output
  57871. * @returns the shader code
  57872. */
  57873. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  57874. protected _buildBlock(state: NodeMaterialBuildState): this;
  57875. protected _dumpPropertiesCode(): string;
  57876. serialize(): any;
  57877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57878. }
  57879. }
  57880. declare module BABYLON {
  57881. /**
  57882. * Defines a connection point to be used for points with a custom object type
  57883. */
  57884. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  57885. private _blockType;
  57886. private _blockName;
  57887. private _nameForCheking?;
  57888. /**
  57889. * Creates a new connection point
  57890. * @param name defines the connection point name
  57891. * @param ownerBlock defines the block hosting this connection point
  57892. * @param direction defines the direction of the connection point
  57893. */
  57894. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  57895. /**
  57896. * Gets a number indicating if the current point can be connected to another point
  57897. * @param connectionPoint defines the other connection point
  57898. * @returns a number defining the compatibility state
  57899. */
  57900. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57901. /**
  57902. * Creates a block suitable to be used as an input for this input point.
  57903. * If null is returned, a block based on the point type will be created.
  57904. * @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
  57905. */
  57906. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  57907. }
  57908. }
  57909. declare module BABYLON {
  57910. /**
  57911. * Enum defining the type of properties that can be edited in the property pages in the NME
  57912. */
  57913. export enum PropertyTypeForEdition {
  57914. /** property is a boolean */
  57915. Boolean = 0,
  57916. /** property is a float */
  57917. Float = 1,
  57918. /** property is a Vector2 */
  57919. Vector2 = 2,
  57920. /** property is a list of values */
  57921. List = 3
  57922. }
  57923. /**
  57924. * Interface that defines an option in a variable of type list
  57925. */
  57926. export interface IEditablePropertyListOption {
  57927. /** label of the option */
  57928. "label": string;
  57929. /** value of the option */
  57930. "value": number;
  57931. }
  57932. /**
  57933. * Interface that defines the options available for an editable property
  57934. */
  57935. export interface IEditablePropertyOption {
  57936. /** min value */
  57937. "min"?: number;
  57938. /** max value */
  57939. "max"?: number;
  57940. /** notifiers: indicates which actions to take when the property is changed */
  57941. "notifiers"?: {
  57942. /** the material should be rebuilt */
  57943. "rebuild"?: boolean;
  57944. /** the preview should be updated */
  57945. "update"?: boolean;
  57946. };
  57947. /** list of the options for a variable of type list */
  57948. "options"?: IEditablePropertyListOption[];
  57949. }
  57950. /**
  57951. * Interface that describes an editable property
  57952. */
  57953. export interface IPropertyDescriptionForEdition {
  57954. /** name of the property */
  57955. "propertyName": string;
  57956. /** display name of the property */
  57957. "displayName": string;
  57958. /** type of the property */
  57959. "type": PropertyTypeForEdition;
  57960. /** group of the property - all properties with the same group value will be displayed in a specific section */
  57961. "groupName": string;
  57962. /** options for the property */
  57963. "options": IEditablePropertyOption;
  57964. }
  57965. /**
  57966. * Decorator that flags a property in a node material block as being editable
  57967. */
  57968. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  57969. }
  57970. declare module BABYLON {
  57971. /**
  57972. * Block used to implement the refraction part of the sub surface module of the PBR material
  57973. */
  57974. export class RefractionBlock extends NodeMaterialBlock {
  57975. /** @hidden */
  57976. _define3DName: string;
  57977. /** @hidden */
  57978. _refractionMatrixName: string;
  57979. /** @hidden */
  57980. _defineLODRefractionAlpha: string;
  57981. /** @hidden */
  57982. _defineLinearSpecularRefraction: string;
  57983. /** @hidden */
  57984. _defineOppositeZ: string;
  57985. /** @hidden */
  57986. _cubeSamplerName: string;
  57987. /** @hidden */
  57988. _2DSamplerName: string;
  57989. /** @hidden */
  57990. _vRefractionMicrosurfaceInfosName: string;
  57991. /** @hidden */
  57992. _vRefractionInfosName: string;
  57993. private _scene;
  57994. /**
  57995. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57996. * Materials half opaque for instance using refraction could benefit from this control.
  57997. */
  57998. linkRefractionWithTransparency: boolean;
  57999. /**
  58000. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58001. */
  58002. invertRefractionY: boolean;
  58003. /**
  58004. * Gets or sets the texture associated with the node
  58005. */
  58006. texture: Nullable<BaseTexture>;
  58007. /**
  58008. * Create a new RefractionBlock
  58009. * @param name defines the block name
  58010. */
  58011. constructor(name: string);
  58012. /**
  58013. * Gets the current class name
  58014. * @returns the class name
  58015. */
  58016. getClassName(): string;
  58017. /**
  58018. * Gets the intensity input component
  58019. */
  58020. get intensity(): NodeMaterialConnectionPoint;
  58021. /**
  58022. * Gets the index of refraction input component
  58023. */
  58024. get indexOfRefraction(): NodeMaterialConnectionPoint;
  58025. /**
  58026. * Gets the tint at distance input component
  58027. */
  58028. get tintAtDistance(): NodeMaterialConnectionPoint;
  58029. /**
  58030. * Gets the view input component
  58031. */
  58032. get view(): NodeMaterialConnectionPoint;
  58033. /**
  58034. * Gets the refraction object output component
  58035. */
  58036. get refraction(): NodeMaterialConnectionPoint;
  58037. /**
  58038. * Returns true if the block has a texture
  58039. */
  58040. get hasTexture(): boolean;
  58041. protected _getTexture(): Nullable<BaseTexture>;
  58042. autoConfigure(material: NodeMaterial): void;
  58043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58044. isReady(): boolean;
  58045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58046. /**
  58047. * Gets the main code of the block (fragment side)
  58048. * @param state current state of the node material building
  58049. * @returns the shader code
  58050. */
  58051. getCode(state: NodeMaterialBuildState): string;
  58052. protected _buildBlock(state: NodeMaterialBuildState): this;
  58053. protected _dumpPropertiesCode(): string;
  58054. serialize(): any;
  58055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58056. }
  58057. }
  58058. declare module BABYLON {
  58059. /**
  58060. * Interface used to configure the node material editor
  58061. */
  58062. export interface INodeMaterialEditorOptions {
  58063. /** Define the URl to load node editor script */
  58064. editorURL?: string;
  58065. }
  58066. /** @hidden */
  58067. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58068. NORMAL: boolean;
  58069. TANGENT: boolean;
  58070. UV1: boolean;
  58071. /** BONES */
  58072. NUM_BONE_INFLUENCERS: number;
  58073. BonesPerMesh: number;
  58074. BONETEXTURE: boolean;
  58075. /** MORPH TARGETS */
  58076. MORPHTARGETS: boolean;
  58077. MORPHTARGETS_NORMAL: boolean;
  58078. MORPHTARGETS_TANGENT: boolean;
  58079. MORPHTARGETS_UV: boolean;
  58080. NUM_MORPH_INFLUENCERS: number;
  58081. /** IMAGE PROCESSING */
  58082. IMAGEPROCESSING: boolean;
  58083. VIGNETTE: boolean;
  58084. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58085. VIGNETTEBLENDMODEOPAQUE: boolean;
  58086. TONEMAPPING: boolean;
  58087. TONEMAPPING_ACES: boolean;
  58088. CONTRAST: boolean;
  58089. EXPOSURE: boolean;
  58090. COLORCURVES: boolean;
  58091. COLORGRADING: boolean;
  58092. COLORGRADING3D: boolean;
  58093. SAMPLER3DGREENDEPTH: boolean;
  58094. SAMPLER3DBGRMAP: boolean;
  58095. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58096. /** MISC. */
  58097. BUMPDIRECTUV: number;
  58098. constructor();
  58099. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  58100. }
  58101. /**
  58102. * Class used to configure NodeMaterial
  58103. */
  58104. export interface INodeMaterialOptions {
  58105. /**
  58106. * Defines if blocks should emit comments
  58107. */
  58108. emitComments: boolean;
  58109. }
  58110. /**
  58111. * Class used to create a node based material built by assembling shader blocks
  58112. */
  58113. export class NodeMaterial extends PushMaterial {
  58114. private static _BuildIdGenerator;
  58115. private _options;
  58116. private _vertexCompilationState;
  58117. private _fragmentCompilationState;
  58118. private _sharedData;
  58119. private _buildId;
  58120. private _buildWasSuccessful;
  58121. private _cachedWorldViewMatrix;
  58122. private _cachedWorldViewProjectionMatrix;
  58123. private _optimizers;
  58124. private _animationFrame;
  58125. /** Define the Url to load node editor script */
  58126. static EditorURL: string;
  58127. /** Define the Url to load snippets */
  58128. static SnippetUrl: string;
  58129. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  58130. static IgnoreTexturesAtLoadTime: boolean;
  58131. private BJSNODEMATERIALEDITOR;
  58132. /** Get the inspector from bundle or global */
  58133. private _getGlobalNodeMaterialEditor;
  58134. /**
  58135. * Snippet ID if the material was created from the snippet server
  58136. */
  58137. snippetId: string;
  58138. /**
  58139. * Gets or sets data used by visual editor
  58140. * @see https://nme.babylonjs.com
  58141. */
  58142. editorData: any;
  58143. /**
  58144. * 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)
  58145. */
  58146. ignoreAlpha: boolean;
  58147. /**
  58148. * Defines the maximum number of lights that can be used in the material
  58149. */
  58150. maxSimultaneousLights: number;
  58151. /**
  58152. * Observable raised when the material is built
  58153. */
  58154. onBuildObservable: Observable<NodeMaterial>;
  58155. /**
  58156. * Gets or sets the root nodes of the material vertex shader
  58157. */
  58158. _vertexOutputNodes: NodeMaterialBlock[];
  58159. /**
  58160. * Gets or sets the root nodes of the material fragment (pixel) shader
  58161. */
  58162. _fragmentOutputNodes: NodeMaterialBlock[];
  58163. /** Gets or sets options to control the node material overall behavior */
  58164. get options(): INodeMaterialOptions;
  58165. set options(options: INodeMaterialOptions);
  58166. /**
  58167. * Default configuration related to image processing available in the standard Material.
  58168. */
  58169. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58170. /**
  58171. * Gets the image processing configuration used either in this material.
  58172. */
  58173. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58174. /**
  58175. * Sets the Default image processing configuration used either in the this material.
  58176. *
  58177. * If sets to null, the scene one is in use.
  58178. */
  58179. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58180. /**
  58181. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58182. */
  58183. attachedBlocks: NodeMaterialBlock[];
  58184. /**
  58185. * Create a new node based material
  58186. * @param name defines the material name
  58187. * @param scene defines the hosting scene
  58188. * @param options defines creation option
  58189. */
  58190. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58191. /**
  58192. * Gets the current class name of the material e.g. "NodeMaterial"
  58193. * @returns the class name
  58194. */
  58195. getClassName(): string;
  58196. /**
  58197. * Keep track of the image processing observer to allow dispose and replace.
  58198. */
  58199. private _imageProcessingObserver;
  58200. /**
  58201. * Attaches a new image processing configuration to the Standard Material.
  58202. * @param configuration
  58203. */
  58204. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58205. /**
  58206. * Get a block by its name
  58207. * @param name defines the name of the block to retrieve
  58208. * @returns the required block or null if not found
  58209. */
  58210. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58211. /**
  58212. * Get a block by its name
  58213. * @param predicate defines the predicate used to find the good candidate
  58214. * @returns the required block or null if not found
  58215. */
  58216. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58217. /**
  58218. * Get an input block by its name
  58219. * @param predicate defines the predicate used to find the good candidate
  58220. * @returns the required input block or null if not found
  58221. */
  58222. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58223. /**
  58224. * Gets the list of input blocks attached to this material
  58225. * @returns an array of InputBlocks
  58226. */
  58227. getInputBlocks(): InputBlock[];
  58228. /**
  58229. * Adds a new optimizer to the list of optimizers
  58230. * @param optimizer defines the optimizers to add
  58231. * @returns the current material
  58232. */
  58233. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58234. /**
  58235. * Remove an optimizer from the list of optimizers
  58236. * @param optimizer defines the optimizers to remove
  58237. * @returns the current material
  58238. */
  58239. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58240. /**
  58241. * Add a new block to the list of output nodes
  58242. * @param node defines the node to add
  58243. * @returns the current material
  58244. */
  58245. addOutputNode(node: NodeMaterialBlock): this;
  58246. /**
  58247. * Remove a block from the list of root nodes
  58248. * @param node defines the node to remove
  58249. * @returns the current material
  58250. */
  58251. removeOutputNode(node: NodeMaterialBlock): this;
  58252. private _addVertexOutputNode;
  58253. private _removeVertexOutputNode;
  58254. private _addFragmentOutputNode;
  58255. private _removeFragmentOutputNode;
  58256. /**
  58257. * Specifies if the material will require alpha blending
  58258. * @returns a boolean specifying if alpha blending is needed
  58259. */
  58260. needAlphaBlending(): boolean;
  58261. /**
  58262. * Specifies if this material should be rendered in alpha test mode
  58263. * @returns a boolean specifying if an alpha test is needed.
  58264. */
  58265. needAlphaTesting(): boolean;
  58266. private _initializeBlock;
  58267. private _resetDualBlocks;
  58268. /**
  58269. * Remove a block from the current node material
  58270. * @param block defines the block to remove
  58271. */
  58272. removeBlock(block: NodeMaterialBlock): void;
  58273. /**
  58274. * Build the material and generates the inner effect
  58275. * @param verbose defines if the build should log activity
  58276. */
  58277. build(verbose?: boolean): void;
  58278. /**
  58279. * Runs an otpimization phase to try to improve the shader code
  58280. */
  58281. optimize(): void;
  58282. private _prepareDefinesForAttributes;
  58283. /**
  58284. * Get if the submesh is ready to be used and all its information available.
  58285. * Child classes can use it to update shaders
  58286. * @param mesh defines the mesh to check
  58287. * @param subMesh defines which submesh to check
  58288. * @param useInstances specifies that instances should be used
  58289. * @returns a boolean indicating that the submesh is ready or not
  58290. */
  58291. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58292. /**
  58293. * Get a string representing the shaders built by the current node graph
  58294. */
  58295. get compiledShaders(): string;
  58296. /**
  58297. * Binds the world matrix to the material
  58298. * @param world defines the world transformation matrix
  58299. */
  58300. bindOnlyWorldMatrix(world: Matrix): void;
  58301. /**
  58302. * Binds the submesh to this material by preparing the effect and shader to draw
  58303. * @param world defines the world transformation matrix
  58304. * @param mesh defines the mesh containing the submesh
  58305. * @param subMesh defines the submesh to bind the material to
  58306. */
  58307. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58308. /**
  58309. * Gets the active textures from the material
  58310. * @returns an array of textures
  58311. */
  58312. getActiveTextures(): BaseTexture[];
  58313. /**
  58314. * Gets the list of texture blocks
  58315. * @returns an array of texture blocks
  58316. */
  58317. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock)[];
  58318. /**
  58319. * Specifies if the material uses a texture
  58320. * @param texture defines the texture to check against the material
  58321. * @returns a boolean specifying if the material uses the texture
  58322. */
  58323. hasTexture(texture: BaseTexture): boolean;
  58324. /**
  58325. * Disposes the material
  58326. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58327. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58328. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58329. */
  58330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58331. /** Creates the node editor window. */
  58332. private _createNodeEditor;
  58333. /**
  58334. * Launch the node material editor
  58335. * @param config Define the configuration of the editor
  58336. * @return a promise fulfilled when the node editor is visible
  58337. */
  58338. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58339. /**
  58340. * Clear the current material
  58341. */
  58342. clear(): void;
  58343. /**
  58344. * Clear the current material and set it to a default state
  58345. */
  58346. setToDefault(): void;
  58347. /**
  58348. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58349. * @param url defines the url to load from
  58350. * @returns a promise that will fullfil when the material is fully loaded
  58351. */
  58352. loadAsync(url: string): Promise<void>;
  58353. private _gatherBlocks;
  58354. /**
  58355. * Generate a string containing the code declaration required to create an equivalent of this material
  58356. * @returns a string
  58357. */
  58358. generateCode(): string;
  58359. /**
  58360. * Serializes this material in a JSON representation
  58361. * @returns the serialized material object
  58362. */
  58363. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58364. private _restoreConnections;
  58365. /**
  58366. * Clear the current graph and load a new one from a serialization object
  58367. * @param source defines the JSON representation of the material
  58368. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58369. */
  58370. loadFromSerialization(source: any, rootUrl?: string): void;
  58371. /**
  58372. * Makes a duplicate of the current material.
  58373. * @param name - name to use for the new material.
  58374. */
  58375. clone(name: string): NodeMaterial;
  58376. /**
  58377. * Creates a node material from parsed material data
  58378. * @param source defines the JSON representation of the material
  58379. * @param scene defines the hosting scene
  58380. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58381. * @returns a new node material
  58382. */
  58383. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58384. /**
  58385. * Creates a node material from a snippet saved in a remote file
  58386. * @param name defines the name of the material to create
  58387. * @param url defines the url to load from
  58388. * @param scene defines the hosting scene
  58389. * @returns a promise that will resolve to the new node material
  58390. */
  58391. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58392. /**
  58393. * Creates a node material from a snippet saved by the node material editor
  58394. * @param snippetId defines the snippet to load
  58395. * @param scene defines the hosting scene
  58396. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58397. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58398. * @returns a promise that will resolve to the new node material
  58399. */
  58400. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58401. /**
  58402. * Creates a new node material set to default basic configuration
  58403. * @param name defines the name of the material
  58404. * @param scene defines the hosting scene
  58405. * @returns a new NodeMaterial
  58406. */
  58407. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58408. }
  58409. }
  58410. declare module BABYLON {
  58411. /**
  58412. * Block used to read a texture from a sampler
  58413. */
  58414. export class TextureBlock extends NodeMaterialBlock {
  58415. private _defineName;
  58416. private _linearDefineName;
  58417. private _gammaDefineName;
  58418. private _tempTextureRead;
  58419. private _samplerName;
  58420. private _transformedUVName;
  58421. private _textureTransformName;
  58422. private _textureInfoName;
  58423. private _mainUVName;
  58424. private _mainUVDefineName;
  58425. /**
  58426. * Gets or sets the texture associated with the node
  58427. */
  58428. texture: Nullable<Texture>;
  58429. /**
  58430. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58431. */
  58432. convertToGammaSpace: boolean;
  58433. /**
  58434. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58435. */
  58436. convertToLinearSpace: boolean;
  58437. /**
  58438. * Create a new TextureBlock
  58439. * @param name defines the block name
  58440. */
  58441. constructor(name: string);
  58442. /**
  58443. * Gets the current class name
  58444. * @returns the class name
  58445. */
  58446. getClassName(): string;
  58447. /**
  58448. * Gets the uv input component
  58449. */
  58450. get uv(): NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the rgba output component
  58453. */
  58454. get rgba(): NodeMaterialConnectionPoint;
  58455. /**
  58456. * Gets the rgb output component
  58457. */
  58458. get rgb(): NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the r output component
  58461. */
  58462. get r(): NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the g output component
  58465. */
  58466. get g(): NodeMaterialConnectionPoint;
  58467. /**
  58468. * Gets the b output component
  58469. */
  58470. get b(): NodeMaterialConnectionPoint;
  58471. /**
  58472. * Gets the a output component
  58473. */
  58474. get a(): NodeMaterialConnectionPoint;
  58475. get target(): NodeMaterialBlockTargets;
  58476. autoConfigure(material: NodeMaterial): void;
  58477. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58479. isReady(): boolean;
  58480. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58481. private get _isMixed();
  58482. private _injectVertexCode;
  58483. private _writeTextureRead;
  58484. private _writeOutput;
  58485. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58486. protected _dumpPropertiesCode(): string;
  58487. serialize(): any;
  58488. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58489. }
  58490. }
  58491. declare module BABYLON {
  58492. /**
  58493. * Class used to store shared data between 2 NodeMaterialBuildState
  58494. */
  58495. export class NodeMaterialBuildStateSharedData {
  58496. /**
  58497. * Gets the list of emitted varyings
  58498. */
  58499. temps: string[];
  58500. /**
  58501. * Gets the list of emitted varyings
  58502. */
  58503. varyings: string[];
  58504. /**
  58505. * Gets the varying declaration string
  58506. */
  58507. varyingDeclaration: string;
  58508. /**
  58509. * Input blocks
  58510. */
  58511. inputBlocks: InputBlock[];
  58512. /**
  58513. * Input blocks
  58514. */
  58515. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock)[];
  58516. /**
  58517. * Bindable blocks (Blocks that need to set data to the effect)
  58518. */
  58519. bindableBlocks: NodeMaterialBlock[];
  58520. /**
  58521. * List of blocks that can provide a compilation fallback
  58522. */
  58523. blocksWithFallbacks: NodeMaterialBlock[];
  58524. /**
  58525. * List of blocks that can provide a define update
  58526. */
  58527. blocksWithDefines: NodeMaterialBlock[];
  58528. /**
  58529. * List of blocks that can provide a repeatable content
  58530. */
  58531. repeatableContentBlocks: NodeMaterialBlock[];
  58532. /**
  58533. * List of blocks that can provide a dynamic list of uniforms
  58534. */
  58535. dynamicUniformBlocks: NodeMaterialBlock[];
  58536. /**
  58537. * List of blocks that can block the isReady function for the material
  58538. */
  58539. blockingBlocks: NodeMaterialBlock[];
  58540. /**
  58541. * Gets the list of animated inputs
  58542. */
  58543. animatedInputs: InputBlock[];
  58544. /**
  58545. * Build Id used to avoid multiple recompilations
  58546. */
  58547. buildId: number;
  58548. /** List of emitted variables */
  58549. variableNames: {
  58550. [key: string]: number;
  58551. };
  58552. /** List of emitted defines */
  58553. defineNames: {
  58554. [key: string]: number;
  58555. };
  58556. /** Should emit comments? */
  58557. emitComments: boolean;
  58558. /** Emit build activity */
  58559. verbose: boolean;
  58560. /** Gets or sets the hosting scene */
  58561. scene: Scene;
  58562. /**
  58563. * Gets the compilation hints emitted at compilation time
  58564. */
  58565. hints: {
  58566. needWorldViewMatrix: boolean;
  58567. needWorldViewProjectionMatrix: boolean;
  58568. needAlphaBlending: boolean;
  58569. needAlphaTesting: boolean;
  58570. };
  58571. /**
  58572. * List of compilation checks
  58573. */
  58574. checks: {
  58575. emitVertex: boolean;
  58576. emitFragment: boolean;
  58577. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58578. };
  58579. /** Creates a new shared data */
  58580. constructor();
  58581. /**
  58582. * Emits console errors and exceptions if there is a failing check
  58583. */
  58584. emitErrors(): void;
  58585. }
  58586. }
  58587. declare module BABYLON {
  58588. /**
  58589. * Class used to store node based material build state
  58590. */
  58591. export class NodeMaterialBuildState {
  58592. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58593. supportUniformBuffers: boolean;
  58594. /**
  58595. * Gets the list of emitted attributes
  58596. */
  58597. attributes: string[];
  58598. /**
  58599. * Gets the list of emitted uniforms
  58600. */
  58601. uniforms: string[];
  58602. /**
  58603. * Gets the list of emitted constants
  58604. */
  58605. constants: string[];
  58606. /**
  58607. * Gets the list of emitted samplers
  58608. */
  58609. samplers: string[];
  58610. /**
  58611. * Gets the list of emitted functions
  58612. */
  58613. functions: {
  58614. [key: string]: string;
  58615. };
  58616. /**
  58617. * Gets the list of emitted extensions
  58618. */
  58619. extensions: {
  58620. [key: string]: string;
  58621. };
  58622. /**
  58623. * Gets the target of the compilation state
  58624. */
  58625. target: NodeMaterialBlockTargets;
  58626. /**
  58627. * Gets the list of emitted counters
  58628. */
  58629. counters: {
  58630. [key: string]: number;
  58631. };
  58632. /**
  58633. * Shared data between multiple NodeMaterialBuildState instances
  58634. */
  58635. sharedData: NodeMaterialBuildStateSharedData;
  58636. /** @hidden */
  58637. _vertexState: NodeMaterialBuildState;
  58638. /** @hidden */
  58639. _attributeDeclaration: string;
  58640. /** @hidden */
  58641. _uniformDeclaration: string;
  58642. /** @hidden */
  58643. _constantDeclaration: string;
  58644. /** @hidden */
  58645. _samplerDeclaration: string;
  58646. /** @hidden */
  58647. _varyingTransfer: string;
  58648. /** @hidden */
  58649. _injectAtEnd: string;
  58650. private _repeatableContentAnchorIndex;
  58651. /** @hidden */
  58652. _builtCompilationString: string;
  58653. /**
  58654. * Gets the emitted compilation strings
  58655. */
  58656. compilationString: string;
  58657. /**
  58658. * Finalize the compilation strings
  58659. * @param state defines the current compilation state
  58660. */
  58661. finalize(state: NodeMaterialBuildState): void;
  58662. /** @hidden */
  58663. get _repeatableContentAnchor(): string;
  58664. /** @hidden */
  58665. _getFreeVariableName(prefix: string): string;
  58666. /** @hidden */
  58667. _getFreeDefineName(prefix: string): string;
  58668. /** @hidden */
  58669. _excludeVariableName(name: string): void;
  58670. /** @hidden */
  58671. _emit2DSampler(name: string): void;
  58672. /** @hidden */
  58673. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58674. /** @hidden */
  58675. _emitExtension(name: string, extension: string, define?: string): void;
  58676. /** @hidden */
  58677. _emitFunction(name: string, code: string, comments: string): void;
  58678. /** @hidden */
  58679. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58680. replaceStrings?: {
  58681. search: RegExp;
  58682. replace: string;
  58683. }[];
  58684. repeatKey?: string;
  58685. }): string;
  58686. /** @hidden */
  58687. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58688. repeatKey?: string;
  58689. removeAttributes?: boolean;
  58690. removeUniforms?: boolean;
  58691. removeVaryings?: boolean;
  58692. removeIfDef?: boolean;
  58693. replaceStrings?: {
  58694. search: RegExp;
  58695. replace: string;
  58696. }[];
  58697. }, storeKey?: string): void;
  58698. /** @hidden */
  58699. _registerTempVariable(name: string): boolean;
  58700. /** @hidden */
  58701. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58702. /** @hidden */
  58703. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58704. /** @hidden */
  58705. _emitFloat(value: number): string;
  58706. }
  58707. }
  58708. declare module BABYLON {
  58709. /**
  58710. * Defines a block that can be used inside a node based material
  58711. */
  58712. export class NodeMaterialBlock {
  58713. private _buildId;
  58714. private _buildTarget;
  58715. private _target;
  58716. private _isFinalMerger;
  58717. private _isInput;
  58718. protected _isUnique: boolean;
  58719. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58720. inputsAreExclusive: boolean;
  58721. /** @hidden */
  58722. _codeVariableName: string;
  58723. /** @hidden */
  58724. _inputs: NodeMaterialConnectionPoint[];
  58725. /** @hidden */
  58726. _outputs: NodeMaterialConnectionPoint[];
  58727. /** @hidden */
  58728. _preparationId: number;
  58729. /**
  58730. * Gets or sets the name of the block
  58731. */
  58732. name: string;
  58733. /**
  58734. * Gets or sets the unique id of the node
  58735. */
  58736. uniqueId: number;
  58737. /**
  58738. * Gets or sets the comments associated with this block
  58739. */
  58740. comments: string;
  58741. /**
  58742. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58743. */
  58744. get isUnique(): boolean;
  58745. /**
  58746. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58747. */
  58748. get isFinalMerger(): boolean;
  58749. /**
  58750. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58751. */
  58752. get isInput(): boolean;
  58753. /**
  58754. * Gets or sets the build Id
  58755. */
  58756. get buildId(): number;
  58757. set buildId(value: number);
  58758. /**
  58759. * Gets or sets the target of the block
  58760. */
  58761. get target(): NodeMaterialBlockTargets;
  58762. set target(value: NodeMaterialBlockTargets);
  58763. /**
  58764. * Gets the list of input points
  58765. */
  58766. get inputs(): NodeMaterialConnectionPoint[];
  58767. /** Gets the list of output points */
  58768. get outputs(): NodeMaterialConnectionPoint[];
  58769. /**
  58770. * Find an input by its name
  58771. * @param name defines the name of the input to look for
  58772. * @returns the input or null if not found
  58773. */
  58774. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58775. /**
  58776. * Find an output by its name
  58777. * @param name defines the name of the outputto look for
  58778. * @returns the output or null if not found
  58779. */
  58780. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58781. /**
  58782. * Creates a new NodeMaterialBlock
  58783. * @param name defines the block name
  58784. * @param target defines the target of that block (Vertex by default)
  58785. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58786. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58787. */
  58788. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58789. /**
  58790. * Initialize the block and prepare the context for build
  58791. * @param state defines the state that will be used for the build
  58792. */
  58793. initialize(state: NodeMaterialBuildState): void;
  58794. /**
  58795. * Bind data to effect. Will only be called for blocks with isBindable === true
  58796. * @param effect defines the effect to bind data to
  58797. * @param nodeMaterial defines the hosting NodeMaterial
  58798. * @param mesh defines the mesh that will be rendered
  58799. * @param subMesh defines the submesh that will be rendered
  58800. */
  58801. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58802. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58803. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58804. protected _writeFloat(value: number): string;
  58805. /**
  58806. * Gets the current class name e.g. "NodeMaterialBlock"
  58807. * @returns the class name
  58808. */
  58809. getClassName(): string;
  58810. /**
  58811. * Register a new input. Must be called inside a block constructor
  58812. * @param name defines the connection point name
  58813. * @param type defines the connection point type
  58814. * @param isOptional defines a boolean indicating that this input can be omitted
  58815. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58816. * @param point an already created connection point. If not provided, create a new one
  58817. * @returns the current block
  58818. */
  58819. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  58820. /**
  58821. * Register a new output. Must be called inside a block constructor
  58822. * @param name defines the connection point name
  58823. * @param type defines the connection point type
  58824. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58825. * @param point an already created connection point. If not provided, create a new one
  58826. * @returns the current block
  58827. */
  58828. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  58829. /**
  58830. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58831. * @param forOutput defines an optional connection point to check compatibility with
  58832. * @returns the first available input or null
  58833. */
  58834. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58835. /**
  58836. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58837. * @param forBlock defines an optional block to check compatibility with
  58838. * @returns the first available input or null
  58839. */
  58840. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58841. /**
  58842. * Gets the sibling of the given output
  58843. * @param current defines the current output
  58844. * @returns the next output in the list or null
  58845. */
  58846. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58847. /**
  58848. * Connect current block with another block
  58849. * @param other defines the block to connect with
  58850. * @param options define the various options to help pick the right connections
  58851. * @returns the current block
  58852. */
  58853. connectTo(other: NodeMaterialBlock, options?: {
  58854. input?: string;
  58855. output?: string;
  58856. outputSwizzle?: string;
  58857. }): this | undefined;
  58858. protected _buildBlock(state: NodeMaterialBuildState): void;
  58859. /**
  58860. * Add uniforms, samplers and uniform buffers at compilation time
  58861. * @param state defines the state to update
  58862. * @param nodeMaterial defines the node material requesting the update
  58863. * @param defines defines the material defines to update
  58864. * @param uniformBuffers defines the list of uniform buffer names
  58865. */
  58866. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58867. /**
  58868. * Add potential fallbacks if shader compilation fails
  58869. * @param mesh defines the mesh to be rendered
  58870. * @param fallbacks defines the current prioritized list of fallbacks
  58871. */
  58872. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58873. /**
  58874. * Initialize defines for shader compilation
  58875. * @param mesh defines the mesh to be rendered
  58876. * @param nodeMaterial defines the node material requesting the update
  58877. * @param defines defines the material defines to update
  58878. * @param useInstances specifies that instances should be used
  58879. */
  58880. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58881. /**
  58882. * Update defines for shader compilation
  58883. * @param mesh defines the mesh to be rendered
  58884. * @param nodeMaterial defines the node material requesting the update
  58885. * @param defines defines the material defines to update
  58886. * @param useInstances specifies that instances should be used
  58887. */
  58888. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58889. /**
  58890. * Lets the block try to connect some inputs automatically
  58891. * @param material defines the hosting NodeMaterial
  58892. */
  58893. autoConfigure(material: NodeMaterial): void;
  58894. /**
  58895. * Function called when a block is declared as repeatable content generator
  58896. * @param vertexShaderState defines the current compilation state for the vertex shader
  58897. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58898. * @param mesh defines the mesh to be rendered
  58899. * @param defines defines the material defines to update
  58900. */
  58901. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58902. /**
  58903. * Checks if the block is ready
  58904. * @param mesh defines the mesh to be rendered
  58905. * @param nodeMaterial defines the node material requesting the update
  58906. * @param defines defines the material defines to update
  58907. * @param useInstances specifies that instances should be used
  58908. * @returns true if the block is ready
  58909. */
  58910. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58911. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58912. private _processBuild;
  58913. /**
  58914. * Compile the current node and generate the shader code
  58915. * @param state defines the current compilation state (uniforms, samplers, current string)
  58916. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58917. * @returns true if already built
  58918. */
  58919. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58920. protected _inputRename(name: string): string;
  58921. protected _outputRename(name: string): string;
  58922. protected _dumpPropertiesCode(): string;
  58923. /** @hidden */
  58924. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58925. /** @hidden */
  58926. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58927. /**
  58928. * Clone the current block to a new identical block
  58929. * @param scene defines the hosting scene
  58930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58931. * @returns a copy of the current block
  58932. */
  58933. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58934. /**
  58935. * Serializes this block in a JSON representation
  58936. * @returns the serialized block object
  58937. */
  58938. serialize(): any;
  58939. /** @hidden */
  58940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58941. private _deserializePortDisplayNames;
  58942. /**
  58943. * Release resources
  58944. */
  58945. dispose(): void;
  58946. }
  58947. }
  58948. declare module BABYLON {
  58949. /**
  58950. * Enum defining the type of animations supported by InputBlock
  58951. */
  58952. export enum AnimatedInputBlockTypes {
  58953. /** No animation */
  58954. None = 0,
  58955. /** Time based animation. Will only work for floats */
  58956. Time = 1
  58957. }
  58958. }
  58959. declare module BABYLON {
  58960. /**
  58961. * Block used to expose an input value
  58962. */
  58963. export class InputBlock extends NodeMaterialBlock {
  58964. private _mode;
  58965. private _associatedVariableName;
  58966. private _storedValue;
  58967. private _valueCallback;
  58968. private _type;
  58969. private _animationType;
  58970. /** Gets or set a value used to limit the range of float values */
  58971. min: number;
  58972. /** Gets or set a value used to limit the range of float values */
  58973. max: number;
  58974. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58975. isBoolean: boolean;
  58976. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58977. matrixMode: number;
  58978. /** @hidden */
  58979. _systemValue: Nullable<NodeMaterialSystemValues>;
  58980. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58981. visibleInInspector: boolean;
  58982. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58983. isConstant: boolean;
  58984. /** Gets or sets the group to use to display this block in the Inspector */
  58985. groupInInspector: string;
  58986. /** Gets an observable raised when the value is changed */
  58987. onValueChangedObservable: Observable<InputBlock>;
  58988. /**
  58989. * Gets or sets the connection point type (default is float)
  58990. */
  58991. get type(): NodeMaterialBlockConnectionPointTypes;
  58992. /**
  58993. * Creates a new InputBlock
  58994. * @param name defines the block name
  58995. * @param target defines the target of that block (Vertex by default)
  58996. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58997. */
  58998. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58999. /**
  59000. * Gets the output component
  59001. */
  59002. get output(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Set the source of this connection point to a vertex attribute
  59005. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59006. * @returns the current connection point
  59007. */
  59008. setAsAttribute(attributeName?: string): InputBlock;
  59009. /**
  59010. * Set the source of this connection point to a system value
  59011. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59012. * @returns the current connection point
  59013. */
  59014. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59015. /**
  59016. * Gets or sets the value of that point.
  59017. * Please note that this value will be ignored if valueCallback is defined
  59018. */
  59019. get value(): any;
  59020. set value(value: any);
  59021. /**
  59022. * Gets or sets a callback used to get the value of that point.
  59023. * Please note that setting this value will force the connection point to ignore the value property
  59024. */
  59025. get valueCallback(): () => any;
  59026. set valueCallback(value: () => any);
  59027. /**
  59028. * Gets or sets the associated variable name in the shader
  59029. */
  59030. get associatedVariableName(): string;
  59031. set associatedVariableName(value: string);
  59032. /** Gets or sets the type of animation applied to the input */
  59033. get animationType(): AnimatedInputBlockTypes;
  59034. set animationType(value: AnimatedInputBlockTypes);
  59035. /**
  59036. * Gets a boolean indicating that this connection point not defined yet
  59037. */
  59038. get isUndefined(): boolean;
  59039. /**
  59040. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59041. * In this case the connection point name must be the name of the uniform to use.
  59042. * Can only be set on inputs
  59043. */
  59044. get isUniform(): boolean;
  59045. set isUniform(value: boolean);
  59046. /**
  59047. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59048. * In this case the connection point name must be the name of the attribute to use
  59049. * Can only be set on inputs
  59050. */
  59051. get isAttribute(): boolean;
  59052. set isAttribute(value: boolean);
  59053. /**
  59054. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59055. * Can only be set on exit points
  59056. */
  59057. get isVarying(): boolean;
  59058. set isVarying(value: boolean);
  59059. /**
  59060. * Gets a boolean indicating that the current connection point is a system value
  59061. */
  59062. get isSystemValue(): boolean;
  59063. /**
  59064. * Gets or sets the current well known value or null if not defined as a system value
  59065. */
  59066. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59067. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59068. /**
  59069. * Gets the current class name
  59070. * @returns the class name
  59071. */
  59072. getClassName(): string;
  59073. /**
  59074. * Animate the input if animationType !== None
  59075. * @param scene defines the rendering scene
  59076. */
  59077. animate(scene: Scene): void;
  59078. private _emitDefine;
  59079. initialize(state: NodeMaterialBuildState): void;
  59080. /**
  59081. * Set the input block to its default value (based on its type)
  59082. */
  59083. setDefaultValue(): void;
  59084. private _emitConstant;
  59085. private _emit;
  59086. /** @hidden */
  59087. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59088. /** @hidden */
  59089. _transmit(effect: Effect, scene: Scene): void;
  59090. protected _buildBlock(state: NodeMaterialBuildState): void;
  59091. protected _dumpPropertiesCode(): string;
  59092. dispose(): void;
  59093. serialize(): any;
  59094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59095. }
  59096. }
  59097. declare module BABYLON {
  59098. /**
  59099. * Enum used to define the compatibility state between two connection points
  59100. */
  59101. export enum NodeMaterialConnectionPointCompatibilityStates {
  59102. /** Points are compatibles */
  59103. Compatible = 0,
  59104. /** Points are incompatible because of their types */
  59105. TypeIncompatible = 1,
  59106. /** Points are incompatible because of their targets (vertex vs fragment) */
  59107. TargetIncompatible = 2
  59108. }
  59109. /**
  59110. * Defines the direction of a connection point
  59111. */
  59112. export enum NodeMaterialConnectionPointDirection {
  59113. /** Input */
  59114. Input = 0,
  59115. /** Output */
  59116. Output = 1
  59117. }
  59118. /**
  59119. * Defines a connection point for a block
  59120. */
  59121. export class NodeMaterialConnectionPoint {
  59122. /** @hidden */
  59123. _ownerBlock: NodeMaterialBlock;
  59124. /** @hidden */
  59125. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59126. private _endpoints;
  59127. private _associatedVariableName;
  59128. private _direction;
  59129. /** @hidden */
  59130. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59131. /** @hidden */
  59132. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59133. private _type;
  59134. /** @hidden */
  59135. _enforceAssociatedVariableName: boolean;
  59136. /** Gets the direction of the point */
  59137. get direction(): NodeMaterialConnectionPointDirection;
  59138. /** Indicates that this connection point needs dual validation before being connected to another point */
  59139. needDualDirectionValidation: boolean;
  59140. /**
  59141. * Gets or sets the additional types supported by this connection point
  59142. */
  59143. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59144. /**
  59145. * Gets or sets the additional types excluded by this connection point
  59146. */
  59147. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59148. /**
  59149. * Observable triggered when this point is connected
  59150. */
  59151. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59152. /**
  59153. * Gets or sets the associated variable name in the shader
  59154. */
  59155. get associatedVariableName(): string;
  59156. set associatedVariableName(value: string);
  59157. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  59158. get innerType(): NodeMaterialBlockConnectionPointTypes;
  59159. /**
  59160. * Gets or sets the connection point type (default is float)
  59161. */
  59162. get type(): NodeMaterialBlockConnectionPointTypes;
  59163. set type(value: NodeMaterialBlockConnectionPointTypes);
  59164. /**
  59165. * Gets or sets the connection point name
  59166. */
  59167. name: string;
  59168. /**
  59169. * Gets or sets the connection point name
  59170. */
  59171. displayName: string;
  59172. /**
  59173. * Gets or sets a boolean indicating that this connection point can be omitted
  59174. */
  59175. isOptional: boolean;
  59176. /**
  59177. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59178. */
  59179. define: string;
  59180. /** @hidden */
  59181. _prioritizeVertex: boolean;
  59182. private _target;
  59183. /** Gets or sets the target of that connection point */
  59184. get target(): NodeMaterialBlockTargets;
  59185. set target(value: NodeMaterialBlockTargets);
  59186. /**
  59187. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  59188. */
  59189. get isConnected(): boolean;
  59190. /**
  59191. * Gets a boolean indicating that the current point is connected to an input block
  59192. */
  59193. get isConnectedToInputBlock(): boolean;
  59194. /**
  59195. * Gets a the connected input block (if any)
  59196. */
  59197. get connectInputBlock(): Nullable<InputBlock>;
  59198. /** Get the other side of the connection (if any) */
  59199. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59200. /** Get the block that owns this connection point */
  59201. get ownerBlock(): NodeMaterialBlock;
  59202. /** Get the block connected on the other side of this connection (if any) */
  59203. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59204. /** Get the block connected on the endpoints of this connection (if any) */
  59205. get connectedBlocks(): Array<NodeMaterialBlock>;
  59206. /** Gets the list of connected endpoints */
  59207. get endpoints(): NodeMaterialConnectionPoint[];
  59208. /** Gets a boolean indicating if that output point is connected to at least one input */
  59209. get hasEndpoints(): boolean;
  59210. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59211. get isConnectedInVertexShader(): boolean;
  59212. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59213. get isConnectedInFragmentShader(): boolean;
  59214. /**
  59215. * Creates a block suitable to be used as an input for this input point.
  59216. * If null is returned, a block based on the point type will be created.
  59217. * @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
  59218. */
  59219. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  59220. /**
  59221. * Creates a new connection point
  59222. * @param name defines the connection point name
  59223. * @param ownerBlock defines the block hosting this connection point
  59224. * @param direction defines the direction of the connection point
  59225. */
  59226. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59227. /**
  59228. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59229. * @returns the class name
  59230. */
  59231. getClassName(): string;
  59232. /**
  59233. * Gets a boolean indicating if the current point can be connected to another point
  59234. * @param connectionPoint defines the other connection point
  59235. * @returns a boolean
  59236. */
  59237. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59238. /**
  59239. * Gets a number indicating if the current point can be connected to another point
  59240. * @param connectionPoint defines the other connection point
  59241. * @returns a number defining the compatibility state
  59242. */
  59243. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59244. /**
  59245. * Connect this point to another connection point
  59246. * @param connectionPoint defines the other connection point
  59247. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59248. * @returns the current connection point
  59249. */
  59250. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59251. /**
  59252. * Disconnect this point from one of his endpoint
  59253. * @param endpoint defines the other connection point
  59254. * @returns the current connection point
  59255. */
  59256. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59257. /**
  59258. * Serializes this point in a JSON representation
  59259. * @param isInput defines if the connection point is an input (default is true)
  59260. * @returns the serialized point object
  59261. */
  59262. serialize(isInput?: boolean): any;
  59263. /**
  59264. * Release resources
  59265. */
  59266. dispose(): void;
  59267. }
  59268. }
  59269. declare module BABYLON {
  59270. /**
  59271. * Block used to add support for vertex skinning (bones)
  59272. */
  59273. export class BonesBlock extends NodeMaterialBlock {
  59274. /**
  59275. * Creates a new BonesBlock
  59276. * @param name defines the block name
  59277. */
  59278. constructor(name: string);
  59279. /**
  59280. * Initialize the block and prepare the context for build
  59281. * @param state defines the state that will be used for the build
  59282. */
  59283. initialize(state: NodeMaterialBuildState): void;
  59284. /**
  59285. * Gets the current class name
  59286. * @returns the class name
  59287. */
  59288. getClassName(): string;
  59289. /**
  59290. * Gets the matrix indices input component
  59291. */
  59292. get matricesIndices(): NodeMaterialConnectionPoint;
  59293. /**
  59294. * Gets the matrix weights input component
  59295. */
  59296. get matricesWeights(): NodeMaterialConnectionPoint;
  59297. /**
  59298. * Gets the extra matrix indices input component
  59299. */
  59300. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59301. /**
  59302. * Gets the extra matrix weights input component
  59303. */
  59304. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59305. /**
  59306. * Gets the world input component
  59307. */
  59308. get world(): NodeMaterialConnectionPoint;
  59309. /**
  59310. * Gets the output component
  59311. */
  59312. get output(): NodeMaterialConnectionPoint;
  59313. autoConfigure(material: NodeMaterial): void;
  59314. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59317. protected _buildBlock(state: NodeMaterialBuildState): this;
  59318. }
  59319. }
  59320. declare module BABYLON {
  59321. /**
  59322. * Block used to add support for instances
  59323. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59324. */
  59325. export class InstancesBlock extends NodeMaterialBlock {
  59326. /**
  59327. * Creates a new InstancesBlock
  59328. * @param name defines the block name
  59329. */
  59330. constructor(name: string);
  59331. /**
  59332. * Gets the current class name
  59333. * @returns the class name
  59334. */
  59335. getClassName(): string;
  59336. /**
  59337. * Gets the first world row input component
  59338. */
  59339. get world0(): NodeMaterialConnectionPoint;
  59340. /**
  59341. * Gets the second world row input component
  59342. */
  59343. get world1(): NodeMaterialConnectionPoint;
  59344. /**
  59345. * Gets the third world row input component
  59346. */
  59347. get world2(): NodeMaterialConnectionPoint;
  59348. /**
  59349. * Gets the forth world row input component
  59350. */
  59351. get world3(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the world input component
  59354. */
  59355. get world(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. get output(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the isntanceID component
  59362. */
  59363. get instanceID(): NodeMaterialConnectionPoint;
  59364. autoConfigure(material: NodeMaterial): void;
  59365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59366. protected _buildBlock(state: NodeMaterialBuildState): this;
  59367. }
  59368. }
  59369. declare module BABYLON {
  59370. /**
  59371. * Block used to add morph targets support to vertex shader
  59372. */
  59373. export class MorphTargetsBlock extends NodeMaterialBlock {
  59374. private _repeatableContentAnchor;
  59375. /**
  59376. * Create a new MorphTargetsBlock
  59377. * @param name defines the block name
  59378. */
  59379. constructor(name: string);
  59380. /**
  59381. * Gets the current class name
  59382. * @returns the class name
  59383. */
  59384. getClassName(): string;
  59385. /**
  59386. * Gets the position input component
  59387. */
  59388. get position(): NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the normal input component
  59391. */
  59392. get normal(): NodeMaterialConnectionPoint;
  59393. /**
  59394. * Gets the tangent input component
  59395. */
  59396. get tangent(): NodeMaterialConnectionPoint;
  59397. /**
  59398. * Gets the tangent input component
  59399. */
  59400. get uv(): NodeMaterialConnectionPoint;
  59401. /**
  59402. * Gets the position output component
  59403. */
  59404. get positionOutput(): NodeMaterialConnectionPoint;
  59405. /**
  59406. * Gets the normal output component
  59407. */
  59408. get normalOutput(): NodeMaterialConnectionPoint;
  59409. /**
  59410. * Gets the tangent output component
  59411. */
  59412. get tangentOutput(): NodeMaterialConnectionPoint;
  59413. /**
  59414. * Gets the tangent output component
  59415. */
  59416. get uvOutput(): NodeMaterialConnectionPoint;
  59417. initialize(state: NodeMaterialBuildState): void;
  59418. autoConfigure(material: NodeMaterial): void;
  59419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59421. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59422. protected _buildBlock(state: NodeMaterialBuildState): this;
  59423. }
  59424. }
  59425. declare module BABYLON {
  59426. /**
  59427. * Block used to get data information from a light
  59428. */
  59429. export class LightInformationBlock extends NodeMaterialBlock {
  59430. private _lightDataUniformName;
  59431. private _lightColorUniformName;
  59432. private _lightTypeDefineName;
  59433. /**
  59434. * Gets or sets the light associated with this block
  59435. */
  59436. light: Nullable<Light>;
  59437. /**
  59438. * Creates a new LightInformationBlock
  59439. * @param name defines the block name
  59440. */
  59441. constructor(name: string);
  59442. /**
  59443. * Gets the current class name
  59444. * @returns the class name
  59445. */
  59446. getClassName(): string;
  59447. /**
  59448. * Gets the world position input component
  59449. */
  59450. get worldPosition(): NodeMaterialConnectionPoint;
  59451. /**
  59452. * Gets the direction output component
  59453. */
  59454. get direction(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the direction output component
  59457. */
  59458. get color(): NodeMaterialConnectionPoint;
  59459. /**
  59460. * Gets the direction output component
  59461. */
  59462. get intensity(): NodeMaterialConnectionPoint;
  59463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59464. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59465. protected _buildBlock(state: NodeMaterialBuildState): this;
  59466. serialize(): any;
  59467. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59468. }
  59469. }
  59470. declare module BABYLON {
  59471. /**
  59472. * Block used to add image processing support to fragment shader
  59473. */
  59474. export class ImageProcessingBlock extends NodeMaterialBlock {
  59475. /**
  59476. * Create a new ImageProcessingBlock
  59477. * @param name defines the block name
  59478. */
  59479. constructor(name: string);
  59480. /**
  59481. * Gets the current class name
  59482. * @returns the class name
  59483. */
  59484. getClassName(): string;
  59485. /**
  59486. * Gets the color input component
  59487. */
  59488. get color(): NodeMaterialConnectionPoint;
  59489. /**
  59490. * Gets the output component
  59491. */
  59492. get output(): NodeMaterialConnectionPoint;
  59493. /**
  59494. * Initialize the block and prepare the context for build
  59495. * @param state defines the state that will be used for the build
  59496. */
  59497. initialize(state: NodeMaterialBuildState): void;
  59498. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59501. protected _buildBlock(state: NodeMaterialBuildState): this;
  59502. }
  59503. }
  59504. declare module BABYLON {
  59505. /**
  59506. * Block used to pertub normals based on a normal map
  59507. */
  59508. export class PerturbNormalBlock extends NodeMaterialBlock {
  59509. private _tangentSpaceParameterName;
  59510. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59511. invertX: boolean;
  59512. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59513. invertY: boolean;
  59514. /**
  59515. * Create a new PerturbNormalBlock
  59516. * @param name defines the block name
  59517. */
  59518. constructor(name: string);
  59519. /**
  59520. * Gets the current class name
  59521. * @returns the class name
  59522. */
  59523. getClassName(): string;
  59524. /**
  59525. * Gets the world position input component
  59526. */
  59527. get worldPosition(): NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the world normal input component
  59530. */
  59531. get worldNormal(): NodeMaterialConnectionPoint;
  59532. /**
  59533. * Gets the world tangent input component
  59534. */
  59535. get worldTangent(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the uv input component
  59538. */
  59539. get uv(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the normal map color input component
  59542. */
  59543. get normalMapColor(): NodeMaterialConnectionPoint;
  59544. /**
  59545. * Gets the strength input component
  59546. */
  59547. get strength(): NodeMaterialConnectionPoint;
  59548. /**
  59549. * Gets the output component
  59550. */
  59551. get output(): NodeMaterialConnectionPoint;
  59552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59554. autoConfigure(material: NodeMaterial): void;
  59555. protected _buildBlock(state: NodeMaterialBuildState): this;
  59556. protected _dumpPropertiesCode(): string;
  59557. serialize(): any;
  59558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59559. }
  59560. }
  59561. declare module BABYLON {
  59562. /**
  59563. * Block used to discard a pixel if a value is smaller than a cutoff
  59564. */
  59565. export class DiscardBlock extends NodeMaterialBlock {
  59566. /**
  59567. * Create a new DiscardBlock
  59568. * @param name defines the block name
  59569. */
  59570. constructor(name: string);
  59571. /**
  59572. * Gets the current class name
  59573. * @returns the class name
  59574. */
  59575. getClassName(): string;
  59576. /**
  59577. * Gets the color input component
  59578. */
  59579. get value(): NodeMaterialConnectionPoint;
  59580. /**
  59581. * Gets the cutoff input component
  59582. */
  59583. get cutoff(): NodeMaterialConnectionPoint;
  59584. protected _buildBlock(state: NodeMaterialBuildState): this;
  59585. }
  59586. }
  59587. declare module BABYLON {
  59588. /**
  59589. * Block used to test if the fragment shader is front facing
  59590. */
  59591. export class FrontFacingBlock extends NodeMaterialBlock {
  59592. /**
  59593. * Creates a new FrontFacingBlock
  59594. * @param name defines the block name
  59595. */
  59596. constructor(name: string);
  59597. /**
  59598. * Gets the current class name
  59599. * @returns the class name
  59600. */
  59601. getClassName(): string;
  59602. /**
  59603. * Gets the output component
  59604. */
  59605. get output(): NodeMaterialConnectionPoint;
  59606. protected _buildBlock(state: NodeMaterialBuildState): this;
  59607. }
  59608. }
  59609. declare module BABYLON {
  59610. /**
  59611. * Block used to get the derivative value on x and y of a given input
  59612. */
  59613. export class DerivativeBlock extends NodeMaterialBlock {
  59614. /**
  59615. * Create a new DerivativeBlock
  59616. * @param name defines the block name
  59617. */
  59618. constructor(name: string);
  59619. /**
  59620. * Gets the current class name
  59621. * @returns the class name
  59622. */
  59623. getClassName(): string;
  59624. /**
  59625. * Gets the input component
  59626. */
  59627. get input(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the derivative output on x
  59630. */
  59631. get dx(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the derivative output on y
  59634. */
  59635. get dy(): NodeMaterialConnectionPoint;
  59636. protected _buildBlock(state: NodeMaterialBuildState): this;
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /**
  59641. * Block used to add support for scene fog
  59642. */
  59643. export class FogBlock extends NodeMaterialBlock {
  59644. private _fogDistanceName;
  59645. private _fogParameters;
  59646. /**
  59647. * Create a new FogBlock
  59648. * @param name defines the block name
  59649. */
  59650. constructor(name: string);
  59651. /**
  59652. * Gets the current class name
  59653. * @returns the class name
  59654. */
  59655. getClassName(): string;
  59656. /**
  59657. * Gets the world position input component
  59658. */
  59659. get worldPosition(): NodeMaterialConnectionPoint;
  59660. /**
  59661. * Gets the view input component
  59662. */
  59663. get view(): NodeMaterialConnectionPoint;
  59664. /**
  59665. * Gets the color input component
  59666. */
  59667. get input(): NodeMaterialConnectionPoint;
  59668. /**
  59669. * Gets the fog color input component
  59670. */
  59671. get fogColor(): NodeMaterialConnectionPoint;
  59672. /**
  59673. * Gets the output component
  59674. */
  59675. get output(): NodeMaterialConnectionPoint;
  59676. autoConfigure(material: NodeMaterial): void;
  59677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59679. protected _buildBlock(state: NodeMaterialBuildState): this;
  59680. }
  59681. }
  59682. declare module BABYLON {
  59683. /**
  59684. * Block used to add light in the fragment shader
  59685. */
  59686. export class LightBlock extends NodeMaterialBlock {
  59687. private _lightId;
  59688. /**
  59689. * Gets or sets the light associated with this block
  59690. */
  59691. light: Nullable<Light>;
  59692. /**
  59693. * Create a new LightBlock
  59694. * @param name defines the block name
  59695. */
  59696. constructor(name: string);
  59697. /**
  59698. * Gets the current class name
  59699. * @returns the class name
  59700. */
  59701. getClassName(): string;
  59702. /**
  59703. * Gets the world position input component
  59704. */
  59705. get worldPosition(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the world normal input component
  59708. */
  59709. get worldNormal(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the camera (or eye) position component
  59712. */
  59713. get cameraPosition(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the glossiness component
  59716. */
  59717. get glossiness(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the glossinness power component
  59720. */
  59721. get glossPower(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the diffuse color component
  59724. */
  59725. get diffuseColor(): NodeMaterialConnectionPoint;
  59726. /**
  59727. * Gets the specular color component
  59728. */
  59729. get specularColor(): NodeMaterialConnectionPoint;
  59730. /**
  59731. * Gets the diffuse output component
  59732. */
  59733. get diffuseOutput(): NodeMaterialConnectionPoint;
  59734. /**
  59735. * Gets the specular output component
  59736. */
  59737. get specularOutput(): NodeMaterialConnectionPoint;
  59738. /**
  59739. * Gets the shadow output component
  59740. */
  59741. get shadow(): NodeMaterialConnectionPoint;
  59742. autoConfigure(material: NodeMaterial): void;
  59743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59744. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59746. private _injectVertexCode;
  59747. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59748. serialize(): any;
  59749. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59750. }
  59751. }
  59752. declare module BABYLON {
  59753. /**
  59754. * Block used to read a reflection texture from a sampler
  59755. */
  59756. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  59757. /**
  59758. * Create a new ReflectionTextureBlock
  59759. * @param name defines the block name
  59760. */
  59761. constructor(name: string);
  59762. /**
  59763. * Gets the current class name
  59764. * @returns the class name
  59765. */
  59766. getClassName(): string;
  59767. /**
  59768. * Gets the world position input component
  59769. */
  59770. get position(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the world position input component
  59773. */
  59774. get worldPosition(): NodeMaterialConnectionPoint;
  59775. /**
  59776. * Gets the world normal input component
  59777. */
  59778. get worldNormal(): NodeMaterialConnectionPoint;
  59779. /**
  59780. * Gets the world input component
  59781. */
  59782. get world(): NodeMaterialConnectionPoint;
  59783. /**
  59784. * Gets the camera (or eye) position component
  59785. */
  59786. get cameraPosition(): NodeMaterialConnectionPoint;
  59787. /**
  59788. * Gets the view input component
  59789. */
  59790. get view(): NodeMaterialConnectionPoint;
  59791. /**
  59792. * Gets the rgb output component
  59793. */
  59794. get rgb(): NodeMaterialConnectionPoint;
  59795. /**
  59796. * Gets the r output component
  59797. */
  59798. get r(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the g output component
  59801. */
  59802. get g(): NodeMaterialConnectionPoint;
  59803. /**
  59804. * Gets the b output component
  59805. */
  59806. get b(): NodeMaterialConnectionPoint;
  59807. autoConfigure(material: NodeMaterial): void;
  59808. protected _buildBlock(state: NodeMaterialBuildState): this;
  59809. }
  59810. }
  59811. declare module BABYLON {
  59812. /**
  59813. * Block used to multiply 2 values
  59814. */
  59815. export class MultiplyBlock extends NodeMaterialBlock {
  59816. /**
  59817. * Creates a new MultiplyBlock
  59818. * @param name defines the block name
  59819. */
  59820. constructor(name: string);
  59821. /**
  59822. * Gets the current class name
  59823. * @returns the class name
  59824. */
  59825. getClassName(): string;
  59826. /**
  59827. * Gets the left operand input component
  59828. */
  59829. get left(): NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the right operand input component
  59832. */
  59833. get right(): NodeMaterialConnectionPoint;
  59834. /**
  59835. * Gets the output component
  59836. */
  59837. get output(): NodeMaterialConnectionPoint;
  59838. protected _buildBlock(state: NodeMaterialBuildState): this;
  59839. }
  59840. }
  59841. declare module BABYLON {
  59842. /**
  59843. * Block used to add 2 vectors
  59844. */
  59845. export class AddBlock extends NodeMaterialBlock {
  59846. /**
  59847. * Creates a new AddBlock
  59848. * @param name defines the block name
  59849. */
  59850. constructor(name: string);
  59851. /**
  59852. * Gets the current class name
  59853. * @returns the class name
  59854. */
  59855. getClassName(): string;
  59856. /**
  59857. * Gets the left operand input component
  59858. */
  59859. get left(): NodeMaterialConnectionPoint;
  59860. /**
  59861. * Gets the right operand input component
  59862. */
  59863. get right(): NodeMaterialConnectionPoint;
  59864. /**
  59865. * Gets the output component
  59866. */
  59867. get output(): NodeMaterialConnectionPoint;
  59868. protected _buildBlock(state: NodeMaterialBuildState): this;
  59869. }
  59870. }
  59871. declare module BABYLON {
  59872. /**
  59873. * Block used to scale a vector by a float
  59874. */
  59875. export class ScaleBlock extends NodeMaterialBlock {
  59876. /**
  59877. * Creates a new ScaleBlock
  59878. * @param name defines the block name
  59879. */
  59880. constructor(name: string);
  59881. /**
  59882. * Gets the current class name
  59883. * @returns the class name
  59884. */
  59885. getClassName(): string;
  59886. /**
  59887. * Gets the input component
  59888. */
  59889. get input(): NodeMaterialConnectionPoint;
  59890. /**
  59891. * Gets the factor input component
  59892. */
  59893. get factor(): NodeMaterialConnectionPoint;
  59894. /**
  59895. * Gets the output component
  59896. */
  59897. get output(): NodeMaterialConnectionPoint;
  59898. protected _buildBlock(state: NodeMaterialBuildState): this;
  59899. }
  59900. }
  59901. declare module BABYLON {
  59902. /**
  59903. * Block used to clamp a float
  59904. */
  59905. export class ClampBlock extends NodeMaterialBlock {
  59906. /** Gets or sets the minimum range */
  59907. minimum: number;
  59908. /** Gets or sets the maximum range */
  59909. maximum: number;
  59910. /**
  59911. * Creates a new ClampBlock
  59912. * @param name defines the block name
  59913. */
  59914. constructor(name: string);
  59915. /**
  59916. * Gets the current class name
  59917. * @returns the class name
  59918. */
  59919. getClassName(): string;
  59920. /**
  59921. * Gets the value input component
  59922. */
  59923. get value(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the output component
  59926. */
  59927. get output(): NodeMaterialConnectionPoint;
  59928. protected _buildBlock(state: NodeMaterialBuildState): this;
  59929. protected _dumpPropertiesCode(): string;
  59930. serialize(): any;
  59931. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /**
  59936. * Block used to apply a cross product between 2 vectors
  59937. */
  59938. export class CrossBlock extends NodeMaterialBlock {
  59939. /**
  59940. * Creates a new CrossBlock
  59941. * @param name defines the block name
  59942. */
  59943. constructor(name: string);
  59944. /**
  59945. * Gets the current class name
  59946. * @returns the class name
  59947. */
  59948. getClassName(): string;
  59949. /**
  59950. * Gets the left operand input component
  59951. */
  59952. get left(): NodeMaterialConnectionPoint;
  59953. /**
  59954. * Gets the right operand input component
  59955. */
  59956. get right(): NodeMaterialConnectionPoint;
  59957. /**
  59958. * Gets the output component
  59959. */
  59960. get output(): NodeMaterialConnectionPoint;
  59961. protected _buildBlock(state: NodeMaterialBuildState): this;
  59962. }
  59963. }
  59964. declare module BABYLON {
  59965. /**
  59966. * Block used to apply a dot product between 2 vectors
  59967. */
  59968. export class DotBlock extends NodeMaterialBlock {
  59969. /**
  59970. * Creates a new DotBlock
  59971. * @param name defines the block name
  59972. */
  59973. constructor(name: string);
  59974. /**
  59975. * Gets the current class name
  59976. * @returns the class name
  59977. */
  59978. getClassName(): string;
  59979. /**
  59980. * Gets the left operand input component
  59981. */
  59982. get left(): NodeMaterialConnectionPoint;
  59983. /**
  59984. * Gets the right operand input component
  59985. */
  59986. get right(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the output component
  59989. */
  59990. get output(): NodeMaterialConnectionPoint;
  59991. protected _buildBlock(state: NodeMaterialBuildState): this;
  59992. }
  59993. }
  59994. declare module BABYLON {
  59995. /**
  59996. * Block used to remap a float from a range to a new one
  59997. */
  59998. export class RemapBlock extends NodeMaterialBlock {
  59999. /**
  60000. * Gets or sets the source range
  60001. */
  60002. sourceRange: Vector2;
  60003. /**
  60004. * Gets or sets the target range
  60005. */
  60006. targetRange: Vector2;
  60007. /**
  60008. * Creates a new RemapBlock
  60009. * @param name defines the block name
  60010. */
  60011. constructor(name: string);
  60012. /**
  60013. * Gets the current class name
  60014. * @returns the class name
  60015. */
  60016. getClassName(): string;
  60017. /**
  60018. * Gets the input component
  60019. */
  60020. get input(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the source min input component
  60023. */
  60024. get sourceMin(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the source max input component
  60027. */
  60028. get sourceMax(): NodeMaterialConnectionPoint;
  60029. /**
  60030. * Gets the target min input component
  60031. */
  60032. get targetMin(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the target max input component
  60035. */
  60036. get targetMax(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the output component
  60039. */
  60040. get output(): NodeMaterialConnectionPoint;
  60041. protected _buildBlock(state: NodeMaterialBuildState): this;
  60042. protected _dumpPropertiesCode(): string;
  60043. serialize(): any;
  60044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60045. }
  60046. }
  60047. declare module BABYLON {
  60048. /**
  60049. * Block used to normalize a vector
  60050. */
  60051. export class NormalizeBlock extends NodeMaterialBlock {
  60052. /**
  60053. * Creates a new NormalizeBlock
  60054. * @param name defines the block name
  60055. */
  60056. constructor(name: string);
  60057. /**
  60058. * Gets the current class name
  60059. * @returns the class name
  60060. */
  60061. getClassName(): string;
  60062. /**
  60063. * Gets the input component
  60064. */
  60065. get input(): NodeMaterialConnectionPoint;
  60066. /**
  60067. * Gets the output component
  60068. */
  60069. get output(): NodeMaterialConnectionPoint;
  60070. protected _buildBlock(state: NodeMaterialBuildState): this;
  60071. }
  60072. }
  60073. declare module BABYLON {
  60074. /**
  60075. * Operations supported by the Trigonometry block
  60076. */
  60077. export enum TrigonometryBlockOperations {
  60078. /** Cos */
  60079. Cos = 0,
  60080. /** Sin */
  60081. Sin = 1,
  60082. /** Abs */
  60083. Abs = 2,
  60084. /** Exp */
  60085. Exp = 3,
  60086. /** Exp2 */
  60087. Exp2 = 4,
  60088. /** Round */
  60089. Round = 5,
  60090. /** Floor */
  60091. Floor = 6,
  60092. /** Ceiling */
  60093. Ceiling = 7,
  60094. /** Square root */
  60095. Sqrt = 8,
  60096. /** Log */
  60097. Log = 9,
  60098. /** Tangent */
  60099. Tan = 10,
  60100. /** Arc tangent */
  60101. ArcTan = 11,
  60102. /** Arc cosinus */
  60103. ArcCos = 12,
  60104. /** Arc sinus */
  60105. ArcSin = 13,
  60106. /** Fraction */
  60107. Fract = 14,
  60108. /** Sign */
  60109. Sign = 15,
  60110. /** To radians (from degrees) */
  60111. Radians = 16,
  60112. /** To degrees (from radians) */
  60113. Degrees = 17
  60114. }
  60115. /**
  60116. * Block used to apply trigonometry operation to floats
  60117. */
  60118. export class TrigonometryBlock extends NodeMaterialBlock {
  60119. /**
  60120. * Gets or sets the operation applied by the block
  60121. */
  60122. operation: TrigonometryBlockOperations;
  60123. /**
  60124. * Creates a new TrigonometryBlock
  60125. * @param name defines the block name
  60126. */
  60127. constructor(name: string);
  60128. /**
  60129. * Gets the current class name
  60130. * @returns the class name
  60131. */
  60132. getClassName(): string;
  60133. /**
  60134. * Gets the input component
  60135. */
  60136. get input(): NodeMaterialConnectionPoint;
  60137. /**
  60138. * Gets the output component
  60139. */
  60140. get output(): NodeMaterialConnectionPoint;
  60141. protected _buildBlock(state: NodeMaterialBuildState): this;
  60142. serialize(): any;
  60143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60144. protected _dumpPropertiesCode(): string;
  60145. }
  60146. }
  60147. declare module BABYLON {
  60148. /**
  60149. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60150. */
  60151. export class ColorMergerBlock extends NodeMaterialBlock {
  60152. /**
  60153. * Create a new ColorMergerBlock
  60154. * @param name defines the block name
  60155. */
  60156. constructor(name: string);
  60157. /**
  60158. * Gets the current class name
  60159. * @returns the class name
  60160. */
  60161. getClassName(): string;
  60162. /**
  60163. * Gets the rgb component (input)
  60164. */
  60165. get rgbIn(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the r component (input)
  60168. */
  60169. get r(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the g component (input)
  60172. */
  60173. get g(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the b component (input)
  60176. */
  60177. get b(): NodeMaterialConnectionPoint;
  60178. /**
  60179. * Gets the a component (input)
  60180. */
  60181. get a(): NodeMaterialConnectionPoint;
  60182. /**
  60183. * Gets the rgba component (output)
  60184. */
  60185. get rgba(): NodeMaterialConnectionPoint;
  60186. /**
  60187. * Gets the rgb component (output)
  60188. */
  60189. get rgbOut(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the rgb component (output)
  60192. * @deprecated Please use rgbOut instead.
  60193. */
  60194. get rgb(): NodeMaterialConnectionPoint;
  60195. protected _buildBlock(state: NodeMaterialBuildState): this;
  60196. }
  60197. }
  60198. declare module BABYLON {
  60199. /**
  60200. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60201. */
  60202. export class VectorMergerBlock extends NodeMaterialBlock {
  60203. /**
  60204. * Create a new VectorMergerBlock
  60205. * @param name defines the block name
  60206. */
  60207. constructor(name: string);
  60208. /**
  60209. * Gets the current class name
  60210. * @returns the class name
  60211. */
  60212. getClassName(): string;
  60213. /**
  60214. * Gets the xyz component (input)
  60215. */
  60216. get xyzIn(): NodeMaterialConnectionPoint;
  60217. /**
  60218. * Gets the xy component (input)
  60219. */
  60220. get xyIn(): NodeMaterialConnectionPoint;
  60221. /**
  60222. * Gets the x component (input)
  60223. */
  60224. get x(): NodeMaterialConnectionPoint;
  60225. /**
  60226. * Gets the y component (input)
  60227. */
  60228. get y(): NodeMaterialConnectionPoint;
  60229. /**
  60230. * Gets the z component (input)
  60231. */
  60232. get z(): NodeMaterialConnectionPoint;
  60233. /**
  60234. * Gets the w component (input)
  60235. */
  60236. get w(): NodeMaterialConnectionPoint;
  60237. /**
  60238. * Gets the xyzw component (output)
  60239. */
  60240. get xyzw(): NodeMaterialConnectionPoint;
  60241. /**
  60242. * Gets the xyz component (output)
  60243. */
  60244. get xyzOut(): NodeMaterialConnectionPoint;
  60245. /**
  60246. * Gets the xy component (output)
  60247. */
  60248. get xyOut(): NodeMaterialConnectionPoint;
  60249. /**
  60250. * Gets the xy component (output)
  60251. * @deprecated Please use xyOut instead.
  60252. */
  60253. get xy(): NodeMaterialConnectionPoint;
  60254. /**
  60255. * Gets the xyz component (output)
  60256. * @deprecated Please use xyzOut instead.
  60257. */
  60258. get xyz(): NodeMaterialConnectionPoint;
  60259. protected _buildBlock(state: NodeMaterialBuildState): this;
  60260. }
  60261. }
  60262. declare module BABYLON {
  60263. /**
  60264. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60265. */
  60266. export class ColorSplitterBlock extends NodeMaterialBlock {
  60267. /**
  60268. * Create a new ColorSplitterBlock
  60269. * @param name defines the block name
  60270. */
  60271. constructor(name: string);
  60272. /**
  60273. * Gets the current class name
  60274. * @returns the class name
  60275. */
  60276. getClassName(): string;
  60277. /**
  60278. * Gets the rgba component (input)
  60279. */
  60280. get rgba(): NodeMaterialConnectionPoint;
  60281. /**
  60282. * Gets the rgb component (input)
  60283. */
  60284. get rgbIn(): NodeMaterialConnectionPoint;
  60285. /**
  60286. * Gets the rgb component (output)
  60287. */
  60288. get rgbOut(): NodeMaterialConnectionPoint;
  60289. /**
  60290. * Gets the r component (output)
  60291. */
  60292. get r(): NodeMaterialConnectionPoint;
  60293. /**
  60294. * Gets the g component (output)
  60295. */
  60296. get g(): NodeMaterialConnectionPoint;
  60297. /**
  60298. * Gets the b component (output)
  60299. */
  60300. get b(): NodeMaterialConnectionPoint;
  60301. /**
  60302. * Gets the a component (output)
  60303. */
  60304. get a(): NodeMaterialConnectionPoint;
  60305. protected _inputRename(name: string): string;
  60306. protected _outputRename(name: string): string;
  60307. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60308. }
  60309. }
  60310. declare module BABYLON {
  60311. /**
  60312. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60313. */
  60314. export class VectorSplitterBlock extends NodeMaterialBlock {
  60315. /**
  60316. * Create a new VectorSplitterBlock
  60317. * @param name defines the block name
  60318. */
  60319. constructor(name: string);
  60320. /**
  60321. * Gets the current class name
  60322. * @returns the class name
  60323. */
  60324. getClassName(): string;
  60325. /**
  60326. * Gets the xyzw component (input)
  60327. */
  60328. get xyzw(): NodeMaterialConnectionPoint;
  60329. /**
  60330. * Gets the xyz component (input)
  60331. */
  60332. get xyzIn(): NodeMaterialConnectionPoint;
  60333. /**
  60334. * Gets the xy component (input)
  60335. */
  60336. get xyIn(): NodeMaterialConnectionPoint;
  60337. /**
  60338. * Gets the xyz component (output)
  60339. */
  60340. get xyzOut(): NodeMaterialConnectionPoint;
  60341. /**
  60342. * Gets the xy component (output)
  60343. */
  60344. get xyOut(): NodeMaterialConnectionPoint;
  60345. /**
  60346. * Gets the x component (output)
  60347. */
  60348. get x(): NodeMaterialConnectionPoint;
  60349. /**
  60350. * Gets the y component (output)
  60351. */
  60352. get y(): NodeMaterialConnectionPoint;
  60353. /**
  60354. * Gets the z component (output)
  60355. */
  60356. get z(): NodeMaterialConnectionPoint;
  60357. /**
  60358. * Gets the w component (output)
  60359. */
  60360. get w(): NodeMaterialConnectionPoint;
  60361. protected _inputRename(name: string): string;
  60362. protected _outputRename(name: string): string;
  60363. protected _buildBlock(state: NodeMaterialBuildState): this;
  60364. }
  60365. }
  60366. declare module BABYLON {
  60367. /**
  60368. * Block used to lerp between 2 values
  60369. */
  60370. export class LerpBlock extends NodeMaterialBlock {
  60371. /**
  60372. * Creates a new LerpBlock
  60373. * @param name defines the block name
  60374. */
  60375. constructor(name: string);
  60376. /**
  60377. * Gets the current class name
  60378. * @returns the class name
  60379. */
  60380. getClassName(): string;
  60381. /**
  60382. * Gets the left operand input component
  60383. */
  60384. get left(): NodeMaterialConnectionPoint;
  60385. /**
  60386. * Gets the right operand input component
  60387. */
  60388. get right(): NodeMaterialConnectionPoint;
  60389. /**
  60390. * Gets the gradient operand input component
  60391. */
  60392. get gradient(): NodeMaterialConnectionPoint;
  60393. /**
  60394. * Gets the output component
  60395. */
  60396. get output(): NodeMaterialConnectionPoint;
  60397. protected _buildBlock(state: NodeMaterialBuildState): this;
  60398. }
  60399. }
  60400. declare module BABYLON {
  60401. /**
  60402. * Block used to divide 2 vectors
  60403. */
  60404. export class DivideBlock extends NodeMaterialBlock {
  60405. /**
  60406. * Creates a new DivideBlock
  60407. * @param name defines the block name
  60408. */
  60409. constructor(name: string);
  60410. /**
  60411. * Gets the current class name
  60412. * @returns the class name
  60413. */
  60414. getClassName(): string;
  60415. /**
  60416. * Gets the left operand input component
  60417. */
  60418. get left(): NodeMaterialConnectionPoint;
  60419. /**
  60420. * Gets the right operand input component
  60421. */
  60422. get right(): NodeMaterialConnectionPoint;
  60423. /**
  60424. * Gets the output component
  60425. */
  60426. get output(): NodeMaterialConnectionPoint;
  60427. protected _buildBlock(state: NodeMaterialBuildState): this;
  60428. }
  60429. }
  60430. declare module BABYLON {
  60431. /**
  60432. * Block used to subtract 2 vectors
  60433. */
  60434. export class SubtractBlock extends NodeMaterialBlock {
  60435. /**
  60436. * Creates a new SubtractBlock
  60437. * @param name defines the block name
  60438. */
  60439. constructor(name: string);
  60440. /**
  60441. * Gets the current class name
  60442. * @returns the class name
  60443. */
  60444. getClassName(): string;
  60445. /**
  60446. * Gets the left operand input component
  60447. */
  60448. get left(): NodeMaterialConnectionPoint;
  60449. /**
  60450. * Gets the right operand input component
  60451. */
  60452. get right(): NodeMaterialConnectionPoint;
  60453. /**
  60454. * Gets the output component
  60455. */
  60456. get output(): NodeMaterialConnectionPoint;
  60457. protected _buildBlock(state: NodeMaterialBuildState): this;
  60458. }
  60459. }
  60460. declare module BABYLON {
  60461. /**
  60462. * Block used to step a value
  60463. */
  60464. export class StepBlock extends NodeMaterialBlock {
  60465. /**
  60466. * Creates a new StepBlock
  60467. * @param name defines the block name
  60468. */
  60469. constructor(name: string);
  60470. /**
  60471. * Gets the current class name
  60472. * @returns the class name
  60473. */
  60474. getClassName(): string;
  60475. /**
  60476. * Gets the value operand input component
  60477. */
  60478. get value(): NodeMaterialConnectionPoint;
  60479. /**
  60480. * Gets the edge operand input component
  60481. */
  60482. get edge(): NodeMaterialConnectionPoint;
  60483. /**
  60484. * Gets the output component
  60485. */
  60486. get output(): NodeMaterialConnectionPoint;
  60487. protected _buildBlock(state: NodeMaterialBuildState): this;
  60488. }
  60489. }
  60490. declare module BABYLON {
  60491. /**
  60492. * Block used to get the opposite (1 - x) of a value
  60493. */
  60494. export class OneMinusBlock extends NodeMaterialBlock {
  60495. /**
  60496. * Creates a new OneMinusBlock
  60497. * @param name defines the block name
  60498. */
  60499. constructor(name: string);
  60500. /**
  60501. * Gets the current class name
  60502. * @returns the class name
  60503. */
  60504. getClassName(): string;
  60505. /**
  60506. * Gets the input component
  60507. */
  60508. get input(): NodeMaterialConnectionPoint;
  60509. /**
  60510. * Gets the output component
  60511. */
  60512. get output(): NodeMaterialConnectionPoint;
  60513. protected _buildBlock(state: NodeMaterialBuildState): this;
  60514. }
  60515. }
  60516. declare module BABYLON {
  60517. /**
  60518. * Block used to get the view direction
  60519. */
  60520. export class ViewDirectionBlock extends NodeMaterialBlock {
  60521. /**
  60522. * Creates a new ViewDirectionBlock
  60523. * @param name defines the block name
  60524. */
  60525. constructor(name: string);
  60526. /**
  60527. * Gets the current class name
  60528. * @returns the class name
  60529. */
  60530. getClassName(): string;
  60531. /**
  60532. * Gets the world position component
  60533. */
  60534. get worldPosition(): NodeMaterialConnectionPoint;
  60535. /**
  60536. * Gets the camera position component
  60537. */
  60538. get cameraPosition(): NodeMaterialConnectionPoint;
  60539. /**
  60540. * Gets the output component
  60541. */
  60542. get output(): NodeMaterialConnectionPoint;
  60543. autoConfigure(material: NodeMaterial): void;
  60544. protected _buildBlock(state: NodeMaterialBuildState): this;
  60545. }
  60546. }
  60547. declare module BABYLON {
  60548. /**
  60549. * Block used to compute fresnel value
  60550. */
  60551. export class FresnelBlock extends NodeMaterialBlock {
  60552. /**
  60553. * Create a new FresnelBlock
  60554. * @param name defines the block name
  60555. */
  60556. constructor(name: string);
  60557. /**
  60558. * Gets the current class name
  60559. * @returns the class name
  60560. */
  60561. getClassName(): string;
  60562. /**
  60563. * Gets the world normal input component
  60564. */
  60565. get worldNormal(): NodeMaterialConnectionPoint;
  60566. /**
  60567. * Gets the view direction input component
  60568. */
  60569. get viewDirection(): NodeMaterialConnectionPoint;
  60570. /**
  60571. * Gets the bias input component
  60572. */
  60573. get bias(): NodeMaterialConnectionPoint;
  60574. /**
  60575. * Gets the camera (or eye) position component
  60576. */
  60577. get power(): NodeMaterialConnectionPoint;
  60578. /**
  60579. * Gets the fresnel output component
  60580. */
  60581. get fresnel(): NodeMaterialConnectionPoint;
  60582. autoConfigure(material: NodeMaterial): void;
  60583. protected _buildBlock(state: NodeMaterialBuildState): this;
  60584. }
  60585. }
  60586. declare module BABYLON {
  60587. /**
  60588. * Block used to get the max of 2 values
  60589. */
  60590. export class MaxBlock extends NodeMaterialBlock {
  60591. /**
  60592. * Creates a new MaxBlock
  60593. * @param name defines the block name
  60594. */
  60595. constructor(name: string);
  60596. /**
  60597. * Gets the current class name
  60598. * @returns the class name
  60599. */
  60600. getClassName(): string;
  60601. /**
  60602. * Gets the left operand input component
  60603. */
  60604. get left(): NodeMaterialConnectionPoint;
  60605. /**
  60606. * Gets the right operand input component
  60607. */
  60608. get right(): NodeMaterialConnectionPoint;
  60609. /**
  60610. * Gets the output component
  60611. */
  60612. get output(): NodeMaterialConnectionPoint;
  60613. protected _buildBlock(state: NodeMaterialBuildState): this;
  60614. }
  60615. }
  60616. declare module BABYLON {
  60617. /**
  60618. * Block used to get the min of 2 values
  60619. */
  60620. export class MinBlock extends NodeMaterialBlock {
  60621. /**
  60622. * Creates a new MinBlock
  60623. * @param name defines the block name
  60624. */
  60625. constructor(name: string);
  60626. /**
  60627. * Gets the current class name
  60628. * @returns the class name
  60629. */
  60630. getClassName(): string;
  60631. /**
  60632. * Gets the left operand input component
  60633. */
  60634. get left(): NodeMaterialConnectionPoint;
  60635. /**
  60636. * Gets the right operand input component
  60637. */
  60638. get right(): NodeMaterialConnectionPoint;
  60639. /**
  60640. * Gets the output component
  60641. */
  60642. get output(): NodeMaterialConnectionPoint;
  60643. protected _buildBlock(state: NodeMaterialBuildState): this;
  60644. }
  60645. }
  60646. declare module BABYLON {
  60647. /**
  60648. * Block used to get the distance between 2 values
  60649. */
  60650. export class DistanceBlock extends NodeMaterialBlock {
  60651. /**
  60652. * Creates a new DistanceBlock
  60653. * @param name defines the block name
  60654. */
  60655. constructor(name: string);
  60656. /**
  60657. * Gets the current class name
  60658. * @returns the class name
  60659. */
  60660. getClassName(): string;
  60661. /**
  60662. * Gets the left operand input component
  60663. */
  60664. get left(): NodeMaterialConnectionPoint;
  60665. /**
  60666. * Gets the right operand input component
  60667. */
  60668. get right(): NodeMaterialConnectionPoint;
  60669. /**
  60670. * Gets the output component
  60671. */
  60672. get output(): NodeMaterialConnectionPoint;
  60673. protected _buildBlock(state: NodeMaterialBuildState): this;
  60674. }
  60675. }
  60676. declare module BABYLON {
  60677. /**
  60678. * Block used to get the length of a vector
  60679. */
  60680. export class LengthBlock extends NodeMaterialBlock {
  60681. /**
  60682. * Creates a new LengthBlock
  60683. * @param name defines the block name
  60684. */
  60685. constructor(name: string);
  60686. /**
  60687. * Gets the current class name
  60688. * @returns the class name
  60689. */
  60690. getClassName(): string;
  60691. /**
  60692. * Gets the value input component
  60693. */
  60694. get value(): NodeMaterialConnectionPoint;
  60695. /**
  60696. * Gets the output component
  60697. */
  60698. get output(): NodeMaterialConnectionPoint;
  60699. protected _buildBlock(state: NodeMaterialBuildState): this;
  60700. }
  60701. }
  60702. declare module BABYLON {
  60703. /**
  60704. * Block used to get negative version of a value (i.e. x * -1)
  60705. */
  60706. export class NegateBlock extends NodeMaterialBlock {
  60707. /**
  60708. * Creates a new NegateBlock
  60709. * @param name defines the block name
  60710. */
  60711. constructor(name: string);
  60712. /**
  60713. * Gets the current class name
  60714. * @returns the class name
  60715. */
  60716. getClassName(): string;
  60717. /**
  60718. * Gets the value input component
  60719. */
  60720. get value(): NodeMaterialConnectionPoint;
  60721. /**
  60722. * Gets the output component
  60723. */
  60724. get output(): NodeMaterialConnectionPoint;
  60725. protected _buildBlock(state: NodeMaterialBuildState): this;
  60726. }
  60727. }
  60728. declare module BABYLON {
  60729. /**
  60730. * Block used to get the value of the first parameter raised to the power of the second
  60731. */
  60732. export class PowBlock extends NodeMaterialBlock {
  60733. /**
  60734. * Creates a new PowBlock
  60735. * @param name defines the block name
  60736. */
  60737. constructor(name: string);
  60738. /**
  60739. * Gets the current class name
  60740. * @returns the class name
  60741. */
  60742. getClassName(): string;
  60743. /**
  60744. * Gets the value operand input component
  60745. */
  60746. get value(): NodeMaterialConnectionPoint;
  60747. /**
  60748. * Gets the power operand input component
  60749. */
  60750. get power(): NodeMaterialConnectionPoint;
  60751. /**
  60752. * Gets the output component
  60753. */
  60754. get output(): NodeMaterialConnectionPoint;
  60755. protected _buildBlock(state: NodeMaterialBuildState): this;
  60756. }
  60757. }
  60758. declare module BABYLON {
  60759. /**
  60760. * Block used to get a random number
  60761. */
  60762. export class RandomNumberBlock extends NodeMaterialBlock {
  60763. /**
  60764. * Creates a new RandomNumberBlock
  60765. * @param name defines the block name
  60766. */
  60767. constructor(name: string);
  60768. /**
  60769. * Gets the current class name
  60770. * @returns the class name
  60771. */
  60772. getClassName(): string;
  60773. /**
  60774. * Gets the seed input component
  60775. */
  60776. get seed(): NodeMaterialConnectionPoint;
  60777. /**
  60778. * Gets the output component
  60779. */
  60780. get output(): NodeMaterialConnectionPoint;
  60781. protected _buildBlock(state: NodeMaterialBuildState): this;
  60782. }
  60783. }
  60784. declare module BABYLON {
  60785. /**
  60786. * Block used to compute arc tangent of 2 values
  60787. */
  60788. export class ArcTan2Block extends NodeMaterialBlock {
  60789. /**
  60790. * Creates a new ArcTan2Block
  60791. * @param name defines the block name
  60792. */
  60793. constructor(name: string);
  60794. /**
  60795. * Gets the current class name
  60796. * @returns the class name
  60797. */
  60798. getClassName(): string;
  60799. /**
  60800. * Gets the x operand input component
  60801. */
  60802. get x(): NodeMaterialConnectionPoint;
  60803. /**
  60804. * Gets the y operand input component
  60805. */
  60806. get y(): NodeMaterialConnectionPoint;
  60807. /**
  60808. * Gets the output component
  60809. */
  60810. get output(): NodeMaterialConnectionPoint;
  60811. protected _buildBlock(state: NodeMaterialBuildState): this;
  60812. }
  60813. }
  60814. declare module BABYLON {
  60815. /**
  60816. * Block used to smooth step a value
  60817. */
  60818. export class SmoothStepBlock extends NodeMaterialBlock {
  60819. /**
  60820. * Creates a new SmoothStepBlock
  60821. * @param name defines the block name
  60822. */
  60823. constructor(name: string);
  60824. /**
  60825. * Gets the current class name
  60826. * @returns the class name
  60827. */
  60828. getClassName(): string;
  60829. /**
  60830. * Gets the value operand input component
  60831. */
  60832. get value(): NodeMaterialConnectionPoint;
  60833. /**
  60834. * Gets the first edge operand input component
  60835. */
  60836. get edge0(): NodeMaterialConnectionPoint;
  60837. /**
  60838. * Gets the second edge operand input component
  60839. */
  60840. get edge1(): NodeMaterialConnectionPoint;
  60841. /**
  60842. * Gets the output component
  60843. */
  60844. get output(): NodeMaterialConnectionPoint;
  60845. protected _buildBlock(state: NodeMaterialBuildState): this;
  60846. }
  60847. }
  60848. declare module BABYLON {
  60849. /**
  60850. * Block used to get the reciprocal (1 / x) of a value
  60851. */
  60852. export class ReciprocalBlock extends NodeMaterialBlock {
  60853. /**
  60854. * Creates a new ReciprocalBlock
  60855. * @param name defines the block name
  60856. */
  60857. constructor(name: string);
  60858. /**
  60859. * Gets the current class name
  60860. * @returns the class name
  60861. */
  60862. getClassName(): string;
  60863. /**
  60864. * Gets the input component
  60865. */
  60866. get input(): NodeMaterialConnectionPoint;
  60867. /**
  60868. * Gets the output component
  60869. */
  60870. get output(): NodeMaterialConnectionPoint;
  60871. protected _buildBlock(state: NodeMaterialBuildState): this;
  60872. }
  60873. }
  60874. declare module BABYLON {
  60875. /**
  60876. * Block used to replace a color by another one
  60877. */
  60878. export class ReplaceColorBlock extends NodeMaterialBlock {
  60879. /**
  60880. * Creates a new ReplaceColorBlock
  60881. * @param name defines the block name
  60882. */
  60883. constructor(name: string);
  60884. /**
  60885. * Gets the current class name
  60886. * @returns the class name
  60887. */
  60888. getClassName(): string;
  60889. /**
  60890. * Gets the value input component
  60891. */
  60892. get value(): NodeMaterialConnectionPoint;
  60893. /**
  60894. * Gets the reference input component
  60895. */
  60896. get reference(): NodeMaterialConnectionPoint;
  60897. /**
  60898. * Gets the distance input component
  60899. */
  60900. get distance(): NodeMaterialConnectionPoint;
  60901. /**
  60902. * Gets the replacement input component
  60903. */
  60904. get replacement(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the output component
  60907. */
  60908. get output(): NodeMaterialConnectionPoint;
  60909. protected _buildBlock(state: NodeMaterialBuildState): this;
  60910. }
  60911. }
  60912. declare module BABYLON {
  60913. /**
  60914. * Block used to posterize a value
  60915. * @see https://en.wikipedia.org/wiki/Posterization
  60916. */
  60917. export class PosterizeBlock extends NodeMaterialBlock {
  60918. /**
  60919. * Creates a new PosterizeBlock
  60920. * @param name defines the block name
  60921. */
  60922. constructor(name: string);
  60923. /**
  60924. * Gets the current class name
  60925. * @returns the class name
  60926. */
  60927. getClassName(): string;
  60928. /**
  60929. * Gets the value input component
  60930. */
  60931. get value(): NodeMaterialConnectionPoint;
  60932. /**
  60933. * Gets the steps input component
  60934. */
  60935. get steps(): NodeMaterialConnectionPoint;
  60936. /**
  60937. * Gets the output component
  60938. */
  60939. get output(): NodeMaterialConnectionPoint;
  60940. protected _buildBlock(state: NodeMaterialBuildState): this;
  60941. }
  60942. }
  60943. declare module BABYLON {
  60944. /**
  60945. * Operations supported by the Wave block
  60946. */
  60947. export enum WaveBlockKind {
  60948. /** SawTooth */
  60949. SawTooth = 0,
  60950. /** Square */
  60951. Square = 1,
  60952. /** Triangle */
  60953. Triangle = 2
  60954. }
  60955. /**
  60956. * Block used to apply wave operation to floats
  60957. */
  60958. export class WaveBlock extends NodeMaterialBlock {
  60959. /**
  60960. * Gets or sets the kibnd of wave to be applied by the block
  60961. */
  60962. kind: WaveBlockKind;
  60963. /**
  60964. * Creates a new WaveBlock
  60965. * @param name defines the block name
  60966. */
  60967. constructor(name: string);
  60968. /**
  60969. * Gets the current class name
  60970. * @returns the class name
  60971. */
  60972. getClassName(): string;
  60973. /**
  60974. * Gets the input component
  60975. */
  60976. get input(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the output component
  60979. */
  60980. get output(): NodeMaterialConnectionPoint;
  60981. protected _buildBlock(state: NodeMaterialBuildState): this;
  60982. serialize(): any;
  60983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60984. }
  60985. }
  60986. declare module BABYLON {
  60987. /**
  60988. * Class used to store a color step for the GradientBlock
  60989. */
  60990. export class GradientBlockColorStep {
  60991. /**
  60992. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60993. */
  60994. step: number;
  60995. /**
  60996. * Gets or sets the color associated with this step
  60997. */
  60998. color: Color3;
  60999. /**
  61000. * Creates a new GradientBlockColorStep
  61001. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61002. * @param color defines the color associated with this step
  61003. */
  61004. constructor(
  61005. /**
  61006. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61007. */
  61008. step: number,
  61009. /**
  61010. * Gets or sets the color associated with this step
  61011. */
  61012. color: Color3);
  61013. }
  61014. /**
  61015. * Block used to return a color from a gradient based on an input value between 0 and 1
  61016. */
  61017. export class GradientBlock extends NodeMaterialBlock {
  61018. /**
  61019. * Gets or sets the list of color steps
  61020. */
  61021. colorSteps: GradientBlockColorStep[];
  61022. /**
  61023. * Creates a new GradientBlock
  61024. * @param name defines the block name
  61025. */
  61026. constructor(name: string);
  61027. /**
  61028. * Gets the current class name
  61029. * @returns the class name
  61030. */
  61031. getClassName(): string;
  61032. /**
  61033. * Gets the gradient input component
  61034. */
  61035. get gradient(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the output component
  61038. */
  61039. get output(): NodeMaterialConnectionPoint;
  61040. private _writeColorConstant;
  61041. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61042. serialize(): any;
  61043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61044. protected _dumpPropertiesCode(): string;
  61045. }
  61046. }
  61047. declare module BABYLON {
  61048. /**
  61049. * Block used to normalize lerp between 2 values
  61050. */
  61051. export class NLerpBlock extends NodeMaterialBlock {
  61052. /**
  61053. * Creates a new NLerpBlock
  61054. * @param name defines the block name
  61055. */
  61056. constructor(name: string);
  61057. /**
  61058. * Gets the current class name
  61059. * @returns the class name
  61060. */
  61061. getClassName(): string;
  61062. /**
  61063. * Gets the left operand input component
  61064. */
  61065. get left(): NodeMaterialConnectionPoint;
  61066. /**
  61067. * Gets the right operand input component
  61068. */
  61069. get right(): NodeMaterialConnectionPoint;
  61070. /**
  61071. * Gets the gradient operand input component
  61072. */
  61073. get gradient(): NodeMaterialConnectionPoint;
  61074. /**
  61075. * Gets the output component
  61076. */
  61077. get output(): NodeMaterialConnectionPoint;
  61078. protected _buildBlock(state: NodeMaterialBuildState): this;
  61079. }
  61080. }
  61081. declare module BABYLON {
  61082. /**
  61083. * block used to Generate a Worley Noise 3D Noise Pattern
  61084. */
  61085. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61086. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61087. manhattanDistance: boolean;
  61088. /**
  61089. * Creates a new WorleyNoise3DBlock
  61090. * @param name defines the block name
  61091. */
  61092. constructor(name: string);
  61093. /**
  61094. * Gets the current class name
  61095. * @returns the class name
  61096. */
  61097. getClassName(): string;
  61098. /**
  61099. * Gets the seed input component
  61100. */
  61101. get seed(): NodeMaterialConnectionPoint;
  61102. /**
  61103. * Gets the jitter input component
  61104. */
  61105. get jitter(): NodeMaterialConnectionPoint;
  61106. /**
  61107. * Gets the output component
  61108. */
  61109. get output(): NodeMaterialConnectionPoint;
  61110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61111. /**
  61112. * Exposes the properties to the UI?
  61113. */
  61114. protected _dumpPropertiesCode(): string;
  61115. /**
  61116. * Exposes the properties to the Seralize?
  61117. */
  61118. serialize(): any;
  61119. /**
  61120. * Exposes the properties to the deseralize?
  61121. */
  61122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61123. }
  61124. }
  61125. declare module BABYLON {
  61126. /**
  61127. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61128. */
  61129. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61130. /**
  61131. * Creates a new SimplexPerlin3DBlock
  61132. * @param name defines the block name
  61133. */
  61134. constructor(name: string);
  61135. /**
  61136. * Gets the current class name
  61137. * @returns the class name
  61138. */
  61139. getClassName(): string;
  61140. /**
  61141. * Gets the seed operand input component
  61142. */
  61143. get seed(): NodeMaterialConnectionPoint;
  61144. /**
  61145. * Gets the output component
  61146. */
  61147. get output(): NodeMaterialConnectionPoint;
  61148. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61149. }
  61150. }
  61151. declare module BABYLON {
  61152. /**
  61153. * Block used to blend normals
  61154. */
  61155. export class NormalBlendBlock extends NodeMaterialBlock {
  61156. /**
  61157. * Creates a new NormalBlendBlock
  61158. * @param name defines the block name
  61159. */
  61160. constructor(name: string);
  61161. /**
  61162. * Gets the current class name
  61163. * @returns the class name
  61164. */
  61165. getClassName(): string;
  61166. /**
  61167. * Gets the first input component
  61168. */
  61169. get normalMap0(): NodeMaterialConnectionPoint;
  61170. /**
  61171. * Gets the second input component
  61172. */
  61173. get normalMap1(): NodeMaterialConnectionPoint;
  61174. /**
  61175. * Gets the output component
  61176. */
  61177. get output(): NodeMaterialConnectionPoint;
  61178. protected _buildBlock(state: NodeMaterialBuildState): this;
  61179. }
  61180. }
  61181. declare module BABYLON {
  61182. /**
  61183. * Block used to rotate a 2d vector by a given angle
  61184. */
  61185. export class Rotate2dBlock extends NodeMaterialBlock {
  61186. /**
  61187. * Creates a new Rotate2dBlock
  61188. * @param name defines the block name
  61189. */
  61190. constructor(name: string);
  61191. /**
  61192. * Gets the current class name
  61193. * @returns the class name
  61194. */
  61195. getClassName(): string;
  61196. /**
  61197. * Gets the input vector
  61198. */
  61199. get input(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the input angle
  61202. */
  61203. get angle(): NodeMaterialConnectionPoint;
  61204. /**
  61205. * Gets the output component
  61206. */
  61207. get output(): NodeMaterialConnectionPoint;
  61208. autoConfigure(material: NodeMaterial): void;
  61209. protected _buildBlock(state: NodeMaterialBuildState): this;
  61210. }
  61211. }
  61212. declare module BABYLON {
  61213. /**
  61214. * Block used to get the reflected vector from a direction and a normal
  61215. */
  61216. export class ReflectBlock extends NodeMaterialBlock {
  61217. /**
  61218. * Creates a new ReflectBlock
  61219. * @param name defines the block name
  61220. */
  61221. constructor(name: string);
  61222. /**
  61223. * Gets the current class name
  61224. * @returns the class name
  61225. */
  61226. getClassName(): string;
  61227. /**
  61228. * Gets the incident component
  61229. */
  61230. get incident(): NodeMaterialConnectionPoint;
  61231. /**
  61232. * Gets the normal component
  61233. */
  61234. get normal(): NodeMaterialConnectionPoint;
  61235. /**
  61236. * Gets the output component
  61237. */
  61238. get output(): NodeMaterialConnectionPoint;
  61239. protected _buildBlock(state: NodeMaterialBuildState): this;
  61240. }
  61241. }
  61242. declare module BABYLON {
  61243. /**
  61244. * Block used to get the refracted vector from a direction and a normal
  61245. */
  61246. export class RefractBlock extends NodeMaterialBlock {
  61247. /**
  61248. * Creates a new RefractBlock
  61249. * @param name defines the block name
  61250. */
  61251. constructor(name: string);
  61252. /**
  61253. * Gets the current class name
  61254. * @returns the class name
  61255. */
  61256. getClassName(): string;
  61257. /**
  61258. * Gets the incident component
  61259. */
  61260. get incident(): NodeMaterialConnectionPoint;
  61261. /**
  61262. * Gets the normal component
  61263. */
  61264. get normal(): NodeMaterialConnectionPoint;
  61265. /**
  61266. * Gets the index of refraction component
  61267. */
  61268. get ior(): NodeMaterialConnectionPoint;
  61269. /**
  61270. * Gets the output component
  61271. */
  61272. get output(): NodeMaterialConnectionPoint;
  61273. protected _buildBlock(state: NodeMaterialBuildState): this;
  61274. }
  61275. }
  61276. declare module BABYLON {
  61277. /**
  61278. * Block used to desaturate a color
  61279. */
  61280. export class DesaturateBlock extends NodeMaterialBlock {
  61281. /**
  61282. * Creates a new DesaturateBlock
  61283. * @param name defines the block name
  61284. */
  61285. constructor(name: string);
  61286. /**
  61287. * Gets the current class name
  61288. * @returns the class name
  61289. */
  61290. getClassName(): string;
  61291. /**
  61292. * Gets the color operand input component
  61293. */
  61294. get color(): NodeMaterialConnectionPoint;
  61295. /**
  61296. * Gets the level operand input component
  61297. */
  61298. get level(): NodeMaterialConnectionPoint;
  61299. /**
  61300. * Gets the output component
  61301. */
  61302. get output(): NodeMaterialConnectionPoint;
  61303. protected _buildBlock(state: NodeMaterialBuildState): this;
  61304. }
  61305. }
  61306. declare module BABYLON {
  61307. /**
  61308. * Block used to implement the ambient occlusion module of the PBR material
  61309. */
  61310. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  61311. /**
  61312. * Create a new AmbientOcclusionBlock
  61313. * @param name defines the block name
  61314. */
  61315. constructor(name: string);
  61316. /**
  61317. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  61318. */
  61319. useAmbientInGrayScale: boolean;
  61320. /**
  61321. * Initialize the block and prepare the context for build
  61322. * @param state defines the state that will be used for the build
  61323. */
  61324. initialize(state: NodeMaterialBuildState): void;
  61325. /**
  61326. * Gets the current class name
  61327. * @returns the class name
  61328. */
  61329. getClassName(): string;
  61330. /**
  61331. * Gets the texture input component
  61332. */
  61333. get texture(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the texture intensity component
  61336. */
  61337. get intensity(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the direct light intensity input component
  61340. */
  61341. get directLightIntensity(): NodeMaterialConnectionPoint;
  61342. /**
  61343. * Gets the ambient occlusion object output component
  61344. */
  61345. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61346. /**
  61347. * Gets the main code of the block (fragment side)
  61348. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  61349. * @returns the shader code
  61350. */
  61351. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  61352. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61353. protected _buildBlock(state: NodeMaterialBuildState): this;
  61354. protected _dumpPropertiesCode(): string;
  61355. serialize(): any;
  61356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * Block used to implement the reflection module of the PBR material
  61362. */
  61363. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  61364. /** @hidden */
  61365. _defineLODReflectionAlpha: string;
  61366. /** @hidden */
  61367. _defineLinearSpecularReflection: string;
  61368. private _vEnvironmentIrradianceName;
  61369. /** @hidden */
  61370. _vReflectionMicrosurfaceInfosName: string;
  61371. /** @hidden */
  61372. _vReflectionInfosName: string;
  61373. private _scene;
  61374. /**
  61375. * The three properties below are set by the main PBR block prior to calling methods of this class.
  61376. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61377. * It's less burden on the user side in the editor part.
  61378. */
  61379. /** @hidden */
  61380. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61381. /** @hidden */
  61382. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61383. /** @hidden */
  61384. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  61385. /**
  61386. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  61387. * diffuse part of the IBL.
  61388. */
  61389. useSphericalHarmonics: boolean;
  61390. /**
  61391. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  61392. */
  61393. forceIrradianceInFragment: boolean;
  61394. /**
  61395. * Create a new ReflectionBlock
  61396. * @param name defines the block name
  61397. */
  61398. constructor(name: string);
  61399. /**
  61400. * Gets the current class name
  61401. * @returns the class name
  61402. */
  61403. getClassName(): string;
  61404. /**
  61405. * Gets the position input component
  61406. */
  61407. get position(): NodeMaterialConnectionPoint;
  61408. /**
  61409. * Gets the world position input component
  61410. */
  61411. get worldPosition(): NodeMaterialConnectionPoint;
  61412. /**
  61413. * Gets the world normal input component
  61414. */
  61415. get worldNormal(): NodeMaterialConnectionPoint;
  61416. /**
  61417. * Gets the world input component
  61418. */
  61419. get world(): NodeMaterialConnectionPoint;
  61420. /**
  61421. * Gets the camera (or eye) position component
  61422. */
  61423. get cameraPosition(): NodeMaterialConnectionPoint;
  61424. /**
  61425. * Gets the view input component
  61426. */
  61427. get view(): NodeMaterialConnectionPoint;
  61428. /**
  61429. * Gets the color input component
  61430. */
  61431. get color(): NodeMaterialConnectionPoint;
  61432. /**
  61433. * Gets the reflection object output component
  61434. */
  61435. get reflection(): NodeMaterialConnectionPoint;
  61436. /**
  61437. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  61438. */
  61439. get hasTexture(): boolean;
  61440. /**
  61441. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  61442. */
  61443. get reflectionColor(): string;
  61444. protected _getTexture(): Nullable<BaseTexture>;
  61445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61447. /**
  61448. * Gets the code to inject in the vertex shader
  61449. * @param state current state of the node material building
  61450. * @returns the shader code
  61451. */
  61452. handleVertexSide(state: NodeMaterialBuildState): string;
  61453. /**
  61454. * Gets the main code of the block (fragment side)
  61455. * @param state current state of the node material building
  61456. * @param normalVarName name of the existing variable corresponding to the normal
  61457. * @returns the shader code
  61458. */
  61459. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  61460. protected _buildBlock(state: NodeMaterialBuildState): this;
  61461. protected _dumpPropertiesCode(): string;
  61462. serialize(): any;
  61463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61464. }
  61465. }
  61466. declare module BABYLON {
  61467. /**
  61468. * Block used to implement the sheen module of the PBR material
  61469. */
  61470. export class SheenBlock extends NodeMaterialBlock {
  61471. /**
  61472. * Create a new SheenBlock
  61473. * @param name defines the block name
  61474. */
  61475. constructor(name: string);
  61476. /**
  61477. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  61478. * It allows the strength of the sheen effect to not depend on the base color of the material,
  61479. * making it easier to setup and tweak the effect
  61480. */
  61481. albedoScaling: boolean;
  61482. /**
  61483. * Defines if the sheen is linked to the sheen color.
  61484. */
  61485. linkSheenWithAlbedo: boolean;
  61486. /**
  61487. * Initialize the block and prepare the context for build
  61488. * @param state defines the state that will be used for the build
  61489. */
  61490. initialize(state: NodeMaterialBuildState): void;
  61491. /**
  61492. * Gets the current class name
  61493. * @returns the class name
  61494. */
  61495. getClassName(): string;
  61496. /**
  61497. * Gets the intensity input component
  61498. */
  61499. get intensity(): NodeMaterialConnectionPoint;
  61500. /**
  61501. * Gets the color input component
  61502. */
  61503. get color(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the roughness input component
  61506. */
  61507. get roughness(): NodeMaterialConnectionPoint;
  61508. /**
  61509. * Gets the texture input component
  61510. */
  61511. get texture(): NodeMaterialConnectionPoint;
  61512. /**
  61513. * Gets the sheen object output component
  61514. */
  61515. get sheen(): NodeMaterialConnectionPoint;
  61516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61517. /**
  61518. * Gets the main code of the block (fragment side)
  61519. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61520. * @returns the shader code
  61521. */
  61522. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  61523. protected _buildBlock(state: NodeMaterialBuildState): this;
  61524. protected _dumpPropertiesCode(): string;
  61525. serialize(): any;
  61526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61527. }
  61528. }
  61529. declare module BABYLON {
  61530. /**
  61531. * Block used to implement the reflectivity module of the PBR material
  61532. */
  61533. export class ReflectivityBlock extends NodeMaterialBlock {
  61534. /**
  61535. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  61536. */
  61537. useAmbientOcclusionFromMetallicTextureRed: boolean;
  61538. /**
  61539. * Specifies if the metallic texture contains the metallness information in its blue channel.
  61540. */
  61541. useMetallnessFromMetallicTextureBlue: boolean;
  61542. /**
  61543. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  61544. */
  61545. useRoughnessFromMetallicTextureAlpha: boolean;
  61546. /**
  61547. * Specifies if the metallic texture contains the roughness information in its green channel.
  61548. */
  61549. useRoughnessFromMetallicTextureGreen: boolean;
  61550. /**
  61551. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  61552. */
  61553. useMetallicF0FactorFromMetallicTexture: boolean;
  61554. /**
  61555. * Create a new ReflectivityBlock
  61556. * @param name defines the block name
  61557. */
  61558. constructor(name: string);
  61559. /**
  61560. * Initialize the block and prepare the context for build
  61561. * @param state defines the state that will be used for the build
  61562. */
  61563. initialize(state: NodeMaterialBuildState): void;
  61564. /**
  61565. * Gets the current class name
  61566. * @returns the class name
  61567. */
  61568. getClassName(): string;
  61569. /**
  61570. * Gets the metallic input component
  61571. */
  61572. get metallic(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the roughness input component
  61575. */
  61576. get roughness(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the texture input component
  61579. */
  61580. get texture(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the reflectivity object output component
  61583. */
  61584. get reflectivity(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the main code of the block (fragment side)
  61587. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  61588. * @returns the shader code
  61589. */
  61590. getCode(aoIntensityVarName: string): string;
  61591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61592. protected _buildBlock(state: NodeMaterialBuildState): this;
  61593. protected _dumpPropertiesCode(): string;
  61594. serialize(): any;
  61595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61596. }
  61597. }
  61598. declare module BABYLON {
  61599. /**
  61600. * Block used to implement the anisotropy module of the PBR material
  61601. */
  61602. export class AnisotropyBlock extends NodeMaterialBlock {
  61603. /**
  61604. * The two properties below are set by the main PBR block prior to calling methods of this class.
  61605. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61606. * It's less burden on the user side in the editor part.
  61607. */
  61608. /** @hidden */
  61609. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61610. /** @hidden */
  61611. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61612. /**
  61613. * Create a new AnisotropyBlock
  61614. * @param name defines the block name
  61615. */
  61616. constructor(name: string);
  61617. /**
  61618. * Initialize the block and prepare the context for build
  61619. * @param state defines the state that will be used for the build
  61620. */
  61621. initialize(state: NodeMaterialBuildState): void;
  61622. /**
  61623. * Gets the current class name
  61624. * @returns the class name
  61625. */
  61626. getClassName(): string;
  61627. /**
  61628. * Gets the intensity input component
  61629. */
  61630. get intensity(): NodeMaterialConnectionPoint;
  61631. /**
  61632. * Gets the direction input component
  61633. */
  61634. get direction(): NodeMaterialConnectionPoint;
  61635. /**
  61636. * Gets the texture input component
  61637. */
  61638. get texture(): NodeMaterialConnectionPoint;
  61639. /**
  61640. * Gets the uv input component
  61641. */
  61642. get uv(): NodeMaterialConnectionPoint;
  61643. /**
  61644. * Gets the worldTangent input component
  61645. */
  61646. get worldTangent(): NodeMaterialConnectionPoint;
  61647. /**
  61648. * Gets the anisotropy object output component
  61649. */
  61650. get anisotropy(): NodeMaterialConnectionPoint;
  61651. private _generateTBNSpace;
  61652. /**
  61653. * Gets the main code of the block (fragment side)
  61654. * @param state current state of the node material building
  61655. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61656. * @returns the shader code
  61657. */
  61658. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  61659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61660. protected _buildBlock(state: NodeMaterialBuildState): this;
  61661. }
  61662. }
  61663. declare module BABYLON {
  61664. /**
  61665. * Block used to implement the clear coat module of the PBR material
  61666. */
  61667. export class ClearCoatBlock extends NodeMaterialBlock {
  61668. private _scene;
  61669. /**
  61670. * Create a new ClearCoatBlock
  61671. * @param name defines the block name
  61672. */
  61673. constructor(name: string);
  61674. /**
  61675. * Initialize the block and prepare the context for build
  61676. * @param state defines the state that will be used for the build
  61677. */
  61678. initialize(state: NodeMaterialBuildState): void;
  61679. /**
  61680. * Gets the current class name
  61681. * @returns the class name
  61682. */
  61683. getClassName(): string;
  61684. /**
  61685. * Gets the intensity input component
  61686. */
  61687. get intensity(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the roughness input component
  61690. */
  61691. get roughness(): NodeMaterialConnectionPoint;
  61692. /**
  61693. * Gets the ior input component
  61694. */
  61695. get ior(): NodeMaterialConnectionPoint;
  61696. /**
  61697. * Gets the texture input component
  61698. */
  61699. get texture(): NodeMaterialConnectionPoint;
  61700. /**
  61701. * Gets the bump texture input component
  61702. */
  61703. get bumpTexture(): NodeMaterialConnectionPoint;
  61704. /**
  61705. * Gets the uv input component
  61706. */
  61707. get uv(): NodeMaterialConnectionPoint;
  61708. /**
  61709. * Gets the tint color input component
  61710. */
  61711. get tintColor(): NodeMaterialConnectionPoint;
  61712. /**
  61713. * Gets the tint "at distance" input component
  61714. */
  61715. get tintAtDistance(): NodeMaterialConnectionPoint;
  61716. /**
  61717. * Gets the tint thickness input component
  61718. */
  61719. get tintThickness(): NodeMaterialConnectionPoint;
  61720. /**
  61721. * Gets the tint texture input component
  61722. */
  61723. get tintTexture(): NodeMaterialConnectionPoint;
  61724. /**
  61725. * Gets the world tangent input component
  61726. */
  61727. get worldTangent(): NodeMaterialConnectionPoint;
  61728. /**
  61729. * Gets the clear coat object output component
  61730. */
  61731. get clearcoat(): NodeMaterialConnectionPoint;
  61732. autoConfigure(material: NodeMaterial): void;
  61733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61734. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61735. private _generateTBNSpace;
  61736. /**
  61737. * Gets the main code of the block (fragment side)
  61738. * @param state current state of the node material building
  61739. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  61740. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61741. * @param worldPosVarName name of the variable holding the world position
  61742. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61743. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  61744. * @param worldNormalVarName name of the variable holding the world normal
  61745. * @returns the shader code
  61746. */
  61747. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  61748. protected _buildBlock(state: NodeMaterialBuildState): this;
  61749. }
  61750. }
  61751. declare module BABYLON {
  61752. /**
  61753. * Block used to implement the sub surface module of the PBR material
  61754. */
  61755. export class SubSurfaceBlock extends NodeMaterialBlock {
  61756. /**
  61757. * Create a new SubSurfaceBlock
  61758. * @param name defines the block name
  61759. */
  61760. constructor(name: string);
  61761. /**
  61762. * Stores the intensity of the different subsurface effects in the thickness texture.
  61763. * * the green channel is the translucency intensity.
  61764. * * the blue channel is the scattering intensity.
  61765. * * the alpha channel is the refraction intensity.
  61766. */
  61767. useMaskFromThicknessTexture: boolean;
  61768. /**
  61769. * Initialize the block and prepare the context for build
  61770. * @param state defines the state that will be used for the build
  61771. */
  61772. initialize(state: NodeMaterialBuildState): void;
  61773. /**
  61774. * Gets the current class name
  61775. * @returns the class name
  61776. */
  61777. getClassName(): string;
  61778. /**
  61779. * Gets the min thickness input component
  61780. */
  61781. get minThickness(): NodeMaterialConnectionPoint;
  61782. /**
  61783. * Gets the max thickness input component
  61784. */
  61785. get maxThickness(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the thickness texture component
  61788. */
  61789. get thicknessTexture(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the tint color input component
  61792. */
  61793. get tintColor(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the translucency intensity input component
  61796. */
  61797. get translucencyIntensity(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the translucency diffusion distance input component
  61800. */
  61801. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the refraction object parameters
  61804. */
  61805. get refraction(): NodeMaterialConnectionPoint;
  61806. /**
  61807. * Gets the sub surface object output component
  61808. */
  61809. get subsurface(): NodeMaterialConnectionPoint;
  61810. autoConfigure(material: NodeMaterial): void;
  61811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61812. /**
  61813. * Gets the main code of the block (fragment side)
  61814. * @param state current state of the node material building
  61815. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  61816. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61817. * @param worldPosVarName name of the variable holding the world position
  61818. * @returns the shader code
  61819. */
  61820. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  61821. protected _buildBlock(state: NodeMaterialBuildState): this;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Block used to implement the PBR metallic/roughness model
  61827. */
  61828. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  61829. /**
  61830. * Gets or sets the light associated with this block
  61831. */
  61832. light: Nullable<Light>;
  61833. private _lightId;
  61834. private _scene;
  61835. private _environmentBRDFTexture;
  61836. private _environmentBrdfSamplerName;
  61837. private _vNormalWName;
  61838. private _invertNormalName;
  61839. /**
  61840. * Create a new ReflectionBlock
  61841. * @param name defines the block name
  61842. */
  61843. constructor(name: string);
  61844. /**
  61845. * Intensity of the direct lights e.g. the four lights available in your scene.
  61846. * This impacts both the direct diffuse and specular highlights.
  61847. */
  61848. directIntensity: number;
  61849. /**
  61850. * Intensity of the environment e.g. how much the environment will light the object
  61851. * either through harmonics for rough material or through the refelction for shiny ones.
  61852. */
  61853. environmentIntensity: number;
  61854. /**
  61855. * This is a special control allowing the reduction of the specular highlights coming from the
  61856. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  61857. */
  61858. specularIntensity: number;
  61859. /**
  61860. * Defines the falloff type used in this material.
  61861. * It by default is Physical.
  61862. */
  61863. lightFalloff: number;
  61864. /**
  61865. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  61866. */
  61867. useAlphaFromAlbedoTexture: boolean;
  61868. /**
  61869. * Specifies that alpha test should be used
  61870. */
  61871. useAlphaTest: boolean;
  61872. /**
  61873. * Defines the alpha limits in alpha test mode.
  61874. */
  61875. alphaTestCutoff: number;
  61876. /**
  61877. * Specifies that alpha blending should be used
  61878. */
  61879. useAlphaBlending: boolean;
  61880. /**
  61881. * Defines if the alpha value should be determined via the rgb values.
  61882. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  61883. */
  61884. opacityRGB: boolean;
  61885. /**
  61886. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  61887. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  61888. */
  61889. useRadianceOverAlpha: boolean;
  61890. /**
  61891. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  61892. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  61893. */
  61894. useSpecularOverAlpha: boolean;
  61895. /**
  61896. * Enables specular anti aliasing in the PBR shader.
  61897. * It will both interacts on the Geometry for analytical and IBL lighting.
  61898. * It also prefilter the roughness map based on the bump values.
  61899. */
  61900. enableSpecularAntiAliasing: boolean;
  61901. /**
  61902. * Defines if the material uses energy conservation.
  61903. */
  61904. useEnergyConservation: boolean;
  61905. /**
  61906. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  61907. * too much the area relying on ambient texture to define their ambient occlusion.
  61908. */
  61909. useRadianceOcclusion: boolean;
  61910. /**
  61911. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  61912. * makes the reflect vector face the model (under horizon).
  61913. */
  61914. useHorizonOcclusion: boolean;
  61915. /**
  61916. * If set to true, no lighting calculations will be applied.
  61917. */
  61918. unlit: boolean;
  61919. /**
  61920. * Force normal to face away from face.
  61921. */
  61922. forceNormalForward: boolean;
  61923. /**
  61924. * Defines the material debug mode.
  61925. * It helps seeing only some components of the material while troubleshooting.
  61926. */
  61927. debugMode: number;
  61928. /**
  61929. * Specify from where on screen the debug mode should start.
  61930. * The value goes from -1 (full screen) to 1 (not visible)
  61931. * It helps with side by side comparison against the final render
  61932. * This defaults to 0
  61933. */
  61934. debugLimit: number;
  61935. /**
  61936. * As the default viewing range might not be enough (if the ambient is really small for instance)
  61937. * You can use the factor to better multiply the final value.
  61938. */
  61939. debugFactor: number;
  61940. /**
  61941. * Initialize the block and prepare the context for build
  61942. * @param state defines the state that will be used for the build
  61943. */
  61944. initialize(state: NodeMaterialBuildState): void;
  61945. /**
  61946. * Gets the current class name
  61947. * @returns the class name
  61948. */
  61949. getClassName(): string;
  61950. /**
  61951. * Gets the world position input component
  61952. */
  61953. get worldPosition(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the world normal input component
  61956. */
  61957. get worldNormal(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the perturbed normal input component
  61960. */
  61961. get perturbedNormal(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the camera position input component
  61964. */
  61965. get cameraPosition(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the base color input component
  61968. */
  61969. get baseColor(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the base texture input component
  61972. */
  61973. get baseTexture(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the opacity texture input component
  61976. */
  61977. get opacityTexture(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the ambient color input component
  61980. */
  61981. get ambientColor(): NodeMaterialConnectionPoint;
  61982. /**
  61983. * Gets the reflectivity object parameters
  61984. */
  61985. get reflectivity(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the ambient occlusion object parameters
  61988. */
  61989. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the reflection object parameters
  61992. */
  61993. get reflection(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the sheen object parameters
  61996. */
  61997. get sheen(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the clear coat object parameters
  62000. */
  62001. get clearcoat(): NodeMaterialConnectionPoint;
  62002. /**
  62003. * Gets the sub surface object parameters
  62004. */
  62005. get subsurface(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the anisotropy object parameters
  62008. */
  62009. get anisotropy(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Gets the ambient output component
  62012. */
  62013. get ambient(): NodeMaterialConnectionPoint;
  62014. /**
  62015. * Gets the diffuse output component
  62016. */
  62017. get diffuse(): NodeMaterialConnectionPoint;
  62018. /**
  62019. * Gets the specular output component
  62020. */
  62021. get specular(): NodeMaterialConnectionPoint;
  62022. /**
  62023. * Gets the sheen output component
  62024. */
  62025. get sheenDir(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the clear coat output component
  62028. */
  62029. get clearcoatDir(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the indirect diffuse output component
  62032. */
  62033. get diffuseIndirect(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the indirect specular output component
  62036. */
  62037. get specularIndirect(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the indirect sheen output component
  62040. */
  62041. get sheenIndirect(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the indirect clear coat output component
  62044. */
  62045. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  62046. /**
  62047. * Gets the refraction output component
  62048. */
  62049. get refraction(): NodeMaterialConnectionPoint;
  62050. /**
  62051. * Gets the global lighting output component
  62052. */
  62053. get lighting(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the shadow output component
  62056. */
  62057. get shadow(): NodeMaterialConnectionPoint;
  62058. /**
  62059. * Gets the alpha output component
  62060. */
  62061. get alpha(): NodeMaterialConnectionPoint;
  62062. autoConfigure(material: NodeMaterial): void;
  62063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62064. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62066. private _injectVertexCode;
  62067. /**
  62068. * Gets the code corresponding to the albedo/opacity module
  62069. * @returns the shader code
  62070. */
  62071. getAlbedoOpacityCode(): string;
  62072. protected _buildBlock(state: NodeMaterialBuildState): this;
  62073. protected _dumpPropertiesCode(): string;
  62074. serialize(): any;
  62075. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62076. }
  62077. }
  62078. declare module BABYLON {
  62079. /**
  62080. * Effect Render Options
  62081. */
  62082. export interface IEffectRendererOptions {
  62083. /**
  62084. * Defines the vertices positions.
  62085. */
  62086. positions?: number[];
  62087. /**
  62088. * Defines the indices.
  62089. */
  62090. indices?: number[];
  62091. }
  62092. /**
  62093. * Helper class to render one or more effects.
  62094. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62095. */
  62096. export class EffectRenderer {
  62097. private engine;
  62098. private static _DefaultOptions;
  62099. private _vertexBuffers;
  62100. private _indexBuffer;
  62101. private _fullscreenViewport;
  62102. /**
  62103. * Creates an effect renderer
  62104. * @param engine the engine to use for rendering
  62105. * @param options defines the options of the effect renderer
  62106. */
  62107. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62108. /**
  62109. * Sets the current viewport in normalized coordinates 0-1
  62110. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62111. */
  62112. setViewport(viewport?: Viewport): void;
  62113. /**
  62114. * Binds the embedded attributes buffer to the effect.
  62115. * @param effect Defines the effect to bind the attributes for
  62116. */
  62117. bindBuffers(effect: Effect): void;
  62118. /**
  62119. * Sets the current effect wrapper to use during draw.
  62120. * The effect needs to be ready before calling this api.
  62121. * This also sets the default full screen position attribute.
  62122. * @param effectWrapper Defines the effect to draw with
  62123. */
  62124. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62125. /**
  62126. * Draws a full screen quad.
  62127. */
  62128. draw(): void;
  62129. private isRenderTargetTexture;
  62130. /**
  62131. * renders one or more effects to a specified texture
  62132. * @param effectWrapper the effect to renderer
  62133. * @param outputTexture texture to draw to, if null it will render to the screen.
  62134. */
  62135. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62136. /**
  62137. * Disposes of the effect renderer
  62138. */
  62139. dispose(): void;
  62140. }
  62141. /**
  62142. * Options to create an EffectWrapper
  62143. */
  62144. interface EffectWrapperCreationOptions {
  62145. /**
  62146. * Engine to use to create the effect
  62147. */
  62148. engine: ThinEngine;
  62149. /**
  62150. * Fragment shader for the effect
  62151. */
  62152. fragmentShader: string;
  62153. /**
  62154. * Vertex shader for the effect
  62155. */
  62156. vertexShader?: string;
  62157. /**
  62158. * Attributes to use in the shader
  62159. */
  62160. attributeNames?: Array<string>;
  62161. /**
  62162. * Uniforms to use in the shader
  62163. */
  62164. uniformNames?: Array<string>;
  62165. /**
  62166. * Texture sampler names to use in the shader
  62167. */
  62168. samplerNames?: Array<string>;
  62169. /**
  62170. * The friendly name of the effect displayed in Spector.
  62171. */
  62172. name?: string;
  62173. }
  62174. /**
  62175. * Wraps an effect to be used for rendering
  62176. */
  62177. export class EffectWrapper {
  62178. /**
  62179. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62180. */
  62181. onApplyObservable: Observable<{}>;
  62182. /**
  62183. * The underlying effect
  62184. */
  62185. effect: Effect;
  62186. /**
  62187. * Creates an effect to be renderer
  62188. * @param creationOptions options to create the effect
  62189. */
  62190. constructor(creationOptions: EffectWrapperCreationOptions);
  62191. /**
  62192. * Disposes of the effect wrapper
  62193. */
  62194. dispose(): void;
  62195. }
  62196. }
  62197. declare module BABYLON {
  62198. /**
  62199. * Helper class to push actions to a pool of workers.
  62200. */
  62201. export class WorkerPool implements IDisposable {
  62202. private _workerInfos;
  62203. private _pendingActions;
  62204. /**
  62205. * Constructor
  62206. * @param workers Array of workers to use for actions
  62207. */
  62208. constructor(workers: Array<Worker>);
  62209. /**
  62210. * Terminates all workers and clears any pending actions.
  62211. */
  62212. dispose(): void;
  62213. /**
  62214. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62215. * pended until a worker has completed its action.
  62216. * @param action The action to perform. Call onComplete when the action is complete.
  62217. */
  62218. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62219. private _execute;
  62220. }
  62221. }
  62222. declare module BABYLON {
  62223. /**
  62224. * Configuration for Draco compression
  62225. */
  62226. export interface IDracoCompressionConfiguration {
  62227. /**
  62228. * Configuration for the decoder.
  62229. */
  62230. decoder: {
  62231. /**
  62232. * The url to the WebAssembly module.
  62233. */
  62234. wasmUrl?: string;
  62235. /**
  62236. * The url to the WebAssembly binary.
  62237. */
  62238. wasmBinaryUrl?: string;
  62239. /**
  62240. * The url to the fallback JavaScript module.
  62241. */
  62242. fallbackUrl?: string;
  62243. };
  62244. }
  62245. /**
  62246. * Draco compression (https://google.github.io/draco/)
  62247. *
  62248. * This class wraps the Draco module.
  62249. *
  62250. * **Encoder**
  62251. *
  62252. * The encoder is not currently implemented.
  62253. *
  62254. * **Decoder**
  62255. *
  62256. * 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.
  62257. *
  62258. * To update the configuration, use the following code:
  62259. * ```javascript
  62260. * DracoCompression.Configuration = {
  62261. * decoder: {
  62262. * wasmUrl: "<url to the WebAssembly library>",
  62263. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62264. * fallbackUrl: "<url to the fallback JavaScript library>",
  62265. * }
  62266. * };
  62267. * ```
  62268. *
  62269. * 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.
  62270. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62271. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62272. *
  62273. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62274. * ```javascript
  62275. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62276. * ```
  62277. *
  62278. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62279. */
  62280. export class DracoCompression implements IDisposable {
  62281. private _workerPoolPromise?;
  62282. private _decoderModulePromise?;
  62283. /**
  62284. * The configuration. Defaults to the following urls:
  62285. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62286. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62287. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62288. */
  62289. static Configuration: IDracoCompressionConfiguration;
  62290. /**
  62291. * Returns true if the decoder configuration is available.
  62292. */
  62293. static get DecoderAvailable(): boolean;
  62294. /**
  62295. * Default number of workers to create when creating the draco compression object.
  62296. */
  62297. static DefaultNumWorkers: number;
  62298. private static GetDefaultNumWorkers;
  62299. private static _Default;
  62300. /**
  62301. * Default instance for the draco compression object.
  62302. */
  62303. static get Default(): DracoCompression;
  62304. /**
  62305. * Constructor
  62306. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62307. */
  62308. constructor(numWorkers?: number);
  62309. /**
  62310. * Stop all async operations and release resources.
  62311. */
  62312. dispose(): void;
  62313. /**
  62314. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62315. * @returns a promise that resolves when ready
  62316. */
  62317. whenReadyAsync(): Promise<void>;
  62318. /**
  62319. * Decode Draco compressed mesh data to vertex data.
  62320. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62321. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62322. * @returns A promise that resolves with the decoded vertex data
  62323. */
  62324. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62325. [kind: string]: number;
  62326. }): Promise<VertexData>;
  62327. }
  62328. }
  62329. declare module BABYLON {
  62330. /**
  62331. * Class for building Constructive Solid Geometry
  62332. */
  62333. export class CSG {
  62334. private polygons;
  62335. /**
  62336. * The world matrix
  62337. */
  62338. matrix: Matrix;
  62339. /**
  62340. * Stores the position
  62341. */
  62342. position: Vector3;
  62343. /**
  62344. * Stores the rotation
  62345. */
  62346. rotation: Vector3;
  62347. /**
  62348. * Stores the rotation quaternion
  62349. */
  62350. rotationQuaternion: Nullable<Quaternion>;
  62351. /**
  62352. * Stores the scaling vector
  62353. */
  62354. scaling: Vector3;
  62355. /**
  62356. * Convert the Mesh to CSG
  62357. * @param mesh The Mesh to convert to CSG
  62358. * @returns A new CSG from the Mesh
  62359. */
  62360. static FromMesh(mesh: Mesh): CSG;
  62361. /**
  62362. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62363. * @param polygons Polygons used to construct a CSG solid
  62364. */
  62365. private static FromPolygons;
  62366. /**
  62367. * Clones, or makes a deep copy, of the CSG
  62368. * @returns A new CSG
  62369. */
  62370. clone(): CSG;
  62371. /**
  62372. * Unions this CSG with another CSG
  62373. * @param csg The CSG to union against this CSG
  62374. * @returns The unioned CSG
  62375. */
  62376. union(csg: CSG): CSG;
  62377. /**
  62378. * Unions this CSG with another CSG in place
  62379. * @param csg The CSG to union against this CSG
  62380. */
  62381. unionInPlace(csg: CSG): void;
  62382. /**
  62383. * Subtracts this CSG with another CSG
  62384. * @param csg The CSG to subtract against this CSG
  62385. * @returns A new CSG
  62386. */
  62387. subtract(csg: CSG): CSG;
  62388. /**
  62389. * Subtracts this CSG with another CSG in place
  62390. * @param csg The CSG to subtact against this CSG
  62391. */
  62392. subtractInPlace(csg: CSG): void;
  62393. /**
  62394. * Intersect this CSG with another CSG
  62395. * @param csg The CSG to intersect against this CSG
  62396. * @returns A new CSG
  62397. */
  62398. intersect(csg: CSG): CSG;
  62399. /**
  62400. * Intersects this CSG with another CSG in place
  62401. * @param csg The CSG to intersect against this CSG
  62402. */
  62403. intersectInPlace(csg: CSG): void;
  62404. /**
  62405. * Return a new CSG solid with solid and empty space switched. This solid is
  62406. * not modified.
  62407. * @returns A new CSG solid with solid and empty space switched
  62408. */
  62409. inverse(): CSG;
  62410. /**
  62411. * Inverses the CSG in place
  62412. */
  62413. inverseInPlace(): void;
  62414. /**
  62415. * This is used to keep meshes transformations so they can be restored
  62416. * when we build back a Babylon Mesh
  62417. * NB : All CSG operations are performed in world coordinates
  62418. * @param csg The CSG to copy the transform attributes from
  62419. * @returns This CSG
  62420. */
  62421. copyTransformAttributes(csg: CSG): CSG;
  62422. /**
  62423. * Build Raw mesh from CSG
  62424. * Coordinates here are in world space
  62425. * @param name The name of the mesh geometry
  62426. * @param scene The Scene
  62427. * @param keepSubMeshes Specifies if the submeshes should be kept
  62428. * @returns A new Mesh
  62429. */
  62430. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62431. /**
  62432. * Build Mesh from CSG taking material and transforms into account
  62433. * @param name The name of the Mesh
  62434. * @param material The material of the Mesh
  62435. * @param scene The Scene
  62436. * @param keepSubMeshes Specifies if submeshes should be kept
  62437. * @returns The new Mesh
  62438. */
  62439. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62440. }
  62441. }
  62442. declare module BABYLON {
  62443. /**
  62444. * Class used to create a trail following a mesh
  62445. */
  62446. export class TrailMesh extends Mesh {
  62447. private _generator;
  62448. private _autoStart;
  62449. private _running;
  62450. private _diameter;
  62451. private _length;
  62452. private _sectionPolygonPointsCount;
  62453. private _sectionVectors;
  62454. private _sectionNormalVectors;
  62455. private _beforeRenderObserver;
  62456. /**
  62457. * @constructor
  62458. * @param name The value used by scene.getMeshByName() to do a lookup.
  62459. * @param generator The mesh or transform node to generate a trail.
  62460. * @param scene The scene to add this mesh to.
  62461. * @param diameter Diameter of trailing mesh. Default is 1.
  62462. * @param length Length of trailing mesh. Default is 60.
  62463. * @param autoStart Automatically start trailing mesh. Default true.
  62464. */
  62465. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62466. /**
  62467. * "TrailMesh"
  62468. * @returns "TrailMesh"
  62469. */
  62470. getClassName(): string;
  62471. private _createMesh;
  62472. /**
  62473. * Start trailing mesh.
  62474. */
  62475. start(): void;
  62476. /**
  62477. * Stop trailing mesh.
  62478. */
  62479. stop(): void;
  62480. /**
  62481. * Update trailing mesh geometry.
  62482. */
  62483. update(): void;
  62484. /**
  62485. * Returns a new TrailMesh object.
  62486. * @param name is a string, the name given to the new mesh
  62487. * @param newGenerator use new generator object for cloned trail mesh
  62488. * @returns a new mesh
  62489. */
  62490. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  62491. /**
  62492. * Serializes this trail mesh
  62493. * @param serializationObject object to write serialization to
  62494. */
  62495. serialize(serializationObject: any): void;
  62496. /**
  62497. * Parses a serialized trail mesh
  62498. * @param parsedMesh the serialized mesh
  62499. * @param scene the scene to create the trail mesh in
  62500. * @returns the created trail mesh
  62501. */
  62502. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62503. }
  62504. }
  62505. declare module BABYLON {
  62506. /**
  62507. * Class containing static functions to help procedurally build meshes
  62508. */
  62509. export class TiledBoxBuilder {
  62510. /**
  62511. * Creates a box mesh
  62512. * 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)
  62513. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62515. * * 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
  62516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62517. * @param name defines the name of the mesh
  62518. * @param options defines the options used to create the mesh
  62519. * @param scene defines the hosting scene
  62520. * @returns the box mesh
  62521. */
  62522. static CreateTiledBox(name: string, options: {
  62523. pattern?: number;
  62524. width?: number;
  62525. height?: number;
  62526. depth?: number;
  62527. tileSize?: number;
  62528. tileWidth?: number;
  62529. tileHeight?: number;
  62530. alignHorizontal?: number;
  62531. alignVertical?: number;
  62532. faceUV?: Vector4[];
  62533. faceColors?: Color4[];
  62534. sideOrientation?: number;
  62535. updatable?: boolean;
  62536. }, scene?: Nullable<Scene>): Mesh;
  62537. }
  62538. }
  62539. declare module BABYLON {
  62540. /**
  62541. * Class containing static functions to help procedurally build meshes
  62542. */
  62543. export class TorusKnotBuilder {
  62544. /**
  62545. * Creates a torus knot mesh
  62546. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62547. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62548. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62549. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62551. * * 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
  62552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62553. * @param name defines the name of the mesh
  62554. * @param options defines the options used to create the mesh
  62555. * @param scene defines the hosting scene
  62556. * @returns the torus knot mesh
  62557. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62558. */
  62559. static CreateTorusKnot(name: string, options: {
  62560. radius?: number;
  62561. tube?: number;
  62562. radialSegments?: number;
  62563. tubularSegments?: number;
  62564. p?: number;
  62565. q?: number;
  62566. updatable?: boolean;
  62567. sideOrientation?: number;
  62568. frontUVs?: Vector4;
  62569. backUVs?: Vector4;
  62570. }, scene: any): Mesh;
  62571. }
  62572. }
  62573. declare module BABYLON {
  62574. /**
  62575. * Polygon
  62576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62577. */
  62578. export class Polygon {
  62579. /**
  62580. * Creates a rectangle
  62581. * @param xmin bottom X coord
  62582. * @param ymin bottom Y coord
  62583. * @param xmax top X coord
  62584. * @param ymax top Y coord
  62585. * @returns points that make the resulting rectation
  62586. */
  62587. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62588. /**
  62589. * Creates a circle
  62590. * @param radius radius of circle
  62591. * @param cx scale in x
  62592. * @param cy scale in y
  62593. * @param numberOfSides number of sides that make up the circle
  62594. * @returns points that make the resulting circle
  62595. */
  62596. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62597. /**
  62598. * Creates a polygon from input string
  62599. * @param input Input polygon data
  62600. * @returns the parsed points
  62601. */
  62602. static Parse(input: string): Vector2[];
  62603. /**
  62604. * Starts building a polygon from x and y coordinates
  62605. * @param x x coordinate
  62606. * @param y y coordinate
  62607. * @returns the started path2
  62608. */
  62609. static StartingAt(x: number, y: number): Path2;
  62610. }
  62611. /**
  62612. * Builds a polygon
  62613. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62614. */
  62615. export class PolygonMeshBuilder {
  62616. private _points;
  62617. private _outlinepoints;
  62618. private _holes;
  62619. private _name;
  62620. private _scene;
  62621. private _epoints;
  62622. private _eholes;
  62623. private _addToepoint;
  62624. /**
  62625. * Babylon reference to the earcut plugin.
  62626. */
  62627. bjsEarcut: any;
  62628. /**
  62629. * Creates a PolygonMeshBuilder
  62630. * @param name name of the builder
  62631. * @param contours Path of the polygon
  62632. * @param scene scene to add to when creating the mesh
  62633. * @param earcutInjection can be used to inject your own earcut reference
  62634. */
  62635. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62636. /**
  62637. * Adds a whole within the polygon
  62638. * @param hole Array of points defining the hole
  62639. * @returns this
  62640. */
  62641. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62642. /**
  62643. * Creates the polygon
  62644. * @param updatable If the mesh should be updatable
  62645. * @param depth The depth of the mesh created
  62646. * @returns the created mesh
  62647. */
  62648. build(updatable?: boolean, depth?: number): Mesh;
  62649. /**
  62650. * Creates the polygon
  62651. * @param depth The depth of the mesh created
  62652. * @returns the created VertexData
  62653. */
  62654. buildVertexData(depth?: number): VertexData;
  62655. /**
  62656. * Adds a side to the polygon
  62657. * @param positions points that make the polygon
  62658. * @param normals normals of the polygon
  62659. * @param uvs uvs of the polygon
  62660. * @param indices indices of the polygon
  62661. * @param bounds bounds of the polygon
  62662. * @param points points of the polygon
  62663. * @param depth depth of the polygon
  62664. * @param flip flip of the polygon
  62665. */
  62666. private addSide;
  62667. }
  62668. }
  62669. declare module BABYLON {
  62670. /**
  62671. * Class containing static functions to help procedurally build meshes
  62672. */
  62673. export class PolygonBuilder {
  62674. /**
  62675. * Creates a polygon mesh
  62676. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62677. * * 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
  62678. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62680. * * 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)
  62681. * * Remember you can only change the shape positions, not their number when updating a polygon
  62682. * @param name defines the name of the mesh
  62683. * @param options defines the options used to create the mesh
  62684. * @param scene defines the hosting scene
  62685. * @param earcutInjection can be used to inject your own earcut reference
  62686. * @returns the polygon mesh
  62687. */
  62688. static CreatePolygon(name: string, options: {
  62689. shape: Vector3[];
  62690. holes?: Vector3[][];
  62691. depth?: number;
  62692. faceUV?: Vector4[];
  62693. faceColors?: Color4[];
  62694. updatable?: boolean;
  62695. sideOrientation?: number;
  62696. frontUVs?: Vector4;
  62697. backUVs?: Vector4;
  62698. wrap?: boolean;
  62699. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62700. /**
  62701. * Creates an extruded polygon mesh, with depth in the Y direction.
  62702. * * 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)
  62703. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62704. * @param name defines the name of the mesh
  62705. * @param options defines the options used to create the mesh
  62706. * @param scene defines the hosting scene
  62707. * @param earcutInjection can be used to inject your own earcut reference
  62708. * @returns the polygon mesh
  62709. */
  62710. static ExtrudePolygon(name: string, options: {
  62711. shape: Vector3[];
  62712. holes?: Vector3[][];
  62713. depth?: number;
  62714. faceUV?: Vector4[];
  62715. faceColors?: Color4[];
  62716. updatable?: boolean;
  62717. sideOrientation?: number;
  62718. frontUVs?: Vector4;
  62719. backUVs?: Vector4;
  62720. wrap?: boolean;
  62721. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62722. }
  62723. }
  62724. declare module BABYLON {
  62725. /**
  62726. * Class containing static functions to help procedurally build meshes
  62727. */
  62728. export class LatheBuilder {
  62729. /**
  62730. * Creates lathe mesh.
  62731. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62732. * * 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
  62733. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62734. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62735. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62736. * * 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
  62737. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62738. * * 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
  62739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62740. * * 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
  62741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62743. * @param name defines the name of the mesh
  62744. * @param options defines the options used to create the mesh
  62745. * @param scene defines the hosting scene
  62746. * @returns the lathe mesh
  62747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62748. */
  62749. static CreateLathe(name: string, options: {
  62750. shape: Vector3[];
  62751. radius?: number;
  62752. tessellation?: number;
  62753. clip?: number;
  62754. arc?: number;
  62755. closed?: boolean;
  62756. updatable?: boolean;
  62757. sideOrientation?: number;
  62758. frontUVs?: Vector4;
  62759. backUVs?: Vector4;
  62760. cap?: number;
  62761. invertUV?: boolean;
  62762. }, scene?: Nullable<Scene>): Mesh;
  62763. }
  62764. }
  62765. declare module BABYLON {
  62766. /**
  62767. * Class containing static functions to help procedurally build meshes
  62768. */
  62769. export class TiledPlaneBuilder {
  62770. /**
  62771. * Creates a tiled plane mesh
  62772. * * The parameter `pattern` will, depending on value, do nothing or
  62773. * * * flip (reflect about central vertical) alternate tiles across and up
  62774. * * * flip every tile on alternate rows
  62775. * * * rotate (180 degs) alternate tiles across and up
  62776. * * * rotate every tile on alternate rows
  62777. * * * flip and rotate alternate tiles across and up
  62778. * * * flip and rotate every tile on alternate rows
  62779. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62780. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  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. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62783. * * 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)
  62784. * * 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)
  62785. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62786. * @param name defines the name of the mesh
  62787. * @param options defines the options used to create the mesh
  62788. * @param scene defines the hosting scene
  62789. * @returns the box mesh
  62790. */
  62791. static CreateTiledPlane(name: string, options: {
  62792. pattern?: number;
  62793. tileSize?: number;
  62794. tileWidth?: number;
  62795. tileHeight?: number;
  62796. size?: number;
  62797. width?: number;
  62798. height?: number;
  62799. alignHorizontal?: number;
  62800. alignVertical?: number;
  62801. sideOrientation?: number;
  62802. frontUVs?: Vector4;
  62803. backUVs?: Vector4;
  62804. updatable?: boolean;
  62805. }, scene?: Nullable<Scene>): Mesh;
  62806. }
  62807. }
  62808. declare module BABYLON {
  62809. /**
  62810. * Class containing static functions to help procedurally build meshes
  62811. */
  62812. export class TubeBuilder {
  62813. /**
  62814. * Creates a tube mesh.
  62815. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62816. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62817. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62818. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62819. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62820. * * 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)
  62821. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62822. * * 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
  62823. * * 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
  62824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62825. * * 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
  62826. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62828. * @param name defines the name of the mesh
  62829. * @param options defines the options used to create the mesh
  62830. * @param scene defines the hosting scene
  62831. * @returns the tube mesh
  62832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62833. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62834. */
  62835. static CreateTube(name: string, options: {
  62836. path: Vector3[];
  62837. radius?: number;
  62838. tessellation?: number;
  62839. radiusFunction?: {
  62840. (i: number, distance: number): number;
  62841. };
  62842. cap?: number;
  62843. arc?: number;
  62844. updatable?: boolean;
  62845. sideOrientation?: number;
  62846. frontUVs?: Vector4;
  62847. backUVs?: Vector4;
  62848. instance?: Mesh;
  62849. invertUV?: boolean;
  62850. }, scene?: Nullable<Scene>): Mesh;
  62851. }
  62852. }
  62853. declare module BABYLON {
  62854. /**
  62855. * Class containing static functions to help procedurally build meshes
  62856. */
  62857. export class IcoSphereBuilder {
  62858. /**
  62859. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62860. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62861. * * 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`)
  62862. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62863. * * 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
  62864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62865. * * 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
  62866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62867. * @param name defines the name of the mesh
  62868. * @param options defines the options used to create the mesh
  62869. * @param scene defines the hosting scene
  62870. * @returns the icosahedron mesh
  62871. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62872. */
  62873. static CreateIcoSphere(name: string, options: {
  62874. radius?: number;
  62875. radiusX?: number;
  62876. radiusY?: number;
  62877. radiusZ?: number;
  62878. flat?: boolean;
  62879. subdivisions?: number;
  62880. sideOrientation?: number;
  62881. frontUVs?: Vector4;
  62882. backUVs?: Vector4;
  62883. updatable?: boolean;
  62884. }, scene?: Nullable<Scene>): Mesh;
  62885. }
  62886. }
  62887. declare module BABYLON {
  62888. /**
  62889. * Class containing static functions to help procedurally build meshes
  62890. */
  62891. export class DecalBuilder {
  62892. /**
  62893. * Creates a decal mesh.
  62894. * 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
  62895. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62896. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62897. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62898. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62899. * @param name defines the name of the mesh
  62900. * @param sourceMesh defines the mesh where the decal must be applied
  62901. * @param options defines the options used to create the mesh
  62902. * @param scene defines the hosting scene
  62903. * @returns the decal mesh
  62904. * @see https://doc.babylonjs.com/how_to/decals
  62905. */
  62906. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62907. position?: Vector3;
  62908. normal?: Vector3;
  62909. size?: Vector3;
  62910. angle?: number;
  62911. }): Mesh;
  62912. }
  62913. }
  62914. declare module BABYLON {
  62915. /**
  62916. * Class containing static functions to help procedurally build meshes
  62917. */
  62918. export class MeshBuilder {
  62919. /**
  62920. * Creates a box mesh
  62921. * * The parameter `size` sets the size (float) of each box side (default 1)
  62922. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62923. * * 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)
  62924. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62926. * * 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
  62927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62928. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62929. * @param name defines the name of the mesh
  62930. * @param options defines the options used to create the mesh
  62931. * @param scene defines the hosting scene
  62932. * @returns the box mesh
  62933. */
  62934. static CreateBox(name: string, options: {
  62935. size?: number;
  62936. width?: number;
  62937. height?: number;
  62938. depth?: number;
  62939. faceUV?: Vector4[];
  62940. faceColors?: Color4[];
  62941. sideOrientation?: number;
  62942. frontUVs?: Vector4;
  62943. backUVs?: Vector4;
  62944. wrap?: boolean;
  62945. topBaseAt?: number;
  62946. bottomBaseAt?: number;
  62947. updatable?: boolean;
  62948. }, scene?: Nullable<Scene>): Mesh;
  62949. /**
  62950. * Creates a tiled box mesh
  62951. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62953. * @param name defines the name of the mesh
  62954. * @param options defines the options used to create the mesh
  62955. * @param scene defines the hosting scene
  62956. * @returns the tiled box mesh
  62957. */
  62958. static CreateTiledBox(name: string, options: {
  62959. pattern?: number;
  62960. size?: number;
  62961. width?: number;
  62962. height?: number;
  62963. depth: number;
  62964. tileSize?: number;
  62965. tileWidth?: number;
  62966. tileHeight?: number;
  62967. faceUV?: Vector4[];
  62968. faceColors?: Color4[];
  62969. alignHorizontal?: number;
  62970. alignVertical?: number;
  62971. sideOrientation?: number;
  62972. updatable?: boolean;
  62973. }, scene?: Nullable<Scene>): Mesh;
  62974. /**
  62975. * Creates a sphere mesh
  62976. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62977. * * 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`)
  62978. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62979. * * 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
  62980. * * 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)
  62981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62982. * * 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
  62983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62984. * @param name defines the name of the mesh
  62985. * @param options defines the options used to create the mesh
  62986. * @param scene defines the hosting scene
  62987. * @returns the sphere mesh
  62988. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62989. */
  62990. static CreateSphere(name: string, options: {
  62991. segments?: number;
  62992. diameter?: number;
  62993. diameterX?: number;
  62994. diameterY?: number;
  62995. diameterZ?: number;
  62996. arc?: number;
  62997. slice?: number;
  62998. sideOrientation?: number;
  62999. frontUVs?: Vector4;
  63000. backUVs?: Vector4;
  63001. updatable?: boolean;
  63002. }, scene?: Nullable<Scene>): Mesh;
  63003. /**
  63004. * Creates a plane polygonal mesh. By default, this is a disc
  63005. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63006. * * 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
  63007. * * 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
  63008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63009. * * 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
  63010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63011. * @param name defines the name of the mesh
  63012. * @param options defines the options used to create the mesh
  63013. * @param scene defines the hosting scene
  63014. * @returns the plane polygonal mesh
  63015. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63016. */
  63017. static CreateDisc(name: string, options: {
  63018. radius?: number;
  63019. tessellation?: number;
  63020. arc?: number;
  63021. updatable?: boolean;
  63022. sideOrientation?: number;
  63023. frontUVs?: Vector4;
  63024. backUVs?: Vector4;
  63025. }, scene?: Nullable<Scene>): Mesh;
  63026. /**
  63027. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63028. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63029. * * 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`)
  63030. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63031. * * 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
  63032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63033. * * 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
  63034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63035. * @param name defines the name of the mesh
  63036. * @param options defines the options used to create the mesh
  63037. * @param scene defines the hosting scene
  63038. * @returns the icosahedron mesh
  63039. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63040. */
  63041. static CreateIcoSphere(name: string, options: {
  63042. radius?: number;
  63043. radiusX?: number;
  63044. radiusY?: number;
  63045. radiusZ?: number;
  63046. flat?: boolean;
  63047. subdivisions?: number;
  63048. sideOrientation?: number;
  63049. frontUVs?: Vector4;
  63050. backUVs?: Vector4;
  63051. updatable?: boolean;
  63052. }, scene?: Nullable<Scene>): Mesh;
  63053. /**
  63054. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63055. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63056. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63057. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63058. * * 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
  63059. * * 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
  63060. * * 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
  63061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63062. * * 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
  63063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63064. * * 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
  63065. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63066. * * 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
  63067. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63069. * @param name defines the name of the mesh
  63070. * @param options defines the options used to create the mesh
  63071. * @param scene defines the hosting scene
  63072. * @returns the ribbon mesh
  63073. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63075. */
  63076. static CreateRibbon(name: string, options: {
  63077. pathArray: Vector3[][];
  63078. closeArray?: boolean;
  63079. closePath?: boolean;
  63080. offset?: number;
  63081. updatable?: boolean;
  63082. sideOrientation?: number;
  63083. frontUVs?: Vector4;
  63084. backUVs?: Vector4;
  63085. instance?: Mesh;
  63086. invertUV?: boolean;
  63087. uvs?: Vector2[];
  63088. colors?: Color4[];
  63089. }, scene?: Nullable<Scene>): Mesh;
  63090. /**
  63091. * Creates a cylinder or a cone mesh
  63092. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63093. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63094. * * 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.
  63095. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63096. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63097. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63098. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63099. * * 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).
  63100. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63101. * * 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).
  63102. * * 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
  63103. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63104. * * 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
  63105. * * 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.
  63106. * * If `enclose` is false, a ring surface is one element.
  63107. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63108. * * 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
  63109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63110. * * 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
  63111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63112. * @param name defines the name of the mesh
  63113. * @param options defines the options used to create the mesh
  63114. * @param scene defines the hosting scene
  63115. * @returns the cylinder mesh
  63116. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63117. */
  63118. static CreateCylinder(name: string, options: {
  63119. height?: number;
  63120. diameterTop?: number;
  63121. diameterBottom?: number;
  63122. diameter?: number;
  63123. tessellation?: number;
  63124. subdivisions?: number;
  63125. arc?: number;
  63126. faceColors?: Color4[];
  63127. faceUV?: Vector4[];
  63128. updatable?: boolean;
  63129. hasRings?: boolean;
  63130. enclose?: boolean;
  63131. cap?: number;
  63132. sideOrientation?: number;
  63133. frontUVs?: Vector4;
  63134. backUVs?: Vector4;
  63135. }, scene?: Nullable<Scene>): Mesh;
  63136. /**
  63137. * Creates a torus mesh
  63138. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63139. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63140. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63142. * * 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
  63143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63144. * @param name defines the name of the mesh
  63145. * @param options defines the options used to create the mesh
  63146. * @param scene defines the hosting scene
  63147. * @returns the torus mesh
  63148. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63149. */
  63150. static CreateTorus(name: string, options: {
  63151. diameter?: number;
  63152. thickness?: number;
  63153. tessellation?: number;
  63154. updatable?: boolean;
  63155. sideOrientation?: number;
  63156. frontUVs?: Vector4;
  63157. backUVs?: Vector4;
  63158. }, scene?: Nullable<Scene>): Mesh;
  63159. /**
  63160. * Creates a torus knot mesh
  63161. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63162. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63163. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63164. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63166. * * 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
  63167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63168. * @param name defines the name of the mesh
  63169. * @param options defines the options used to create the mesh
  63170. * @param scene defines the hosting scene
  63171. * @returns the torus knot mesh
  63172. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63173. */
  63174. static CreateTorusKnot(name: string, options: {
  63175. radius?: number;
  63176. tube?: number;
  63177. radialSegments?: number;
  63178. tubularSegments?: number;
  63179. p?: number;
  63180. q?: number;
  63181. updatable?: boolean;
  63182. sideOrientation?: number;
  63183. frontUVs?: Vector4;
  63184. backUVs?: Vector4;
  63185. }, scene?: Nullable<Scene>): Mesh;
  63186. /**
  63187. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63188. * * 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
  63189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63190. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63191. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63192. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63193. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63194. * * 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
  63195. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63198. * @param name defines the name of the new line system
  63199. * @param options defines the options used to create the line system
  63200. * @param scene defines the hosting scene
  63201. * @returns a new line system mesh
  63202. */
  63203. static CreateLineSystem(name: string, options: {
  63204. lines: Vector3[][];
  63205. updatable?: boolean;
  63206. instance?: Nullable<LinesMesh>;
  63207. colors?: Nullable<Color4[][]>;
  63208. useVertexAlpha?: boolean;
  63209. }, scene: Nullable<Scene>): LinesMesh;
  63210. /**
  63211. * Creates a line mesh
  63212. * 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
  63213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63214. * * The parameter `points` is an array successive Vector3
  63215. * * 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
  63216. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63217. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63218. * * When updating an instance, remember that only point positions can change, not the number of points
  63219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63221. * @param name defines the name of the new line system
  63222. * @param options defines the options used to create the line system
  63223. * @param scene defines the hosting scene
  63224. * @returns a new line mesh
  63225. */
  63226. static CreateLines(name: string, options: {
  63227. points: Vector3[];
  63228. updatable?: boolean;
  63229. instance?: Nullable<LinesMesh>;
  63230. colors?: Color4[];
  63231. useVertexAlpha?: boolean;
  63232. }, scene?: Nullable<Scene>): LinesMesh;
  63233. /**
  63234. * Creates a dashed line mesh
  63235. * * 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
  63236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63237. * * The parameter `points` is an array successive Vector3
  63238. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63239. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63240. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63241. * * 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
  63242. * * When updating an instance, remember that only point positions can change, not the number of points
  63243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63244. * @param name defines the name of the mesh
  63245. * @param options defines the options used to create the mesh
  63246. * @param scene defines the hosting scene
  63247. * @returns the dashed line mesh
  63248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63249. */
  63250. static CreateDashedLines(name: string, options: {
  63251. points: Vector3[];
  63252. dashSize?: number;
  63253. gapSize?: number;
  63254. dashNb?: number;
  63255. updatable?: boolean;
  63256. instance?: LinesMesh;
  63257. }, scene?: Nullable<Scene>): LinesMesh;
  63258. /**
  63259. * 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.
  63260. * * 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.
  63261. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63262. * * 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.
  63263. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63264. * * 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
  63265. * * 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
  63266. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63268. * * 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
  63269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63271. * @param name defines the name of the mesh
  63272. * @param options defines the options used to create the mesh
  63273. * @param scene defines the hosting scene
  63274. * @returns the extruded shape mesh
  63275. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63277. */
  63278. static ExtrudeShape(name: string, options: {
  63279. shape: Vector3[];
  63280. path: Vector3[];
  63281. scale?: number;
  63282. rotation?: number;
  63283. cap?: number;
  63284. updatable?: boolean;
  63285. sideOrientation?: number;
  63286. frontUVs?: Vector4;
  63287. backUVs?: Vector4;
  63288. instance?: Mesh;
  63289. invertUV?: boolean;
  63290. }, scene?: Nullable<Scene>): Mesh;
  63291. /**
  63292. * Creates an custom extruded shape mesh.
  63293. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63294. * * 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.
  63295. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63296. * * 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
  63297. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63298. * * 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
  63299. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63300. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63301. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63302. * * 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
  63303. * * 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
  63304. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63306. * * 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
  63307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63309. * @param name defines the name of the mesh
  63310. * @param options defines the options used to create the mesh
  63311. * @param scene defines the hosting scene
  63312. * @returns the custom extruded shape mesh
  63313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63316. */
  63317. static ExtrudeShapeCustom(name: string, options: {
  63318. shape: Vector3[];
  63319. path: Vector3[];
  63320. scaleFunction?: any;
  63321. rotationFunction?: any;
  63322. ribbonCloseArray?: boolean;
  63323. ribbonClosePath?: boolean;
  63324. cap?: number;
  63325. updatable?: boolean;
  63326. sideOrientation?: number;
  63327. frontUVs?: Vector4;
  63328. backUVs?: Vector4;
  63329. instance?: Mesh;
  63330. invertUV?: boolean;
  63331. }, scene?: Nullable<Scene>): Mesh;
  63332. /**
  63333. * Creates lathe mesh.
  63334. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63335. * * 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
  63336. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63337. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63338. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63339. * * 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
  63340. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63341. * * 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
  63342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63343. * * 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
  63344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63346. * @param name defines the name of the mesh
  63347. * @param options defines the options used to create the mesh
  63348. * @param scene defines the hosting scene
  63349. * @returns the lathe mesh
  63350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63351. */
  63352. static CreateLathe(name: string, options: {
  63353. shape: Vector3[];
  63354. radius?: number;
  63355. tessellation?: number;
  63356. clip?: number;
  63357. arc?: number;
  63358. closed?: boolean;
  63359. updatable?: boolean;
  63360. sideOrientation?: number;
  63361. frontUVs?: Vector4;
  63362. backUVs?: Vector4;
  63363. cap?: number;
  63364. invertUV?: boolean;
  63365. }, scene?: Nullable<Scene>): Mesh;
  63366. /**
  63367. * Creates a tiled plane mesh
  63368. * * You can set a limited pattern arrangement with the tiles
  63369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63370. * * 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
  63371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63372. * @param name defines the name of the mesh
  63373. * @param options defines the options used to create the mesh
  63374. * @param scene defines the hosting scene
  63375. * @returns the plane mesh
  63376. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63377. */
  63378. static CreateTiledPlane(name: string, options: {
  63379. pattern?: number;
  63380. tileSize?: number;
  63381. tileWidth?: number;
  63382. tileHeight?: number;
  63383. size?: number;
  63384. width?: number;
  63385. height?: number;
  63386. alignHorizontal?: number;
  63387. alignVertical?: number;
  63388. sideOrientation?: number;
  63389. frontUVs?: Vector4;
  63390. backUVs?: Vector4;
  63391. updatable?: boolean;
  63392. }, scene?: Nullable<Scene>): Mesh;
  63393. /**
  63394. * Creates a plane mesh
  63395. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63396. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63397. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63399. * * 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
  63400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63401. * @param name defines the name of the mesh
  63402. * @param options defines the options used to create the mesh
  63403. * @param scene defines the hosting scene
  63404. * @returns the plane mesh
  63405. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63406. */
  63407. static CreatePlane(name: string, options: {
  63408. size?: number;
  63409. width?: number;
  63410. height?: number;
  63411. sideOrientation?: number;
  63412. frontUVs?: Vector4;
  63413. backUVs?: Vector4;
  63414. updatable?: boolean;
  63415. sourcePlane?: Plane;
  63416. }, scene?: Nullable<Scene>): Mesh;
  63417. /**
  63418. * Creates a ground mesh
  63419. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63420. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63422. * @param name defines the name of the mesh
  63423. * @param options defines the options used to create the mesh
  63424. * @param scene defines the hosting scene
  63425. * @returns the ground mesh
  63426. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63427. */
  63428. static CreateGround(name: string, options: {
  63429. width?: number;
  63430. height?: number;
  63431. subdivisions?: number;
  63432. subdivisionsX?: number;
  63433. subdivisionsY?: number;
  63434. updatable?: boolean;
  63435. }, scene?: Nullable<Scene>): Mesh;
  63436. /**
  63437. * Creates a tiled ground mesh
  63438. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63439. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63440. * * 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
  63441. * * 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
  63442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63443. * @param name defines the name of the mesh
  63444. * @param options defines the options used to create the mesh
  63445. * @param scene defines the hosting scene
  63446. * @returns the tiled ground mesh
  63447. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63448. */
  63449. static CreateTiledGround(name: string, options: {
  63450. xmin: number;
  63451. zmin: number;
  63452. xmax: number;
  63453. zmax: number;
  63454. subdivisions?: {
  63455. w: number;
  63456. h: number;
  63457. };
  63458. precision?: {
  63459. w: number;
  63460. h: number;
  63461. };
  63462. updatable?: boolean;
  63463. }, scene?: Nullable<Scene>): Mesh;
  63464. /**
  63465. * Creates a ground mesh from a height map
  63466. * * The parameter `url` sets the URL of the height map image resource.
  63467. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63468. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63469. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63470. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63471. * * 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.
  63472. * * 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).
  63473. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63475. * @param name defines the name of the mesh
  63476. * @param url defines the url to the height map
  63477. * @param options defines the options used to create the mesh
  63478. * @param scene defines the hosting scene
  63479. * @returns the ground mesh
  63480. * @see https://doc.babylonjs.com/babylon101/height_map
  63481. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63482. */
  63483. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63484. width?: number;
  63485. height?: number;
  63486. subdivisions?: number;
  63487. minHeight?: number;
  63488. maxHeight?: number;
  63489. colorFilter?: Color3;
  63490. alphaFilter?: number;
  63491. updatable?: boolean;
  63492. onReady?: (mesh: GroundMesh) => void;
  63493. }, scene?: Nullable<Scene>): GroundMesh;
  63494. /**
  63495. * Creates a polygon mesh
  63496. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63497. * * 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
  63498. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63500. * * 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)
  63501. * * Remember you can only change the shape positions, not their number when updating a polygon
  63502. * @param name defines the name of the mesh
  63503. * @param options defines the options used to create the mesh
  63504. * @param scene defines the hosting scene
  63505. * @param earcutInjection can be used to inject your own earcut reference
  63506. * @returns the polygon mesh
  63507. */
  63508. static CreatePolygon(name: string, options: {
  63509. shape: Vector3[];
  63510. holes?: Vector3[][];
  63511. depth?: number;
  63512. faceUV?: Vector4[];
  63513. faceColors?: Color4[];
  63514. updatable?: boolean;
  63515. sideOrientation?: number;
  63516. frontUVs?: Vector4;
  63517. backUVs?: Vector4;
  63518. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63519. /**
  63520. * Creates an extruded polygon mesh, with depth in the Y direction.
  63521. * * 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)
  63522. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63523. * @param name defines the name of the mesh
  63524. * @param options defines the options used to create the mesh
  63525. * @param scene defines the hosting scene
  63526. * @param earcutInjection can be used to inject your own earcut reference
  63527. * @returns the polygon mesh
  63528. */
  63529. static ExtrudePolygon(name: string, options: {
  63530. shape: Vector3[];
  63531. holes?: Vector3[][];
  63532. depth?: number;
  63533. faceUV?: Vector4[];
  63534. faceColors?: Color4[];
  63535. updatable?: boolean;
  63536. sideOrientation?: number;
  63537. frontUVs?: Vector4;
  63538. backUVs?: Vector4;
  63539. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63540. /**
  63541. * Creates a tube mesh.
  63542. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63543. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63544. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63545. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63546. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63547. * * 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)
  63548. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63549. * * 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
  63550. * * 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
  63551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63552. * * 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
  63553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63555. * @param name defines the name of the mesh
  63556. * @param options defines the options used to create the mesh
  63557. * @param scene defines the hosting scene
  63558. * @returns the tube mesh
  63559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63560. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63561. */
  63562. static CreateTube(name: string, options: {
  63563. path: Vector3[];
  63564. radius?: number;
  63565. tessellation?: number;
  63566. radiusFunction?: {
  63567. (i: number, distance: number): number;
  63568. };
  63569. cap?: number;
  63570. arc?: number;
  63571. updatable?: boolean;
  63572. sideOrientation?: number;
  63573. frontUVs?: Vector4;
  63574. backUVs?: Vector4;
  63575. instance?: Mesh;
  63576. invertUV?: boolean;
  63577. }, scene?: Nullable<Scene>): Mesh;
  63578. /**
  63579. * Creates a polyhedron mesh
  63580. * * 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
  63581. * * The parameter `size` (positive float, default 1) sets the polygon size
  63582. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63583. * * 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`
  63584. * * 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
  63585. * * 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)`)
  63586. * * 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
  63587. * * 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
  63588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63589. * * 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
  63590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63591. * @param name defines the name of the mesh
  63592. * @param options defines the options used to create the mesh
  63593. * @param scene defines the hosting scene
  63594. * @returns the polyhedron mesh
  63595. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63596. */
  63597. static CreatePolyhedron(name: string, options: {
  63598. type?: number;
  63599. size?: number;
  63600. sizeX?: number;
  63601. sizeY?: number;
  63602. sizeZ?: number;
  63603. custom?: any;
  63604. faceUV?: Vector4[];
  63605. faceColors?: Color4[];
  63606. flat?: boolean;
  63607. updatable?: boolean;
  63608. sideOrientation?: number;
  63609. frontUVs?: Vector4;
  63610. backUVs?: Vector4;
  63611. }, scene?: Nullable<Scene>): Mesh;
  63612. /**
  63613. * Creates a decal mesh.
  63614. * 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
  63615. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63616. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63617. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63618. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63619. * @param name defines the name of the mesh
  63620. * @param sourceMesh defines the mesh where the decal must be applied
  63621. * @param options defines the options used to create the mesh
  63622. * @param scene defines the hosting scene
  63623. * @returns the decal mesh
  63624. * @see https://doc.babylonjs.com/how_to/decals
  63625. */
  63626. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63627. position?: Vector3;
  63628. normal?: Vector3;
  63629. size?: Vector3;
  63630. angle?: number;
  63631. }): Mesh;
  63632. }
  63633. }
  63634. declare module BABYLON {
  63635. /**
  63636. * A simplifier interface for future simplification implementations
  63637. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63638. */
  63639. export interface ISimplifier {
  63640. /**
  63641. * Simplification of a given mesh according to the given settings.
  63642. * Since this requires computation, it is assumed that the function runs async.
  63643. * @param settings The settings of the simplification, including quality and distance
  63644. * @param successCallback A callback that will be called after the mesh was simplified.
  63645. * @param errorCallback in case of an error, this callback will be called. optional.
  63646. */
  63647. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63648. }
  63649. /**
  63650. * Expected simplification settings.
  63651. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63652. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63653. */
  63654. export interface ISimplificationSettings {
  63655. /**
  63656. * Gets or sets the expected quality
  63657. */
  63658. quality: number;
  63659. /**
  63660. * Gets or sets the distance when this optimized version should be used
  63661. */
  63662. distance: number;
  63663. /**
  63664. * Gets an already optimized mesh
  63665. */
  63666. optimizeMesh?: boolean;
  63667. }
  63668. /**
  63669. * Class used to specify simplification options
  63670. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63671. */
  63672. export class SimplificationSettings implements ISimplificationSettings {
  63673. /** expected quality */
  63674. quality: number;
  63675. /** distance when this optimized version should be used */
  63676. distance: number;
  63677. /** already optimized mesh */
  63678. optimizeMesh?: boolean | undefined;
  63679. /**
  63680. * Creates a SimplificationSettings
  63681. * @param quality expected quality
  63682. * @param distance distance when this optimized version should be used
  63683. * @param optimizeMesh already optimized mesh
  63684. */
  63685. constructor(
  63686. /** expected quality */
  63687. quality: number,
  63688. /** distance when this optimized version should be used */
  63689. distance: number,
  63690. /** already optimized mesh */
  63691. optimizeMesh?: boolean | undefined);
  63692. }
  63693. /**
  63694. * Interface used to define a simplification task
  63695. */
  63696. export interface ISimplificationTask {
  63697. /**
  63698. * Array of settings
  63699. */
  63700. settings: Array<ISimplificationSettings>;
  63701. /**
  63702. * Simplification type
  63703. */
  63704. simplificationType: SimplificationType;
  63705. /**
  63706. * Mesh to simplify
  63707. */
  63708. mesh: Mesh;
  63709. /**
  63710. * Callback called on success
  63711. */
  63712. successCallback?: () => void;
  63713. /**
  63714. * Defines if parallel processing can be used
  63715. */
  63716. parallelProcessing: boolean;
  63717. }
  63718. /**
  63719. * Queue used to order the simplification tasks
  63720. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63721. */
  63722. export class SimplificationQueue {
  63723. private _simplificationArray;
  63724. /**
  63725. * Gets a boolean indicating that the process is still running
  63726. */
  63727. running: boolean;
  63728. /**
  63729. * Creates a new queue
  63730. */
  63731. constructor();
  63732. /**
  63733. * Adds a new simplification task
  63734. * @param task defines a task to add
  63735. */
  63736. addTask(task: ISimplificationTask): void;
  63737. /**
  63738. * Execute next task
  63739. */
  63740. executeNext(): void;
  63741. /**
  63742. * Execute a simplification task
  63743. * @param task defines the task to run
  63744. */
  63745. runSimplification(task: ISimplificationTask): void;
  63746. private getSimplifier;
  63747. }
  63748. /**
  63749. * The implemented types of simplification
  63750. * At the moment only Quadratic Error Decimation is implemented
  63751. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63752. */
  63753. export enum SimplificationType {
  63754. /** Quadratic error decimation */
  63755. QUADRATIC = 0
  63756. }
  63757. /**
  63758. * An implementation of the Quadratic Error simplification algorithm.
  63759. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  63760. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  63761. * @author RaananW
  63762. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63763. */
  63764. export class QuadraticErrorSimplification implements ISimplifier {
  63765. private _mesh;
  63766. private triangles;
  63767. private vertices;
  63768. private references;
  63769. private _reconstructedMesh;
  63770. /** Gets or sets the number pf sync interations */
  63771. syncIterations: number;
  63772. /** Gets or sets the aggressiveness of the simplifier */
  63773. aggressiveness: number;
  63774. /** Gets or sets the number of allowed iterations for decimation */
  63775. decimationIterations: number;
  63776. /** Gets or sets the espilon to use for bounding box computation */
  63777. boundingBoxEpsilon: number;
  63778. /**
  63779. * Creates a new QuadraticErrorSimplification
  63780. * @param _mesh defines the target mesh
  63781. */
  63782. constructor(_mesh: Mesh);
  63783. /**
  63784. * Simplification of a given mesh according to the given settings.
  63785. * Since this requires computation, it is assumed that the function runs async.
  63786. * @param settings The settings of the simplification, including quality and distance
  63787. * @param successCallback A callback that will be called after the mesh was simplified.
  63788. */
  63789. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  63790. private runDecimation;
  63791. private initWithMesh;
  63792. private init;
  63793. private reconstructMesh;
  63794. private initDecimatedMesh;
  63795. private isFlipped;
  63796. private updateTriangles;
  63797. private identifyBorder;
  63798. private updateMesh;
  63799. private vertexError;
  63800. private calculateError;
  63801. }
  63802. }
  63803. declare module BABYLON {
  63804. interface Scene {
  63805. /** @hidden (Backing field) */
  63806. _simplificationQueue: SimplificationQueue;
  63807. /**
  63808. * Gets or sets the simplification queue attached to the scene
  63809. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63810. */
  63811. simplificationQueue: SimplificationQueue;
  63812. }
  63813. interface Mesh {
  63814. /**
  63815. * Simplify the mesh according to the given array of settings.
  63816. * Function will return immediately and will simplify async
  63817. * @param settings a collection of simplification settings
  63818. * @param parallelProcessing should all levels calculate parallel or one after the other
  63819. * @param simplificationType the type of simplification to run
  63820. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63821. * @returns the current mesh
  63822. */
  63823. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63824. }
  63825. /**
  63826. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63827. * created in a scene
  63828. */
  63829. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63830. /**
  63831. * The component name helpfull to identify the component in the list of scene components.
  63832. */
  63833. readonly name: string;
  63834. /**
  63835. * The scene the component belongs to.
  63836. */
  63837. scene: Scene;
  63838. /**
  63839. * Creates a new instance of the component for the given scene
  63840. * @param scene Defines the scene to register the component in
  63841. */
  63842. constructor(scene: Scene);
  63843. /**
  63844. * Registers the component in a given scene
  63845. */
  63846. register(): void;
  63847. /**
  63848. * Rebuilds the elements related to this component in case of
  63849. * context lost for instance.
  63850. */
  63851. rebuild(): void;
  63852. /**
  63853. * Disposes the component and the associated ressources
  63854. */
  63855. dispose(): void;
  63856. private _beforeCameraUpdate;
  63857. }
  63858. }
  63859. declare module BABYLON {
  63860. /**
  63861. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63862. */
  63863. export interface INavigationEnginePlugin {
  63864. /**
  63865. * plugin name
  63866. */
  63867. name: string;
  63868. /**
  63869. * Creates a navigation mesh
  63870. * @param meshes array of all the geometry used to compute the navigatio mesh
  63871. * @param parameters bunch of parameters used to filter geometry
  63872. */
  63873. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63874. /**
  63875. * Create a navigation mesh debug mesh
  63876. * @param scene is where the mesh will be added
  63877. * @returns debug display mesh
  63878. */
  63879. createDebugNavMesh(scene: Scene): Mesh;
  63880. /**
  63881. * Get a navigation mesh constrained position, closest to the parameter position
  63882. * @param position world position
  63883. * @returns the closest point to position constrained by the navigation mesh
  63884. */
  63885. getClosestPoint(position: Vector3): Vector3;
  63886. /**
  63887. * Get a navigation mesh constrained position, closest to the parameter position
  63888. * @param position world position
  63889. * @param result output the closest point to position constrained by the navigation mesh
  63890. */
  63891. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63892. /**
  63893. * Get a navigation mesh constrained position, within a particular radius
  63894. * @param position world position
  63895. * @param maxRadius the maximum distance to the constrained world position
  63896. * @returns the closest point to position constrained by the navigation mesh
  63897. */
  63898. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63899. /**
  63900. * Get a navigation mesh constrained position, within a particular radius
  63901. * @param position world position
  63902. * @param maxRadius the maximum distance to the constrained world position
  63903. * @param result output the closest point to position constrained by the navigation mesh
  63904. */
  63905. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63906. /**
  63907. * Compute the final position from a segment made of destination-position
  63908. * @param position world position
  63909. * @param destination world position
  63910. * @returns the resulting point along the navmesh
  63911. */
  63912. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63913. /**
  63914. * Compute the final position from a segment made of destination-position
  63915. * @param position world position
  63916. * @param destination world position
  63917. * @param result output the resulting point along the navmesh
  63918. */
  63919. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63920. /**
  63921. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63922. * @param start world position
  63923. * @param end world position
  63924. * @returns array containing world position composing the path
  63925. */
  63926. computePath(start: Vector3, end: Vector3): Vector3[];
  63927. /**
  63928. * If this plugin is supported
  63929. * @returns true if plugin is supported
  63930. */
  63931. isSupported(): boolean;
  63932. /**
  63933. * Create a new Crowd so you can add agents
  63934. * @param maxAgents the maximum agent count in the crowd
  63935. * @param maxAgentRadius the maximum radius an agent can have
  63936. * @param scene to attach the crowd to
  63937. * @returns the crowd you can add agents to
  63938. */
  63939. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63940. /**
  63941. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63942. * The queries will try to find a solution within those bounds
  63943. * default is (1,1,1)
  63944. * @param extent x,y,z value that define the extent around the queries point of reference
  63945. */
  63946. setDefaultQueryExtent(extent: Vector3): void;
  63947. /**
  63948. * Get the Bounding box extent specified by setDefaultQueryExtent
  63949. * @returns the box extent values
  63950. */
  63951. getDefaultQueryExtent(): Vector3;
  63952. /**
  63953. * build the navmesh from a previously saved state using getNavmeshData
  63954. * @param data the Uint8Array returned by getNavmeshData
  63955. */
  63956. buildFromNavmeshData(data: Uint8Array): void;
  63957. /**
  63958. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63959. * @returns data the Uint8Array that can be saved and reused
  63960. */
  63961. getNavmeshData(): Uint8Array;
  63962. /**
  63963. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63964. * @param result output the box extent values
  63965. */
  63966. getDefaultQueryExtentToRef(result: Vector3): void;
  63967. /**
  63968. * Release all resources
  63969. */
  63970. dispose(): void;
  63971. }
  63972. /**
  63973. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63974. */
  63975. export interface ICrowd {
  63976. /**
  63977. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63978. * You can attach anything to that node. The node position is updated in the scene update tick.
  63979. * @param pos world position that will be constrained by the navigation mesh
  63980. * @param parameters agent parameters
  63981. * @param transform hooked to the agent that will be update by the scene
  63982. * @returns agent index
  63983. */
  63984. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63985. /**
  63986. * Returns the agent position in world space
  63987. * @param index agent index returned by addAgent
  63988. * @returns world space position
  63989. */
  63990. getAgentPosition(index: number): Vector3;
  63991. /**
  63992. * Gets the agent position result in world space
  63993. * @param index agent index returned by addAgent
  63994. * @param result output world space position
  63995. */
  63996. getAgentPositionToRef(index: number, result: Vector3): void;
  63997. /**
  63998. * Gets the agent velocity in world space
  63999. * @param index agent index returned by addAgent
  64000. * @returns world space velocity
  64001. */
  64002. getAgentVelocity(index: number): Vector3;
  64003. /**
  64004. * Gets the agent velocity result in world space
  64005. * @param index agent index returned by addAgent
  64006. * @param result output world space velocity
  64007. */
  64008. getAgentVelocityToRef(index: number, result: Vector3): void;
  64009. /**
  64010. * remove a particular agent previously created
  64011. * @param index agent index returned by addAgent
  64012. */
  64013. removeAgent(index: number): void;
  64014. /**
  64015. * get the list of all agents attached to this crowd
  64016. * @returns list of agent indices
  64017. */
  64018. getAgents(): number[];
  64019. /**
  64020. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64021. * @param deltaTime in seconds
  64022. */
  64023. update(deltaTime: number): void;
  64024. /**
  64025. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64026. * @param index agent index returned by addAgent
  64027. * @param destination targeted world position
  64028. */
  64029. agentGoto(index: number, destination: Vector3): void;
  64030. /**
  64031. * Teleport the agent to a new position
  64032. * @param index agent index returned by addAgent
  64033. * @param destination targeted world position
  64034. */
  64035. agentTeleport(index: number, destination: Vector3): void;
  64036. /**
  64037. * Update agent parameters
  64038. * @param index agent index returned by addAgent
  64039. * @param parameters agent parameters
  64040. */
  64041. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64042. /**
  64043. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64044. * The queries will try to find a solution within those bounds
  64045. * default is (1,1,1)
  64046. * @param extent x,y,z value that define the extent around the queries point of reference
  64047. */
  64048. setDefaultQueryExtent(extent: Vector3): void;
  64049. /**
  64050. * Get the Bounding box extent specified by setDefaultQueryExtent
  64051. * @returns the box extent values
  64052. */
  64053. getDefaultQueryExtent(): Vector3;
  64054. /**
  64055. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64056. * @param result output the box extent values
  64057. */
  64058. getDefaultQueryExtentToRef(result: Vector3): void;
  64059. /**
  64060. * Release all resources
  64061. */
  64062. dispose(): void;
  64063. }
  64064. /**
  64065. * Configures an agent
  64066. */
  64067. export interface IAgentParameters {
  64068. /**
  64069. * Agent radius. [Limit: >= 0]
  64070. */
  64071. radius: number;
  64072. /**
  64073. * Agent height. [Limit: > 0]
  64074. */
  64075. height: number;
  64076. /**
  64077. * Maximum allowed acceleration. [Limit: >= 0]
  64078. */
  64079. maxAcceleration: number;
  64080. /**
  64081. * Maximum allowed speed. [Limit: >= 0]
  64082. */
  64083. maxSpeed: number;
  64084. /**
  64085. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64086. */
  64087. collisionQueryRange: number;
  64088. /**
  64089. * The path visibility optimization range. [Limit: > 0]
  64090. */
  64091. pathOptimizationRange: number;
  64092. /**
  64093. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64094. */
  64095. separationWeight: number;
  64096. }
  64097. /**
  64098. * Configures the navigation mesh creation
  64099. */
  64100. export interface INavMeshParameters {
  64101. /**
  64102. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64103. */
  64104. cs: number;
  64105. /**
  64106. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64107. */
  64108. ch: number;
  64109. /**
  64110. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64111. */
  64112. walkableSlopeAngle: number;
  64113. /**
  64114. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64115. * be considered walkable. [Limit: >= 3] [Units: vx]
  64116. */
  64117. walkableHeight: number;
  64118. /**
  64119. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64120. */
  64121. walkableClimb: number;
  64122. /**
  64123. * The distance to erode/shrink the walkable area of the heightfield away from
  64124. * obstructions. [Limit: >=0] [Units: vx]
  64125. */
  64126. walkableRadius: number;
  64127. /**
  64128. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64129. */
  64130. maxEdgeLen: number;
  64131. /**
  64132. * The maximum distance a simplfied contour's border edges should deviate
  64133. * the original raw contour. [Limit: >=0] [Units: vx]
  64134. */
  64135. maxSimplificationError: number;
  64136. /**
  64137. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64138. */
  64139. minRegionArea: number;
  64140. /**
  64141. * Any regions with a span count smaller than this value will, if possible,
  64142. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64143. */
  64144. mergeRegionArea: number;
  64145. /**
  64146. * The maximum number of vertices allowed for polygons generated during the
  64147. * contour to polygon conversion process. [Limit: >= 3]
  64148. */
  64149. maxVertsPerPoly: number;
  64150. /**
  64151. * Sets the sampling distance to use when generating the detail mesh.
  64152. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64153. */
  64154. detailSampleDist: number;
  64155. /**
  64156. * The maximum distance the detail mesh surface should deviate from heightfield
  64157. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64158. */
  64159. detailSampleMaxError: number;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * RecastJS navigation plugin
  64165. */
  64166. export class RecastJSPlugin implements INavigationEnginePlugin {
  64167. /**
  64168. * Reference to the Recast library
  64169. */
  64170. bjsRECAST: any;
  64171. /**
  64172. * plugin name
  64173. */
  64174. name: string;
  64175. /**
  64176. * the first navmesh created. We might extend this to support multiple navmeshes
  64177. */
  64178. navMesh: any;
  64179. /**
  64180. * Initializes the recastJS plugin
  64181. * @param recastInjection can be used to inject your own recast reference
  64182. */
  64183. constructor(recastInjection?: any);
  64184. /**
  64185. * Creates a navigation mesh
  64186. * @param meshes array of all the geometry used to compute the navigatio mesh
  64187. * @param parameters bunch of parameters used to filter geometry
  64188. */
  64189. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64190. /**
  64191. * Create a navigation mesh debug mesh
  64192. * @param scene is where the mesh will be added
  64193. * @returns debug display mesh
  64194. */
  64195. createDebugNavMesh(scene: Scene): Mesh;
  64196. /**
  64197. * Get a navigation mesh constrained position, closest to the parameter position
  64198. * @param position world position
  64199. * @returns the closest point to position constrained by the navigation mesh
  64200. */
  64201. getClosestPoint(position: Vector3): Vector3;
  64202. /**
  64203. * Get a navigation mesh constrained position, closest to the parameter position
  64204. * @param position world position
  64205. * @param result output the closest point to position constrained by the navigation mesh
  64206. */
  64207. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64208. /**
  64209. * Get a navigation mesh constrained position, within a particular radius
  64210. * @param position world position
  64211. * @param maxRadius the maximum distance to the constrained world position
  64212. * @returns the closest point to position constrained by the navigation mesh
  64213. */
  64214. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64215. /**
  64216. * Get a navigation mesh constrained position, within a particular radius
  64217. * @param position world position
  64218. * @param maxRadius the maximum distance to the constrained world position
  64219. * @param result output the closest point to position constrained by the navigation mesh
  64220. */
  64221. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64222. /**
  64223. * Compute the final position from a segment made of destination-position
  64224. * @param position world position
  64225. * @param destination world position
  64226. * @returns the resulting point along the navmesh
  64227. */
  64228. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64229. /**
  64230. * Compute the final position from a segment made of destination-position
  64231. * @param position world position
  64232. * @param destination world position
  64233. * @param result output the resulting point along the navmesh
  64234. */
  64235. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64236. /**
  64237. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64238. * @param start world position
  64239. * @param end world position
  64240. * @returns array containing world position composing the path
  64241. */
  64242. computePath(start: Vector3, end: Vector3): Vector3[];
  64243. /**
  64244. * Create a new Crowd so you can add agents
  64245. * @param maxAgents the maximum agent count in the crowd
  64246. * @param maxAgentRadius the maximum radius an agent can have
  64247. * @param scene to attach the crowd to
  64248. * @returns the crowd you can add agents to
  64249. */
  64250. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64251. /**
  64252. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64253. * The queries will try to find a solution within those bounds
  64254. * default is (1,1,1)
  64255. * @param extent x,y,z value that define the extent around the queries point of reference
  64256. */
  64257. setDefaultQueryExtent(extent: Vector3): void;
  64258. /**
  64259. * Get the Bounding box extent specified by setDefaultQueryExtent
  64260. * @returns the box extent values
  64261. */
  64262. getDefaultQueryExtent(): Vector3;
  64263. /**
  64264. * build the navmesh from a previously saved state using getNavmeshData
  64265. * @param data the Uint8Array returned by getNavmeshData
  64266. */
  64267. buildFromNavmeshData(data: Uint8Array): void;
  64268. /**
  64269. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64270. * @returns data the Uint8Array that can be saved and reused
  64271. */
  64272. getNavmeshData(): Uint8Array;
  64273. /**
  64274. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64275. * @param result output the box extent values
  64276. */
  64277. getDefaultQueryExtentToRef(result: Vector3): void;
  64278. /**
  64279. * Disposes
  64280. */
  64281. dispose(): void;
  64282. /**
  64283. * If this plugin is supported
  64284. * @returns true if plugin is supported
  64285. */
  64286. isSupported(): boolean;
  64287. }
  64288. /**
  64289. * Recast detour crowd implementation
  64290. */
  64291. export class RecastJSCrowd implements ICrowd {
  64292. /**
  64293. * Recast/detour plugin
  64294. */
  64295. bjsRECASTPlugin: RecastJSPlugin;
  64296. /**
  64297. * Link to the detour crowd
  64298. */
  64299. recastCrowd: any;
  64300. /**
  64301. * One transform per agent
  64302. */
  64303. transforms: TransformNode[];
  64304. /**
  64305. * All agents created
  64306. */
  64307. agents: number[];
  64308. /**
  64309. * Link to the scene is kept to unregister the crowd from the scene
  64310. */
  64311. private _scene;
  64312. /**
  64313. * Observer for crowd updates
  64314. */
  64315. private _onBeforeAnimationsObserver;
  64316. /**
  64317. * Constructor
  64318. * @param plugin recastJS plugin
  64319. * @param maxAgents the maximum agent count in the crowd
  64320. * @param maxAgentRadius the maximum radius an agent can have
  64321. * @param scene to attach the crowd to
  64322. * @returns the crowd you can add agents to
  64323. */
  64324. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64325. /**
  64326. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64327. * You can attach anything to that node. The node position is updated in the scene update tick.
  64328. * @param pos world position that will be constrained by the navigation mesh
  64329. * @param parameters agent parameters
  64330. * @param transform hooked to the agent that will be update by the scene
  64331. * @returns agent index
  64332. */
  64333. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64334. /**
  64335. * Returns the agent position in world space
  64336. * @param index agent index returned by addAgent
  64337. * @returns world space position
  64338. */
  64339. getAgentPosition(index: number): Vector3;
  64340. /**
  64341. * Returns the agent position result in world space
  64342. * @param index agent index returned by addAgent
  64343. * @param result output world space position
  64344. */
  64345. getAgentPositionToRef(index: number, result: Vector3): void;
  64346. /**
  64347. * Returns the agent velocity in world space
  64348. * @param index agent index returned by addAgent
  64349. * @returns world space velocity
  64350. */
  64351. getAgentVelocity(index: number): Vector3;
  64352. /**
  64353. * Returns the agent velocity result in world space
  64354. * @param index agent index returned by addAgent
  64355. * @param result output world space velocity
  64356. */
  64357. getAgentVelocityToRef(index: number, result: Vector3): void;
  64358. /**
  64359. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64360. * @param index agent index returned by addAgent
  64361. * @param destination targeted world position
  64362. */
  64363. agentGoto(index: number, destination: Vector3): void;
  64364. /**
  64365. * Teleport the agent to a new position
  64366. * @param index agent index returned by addAgent
  64367. * @param destination targeted world position
  64368. */
  64369. agentTeleport(index: number, destination: Vector3): void;
  64370. /**
  64371. * Update agent parameters
  64372. * @param index agent index returned by addAgent
  64373. * @param parameters agent parameters
  64374. */
  64375. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64376. /**
  64377. * remove a particular agent previously created
  64378. * @param index agent index returned by addAgent
  64379. */
  64380. removeAgent(index: number): void;
  64381. /**
  64382. * get the list of all agents attached to this crowd
  64383. * @returns list of agent indices
  64384. */
  64385. getAgents(): number[];
  64386. /**
  64387. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64388. * @param deltaTime in seconds
  64389. */
  64390. update(deltaTime: number): void;
  64391. /**
  64392. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64393. * The queries will try to find a solution within those bounds
  64394. * default is (1,1,1)
  64395. * @param extent x,y,z value that define the extent around the queries point of reference
  64396. */
  64397. setDefaultQueryExtent(extent: Vector3): void;
  64398. /**
  64399. * Get the Bounding box extent specified by setDefaultQueryExtent
  64400. * @returns the box extent values
  64401. */
  64402. getDefaultQueryExtent(): Vector3;
  64403. /**
  64404. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64405. * @param result output the box extent values
  64406. */
  64407. getDefaultQueryExtentToRef(result: Vector3): void;
  64408. /**
  64409. * Release all resources
  64410. */
  64411. dispose(): void;
  64412. }
  64413. }
  64414. declare module BABYLON {
  64415. /**
  64416. * Class used to enable access to IndexedDB
  64417. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64418. */
  64419. export class Database implements IOfflineProvider {
  64420. private _callbackManifestChecked;
  64421. private _currentSceneUrl;
  64422. private _db;
  64423. private _enableSceneOffline;
  64424. private _enableTexturesOffline;
  64425. private _manifestVersionFound;
  64426. private _mustUpdateRessources;
  64427. private _hasReachedQuota;
  64428. private _isSupported;
  64429. private _idbFactory;
  64430. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64431. private static IsUASupportingBlobStorage;
  64432. /**
  64433. * Gets a boolean indicating if Database storate is enabled (off by default)
  64434. */
  64435. static IDBStorageEnabled: boolean;
  64436. /**
  64437. * Gets a boolean indicating if scene must be saved in the database
  64438. */
  64439. get enableSceneOffline(): boolean;
  64440. /**
  64441. * Gets a boolean indicating if textures must be saved in the database
  64442. */
  64443. get enableTexturesOffline(): boolean;
  64444. /**
  64445. * Creates a new Database
  64446. * @param urlToScene defines the url to load the scene
  64447. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64448. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64449. */
  64450. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64451. private static _ParseURL;
  64452. private static _ReturnFullUrlLocation;
  64453. private _checkManifestFile;
  64454. /**
  64455. * Open the database and make it available
  64456. * @param successCallback defines the callback to call on success
  64457. * @param errorCallback defines the callback to call on error
  64458. */
  64459. open(successCallback: () => void, errorCallback: () => void): void;
  64460. /**
  64461. * Loads an image from the database
  64462. * @param url defines the url to load from
  64463. * @param image defines the target DOM image
  64464. */
  64465. loadImage(url: string, image: HTMLImageElement): void;
  64466. private _loadImageFromDBAsync;
  64467. private _saveImageIntoDBAsync;
  64468. private _checkVersionFromDB;
  64469. private _loadVersionFromDBAsync;
  64470. private _saveVersionIntoDBAsync;
  64471. /**
  64472. * Loads a file from database
  64473. * @param url defines the URL to load from
  64474. * @param sceneLoaded defines a callback to call on success
  64475. * @param progressCallBack defines a callback to call when progress changed
  64476. * @param errorCallback defines a callback to call on error
  64477. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64478. */
  64479. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64480. private _loadFileAsync;
  64481. private _saveFileAsync;
  64482. /**
  64483. * Validates if xhr data is correct
  64484. * @param xhr defines the request to validate
  64485. * @param dataType defines the expected data type
  64486. * @returns true if data is correct
  64487. */
  64488. private static _ValidateXHRData;
  64489. }
  64490. }
  64491. declare module BABYLON {
  64492. /** @hidden */
  64493. export var gpuUpdateParticlesPixelShader: {
  64494. name: string;
  64495. shader: string;
  64496. };
  64497. }
  64498. declare module BABYLON {
  64499. /** @hidden */
  64500. export var gpuUpdateParticlesVertexShader: {
  64501. name: string;
  64502. shader: string;
  64503. };
  64504. }
  64505. declare module BABYLON {
  64506. /** @hidden */
  64507. export var clipPlaneFragmentDeclaration2: {
  64508. name: string;
  64509. shader: string;
  64510. };
  64511. }
  64512. declare module BABYLON {
  64513. /** @hidden */
  64514. export var gpuRenderParticlesPixelShader: {
  64515. name: string;
  64516. shader: string;
  64517. };
  64518. }
  64519. declare module BABYLON {
  64520. /** @hidden */
  64521. export var clipPlaneVertexDeclaration2: {
  64522. name: string;
  64523. shader: string;
  64524. };
  64525. }
  64526. declare module BABYLON {
  64527. /** @hidden */
  64528. export var gpuRenderParticlesVertexShader: {
  64529. name: string;
  64530. shader: string;
  64531. };
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * This represents a GPU particle system in Babylon
  64536. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64537. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64538. */
  64539. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64540. /**
  64541. * The layer mask we are rendering the particles through.
  64542. */
  64543. layerMask: number;
  64544. private _capacity;
  64545. private _activeCount;
  64546. private _currentActiveCount;
  64547. private _accumulatedCount;
  64548. private _renderEffect;
  64549. private _updateEffect;
  64550. private _buffer0;
  64551. private _buffer1;
  64552. private _spriteBuffer;
  64553. private _updateVAO;
  64554. private _renderVAO;
  64555. private _targetIndex;
  64556. private _sourceBuffer;
  64557. private _targetBuffer;
  64558. private _engine;
  64559. private _currentRenderId;
  64560. private _started;
  64561. private _stopped;
  64562. private _timeDelta;
  64563. private _randomTexture;
  64564. private _randomTexture2;
  64565. private _attributesStrideSize;
  64566. private _updateEffectOptions;
  64567. private _randomTextureSize;
  64568. private _actualFrame;
  64569. private readonly _rawTextureWidth;
  64570. /**
  64571. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64572. */
  64573. static get IsSupported(): boolean;
  64574. /**
  64575. * An event triggered when the system is disposed.
  64576. */
  64577. onDisposeObservable: Observable<GPUParticleSystem>;
  64578. /**
  64579. * Gets the maximum number of particles active at the same time.
  64580. * @returns The max number of active particles.
  64581. */
  64582. getCapacity(): number;
  64583. /**
  64584. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64585. * to override the particles.
  64586. */
  64587. forceDepthWrite: boolean;
  64588. /**
  64589. * Gets or set the number of active particles
  64590. */
  64591. get activeParticleCount(): number;
  64592. set activeParticleCount(value: number);
  64593. private _preWarmDone;
  64594. /**
  64595. * Specifies if the particles are updated in emitter local space or world space.
  64596. */
  64597. isLocal: boolean;
  64598. /**
  64599. * Is this system ready to be used/rendered
  64600. * @return true if the system is ready
  64601. */
  64602. isReady(): boolean;
  64603. /**
  64604. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64605. * @returns True if it has been started, otherwise false.
  64606. */
  64607. isStarted(): boolean;
  64608. /**
  64609. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  64610. * @returns True if it has been stopped, otherwise false.
  64611. */
  64612. isStopped(): boolean;
  64613. /**
  64614. * Gets a boolean indicating that the system is stopping
  64615. * @returns true if the system is currently stopping
  64616. */
  64617. isStopping(): boolean;
  64618. /**
  64619. * Gets the number of particles active at the same time.
  64620. * @returns The number of active particles.
  64621. */
  64622. getActiveCount(): number;
  64623. /**
  64624. * Starts the particle system and begins to emit
  64625. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64626. */
  64627. start(delay?: number): void;
  64628. /**
  64629. * Stops the particle system.
  64630. */
  64631. stop(): void;
  64632. /**
  64633. * Remove all active particles
  64634. */
  64635. reset(): void;
  64636. /**
  64637. * Returns the string "GPUParticleSystem"
  64638. * @returns a string containing the class name
  64639. */
  64640. getClassName(): string;
  64641. private _colorGradientsTexture;
  64642. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64643. /**
  64644. * Adds a new color gradient
  64645. * @param gradient defines the gradient to use (between 0 and 1)
  64646. * @param color1 defines the color to affect to the specified gradient
  64647. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64648. * @returns the current particle system
  64649. */
  64650. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64651. private _refreshColorGradient;
  64652. /** Force the system to rebuild all gradients that need to be resync */
  64653. forceRefreshGradients(): void;
  64654. /**
  64655. * Remove a specific color gradient
  64656. * @param gradient defines the gradient to remove
  64657. * @returns the current particle system
  64658. */
  64659. removeColorGradient(gradient: number): GPUParticleSystem;
  64660. private _angularSpeedGradientsTexture;
  64661. private _sizeGradientsTexture;
  64662. private _velocityGradientsTexture;
  64663. private _limitVelocityGradientsTexture;
  64664. private _dragGradientsTexture;
  64665. private _addFactorGradient;
  64666. /**
  64667. * Adds a new size gradient
  64668. * @param gradient defines the gradient to use (between 0 and 1)
  64669. * @param factor defines the size factor to affect to the specified gradient
  64670. * @returns the current particle system
  64671. */
  64672. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64673. /**
  64674. * Remove a specific size gradient
  64675. * @param gradient defines the gradient to remove
  64676. * @returns the current particle system
  64677. */
  64678. removeSizeGradient(gradient: number): GPUParticleSystem;
  64679. private _refreshFactorGradient;
  64680. /**
  64681. * Adds a new angular speed gradient
  64682. * @param gradient defines the gradient to use (between 0 and 1)
  64683. * @param factor defines the angular speed to affect to the specified gradient
  64684. * @returns the current particle system
  64685. */
  64686. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64687. /**
  64688. * Remove a specific angular speed gradient
  64689. * @param gradient defines the gradient to remove
  64690. * @returns the current particle system
  64691. */
  64692. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64693. /**
  64694. * Adds a new velocity gradient
  64695. * @param gradient defines the gradient to use (between 0 and 1)
  64696. * @param factor defines the velocity to affect to the specified gradient
  64697. * @returns the current particle system
  64698. */
  64699. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64700. /**
  64701. * Remove a specific velocity gradient
  64702. * @param gradient defines the gradient to remove
  64703. * @returns the current particle system
  64704. */
  64705. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64706. /**
  64707. * Adds a new limit velocity gradient
  64708. * @param gradient defines the gradient to use (between 0 and 1)
  64709. * @param factor defines the limit velocity value to affect to the specified gradient
  64710. * @returns the current particle system
  64711. */
  64712. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64713. /**
  64714. * Remove a specific limit velocity gradient
  64715. * @param gradient defines the gradient to remove
  64716. * @returns the current particle system
  64717. */
  64718. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64719. /**
  64720. * Adds a new drag gradient
  64721. * @param gradient defines the gradient to use (between 0 and 1)
  64722. * @param factor defines the drag value to affect to the specified gradient
  64723. * @returns the current particle system
  64724. */
  64725. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64726. /**
  64727. * Remove a specific drag gradient
  64728. * @param gradient defines the gradient to remove
  64729. * @returns the current particle system
  64730. */
  64731. removeDragGradient(gradient: number): GPUParticleSystem;
  64732. /**
  64733. * Not supported by GPUParticleSystem
  64734. * @param gradient defines the gradient to use (between 0 and 1)
  64735. * @param factor defines the emit rate value to affect to the specified gradient
  64736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64737. * @returns the current particle system
  64738. */
  64739. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64740. /**
  64741. * Not supported by GPUParticleSystem
  64742. * @param gradient defines the gradient to remove
  64743. * @returns the current particle system
  64744. */
  64745. removeEmitRateGradient(gradient: number): IParticleSystem;
  64746. /**
  64747. * Not supported by GPUParticleSystem
  64748. * @param gradient defines the gradient to use (between 0 and 1)
  64749. * @param factor defines the start size value to affect to the specified gradient
  64750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64751. * @returns the current particle system
  64752. */
  64753. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64754. /**
  64755. * Not supported by GPUParticleSystem
  64756. * @param gradient defines the gradient to remove
  64757. * @returns the current particle system
  64758. */
  64759. removeStartSizeGradient(gradient: number): IParticleSystem;
  64760. /**
  64761. * Not supported by GPUParticleSystem
  64762. * @param gradient defines the gradient to use (between 0 and 1)
  64763. * @param min defines the color remap minimal range
  64764. * @param max defines the color remap maximal range
  64765. * @returns the current particle system
  64766. */
  64767. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64768. /**
  64769. * Not supported by GPUParticleSystem
  64770. * @param gradient defines the gradient to remove
  64771. * @returns the current particle system
  64772. */
  64773. removeColorRemapGradient(): IParticleSystem;
  64774. /**
  64775. * Not supported by GPUParticleSystem
  64776. * @param gradient defines the gradient to use (between 0 and 1)
  64777. * @param min defines the alpha remap minimal range
  64778. * @param max defines the alpha remap maximal range
  64779. * @returns the current particle system
  64780. */
  64781. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64782. /**
  64783. * Not supported by GPUParticleSystem
  64784. * @param gradient defines the gradient to remove
  64785. * @returns the current particle system
  64786. */
  64787. removeAlphaRemapGradient(): IParticleSystem;
  64788. /**
  64789. * Not supported by GPUParticleSystem
  64790. * @param gradient defines the gradient to use (between 0 and 1)
  64791. * @param color defines the color to affect to the specified gradient
  64792. * @returns the current particle system
  64793. */
  64794. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64795. /**
  64796. * Not supported by GPUParticleSystem
  64797. * @param gradient defines the gradient to remove
  64798. * @returns the current particle system
  64799. */
  64800. removeRampGradient(): IParticleSystem;
  64801. /**
  64802. * Not supported by GPUParticleSystem
  64803. * @returns the list of ramp gradients
  64804. */
  64805. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64806. /**
  64807. * Not supported by GPUParticleSystem
  64808. * Gets or sets a boolean indicating that ramp gradients must be used
  64809. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64810. */
  64811. get useRampGradients(): boolean;
  64812. set useRampGradients(value: boolean);
  64813. /**
  64814. * Not supported by GPUParticleSystem
  64815. * @param gradient defines the gradient to use (between 0 and 1)
  64816. * @param factor defines the life time factor to affect to the specified gradient
  64817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64818. * @returns the current particle system
  64819. */
  64820. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64821. /**
  64822. * Not supported by GPUParticleSystem
  64823. * @param gradient defines the gradient to remove
  64824. * @returns the current particle system
  64825. */
  64826. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64827. /**
  64828. * Instantiates a GPU particle system.
  64829. * 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.
  64830. * @param name The name of the particle system
  64831. * @param options The options used to create the system
  64832. * @param scene The scene the particle system belongs to
  64833. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64834. */
  64835. constructor(name: string, options: Partial<{
  64836. capacity: number;
  64837. randomTextureSize: number;
  64838. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64839. protected _reset(): void;
  64840. private _createUpdateVAO;
  64841. private _createRenderVAO;
  64842. private _initialize;
  64843. /** @hidden */
  64844. _recreateUpdateEffect(): void;
  64845. /** @hidden */
  64846. _recreateRenderEffect(): void;
  64847. /**
  64848. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64849. * @param preWarm defines if we are in the pre-warmimg phase
  64850. */
  64851. animate(preWarm?: boolean): void;
  64852. private _createFactorGradientTexture;
  64853. private _createSizeGradientTexture;
  64854. private _createAngularSpeedGradientTexture;
  64855. private _createVelocityGradientTexture;
  64856. private _createLimitVelocityGradientTexture;
  64857. private _createDragGradientTexture;
  64858. private _createColorGradientTexture;
  64859. /**
  64860. * Renders the particle system in its current state
  64861. * @param preWarm defines if the system should only update the particles but not render them
  64862. * @returns the current number of particles
  64863. */
  64864. render(preWarm?: boolean): number;
  64865. /**
  64866. * Rebuilds the particle system
  64867. */
  64868. rebuild(): void;
  64869. private _releaseBuffers;
  64870. private _releaseVAOs;
  64871. /**
  64872. * Disposes the particle system and free the associated resources
  64873. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64874. */
  64875. dispose(disposeTexture?: boolean): void;
  64876. /**
  64877. * Clones the particle system.
  64878. * @param name The name of the cloned object
  64879. * @param newEmitter The new emitter to use
  64880. * @returns the cloned particle system
  64881. */
  64882. clone(name: string, newEmitter: any): GPUParticleSystem;
  64883. /**
  64884. * Serializes the particle system to a JSON object
  64885. * @param serializeTexture defines if the texture must be serialized as well
  64886. * @returns the JSON object
  64887. */
  64888. serialize(serializeTexture?: boolean): any;
  64889. /**
  64890. * Parses a JSON object to create a GPU particle system.
  64891. * @param parsedParticleSystem The JSON object to parse
  64892. * @param scene The scene to create the particle system in
  64893. * @param rootUrl The root url to use to load external dependencies like texture
  64894. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64895. * @returns the parsed GPU particle system
  64896. */
  64897. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * Represents a set of particle systems working together to create a specific effect
  64903. */
  64904. export class ParticleSystemSet implements IDisposable {
  64905. /**
  64906. * Gets or sets base Assets URL
  64907. */
  64908. static BaseAssetsUrl: string;
  64909. private _emitterCreationOptions;
  64910. private _emitterNode;
  64911. /**
  64912. * Gets the particle system list
  64913. */
  64914. systems: IParticleSystem[];
  64915. /**
  64916. * Gets the emitter node used with this set
  64917. */
  64918. get emitterNode(): Nullable<TransformNode>;
  64919. /**
  64920. * Creates a new emitter mesh as a sphere
  64921. * @param options defines the options used to create the sphere
  64922. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64923. * @param scene defines the hosting scene
  64924. */
  64925. setEmitterAsSphere(options: {
  64926. diameter: number;
  64927. segments: number;
  64928. color: Color3;
  64929. }, renderingGroupId: number, scene: Scene): void;
  64930. /**
  64931. * Starts all particle systems of the set
  64932. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64933. */
  64934. start(emitter?: AbstractMesh): void;
  64935. /**
  64936. * Release all associated resources
  64937. */
  64938. dispose(): void;
  64939. /**
  64940. * Serialize the set into a JSON compatible object
  64941. * @param serializeTexture defines if the texture must be serialized as well
  64942. * @returns a JSON compatible representation of the set
  64943. */
  64944. serialize(serializeTexture?: boolean): any;
  64945. /**
  64946. * Parse a new ParticleSystemSet from a serialized source
  64947. * @param data defines a JSON compatible representation of the set
  64948. * @param scene defines the hosting scene
  64949. * @param gpu defines if we want GPU particles or CPU particles
  64950. * @returns a new ParticleSystemSet
  64951. */
  64952. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64953. }
  64954. }
  64955. declare module BABYLON {
  64956. /**
  64957. * This class is made for on one-liner static method to help creating particle system set.
  64958. */
  64959. export class ParticleHelper {
  64960. /**
  64961. * Gets or sets base Assets URL
  64962. */
  64963. static BaseAssetsUrl: string;
  64964. /** Define the Url to load snippets */
  64965. static SnippetUrl: string;
  64966. /**
  64967. * Create a default particle system that you can tweak
  64968. * @param emitter defines the emitter to use
  64969. * @param capacity defines the system capacity (default is 500 particles)
  64970. * @param scene defines the hosting scene
  64971. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64972. * @returns the new Particle system
  64973. */
  64974. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64975. /**
  64976. * This is the main static method (one-liner) of this helper to create different particle systems
  64977. * @param type This string represents the type to the particle system to create
  64978. * @param scene The scene where the particle system should live
  64979. * @param gpu If the system will use gpu
  64980. * @returns the ParticleSystemSet created
  64981. */
  64982. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64983. /**
  64984. * Static function used to export a particle system to a ParticleSystemSet variable.
  64985. * Please note that the emitter shape is not exported
  64986. * @param systems defines the particle systems to export
  64987. * @returns the created particle system set
  64988. */
  64989. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64990. /**
  64991. * Creates a particle system from a snippet saved in a remote file
  64992. * @param name defines the name of the particle system to create
  64993. * @param url defines the url to load from
  64994. * @param scene defines the hosting scene
  64995. * @param gpu If the system will use gpu
  64996. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64997. * @returns a promise that will resolve to the new particle system
  64998. */
  64999. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65000. /**
  65001. * Creates a particle system from a snippet saved by the particle system editor
  65002. * @param snippetId defines the snippet to load
  65003. * @param scene defines the hosting scene
  65004. * @param gpu If the system will use gpu
  65005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65006. * @returns a promise that will resolve to the new particle system
  65007. */
  65008. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65009. }
  65010. }
  65011. declare module BABYLON {
  65012. interface Engine {
  65013. /**
  65014. * Create an effect to use with particle systems.
  65015. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65016. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65017. * @param uniformsNames defines a list of attribute names
  65018. * @param samplers defines an array of string used to represent textures
  65019. * @param defines defines the string containing the defines to use to compile the shaders
  65020. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65021. * @param onCompiled defines a function to call when the effect creation is successful
  65022. * @param onError defines a function to call when the effect creation has failed
  65023. * @returns the new Effect
  65024. */
  65025. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65026. }
  65027. interface Mesh {
  65028. /**
  65029. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65030. * @returns an array of IParticleSystem
  65031. */
  65032. getEmittedParticleSystems(): IParticleSystem[];
  65033. /**
  65034. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65035. * @returns an array of IParticleSystem
  65036. */
  65037. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65038. }
  65039. /**
  65040. * @hidden
  65041. */
  65042. export var _IDoNeedToBeInTheBuild: number;
  65043. }
  65044. declare module BABYLON {
  65045. /** Defines the 4 color options */
  65046. export enum PointColor {
  65047. /** color value */
  65048. Color = 2,
  65049. /** uv value */
  65050. UV = 1,
  65051. /** random value */
  65052. Random = 0,
  65053. /** stated value */
  65054. Stated = 3
  65055. }
  65056. /**
  65057. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65058. * 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.
  65059. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65060. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65061. *
  65062. * Full documentation here : TO BE ENTERED
  65063. */
  65064. export class PointsCloudSystem implements IDisposable {
  65065. /**
  65066. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65067. * Example : var p = SPS.particles[i];
  65068. */
  65069. particles: CloudPoint[];
  65070. /**
  65071. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65072. */
  65073. nbParticles: number;
  65074. /**
  65075. * This a counter for your own usage. It's not set by any SPS functions.
  65076. */
  65077. counter: number;
  65078. /**
  65079. * The PCS name. This name is also given to the underlying mesh.
  65080. */
  65081. name: string;
  65082. /**
  65083. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65084. */
  65085. mesh: Mesh;
  65086. /**
  65087. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65088. * Please read :
  65089. */
  65090. vars: any;
  65091. /**
  65092. * @hidden
  65093. */
  65094. _size: number;
  65095. private _scene;
  65096. private _promises;
  65097. private _positions;
  65098. private _indices;
  65099. private _normals;
  65100. private _colors;
  65101. private _uvs;
  65102. private _indices32;
  65103. private _positions32;
  65104. private _colors32;
  65105. private _uvs32;
  65106. private _updatable;
  65107. private _isVisibilityBoxLocked;
  65108. private _alwaysVisible;
  65109. private _groups;
  65110. private _groupCounter;
  65111. private _computeParticleColor;
  65112. private _computeParticleTexture;
  65113. private _computeParticleRotation;
  65114. private _computeBoundingBox;
  65115. private _isReady;
  65116. /**
  65117. * Creates a PCS (Points Cloud System) object
  65118. * @param name (String) is the PCS name, this will be the underlying mesh name
  65119. * @param pointSize (number) is the size for each point
  65120. * @param scene (Scene) is the scene in which the PCS is added
  65121. * @param options defines the options of the PCS e.g.
  65122. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65123. */
  65124. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65125. updatable?: boolean;
  65126. });
  65127. /**
  65128. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65129. * If no points were added to the PCS, the returned mesh is just a single point.
  65130. * @returns a promise for the created mesh
  65131. */
  65132. buildMeshAsync(): Promise<Mesh>;
  65133. /**
  65134. * @hidden
  65135. */
  65136. private _buildMesh;
  65137. private _addParticle;
  65138. private _randomUnitVector;
  65139. private _getColorIndicesForCoord;
  65140. private _setPointsColorOrUV;
  65141. private _colorFromTexture;
  65142. private _calculateDensity;
  65143. /**
  65144. * Adds points to the PCS in random positions within a unit sphere
  65145. * @param nb (positive integer) the number of particles to be created from this model
  65146. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65147. * @returns the number of groups in the system
  65148. */
  65149. addPoints(nb: number, pointFunction?: any): number;
  65150. /**
  65151. * Adds points to the PCS from the surface of the model shape
  65152. * @param mesh is any Mesh object that will be used as a surface model for the points
  65153. * @param nb (positive integer) the number of particles to be created from this model
  65154. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65155. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65156. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65157. * @returns the number of groups in the system
  65158. */
  65159. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65160. /**
  65161. * Adds points to the PCS inside the model shape
  65162. * @param mesh is any Mesh object that will be used as a surface model for the points
  65163. * @param nb (positive integer) the number of particles to be created from this model
  65164. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65165. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65166. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65167. * @returns the number of groups in the system
  65168. */
  65169. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65170. /**
  65171. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65172. * This method calls `updateParticle()` for each particle of the SPS.
  65173. * For an animated SPS, it is usually called within the render loop.
  65174. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65175. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65176. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65177. * @returns the PCS.
  65178. */
  65179. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65180. /**
  65181. * Disposes the PCS.
  65182. */
  65183. dispose(): void;
  65184. /**
  65185. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65186. * doc :
  65187. * @returns the PCS.
  65188. */
  65189. refreshVisibleSize(): PointsCloudSystem;
  65190. /**
  65191. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65192. * @param size the size (float) of the visibility box
  65193. * note : this doesn't lock the PCS mesh bounding box.
  65194. * doc :
  65195. */
  65196. setVisibilityBox(size: number): void;
  65197. /**
  65198. * Gets whether the PCS is always visible or not
  65199. * doc :
  65200. */
  65201. get isAlwaysVisible(): boolean;
  65202. /**
  65203. * Sets the PCS as always visible or not
  65204. * doc :
  65205. */
  65206. set isAlwaysVisible(val: boolean);
  65207. /**
  65208. * Tells to `setParticles()` to compute the particle rotations or not
  65209. * Default value : false. The PCS is faster when it's set to false
  65210. * Note : particle rotations are only applied to parent particles
  65211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65212. */
  65213. set computeParticleRotation(val: boolean);
  65214. /**
  65215. * Tells to `setParticles()` to compute the particle colors or not.
  65216. * Default value : true. The PCS is faster when it's set to false.
  65217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65218. */
  65219. set computeParticleColor(val: boolean);
  65220. set computeParticleTexture(val: boolean);
  65221. /**
  65222. * Gets if `setParticles()` computes the particle colors or not.
  65223. * Default value : false. The PCS is faster when it's set to false.
  65224. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65225. */
  65226. get computeParticleColor(): boolean;
  65227. /**
  65228. * Gets if `setParticles()` computes the particle textures or not.
  65229. * Default value : false. The PCS is faster when it's set to false.
  65230. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65231. */
  65232. get computeParticleTexture(): boolean;
  65233. /**
  65234. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65235. */
  65236. set computeBoundingBox(val: boolean);
  65237. /**
  65238. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65239. */
  65240. get computeBoundingBox(): boolean;
  65241. /**
  65242. * This function does nothing. It may be overwritten to set all the particle first values.
  65243. * The PCS doesn't call this function, you may have to call it by your own.
  65244. * doc :
  65245. */
  65246. initParticles(): void;
  65247. /**
  65248. * This function does nothing. It may be overwritten to recycle a particle
  65249. * The PCS doesn't call this function, you can to call it
  65250. * doc :
  65251. * @param particle The particle to recycle
  65252. * @returns the recycled particle
  65253. */
  65254. recycleParticle(particle: CloudPoint): CloudPoint;
  65255. /**
  65256. * Updates a particle : this function should be overwritten by the user.
  65257. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65258. * doc :
  65259. * @example : just set a particle position or velocity and recycle conditions
  65260. * @param particle The particle to update
  65261. * @returns the updated particle
  65262. */
  65263. updateParticle(particle: CloudPoint): CloudPoint;
  65264. /**
  65265. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65266. * This does nothing and may be overwritten by the user.
  65267. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65268. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65269. * @param update the boolean update value actually passed to setParticles()
  65270. */
  65271. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65272. /**
  65273. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65274. * This will be passed three parameters.
  65275. * This does nothing and may be overwritten by the user.
  65276. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65277. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65278. * @param update the boolean update value actually passed to setParticles()
  65279. */
  65280. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65281. }
  65282. }
  65283. declare module BABYLON {
  65284. /**
  65285. * Represents one particle of a points cloud system.
  65286. */
  65287. export class CloudPoint {
  65288. /**
  65289. * particle global index
  65290. */
  65291. idx: number;
  65292. /**
  65293. * The color of the particle
  65294. */
  65295. color: Nullable<Color4>;
  65296. /**
  65297. * The world space position of the particle.
  65298. */
  65299. position: Vector3;
  65300. /**
  65301. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65302. */
  65303. rotation: Vector3;
  65304. /**
  65305. * The world space rotation quaternion of the particle.
  65306. */
  65307. rotationQuaternion: Nullable<Quaternion>;
  65308. /**
  65309. * The uv of the particle.
  65310. */
  65311. uv: Nullable<Vector2>;
  65312. /**
  65313. * The current speed of the particle.
  65314. */
  65315. velocity: Vector3;
  65316. /**
  65317. * The pivot point in the particle local space.
  65318. */
  65319. pivot: Vector3;
  65320. /**
  65321. * Must the particle be translated from its pivot point in its local space ?
  65322. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65323. * Default : false
  65324. */
  65325. translateFromPivot: boolean;
  65326. /**
  65327. * Index of this particle in the global "positions" array (Internal use)
  65328. * @hidden
  65329. */
  65330. _pos: number;
  65331. /**
  65332. * @hidden Index of this particle in the global "indices" array (Internal use)
  65333. */
  65334. _ind: number;
  65335. /**
  65336. * Group this particle belongs to
  65337. */
  65338. _group: PointsGroup;
  65339. /**
  65340. * Group id of this particle
  65341. */
  65342. groupId: number;
  65343. /**
  65344. * Index of the particle in its group id (Internal use)
  65345. */
  65346. idxInGroup: number;
  65347. /**
  65348. * @hidden Particle BoundingInfo object (Internal use)
  65349. */
  65350. _boundingInfo: BoundingInfo;
  65351. /**
  65352. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65353. */
  65354. _pcs: PointsCloudSystem;
  65355. /**
  65356. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65357. */
  65358. _stillInvisible: boolean;
  65359. /**
  65360. * @hidden Last computed particle rotation matrix
  65361. */
  65362. _rotationMatrix: number[];
  65363. /**
  65364. * Parent particle Id, if any.
  65365. * Default null.
  65366. */
  65367. parentId: Nullable<number>;
  65368. /**
  65369. * @hidden Internal global position in the PCS.
  65370. */
  65371. _globalPosition: Vector3;
  65372. /**
  65373. * Creates a Point Cloud object.
  65374. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65375. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65376. * @param group (PointsGroup) is the group the particle belongs to
  65377. * @param groupId (integer) is the group identifier in the PCS.
  65378. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65379. * @param pcs defines the PCS it is associated to
  65380. */
  65381. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65382. /**
  65383. * get point size
  65384. */
  65385. get size(): Vector3;
  65386. /**
  65387. * Set point size
  65388. */
  65389. set size(scale: Vector3);
  65390. /**
  65391. * Legacy support, changed quaternion to rotationQuaternion
  65392. */
  65393. get quaternion(): Nullable<Quaternion>;
  65394. /**
  65395. * Legacy support, changed quaternion to rotationQuaternion
  65396. */
  65397. set quaternion(q: Nullable<Quaternion>);
  65398. /**
  65399. * Returns a boolean. True if the particle intersects a mesh, else false
  65400. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65401. * @param target is the object (point or mesh) what the intersection is computed against
  65402. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65403. * @returns true if it intersects
  65404. */
  65405. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65406. /**
  65407. * get the rotation matrix of the particle
  65408. * @hidden
  65409. */
  65410. getRotationMatrix(m: Matrix): void;
  65411. }
  65412. /**
  65413. * Represents a group of points in a points cloud system
  65414. * * PCS internal tool, don't use it manually.
  65415. */
  65416. export class PointsGroup {
  65417. /**
  65418. * The group id
  65419. * @hidden
  65420. */
  65421. groupID: number;
  65422. /**
  65423. * image data for group (internal use)
  65424. * @hidden
  65425. */
  65426. _groupImageData: Nullable<ArrayBufferView>;
  65427. /**
  65428. * Image Width (internal use)
  65429. * @hidden
  65430. */
  65431. _groupImgWidth: number;
  65432. /**
  65433. * Image Height (internal use)
  65434. * @hidden
  65435. */
  65436. _groupImgHeight: number;
  65437. /**
  65438. * Custom position function (internal use)
  65439. * @hidden
  65440. */
  65441. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65442. /**
  65443. * density per facet for surface points
  65444. * @hidden
  65445. */
  65446. _groupDensity: number[];
  65447. /**
  65448. * Only when points are colored by texture carries pointer to texture list array
  65449. * @hidden
  65450. */
  65451. _textureNb: number;
  65452. /**
  65453. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65454. * PCS internal tool, don't use it manually.
  65455. * @hidden
  65456. */
  65457. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65458. }
  65459. }
  65460. declare module BABYLON {
  65461. interface Scene {
  65462. /** @hidden (Backing field) */
  65463. _physicsEngine: Nullable<IPhysicsEngine>;
  65464. /** @hidden */
  65465. _physicsTimeAccumulator: number;
  65466. /**
  65467. * Gets the current physics engine
  65468. * @returns a IPhysicsEngine or null if none attached
  65469. */
  65470. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65471. /**
  65472. * Enables physics to the current scene
  65473. * @param gravity defines the scene's gravity for the physics engine
  65474. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65475. * @return a boolean indicating if the physics engine was initialized
  65476. */
  65477. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65478. /**
  65479. * Disables and disposes the physics engine associated with the scene
  65480. */
  65481. disablePhysicsEngine(): void;
  65482. /**
  65483. * Gets a boolean indicating if there is an active physics engine
  65484. * @returns a boolean indicating if there is an active physics engine
  65485. */
  65486. isPhysicsEnabled(): boolean;
  65487. /**
  65488. * Deletes a physics compound impostor
  65489. * @param compound defines the compound to delete
  65490. */
  65491. deleteCompoundImpostor(compound: any): void;
  65492. /**
  65493. * An event triggered when physic simulation is about to be run
  65494. */
  65495. onBeforePhysicsObservable: Observable<Scene>;
  65496. /**
  65497. * An event triggered when physic simulation has been done
  65498. */
  65499. onAfterPhysicsObservable: Observable<Scene>;
  65500. }
  65501. interface AbstractMesh {
  65502. /** @hidden */
  65503. _physicsImpostor: Nullable<PhysicsImpostor>;
  65504. /**
  65505. * Gets or sets impostor used for physic simulation
  65506. * @see http://doc.babylonjs.com/features/physics_engine
  65507. */
  65508. physicsImpostor: Nullable<PhysicsImpostor>;
  65509. /**
  65510. * Gets the current physics impostor
  65511. * @see http://doc.babylonjs.com/features/physics_engine
  65512. * @returns a physics impostor or null
  65513. */
  65514. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65515. /** Apply a physic impulse to the mesh
  65516. * @param force defines the force to apply
  65517. * @param contactPoint defines where to apply the force
  65518. * @returns the current mesh
  65519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65520. */
  65521. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65522. /**
  65523. * Creates a physic joint between two meshes
  65524. * @param otherMesh defines the other mesh to use
  65525. * @param pivot1 defines the pivot to use on this mesh
  65526. * @param pivot2 defines the pivot to use on the other mesh
  65527. * @param options defines additional options (can be plugin dependent)
  65528. * @returns the current mesh
  65529. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65530. */
  65531. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65532. /** @hidden */
  65533. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65534. }
  65535. /**
  65536. * Defines the physics engine scene component responsible to manage a physics engine
  65537. */
  65538. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65539. /**
  65540. * The component name helpful to identify the component in the list of scene components.
  65541. */
  65542. readonly name: string;
  65543. /**
  65544. * The scene the component belongs to.
  65545. */
  65546. scene: Scene;
  65547. /**
  65548. * Creates a new instance of the component for the given scene
  65549. * @param scene Defines the scene to register the component in
  65550. */
  65551. constructor(scene: Scene);
  65552. /**
  65553. * Registers the component in a given scene
  65554. */
  65555. register(): void;
  65556. /**
  65557. * Rebuilds the elements related to this component in case of
  65558. * context lost for instance.
  65559. */
  65560. rebuild(): void;
  65561. /**
  65562. * Disposes the component and the associated ressources
  65563. */
  65564. dispose(): void;
  65565. }
  65566. }
  65567. declare module BABYLON {
  65568. /**
  65569. * A helper for physics simulations
  65570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65571. */
  65572. export class PhysicsHelper {
  65573. private _scene;
  65574. private _physicsEngine;
  65575. /**
  65576. * Initializes the Physics helper
  65577. * @param scene Babylon.js scene
  65578. */
  65579. constructor(scene: Scene);
  65580. /**
  65581. * Applies a radial explosion impulse
  65582. * @param origin the origin of the explosion
  65583. * @param radiusOrEventOptions the radius or the options of radial explosion
  65584. * @param strength the explosion strength
  65585. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65586. * @returns A physics radial explosion event, or null
  65587. */
  65588. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65589. /**
  65590. * Applies a radial explosion force
  65591. * @param origin the origin of the explosion
  65592. * @param radiusOrEventOptions the radius or the options of radial explosion
  65593. * @param strength the explosion strength
  65594. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65595. * @returns A physics radial explosion event, or null
  65596. */
  65597. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65598. /**
  65599. * Creates a gravitational field
  65600. * @param origin the origin of the explosion
  65601. * @param radiusOrEventOptions the radius or the options of radial explosion
  65602. * @param strength the explosion strength
  65603. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65604. * @returns A physics gravitational field event, or null
  65605. */
  65606. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65607. /**
  65608. * Creates a physics updraft event
  65609. * @param origin the origin of the updraft
  65610. * @param radiusOrEventOptions the radius or the options of the updraft
  65611. * @param strength the strength of the updraft
  65612. * @param height the height of the updraft
  65613. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65614. * @returns A physics updraft event, or null
  65615. */
  65616. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65617. /**
  65618. * Creates a physics vortex event
  65619. * @param origin the of the vortex
  65620. * @param radiusOrEventOptions the radius or the options of the vortex
  65621. * @param strength the strength of the vortex
  65622. * @param height the height of the vortex
  65623. * @returns a Physics vortex event, or null
  65624. * A physics vortex event or null
  65625. */
  65626. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65627. }
  65628. /**
  65629. * Represents a physics radial explosion event
  65630. */
  65631. class PhysicsRadialExplosionEvent {
  65632. private _scene;
  65633. private _options;
  65634. private _sphere;
  65635. private _dataFetched;
  65636. /**
  65637. * Initializes a radial explosioin event
  65638. * @param _scene BabylonJS scene
  65639. * @param _options The options for the vortex event
  65640. */
  65641. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65642. /**
  65643. * Returns the data related to the radial explosion event (sphere).
  65644. * @returns The radial explosion event data
  65645. */
  65646. getData(): PhysicsRadialExplosionEventData;
  65647. /**
  65648. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65649. * @param impostor A physics imposter
  65650. * @param origin the origin of the explosion
  65651. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65652. */
  65653. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65654. /**
  65655. * Triggers affecterd impostors callbacks
  65656. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65657. */
  65658. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65659. /**
  65660. * Disposes the sphere.
  65661. * @param force Specifies if the sphere should be disposed by force
  65662. */
  65663. dispose(force?: boolean): void;
  65664. /*** Helpers ***/
  65665. private _prepareSphere;
  65666. private _intersectsWithSphere;
  65667. }
  65668. /**
  65669. * Represents a gravitational field event
  65670. */
  65671. class PhysicsGravitationalFieldEvent {
  65672. private _physicsHelper;
  65673. private _scene;
  65674. private _origin;
  65675. private _options;
  65676. private _tickCallback;
  65677. private _sphere;
  65678. private _dataFetched;
  65679. /**
  65680. * Initializes the physics gravitational field event
  65681. * @param _physicsHelper A physics helper
  65682. * @param _scene BabylonJS scene
  65683. * @param _origin The origin position of the gravitational field event
  65684. * @param _options The options for the vortex event
  65685. */
  65686. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65687. /**
  65688. * Returns the data related to the gravitational field event (sphere).
  65689. * @returns A gravitational field event
  65690. */
  65691. getData(): PhysicsGravitationalFieldEventData;
  65692. /**
  65693. * Enables the gravitational field.
  65694. */
  65695. enable(): void;
  65696. /**
  65697. * Disables the gravitational field.
  65698. */
  65699. disable(): void;
  65700. /**
  65701. * Disposes the sphere.
  65702. * @param force The force to dispose from the gravitational field event
  65703. */
  65704. dispose(force?: boolean): void;
  65705. private _tick;
  65706. }
  65707. /**
  65708. * Represents a physics updraft event
  65709. */
  65710. class PhysicsUpdraftEvent {
  65711. private _scene;
  65712. private _origin;
  65713. private _options;
  65714. private _physicsEngine;
  65715. private _originTop;
  65716. private _originDirection;
  65717. private _tickCallback;
  65718. private _cylinder;
  65719. private _cylinderPosition;
  65720. private _dataFetched;
  65721. /**
  65722. * Initializes the physics updraft event
  65723. * @param _scene BabylonJS scene
  65724. * @param _origin The origin position of the updraft
  65725. * @param _options The options for the updraft event
  65726. */
  65727. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65728. /**
  65729. * Returns the data related to the updraft event (cylinder).
  65730. * @returns A physics updraft event
  65731. */
  65732. getData(): PhysicsUpdraftEventData;
  65733. /**
  65734. * Enables the updraft.
  65735. */
  65736. enable(): void;
  65737. /**
  65738. * Disables the updraft.
  65739. */
  65740. disable(): void;
  65741. /**
  65742. * Disposes the cylinder.
  65743. * @param force Specifies if the updraft should be disposed by force
  65744. */
  65745. dispose(force?: boolean): void;
  65746. private getImpostorHitData;
  65747. private _tick;
  65748. /*** Helpers ***/
  65749. private _prepareCylinder;
  65750. private _intersectsWithCylinder;
  65751. }
  65752. /**
  65753. * Represents a physics vortex event
  65754. */
  65755. class PhysicsVortexEvent {
  65756. private _scene;
  65757. private _origin;
  65758. private _options;
  65759. private _physicsEngine;
  65760. private _originTop;
  65761. private _tickCallback;
  65762. private _cylinder;
  65763. private _cylinderPosition;
  65764. private _dataFetched;
  65765. /**
  65766. * Initializes the physics vortex event
  65767. * @param _scene The BabylonJS scene
  65768. * @param _origin The origin position of the vortex
  65769. * @param _options The options for the vortex event
  65770. */
  65771. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65772. /**
  65773. * Returns the data related to the vortex event (cylinder).
  65774. * @returns The physics vortex event data
  65775. */
  65776. getData(): PhysicsVortexEventData;
  65777. /**
  65778. * Enables the vortex.
  65779. */
  65780. enable(): void;
  65781. /**
  65782. * Disables the cortex.
  65783. */
  65784. disable(): void;
  65785. /**
  65786. * Disposes the sphere.
  65787. * @param force
  65788. */
  65789. dispose(force?: boolean): void;
  65790. private getImpostorHitData;
  65791. private _tick;
  65792. /*** Helpers ***/
  65793. private _prepareCylinder;
  65794. private _intersectsWithCylinder;
  65795. }
  65796. /**
  65797. * Options fot the radial explosion event
  65798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65799. */
  65800. export class PhysicsRadialExplosionEventOptions {
  65801. /**
  65802. * The radius of the sphere for the radial explosion.
  65803. */
  65804. radius: number;
  65805. /**
  65806. * The strenth of the explosion.
  65807. */
  65808. strength: number;
  65809. /**
  65810. * The strenght of the force in correspondence to the distance of the affected object
  65811. */
  65812. falloff: PhysicsRadialImpulseFalloff;
  65813. /**
  65814. * Sphere options for the radial explosion.
  65815. */
  65816. sphere: {
  65817. segments: number;
  65818. diameter: number;
  65819. };
  65820. /**
  65821. * Sphere options for the radial explosion.
  65822. */
  65823. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65824. }
  65825. /**
  65826. * Options fot the updraft event
  65827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65828. */
  65829. export class PhysicsUpdraftEventOptions {
  65830. /**
  65831. * The radius of the cylinder for the vortex
  65832. */
  65833. radius: number;
  65834. /**
  65835. * The strenth of the updraft.
  65836. */
  65837. strength: number;
  65838. /**
  65839. * The height of the cylinder for the updraft.
  65840. */
  65841. height: number;
  65842. /**
  65843. * The mode for the the updraft.
  65844. */
  65845. updraftMode: PhysicsUpdraftMode;
  65846. }
  65847. /**
  65848. * Options fot the vortex event
  65849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65850. */
  65851. export class PhysicsVortexEventOptions {
  65852. /**
  65853. * The radius of the cylinder for the vortex
  65854. */
  65855. radius: number;
  65856. /**
  65857. * The strenth of the vortex.
  65858. */
  65859. strength: number;
  65860. /**
  65861. * The height of the cylinder for the vortex.
  65862. */
  65863. height: number;
  65864. /**
  65865. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65866. */
  65867. centripetalForceThreshold: number;
  65868. /**
  65869. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65870. */
  65871. centripetalForceMultiplier: number;
  65872. /**
  65873. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65874. */
  65875. centrifugalForceMultiplier: number;
  65876. /**
  65877. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65878. */
  65879. updraftForceMultiplier: number;
  65880. }
  65881. /**
  65882. * The strenght of the force in correspondence to the distance of the affected object
  65883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65884. */
  65885. export enum PhysicsRadialImpulseFalloff {
  65886. /** Defines that impulse is constant in strength across it's whole radius */
  65887. Constant = 0,
  65888. /** Defines that impulse gets weaker if it's further from the origin */
  65889. Linear = 1
  65890. }
  65891. /**
  65892. * The strength of the force in correspondence to the distance of the affected object
  65893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65894. */
  65895. export enum PhysicsUpdraftMode {
  65896. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65897. Center = 0,
  65898. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65899. Perpendicular = 1
  65900. }
  65901. /**
  65902. * Interface for a physics hit data
  65903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65904. */
  65905. export interface PhysicsHitData {
  65906. /**
  65907. * The force applied at the contact point
  65908. */
  65909. force: Vector3;
  65910. /**
  65911. * The contact point
  65912. */
  65913. contactPoint: Vector3;
  65914. /**
  65915. * The distance from the origin to the contact point
  65916. */
  65917. distanceFromOrigin: number;
  65918. }
  65919. /**
  65920. * Interface for radial explosion event data
  65921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65922. */
  65923. export interface PhysicsRadialExplosionEventData {
  65924. /**
  65925. * A sphere used for the radial explosion event
  65926. */
  65927. sphere: Mesh;
  65928. }
  65929. /**
  65930. * Interface for gravitational field event data
  65931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65932. */
  65933. export interface PhysicsGravitationalFieldEventData {
  65934. /**
  65935. * A sphere mesh used for the gravitational field event
  65936. */
  65937. sphere: Mesh;
  65938. }
  65939. /**
  65940. * Interface for updraft event data
  65941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65942. */
  65943. export interface PhysicsUpdraftEventData {
  65944. /**
  65945. * A cylinder used for the updraft event
  65946. */
  65947. cylinder: Mesh;
  65948. }
  65949. /**
  65950. * Interface for vortex event data
  65951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65952. */
  65953. export interface PhysicsVortexEventData {
  65954. /**
  65955. * A cylinder used for the vortex event
  65956. */
  65957. cylinder: Mesh;
  65958. }
  65959. /**
  65960. * Interface for an affected physics impostor
  65961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65962. */
  65963. export interface PhysicsAffectedImpostorWithData {
  65964. /**
  65965. * The impostor affected by the effect
  65966. */
  65967. impostor: PhysicsImpostor;
  65968. /**
  65969. * The data about the hit/horce from the explosion
  65970. */
  65971. hitData: PhysicsHitData;
  65972. }
  65973. }
  65974. declare module BABYLON {
  65975. /** @hidden */
  65976. export var blackAndWhitePixelShader: {
  65977. name: string;
  65978. shader: string;
  65979. };
  65980. }
  65981. declare module BABYLON {
  65982. /**
  65983. * Post process used to render in black and white
  65984. */
  65985. export class BlackAndWhitePostProcess extends PostProcess {
  65986. /**
  65987. * Linear about to convert he result to black and white (default: 1)
  65988. */
  65989. degree: number;
  65990. /**
  65991. * Creates a black and white post process
  65992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65993. * @param name The name of the effect.
  65994. * @param options The required width/height ratio to downsize to before computing the render pass.
  65995. * @param camera The camera to apply the render pass to.
  65996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65997. * @param engine The engine which the post process will be applied. (default: current engine)
  65998. * @param reusable If the post process can be reused on the same frame. (default: false)
  65999. */
  66000. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66001. }
  66002. }
  66003. declare module BABYLON {
  66004. /**
  66005. * This represents a set of one or more post processes in Babylon.
  66006. * A post process can be used to apply a shader to a texture after it is rendered.
  66007. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66008. */
  66009. export class PostProcessRenderEffect {
  66010. private _postProcesses;
  66011. private _getPostProcesses;
  66012. private _singleInstance;
  66013. private _cameras;
  66014. private _indicesForCamera;
  66015. /**
  66016. * Name of the effect
  66017. * @hidden
  66018. */
  66019. _name: string;
  66020. /**
  66021. * Instantiates a post process render effect.
  66022. * A post process can be used to apply a shader to a texture after it is rendered.
  66023. * @param engine The engine the effect is tied to
  66024. * @param name The name of the effect
  66025. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66026. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66027. */
  66028. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66029. /**
  66030. * Checks if all the post processes in the effect are supported.
  66031. */
  66032. get isSupported(): boolean;
  66033. /**
  66034. * Updates the current state of the effect
  66035. * @hidden
  66036. */
  66037. _update(): void;
  66038. /**
  66039. * Attaches the effect on cameras
  66040. * @param cameras The camera to attach to.
  66041. * @hidden
  66042. */
  66043. _attachCameras(cameras: Camera): void;
  66044. /**
  66045. * Attaches the effect on cameras
  66046. * @param cameras The camera to attach to.
  66047. * @hidden
  66048. */
  66049. _attachCameras(cameras: Camera[]): void;
  66050. /**
  66051. * Detaches the effect on cameras
  66052. * @param cameras The camera to detatch from.
  66053. * @hidden
  66054. */
  66055. _detachCameras(cameras: Camera): void;
  66056. /**
  66057. * Detatches the effect on cameras
  66058. * @param cameras The camera to detatch from.
  66059. * @hidden
  66060. */
  66061. _detachCameras(cameras: Camera[]): void;
  66062. /**
  66063. * Enables the effect on given cameras
  66064. * @param cameras The camera to enable.
  66065. * @hidden
  66066. */
  66067. _enable(cameras: Camera): void;
  66068. /**
  66069. * Enables the effect on given cameras
  66070. * @param cameras The camera to enable.
  66071. * @hidden
  66072. */
  66073. _enable(cameras: Nullable<Camera[]>): void;
  66074. /**
  66075. * Disables the effect on the given cameras
  66076. * @param cameras The camera to disable.
  66077. * @hidden
  66078. */
  66079. _disable(cameras: Camera): void;
  66080. /**
  66081. * Disables the effect on the given cameras
  66082. * @param cameras The camera to disable.
  66083. * @hidden
  66084. */
  66085. _disable(cameras: Nullable<Camera[]>): void;
  66086. /**
  66087. * Gets a list of the post processes contained in the effect.
  66088. * @param camera The camera to get the post processes on.
  66089. * @returns The list of the post processes in the effect.
  66090. */
  66091. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66092. }
  66093. }
  66094. declare module BABYLON {
  66095. /** @hidden */
  66096. export var extractHighlightsPixelShader: {
  66097. name: string;
  66098. shader: string;
  66099. };
  66100. }
  66101. declare module BABYLON {
  66102. /**
  66103. * 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.
  66104. */
  66105. export class ExtractHighlightsPostProcess extends PostProcess {
  66106. /**
  66107. * The luminance threshold, pixels below this value will be set to black.
  66108. */
  66109. threshold: number;
  66110. /** @hidden */
  66111. _exposure: number;
  66112. /**
  66113. * Post process which has the input texture to be used when performing highlight extraction
  66114. * @hidden
  66115. */
  66116. _inputPostProcess: Nullable<PostProcess>;
  66117. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66118. }
  66119. }
  66120. declare module BABYLON {
  66121. /** @hidden */
  66122. export var bloomMergePixelShader: {
  66123. name: string;
  66124. shader: string;
  66125. };
  66126. }
  66127. declare module BABYLON {
  66128. /**
  66129. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66130. */
  66131. export class BloomMergePostProcess extends PostProcess {
  66132. /** Weight of the bloom to be added to the original input. */
  66133. weight: number;
  66134. /**
  66135. * Creates a new instance of @see BloomMergePostProcess
  66136. * @param name The name of the effect.
  66137. * @param originalFromInput Post process which's input will be used for the merge.
  66138. * @param blurred Blurred highlights post process which's output will be used.
  66139. * @param weight Weight of the bloom to be added to the original input.
  66140. * @param options The required width/height ratio to downsize to before computing the render pass.
  66141. * @param camera The camera to apply the render pass to.
  66142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66143. * @param engine The engine which the post process will be applied. (default: current engine)
  66144. * @param reusable If the post process can be reused on the same frame. (default: false)
  66145. * @param textureType Type of textures used when performing the post process. (default: 0)
  66146. * @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)
  66147. */
  66148. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66149. /** Weight of the bloom to be added to the original input. */
  66150. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66151. }
  66152. }
  66153. declare module BABYLON {
  66154. /**
  66155. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66156. */
  66157. export class BloomEffect extends PostProcessRenderEffect {
  66158. private bloomScale;
  66159. /**
  66160. * @hidden Internal
  66161. */
  66162. _effects: Array<PostProcess>;
  66163. /**
  66164. * @hidden Internal
  66165. */
  66166. _downscale: ExtractHighlightsPostProcess;
  66167. private _blurX;
  66168. private _blurY;
  66169. private _merge;
  66170. /**
  66171. * The luminance threshold to find bright areas of the image to bloom.
  66172. */
  66173. get threshold(): number;
  66174. set threshold(value: number);
  66175. /**
  66176. * The strength of the bloom.
  66177. */
  66178. get weight(): number;
  66179. set weight(value: number);
  66180. /**
  66181. * Specifies the size of the bloom blur kernel, relative to the final output size
  66182. */
  66183. get kernel(): number;
  66184. set kernel(value: number);
  66185. /**
  66186. * Creates a new instance of @see BloomEffect
  66187. * @param scene The scene the effect belongs to.
  66188. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66189. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66190. * @param bloomWeight The the strength of bloom.
  66191. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66192. * @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)
  66193. */
  66194. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66195. /**
  66196. * Disposes each of the internal effects for a given camera.
  66197. * @param camera The camera to dispose the effect on.
  66198. */
  66199. disposeEffects(camera: Camera): void;
  66200. /**
  66201. * @hidden Internal
  66202. */
  66203. _updateEffects(): void;
  66204. /**
  66205. * Internal
  66206. * @returns if all the contained post processes are ready.
  66207. * @hidden
  66208. */
  66209. _isReady(): boolean;
  66210. }
  66211. }
  66212. declare module BABYLON {
  66213. /** @hidden */
  66214. export var chromaticAberrationPixelShader: {
  66215. name: string;
  66216. shader: string;
  66217. };
  66218. }
  66219. declare module BABYLON {
  66220. /**
  66221. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66222. */
  66223. export class ChromaticAberrationPostProcess extends PostProcess {
  66224. /**
  66225. * The amount of seperation of rgb channels (default: 30)
  66226. */
  66227. aberrationAmount: number;
  66228. /**
  66229. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66230. */
  66231. radialIntensity: number;
  66232. /**
  66233. * 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))
  66234. */
  66235. direction: Vector2;
  66236. /**
  66237. * 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))
  66238. */
  66239. centerPosition: Vector2;
  66240. /**
  66241. * Creates a new instance ChromaticAberrationPostProcess
  66242. * @param name The name of the effect.
  66243. * @param screenWidth The width of the screen to apply the effect on.
  66244. * @param screenHeight The height of the screen to apply the effect on.
  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, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /** @hidden */
  66258. export var circleOfConfusionPixelShader: {
  66259. name: string;
  66260. shader: string;
  66261. };
  66262. }
  66263. declare module BABYLON {
  66264. /**
  66265. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66266. */
  66267. export class CircleOfConfusionPostProcess extends PostProcess {
  66268. /**
  66269. * 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.
  66270. */
  66271. lensSize: number;
  66272. /**
  66273. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66274. */
  66275. fStop: number;
  66276. /**
  66277. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66278. */
  66279. focusDistance: number;
  66280. /**
  66281. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66282. */
  66283. focalLength: number;
  66284. private _depthTexture;
  66285. /**
  66286. * Creates a new instance CircleOfConfusionPostProcess
  66287. * @param name The name of the effect.
  66288. * @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.
  66289. * @param options The required width/height ratio to downsize to before computing the render pass.
  66290. * @param camera The camera to apply the render pass to.
  66291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66292. * @param engine The engine which the post process will be applied. (default: current engine)
  66293. * @param reusable If the post process can be reused on the same frame. (default: false)
  66294. * @param textureType Type of textures used when performing the post process. (default: 0)
  66295. * @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)
  66296. */
  66297. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66298. /**
  66299. * 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.
  66300. */
  66301. set depthTexture(value: RenderTargetTexture);
  66302. }
  66303. }
  66304. declare module BABYLON {
  66305. /** @hidden */
  66306. export var colorCorrectionPixelShader: {
  66307. name: string;
  66308. shader: string;
  66309. };
  66310. }
  66311. declare module BABYLON {
  66312. /**
  66313. *
  66314. * This post-process allows the modification of rendered colors by using
  66315. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66316. *
  66317. * The object needs to be provided an url to a texture containing the color
  66318. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66319. * Use an image editing software to tweak the LUT to match your needs.
  66320. *
  66321. * For an example of a color LUT, see here:
  66322. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66323. * For explanations on color grading, see here:
  66324. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66325. *
  66326. */
  66327. export class ColorCorrectionPostProcess extends PostProcess {
  66328. private _colorTableTexture;
  66329. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66330. }
  66331. }
  66332. declare module BABYLON {
  66333. /** @hidden */
  66334. export var convolutionPixelShader: {
  66335. name: string;
  66336. shader: string;
  66337. };
  66338. }
  66339. declare module BABYLON {
  66340. /**
  66341. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66342. * input texture to perform effects such as edge detection or sharpening
  66343. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66344. */
  66345. export class ConvolutionPostProcess extends PostProcess {
  66346. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66347. kernel: number[];
  66348. /**
  66349. * Creates a new instance ConvolutionPostProcess
  66350. * @param name The name of the effect.
  66351. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66352. * @param options The required width/height ratio to downsize to before computing the render pass.
  66353. * @param camera The camera to apply the render pass to.
  66354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66355. * @param engine The engine which the post process will be applied. (default: current engine)
  66356. * @param reusable If the post process can be reused on the same frame. (default: false)
  66357. * @param textureType Type of textures used when performing the post process. (default: 0)
  66358. */
  66359. constructor(name: string,
  66360. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66361. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66362. /**
  66363. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66364. */
  66365. static EdgeDetect0Kernel: number[];
  66366. /**
  66367. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66368. */
  66369. static EdgeDetect1Kernel: number[];
  66370. /**
  66371. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66372. */
  66373. static EdgeDetect2Kernel: number[];
  66374. /**
  66375. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66376. */
  66377. static SharpenKernel: number[];
  66378. /**
  66379. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66380. */
  66381. static EmbossKernel: number[];
  66382. /**
  66383. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66384. */
  66385. static GaussianKernel: number[];
  66386. }
  66387. }
  66388. declare module BABYLON {
  66389. /**
  66390. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66391. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66392. * based on samples that have a large difference in distance than the center pixel.
  66393. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66394. */
  66395. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66396. direction: Vector2;
  66397. /**
  66398. * Creates a new instance CircleOfConfusionPostProcess
  66399. * @param name The name of the effect.
  66400. * @param scene The scene the effect belongs to.
  66401. * @param direction The direction the blur should be applied.
  66402. * @param kernel The size of the kernel used to blur.
  66403. * @param options The required width/height ratio to downsize to before computing the render pass.
  66404. * @param camera The camera to apply the render pass to.
  66405. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66406. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66408. * @param engine The engine which the post process will be applied. (default: current engine)
  66409. * @param reusable If the post process can be reused on the same frame. (default: false)
  66410. * @param textureType Type of textures used when performing the post process. (default: 0)
  66411. * @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)
  66412. */
  66413. 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);
  66414. }
  66415. }
  66416. declare module BABYLON {
  66417. /** @hidden */
  66418. export var depthOfFieldMergePixelShader: {
  66419. name: string;
  66420. shader: string;
  66421. };
  66422. }
  66423. declare module BABYLON {
  66424. /**
  66425. * Options to be set when merging outputs from the default pipeline.
  66426. */
  66427. export class DepthOfFieldMergePostProcessOptions {
  66428. /**
  66429. * The original image to merge on top of
  66430. */
  66431. originalFromInput: PostProcess;
  66432. /**
  66433. * Parameters to perform the merge of the depth of field effect
  66434. */
  66435. depthOfField?: {
  66436. circleOfConfusion: PostProcess;
  66437. blurSteps: Array<PostProcess>;
  66438. };
  66439. /**
  66440. * Parameters to perform the merge of bloom effect
  66441. */
  66442. bloom?: {
  66443. blurred: PostProcess;
  66444. weight: number;
  66445. };
  66446. }
  66447. /**
  66448. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66449. */
  66450. export class DepthOfFieldMergePostProcess extends PostProcess {
  66451. private blurSteps;
  66452. /**
  66453. * Creates a new instance of DepthOfFieldMergePostProcess
  66454. * @param name The name of the effect.
  66455. * @param originalFromInput Post process which's input will be used for the merge.
  66456. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66457. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66458. * @param options The required width/height ratio to downsize to before computing the render pass.
  66459. * @param camera The camera to apply the render pass to.
  66460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66461. * @param engine The engine which the post process will be applied. (default: current engine)
  66462. * @param reusable If the post process can be reused on the same frame. (default: false)
  66463. * @param textureType Type of textures used when performing the post process. (default: 0)
  66464. * @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)
  66465. */
  66466. 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);
  66467. /**
  66468. * Updates the effect with the current post process compile time values and recompiles the shader.
  66469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66472. * @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
  66473. * @param onCompiled Called when the shader has been compiled.
  66474. * @param onError Called if there is an error when compiling a shader.
  66475. */
  66476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66477. }
  66478. }
  66479. declare module BABYLON {
  66480. /**
  66481. * Specifies the level of max blur that should be applied when using the depth of field effect
  66482. */
  66483. export enum DepthOfFieldEffectBlurLevel {
  66484. /**
  66485. * Subtle blur
  66486. */
  66487. Low = 0,
  66488. /**
  66489. * Medium blur
  66490. */
  66491. Medium = 1,
  66492. /**
  66493. * Large blur
  66494. */
  66495. High = 2
  66496. }
  66497. /**
  66498. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66499. */
  66500. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66501. private _circleOfConfusion;
  66502. /**
  66503. * @hidden Internal, blurs from high to low
  66504. */
  66505. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66506. private _depthOfFieldBlurY;
  66507. private _dofMerge;
  66508. /**
  66509. * @hidden Internal post processes in depth of field effect
  66510. */
  66511. _effects: Array<PostProcess>;
  66512. /**
  66513. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66514. */
  66515. set focalLength(value: number);
  66516. get focalLength(): number;
  66517. /**
  66518. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66519. */
  66520. set fStop(value: number);
  66521. get fStop(): number;
  66522. /**
  66523. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66524. */
  66525. set focusDistance(value: number);
  66526. get focusDistance(): number;
  66527. /**
  66528. * 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.
  66529. */
  66530. set lensSize(value: number);
  66531. get lensSize(): number;
  66532. /**
  66533. * Creates a new instance DepthOfFieldEffect
  66534. * @param scene The scene the effect belongs to.
  66535. * @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.
  66536. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66537. * @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)
  66538. */
  66539. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66540. /**
  66541. * Get the current class name of the current effet
  66542. * @returns "DepthOfFieldEffect"
  66543. */
  66544. getClassName(): string;
  66545. /**
  66546. * 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.
  66547. */
  66548. set depthTexture(value: RenderTargetTexture);
  66549. /**
  66550. * Disposes each of the internal effects for a given camera.
  66551. * @param camera The camera to dispose the effect on.
  66552. */
  66553. disposeEffects(camera: Camera): void;
  66554. /**
  66555. * @hidden Internal
  66556. */
  66557. _updateEffects(): void;
  66558. /**
  66559. * Internal
  66560. * @returns if all the contained post processes are ready.
  66561. * @hidden
  66562. */
  66563. _isReady(): boolean;
  66564. }
  66565. }
  66566. declare module BABYLON {
  66567. /** @hidden */
  66568. export var displayPassPixelShader: {
  66569. name: string;
  66570. shader: string;
  66571. };
  66572. }
  66573. declare module BABYLON {
  66574. /**
  66575. * DisplayPassPostProcess which produces an output the same as it's input
  66576. */
  66577. export class DisplayPassPostProcess extends PostProcess {
  66578. /**
  66579. * Creates the DisplayPassPostProcess
  66580. * @param name The name of the effect.
  66581. * @param options The required width/height ratio to downsize to before computing the render pass.
  66582. * @param camera The camera to apply the render pass to.
  66583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66584. * @param engine The engine which the post process will be applied. (default: current engine)
  66585. * @param reusable If the post process can be reused on the same frame. (default: false)
  66586. */
  66587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66588. }
  66589. }
  66590. declare module BABYLON {
  66591. /** @hidden */
  66592. export var filterPixelShader: {
  66593. name: string;
  66594. shader: string;
  66595. };
  66596. }
  66597. declare module BABYLON {
  66598. /**
  66599. * Applies a kernel filter to the image
  66600. */
  66601. export class FilterPostProcess extends PostProcess {
  66602. /** The matrix to be applied to the image */
  66603. kernelMatrix: Matrix;
  66604. /**
  66605. *
  66606. * @param name The name of the effect.
  66607. * @param kernelMatrix The matrix to be applied to the image
  66608. * @param options The required width/height ratio to downsize to before computing the render pass.
  66609. * @param camera The camera to apply the render pass to.
  66610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66611. * @param engine The engine which the post process will be applied. (default: current engine)
  66612. * @param reusable If the post process can be reused on the same frame. (default: false)
  66613. */
  66614. constructor(name: string,
  66615. /** The matrix to be applied to the image */
  66616. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66617. }
  66618. }
  66619. declare module BABYLON {
  66620. /** @hidden */
  66621. export var fxaaPixelShader: {
  66622. name: string;
  66623. shader: string;
  66624. };
  66625. }
  66626. declare module BABYLON {
  66627. /** @hidden */
  66628. export var fxaaVertexShader: {
  66629. name: string;
  66630. shader: string;
  66631. };
  66632. }
  66633. declare module BABYLON {
  66634. /**
  66635. * Fxaa post process
  66636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66637. */
  66638. export class FxaaPostProcess extends PostProcess {
  66639. /** @hidden */
  66640. texelWidth: number;
  66641. /** @hidden */
  66642. texelHeight: number;
  66643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66644. private _getDefines;
  66645. }
  66646. }
  66647. declare module BABYLON {
  66648. /** @hidden */
  66649. export var grainPixelShader: {
  66650. name: string;
  66651. shader: string;
  66652. };
  66653. }
  66654. declare module BABYLON {
  66655. /**
  66656. * The GrainPostProcess adds noise to the image at mid luminance levels
  66657. */
  66658. export class GrainPostProcess extends PostProcess {
  66659. /**
  66660. * The intensity of the grain added (default: 30)
  66661. */
  66662. intensity: number;
  66663. /**
  66664. * If the grain should be randomized on every frame
  66665. */
  66666. animated: boolean;
  66667. /**
  66668. * Creates a new instance of @see GrainPostProcess
  66669. * @param name The name of the effect.
  66670. * @param options The required width/height ratio to downsize to before computing the render pass.
  66671. * @param camera The camera to apply the render pass to.
  66672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66673. * @param engine The engine which the post process will be applied. (default: current engine)
  66674. * @param reusable If the post process can be reused on the same frame. (default: false)
  66675. * @param textureType Type of textures used when performing the post process. (default: 0)
  66676. * @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)
  66677. */
  66678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66679. }
  66680. }
  66681. declare module BABYLON {
  66682. /** @hidden */
  66683. export var highlightsPixelShader: {
  66684. name: string;
  66685. shader: string;
  66686. };
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * Extracts highlights from the image
  66691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66692. */
  66693. export class HighlightsPostProcess extends PostProcess {
  66694. /**
  66695. * Extracts highlights from the image
  66696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66697. * @param name The name of the effect.
  66698. * @param options The required width/height ratio to downsize to before computing the render pass.
  66699. * @param camera The camera to apply the render pass to.
  66700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66701. * @param engine The engine which the post process will be applied. (default: current engine)
  66702. * @param reusable If the post process can be reused on the same frame. (default: false)
  66703. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66704. */
  66705. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66706. }
  66707. }
  66708. declare module BABYLON {
  66709. /** @hidden */
  66710. export var mrtFragmentDeclaration: {
  66711. name: string;
  66712. shader: string;
  66713. };
  66714. }
  66715. declare module BABYLON {
  66716. /** @hidden */
  66717. export var geometryPixelShader: {
  66718. name: string;
  66719. shader: string;
  66720. };
  66721. }
  66722. declare module BABYLON {
  66723. /** @hidden */
  66724. export var geometryVertexShader: {
  66725. name: string;
  66726. shader: string;
  66727. };
  66728. }
  66729. declare module BABYLON {
  66730. /** @hidden */
  66731. interface ISavedTransformationMatrix {
  66732. world: Matrix;
  66733. viewProjection: Matrix;
  66734. }
  66735. /**
  66736. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66737. */
  66738. export class GeometryBufferRenderer {
  66739. /**
  66740. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66741. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66742. */
  66743. static readonly POSITION_TEXTURE_TYPE: number;
  66744. /**
  66745. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66746. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66747. */
  66748. static readonly VELOCITY_TEXTURE_TYPE: number;
  66749. /**
  66750. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  66751. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  66752. */
  66753. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  66754. /**
  66755. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66756. * in order to compute objects velocities when enableVelocity is set to "true"
  66757. * @hidden
  66758. */
  66759. _previousTransformationMatrices: {
  66760. [index: number]: ISavedTransformationMatrix;
  66761. };
  66762. /**
  66763. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66764. * in order to compute objects velocities when enableVelocity is set to "true"
  66765. * @hidden
  66766. */
  66767. _previousBonesTransformationMatrices: {
  66768. [index: number]: Float32Array;
  66769. };
  66770. /**
  66771. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66772. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66773. */
  66774. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66775. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  66776. renderTransparentMeshes: boolean;
  66777. private _scene;
  66778. private _multiRenderTarget;
  66779. private _ratio;
  66780. private _enablePosition;
  66781. private _enableVelocity;
  66782. private _enableReflectivity;
  66783. private _positionIndex;
  66784. private _velocityIndex;
  66785. private _reflectivityIndex;
  66786. protected _effect: Effect;
  66787. protected _cachedDefines: string;
  66788. /**
  66789. * Set the render list (meshes to be rendered) used in the G buffer.
  66790. */
  66791. set renderList(meshes: Mesh[]);
  66792. /**
  66793. * Gets wether or not G buffer are supported by the running hardware.
  66794. * This requires draw buffer supports
  66795. */
  66796. get isSupported(): boolean;
  66797. /**
  66798. * Returns the index of the given texture type in the G-Buffer textures array
  66799. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66800. * @returns the index of the given texture type in the G-Buffer textures array
  66801. */
  66802. getTextureIndex(textureType: number): number;
  66803. /**
  66804. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66805. */
  66806. get enablePosition(): boolean;
  66807. /**
  66808. * Sets whether or not objects positions are enabled for the G buffer.
  66809. */
  66810. set enablePosition(enable: boolean);
  66811. /**
  66812. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66813. */
  66814. get enableVelocity(): boolean;
  66815. /**
  66816. * Sets wether or not objects velocities are enabled for the G buffer.
  66817. */
  66818. set enableVelocity(enable: boolean);
  66819. /**
  66820. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  66821. */
  66822. get enableReflectivity(): boolean;
  66823. /**
  66824. * Sets wether or not objects roughness are enabled for the G buffer.
  66825. */
  66826. set enableReflectivity(enable: boolean);
  66827. /**
  66828. * Gets the scene associated with the buffer.
  66829. */
  66830. get scene(): Scene;
  66831. /**
  66832. * Gets the ratio used by the buffer during its creation.
  66833. * How big is the buffer related to the main canvas.
  66834. */
  66835. get ratio(): number;
  66836. /** @hidden */
  66837. static _SceneComponentInitialization: (scene: Scene) => void;
  66838. /**
  66839. * Creates a new G Buffer for the scene
  66840. * @param scene The scene the buffer belongs to
  66841. * @param ratio How big is the buffer related to the main canvas.
  66842. */
  66843. constructor(scene: Scene, ratio?: number);
  66844. /**
  66845. * Checks wether everything is ready to render a submesh to the G buffer.
  66846. * @param subMesh the submesh to check readiness for
  66847. * @param useInstances is the mesh drawn using instance or not
  66848. * @returns true if ready otherwise false
  66849. */
  66850. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66851. /**
  66852. * Gets the current underlying G Buffer.
  66853. * @returns the buffer
  66854. */
  66855. getGBuffer(): MultiRenderTarget;
  66856. /**
  66857. * Gets the number of samples used to render the buffer (anti aliasing).
  66858. */
  66859. get samples(): number;
  66860. /**
  66861. * Sets the number of samples used to render the buffer (anti aliasing).
  66862. */
  66863. set samples(value: number);
  66864. /**
  66865. * Disposes the renderer and frees up associated resources.
  66866. */
  66867. dispose(): void;
  66868. protected _createRenderTargets(): void;
  66869. private _copyBonesTransformationMatrices;
  66870. }
  66871. }
  66872. declare module BABYLON {
  66873. interface Scene {
  66874. /** @hidden (Backing field) */
  66875. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66876. /**
  66877. * Gets or Sets the current geometry buffer associated to the scene.
  66878. */
  66879. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66880. /**
  66881. * Enables a GeometryBufferRender and associates it with the scene
  66882. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66883. * @returns the GeometryBufferRenderer
  66884. */
  66885. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66886. /**
  66887. * Disables the GeometryBufferRender associated with the scene
  66888. */
  66889. disableGeometryBufferRenderer(): void;
  66890. }
  66891. /**
  66892. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66893. * in several rendering techniques.
  66894. */
  66895. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66896. /**
  66897. * The component name helpful to identify the component in the list of scene components.
  66898. */
  66899. readonly name: string;
  66900. /**
  66901. * The scene the component belongs to.
  66902. */
  66903. scene: Scene;
  66904. /**
  66905. * Creates a new instance of the component for the given scene
  66906. * @param scene Defines the scene to register the component in
  66907. */
  66908. constructor(scene: Scene);
  66909. /**
  66910. * Registers the component in a given scene
  66911. */
  66912. register(): void;
  66913. /**
  66914. * Rebuilds the elements related to this component in case of
  66915. * context lost for instance.
  66916. */
  66917. rebuild(): void;
  66918. /**
  66919. * Disposes the component and the associated ressources
  66920. */
  66921. dispose(): void;
  66922. private _gatherRenderTargets;
  66923. }
  66924. }
  66925. declare module BABYLON {
  66926. /** @hidden */
  66927. export var motionBlurPixelShader: {
  66928. name: string;
  66929. shader: string;
  66930. };
  66931. }
  66932. declare module BABYLON {
  66933. /**
  66934. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66935. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66936. * As an example, all you have to do is to create the post-process:
  66937. * var mb = new BABYLON.MotionBlurPostProcess(
  66938. * 'mb', // The name of the effect.
  66939. * scene, // The scene containing the objects to blur according to their velocity.
  66940. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66941. * camera // The camera to apply the render pass to.
  66942. * );
  66943. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66944. */
  66945. export class MotionBlurPostProcess extends PostProcess {
  66946. /**
  66947. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66948. */
  66949. motionStrength: number;
  66950. /**
  66951. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66952. */
  66953. get motionBlurSamples(): number;
  66954. /**
  66955. * Sets the number of iterations to be used for motion blur quality
  66956. */
  66957. set motionBlurSamples(samples: number);
  66958. private _motionBlurSamples;
  66959. private _geometryBufferRenderer;
  66960. /**
  66961. * Creates a new instance MotionBlurPostProcess
  66962. * @param name The name of the effect.
  66963. * @param scene The scene containing the objects to blur according to their velocity.
  66964. * @param options The required width/height ratio to downsize to before computing the render pass.
  66965. * @param camera The camera to apply the render pass to.
  66966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66967. * @param engine The engine which the post process will be applied. (default: current engine)
  66968. * @param reusable If the post process can be reused on the same frame. (default: false)
  66969. * @param textureType Type of textures used when performing the post process. (default: 0)
  66970. * @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)
  66971. */
  66972. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66973. /**
  66974. * Excludes the given skinned mesh from computing bones velocities.
  66975. * 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.
  66976. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66977. */
  66978. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66979. /**
  66980. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66981. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66982. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66983. */
  66984. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66985. /**
  66986. * Disposes the post process.
  66987. * @param camera The camera to dispose the post process on.
  66988. */
  66989. dispose(camera?: Camera): void;
  66990. }
  66991. }
  66992. declare module BABYLON {
  66993. /** @hidden */
  66994. export var refractionPixelShader: {
  66995. name: string;
  66996. shader: string;
  66997. };
  66998. }
  66999. declare module BABYLON {
  67000. /**
  67001. * Post process which applies a refractin texture
  67002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67003. */
  67004. export class RefractionPostProcess extends PostProcess {
  67005. /** the base color of the refraction (used to taint the rendering) */
  67006. color: Color3;
  67007. /** simulated refraction depth */
  67008. depth: number;
  67009. /** the coefficient of the base color (0 to remove base color tainting) */
  67010. colorLevel: number;
  67011. private _refTexture;
  67012. private _ownRefractionTexture;
  67013. /**
  67014. * Gets or sets the refraction texture
  67015. * Please note that you are responsible for disposing the texture if you set it manually
  67016. */
  67017. get refractionTexture(): Texture;
  67018. set refractionTexture(value: Texture);
  67019. /**
  67020. * Initializes the RefractionPostProcess
  67021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67022. * @param name The name of the effect.
  67023. * @param refractionTextureUrl Url of the refraction texture to use
  67024. * @param color the base color of the refraction (used to taint the rendering)
  67025. * @param depth simulated refraction depth
  67026. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67027. * @param camera The camera to apply the render pass to.
  67028. * @param options The required width/height ratio to downsize to before computing the render pass.
  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. */
  67033. constructor(name: string, refractionTextureUrl: string,
  67034. /** the base color of the refraction (used to taint the rendering) */
  67035. color: Color3,
  67036. /** simulated refraction depth */
  67037. depth: number,
  67038. /** the coefficient of the base color (0 to remove base color tainting) */
  67039. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67040. /**
  67041. * Disposes of the post process
  67042. * @param camera Camera to dispose post process on
  67043. */
  67044. dispose(camera: Camera): void;
  67045. }
  67046. }
  67047. declare module BABYLON {
  67048. /** @hidden */
  67049. export var sharpenPixelShader: {
  67050. name: string;
  67051. shader: string;
  67052. };
  67053. }
  67054. declare module BABYLON {
  67055. /**
  67056. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67057. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67058. */
  67059. export class SharpenPostProcess extends PostProcess {
  67060. /**
  67061. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67062. */
  67063. colorAmount: number;
  67064. /**
  67065. * How much sharpness should be applied (default: 0.3)
  67066. */
  67067. edgeAmount: number;
  67068. /**
  67069. * Creates a new instance ConvolutionPostProcess
  67070. * @param name The name of the effect.
  67071. * @param options The required width/height ratio to downsize to before computing the render pass.
  67072. * @param camera The camera to apply the render pass to.
  67073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67074. * @param engine The engine which the post process will be applied. (default: current engine)
  67075. * @param reusable If the post process can be reused on the same frame. (default: false)
  67076. * @param textureType Type of textures used when performing the post process. (default: 0)
  67077. * @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)
  67078. */
  67079. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67080. }
  67081. }
  67082. declare module BABYLON {
  67083. /**
  67084. * PostProcessRenderPipeline
  67085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67086. */
  67087. export class PostProcessRenderPipeline {
  67088. private engine;
  67089. private _renderEffects;
  67090. private _renderEffectsForIsolatedPass;
  67091. /**
  67092. * List of inspectable custom properties (used by the Inspector)
  67093. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67094. */
  67095. inspectableCustomProperties: IInspectable[];
  67096. /**
  67097. * @hidden
  67098. */
  67099. protected _cameras: Camera[];
  67100. /** @hidden */
  67101. _name: string;
  67102. /**
  67103. * Gets pipeline name
  67104. */
  67105. get name(): string;
  67106. /** Gets the list of attached cameras */
  67107. get cameras(): Camera[];
  67108. /**
  67109. * Initializes a PostProcessRenderPipeline
  67110. * @param engine engine to add the pipeline to
  67111. * @param name name of the pipeline
  67112. */
  67113. constructor(engine: Engine, name: string);
  67114. /**
  67115. * Gets the class name
  67116. * @returns "PostProcessRenderPipeline"
  67117. */
  67118. getClassName(): string;
  67119. /**
  67120. * If all the render effects in the pipeline are supported
  67121. */
  67122. get isSupported(): boolean;
  67123. /**
  67124. * Adds an effect to the pipeline
  67125. * @param renderEffect the effect to add
  67126. */
  67127. addEffect(renderEffect: PostProcessRenderEffect): void;
  67128. /** @hidden */
  67129. _rebuild(): void;
  67130. /** @hidden */
  67131. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67132. /** @hidden */
  67133. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67134. /** @hidden */
  67135. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67136. /** @hidden */
  67137. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67138. /** @hidden */
  67139. _attachCameras(cameras: Camera, unique: boolean): void;
  67140. /** @hidden */
  67141. _attachCameras(cameras: Camera[], unique: boolean): void;
  67142. /** @hidden */
  67143. _detachCameras(cameras: Camera): void;
  67144. /** @hidden */
  67145. _detachCameras(cameras: Nullable<Camera[]>): void;
  67146. /** @hidden */
  67147. _update(): void;
  67148. /** @hidden */
  67149. _reset(): void;
  67150. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67151. /**
  67152. * Disposes of the pipeline
  67153. */
  67154. dispose(): void;
  67155. }
  67156. }
  67157. declare module BABYLON {
  67158. /**
  67159. * PostProcessRenderPipelineManager class
  67160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67161. */
  67162. export class PostProcessRenderPipelineManager {
  67163. private _renderPipelines;
  67164. /**
  67165. * Initializes a PostProcessRenderPipelineManager
  67166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67167. */
  67168. constructor();
  67169. /**
  67170. * Gets the list of supported render pipelines
  67171. */
  67172. get supportedPipelines(): PostProcessRenderPipeline[];
  67173. /**
  67174. * Adds a pipeline to the manager
  67175. * @param renderPipeline The pipeline to add
  67176. */
  67177. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67178. /**
  67179. * Attaches a camera to the pipeline
  67180. * @param renderPipelineName The name of the pipeline to attach to
  67181. * @param cameras the camera to attach
  67182. * @param unique if the camera can be attached multiple times to the pipeline
  67183. */
  67184. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67185. /**
  67186. * Detaches a camera from the pipeline
  67187. * @param renderPipelineName The name of the pipeline to detach from
  67188. * @param cameras the camera to detach
  67189. */
  67190. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67191. /**
  67192. * Enables an effect by name on a pipeline
  67193. * @param renderPipelineName the name of the pipeline to enable the effect in
  67194. * @param renderEffectName the name of the effect to enable
  67195. * @param cameras the cameras that the effect should be enabled on
  67196. */
  67197. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67198. /**
  67199. * Disables an effect by name on a pipeline
  67200. * @param renderPipelineName the name of the pipeline to disable the effect in
  67201. * @param renderEffectName the name of the effect to disable
  67202. * @param cameras the cameras that the effect should be disabled on
  67203. */
  67204. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67205. /**
  67206. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67207. */
  67208. update(): void;
  67209. /** @hidden */
  67210. _rebuild(): void;
  67211. /**
  67212. * Disposes of the manager and pipelines
  67213. */
  67214. dispose(): void;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. interface Scene {
  67219. /** @hidden (Backing field) */
  67220. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67221. /**
  67222. * Gets the postprocess render pipeline manager
  67223. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67224. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67225. */
  67226. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67227. }
  67228. /**
  67229. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67230. */
  67231. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67232. /**
  67233. * The component name helpfull to identify the component in the list of scene components.
  67234. */
  67235. readonly name: string;
  67236. /**
  67237. * The scene the component belongs to.
  67238. */
  67239. scene: Scene;
  67240. /**
  67241. * Creates a new instance of the component for the given scene
  67242. * @param scene Defines the scene to register the component in
  67243. */
  67244. constructor(scene: Scene);
  67245. /**
  67246. * Registers the component in a given scene
  67247. */
  67248. register(): void;
  67249. /**
  67250. * Rebuilds the elements related to this component in case of
  67251. * context lost for instance.
  67252. */
  67253. rebuild(): void;
  67254. /**
  67255. * Disposes the component and the associated ressources
  67256. */
  67257. dispose(): void;
  67258. private _gatherRenderTargets;
  67259. }
  67260. }
  67261. declare module BABYLON {
  67262. /**
  67263. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67264. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67265. */
  67266. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67267. private _scene;
  67268. private _camerasToBeAttached;
  67269. /**
  67270. * ID of the sharpen post process,
  67271. */
  67272. private readonly SharpenPostProcessId;
  67273. /**
  67274. * @ignore
  67275. * ID of the image processing post process;
  67276. */
  67277. readonly ImageProcessingPostProcessId: string;
  67278. /**
  67279. * @ignore
  67280. * ID of the Fast Approximate Anti-Aliasing post process;
  67281. */
  67282. readonly FxaaPostProcessId: string;
  67283. /**
  67284. * ID of the chromatic aberration post process,
  67285. */
  67286. private readonly ChromaticAberrationPostProcessId;
  67287. /**
  67288. * ID of the grain post process
  67289. */
  67290. private readonly GrainPostProcessId;
  67291. /**
  67292. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67293. */
  67294. sharpen: SharpenPostProcess;
  67295. private _sharpenEffect;
  67296. private bloom;
  67297. /**
  67298. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67299. */
  67300. depthOfField: DepthOfFieldEffect;
  67301. /**
  67302. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67303. */
  67304. fxaa: FxaaPostProcess;
  67305. /**
  67306. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67307. */
  67308. imageProcessing: ImageProcessingPostProcess;
  67309. /**
  67310. * Chromatic aberration post process which will shift rgb colors in the image
  67311. */
  67312. chromaticAberration: ChromaticAberrationPostProcess;
  67313. private _chromaticAberrationEffect;
  67314. /**
  67315. * Grain post process which add noise to the image
  67316. */
  67317. grain: GrainPostProcess;
  67318. private _grainEffect;
  67319. /**
  67320. * Glow post process which adds a glow to emissive areas of the image
  67321. */
  67322. private _glowLayer;
  67323. /**
  67324. * Animations which can be used to tweak settings over a period of time
  67325. */
  67326. animations: Animation[];
  67327. private _imageProcessingConfigurationObserver;
  67328. private _sharpenEnabled;
  67329. private _bloomEnabled;
  67330. private _depthOfFieldEnabled;
  67331. private _depthOfFieldBlurLevel;
  67332. private _fxaaEnabled;
  67333. private _imageProcessingEnabled;
  67334. private _defaultPipelineTextureType;
  67335. private _bloomScale;
  67336. private _chromaticAberrationEnabled;
  67337. private _grainEnabled;
  67338. private _buildAllowed;
  67339. /**
  67340. * Gets active scene
  67341. */
  67342. get scene(): Scene;
  67343. /**
  67344. * Enable or disable the sharpen process from the pipeline
  67345. */
  67346. set sharpenEnabled(enabled: boolean);
  67347. get sharpenEnabled(): boolean;
  67348. private _resizeObserver;
  67349. private _hardwareScaleLevel;
  67350. private _bloomKernel;
  67351. /**
  67352. * Specifies the size of the bloom blur kernel, relative to the final output size
  67353. */
  67354. get bloomKernel(): number;
  67355. set bloomKernel(value: number);
  67356. /**
  67357. * Specifies the weight of the bloom in the final rendering
  67358. */
  67359. private _bloomWeight;
  67360. /**
  67361. * Specifies the luma threshold for the area that will be blurred by the bloom
  67362. */
  67363. private _bloomThreshold;
  67364. private _hdr;
  67365. /**
  67366. * The strength of the bloom.
  67367. */
  67368. set bloomWeight(value: number);
  67369. get bloomWeight(): number;
  67370. /**
  67371. * The strength of the bloom.
  67372. */
  67373. set bloomThreshold(value: number);
  67374. get bloomThreshold(): number;
  67375. /**
  67376. * The scale of the bloom, lower value will provide better performance.
  67377. */
  67378. set bloomScale(value: number);
  67379. get bloomScale(): number;
  67380. /**
  67381. * Enable or disable the bloom from the pipeline
  67382. */
  67383. set bloomEnabled(enabled: boolean);
  67384. get bloomEnabled(): boolean;
  67385. private _rebuildBloom;
  67386. /**
  67387. * If the depth of field is enabled.
  67388. */
  67389. get depthOfFieldEnabled(): boolean;
  67390. set depthOfFieldEnabled(enabled: boolean);
  67391. /**
  67392. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67393. */
  67394. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67395. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67396. /**
  67397. * If the anti aliasing is enabled.
  67398. */
  67399. set fxaaEnabled(enabled: boolean);
  67400. get fxaaEnabled(): boolean;
  67401. private _samples;
  67402. /**
  67403. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67404. */
  67405. set samples(sampleCount: number);
  67406. get samples(): number;
  67407. /**
  67408. * If image processing is enabled.
  67409. */
  67410. set imageProcessingEnabled(enabled: boolean);
  67411. get imageProcessingEnabled(): boolean;
  67412. /**
  67413. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67414. */
  67415. set glowLayerEnabled(enabled: boolean);
  67416. get glowLayerEnabled(): boolean;
  67417. /**
  67418. * Gets the glow layer (or null if not defined)
  67419. */
  67420. get glowLayer(): Nullable<GlowLayer>;
  67421. /**
  67422. * Enable or disable the chromaticAberration process from the pipeline
  67423. */
  67424. set chromaticAberrationEnabled(enabled: boolean);
  67425. get chromaticAberrationEnabled(): boolean;
  67426. /**
  67427. * Enable or disable the grain process from the pipeline
  67428. */
  67429. set grainEnabled(enabled: boolean);
  67430. get grainEnabled(): boolean;
  67431. /**
  67432. * @constructor
  67433. * @param name - The rendering pipeline name (default: "")
  67434. * @param hdr - If high dynamic range textures should be used (default: true)
  67435. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67436. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67437. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67438. */
  67439. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67440. /**
  67441. * Get the class name
  67442. * @returns "DefaultRenderingPipeline"
  67443. */
  67444. getClassName(): string;
  67445. /**
  67446. * Force the compilation of the entire pipeline.
  67447. */
  67448. prepare(): void;
  67449. private _hasCleared;
  67450. private _prevPostProcess;
  67451. private _prevPrevPostProcess;
  67452. private _setAutoClearAndTextureSharing;
  67453. private _depthOfFieldSceneObserver;
  67454. private _buildPipeline;
  67455. private _disposePostProcesses;
  67456. /**
  67457. * Adds a camera to the pipeline
  67458. * @param camera the camera to be added
  67459. */
  67460. addCamera(camera: Camera): void;
  67461. /**
  67462. * Removes a camera from the pipeline
  67463. * @param camera the camera to remove
  67464. */
  67465. removeCamera(camera: Camera): void;
  67466. /**
  67467. * Dispose of the pipeline and stop all post processes
  67468. */
  67469. dispose(): void;
  67470. /**
  67471. * Serialize the rendering pipeline (Used when exporting)
  67472. * @returns the serialized object
  67473. */
  67474. serialize(): any;
  67475. /**
  67476. * Parse the serialized pipeline
  67477. * @param source Source pipeline.
  67478. * @param scene The scene to load the pipeline to.
  67479. * @param rootUrl The URL of the serialized pipeline.
  67480. * @returns An instantiated pipeline from the serialized object.
  67481. */
  67482. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67483. }
  67484. }
  67485. declare module BABYLON {
  67486. /** @hidden */
  67487. export var lensHighlightsPixelShader: {
  67488. name: string;
  67489. shader: string;
  67490. };
  67491. }
  67492. declare module BABYLON {
  67493. /** @hidden */
  67494. export var depthOfFieldPixelShader: {
  67495. name: string;
  67496. shader: string;
  67497. };
  67498. }
  67499. declare module BABYLON {
  67500. /**
  67501. * BABYLON.JS Chromatic Aberration GLSL Shader
  67502. * Author: Olivier Guyot
  67503. * Separates very slightly R, G and B colors on the edges of the screen
  67504. * Inspired by Francois Tarlier & Martins Upitis
  67505. */
  67506. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67507. /**
  67508. * @ignore
  67509. * The chromatic aberration PostProcess id in the pipeline
  67510. */
  67511. LensChromaticAberrationEffect: string;
  67512. /**
  67513. * @ignore
  67514. * The highlights enhancing PostProcess id in the pipeline
  67515. */
  67516. HighlightsEnhancingEffect: string;
  67517. /**
  67518. * @ignore
  67519. * The depth-of-field PostProcess id in the pipeline
  67520. */
  67521. LensDepthOfFieldEffect: string;
  67522. private _scene;
  67523. private _depthTexture;
  67524. private _grainTexture;
  67525. private _chromaticAberrationPostProcess;
  67526. private _highlightsPostProcess;
  67527. private _depthOfFieldPostProcess;
  67528. private _edgeBlur;
  67529. private _grainAmount;
  67530. private _chromaticAberration;
  67531. private _distortion;
  67532. private _highlightsGain;
  67533. private _highlightsThreshold;
  67534. private _dofDistance;
  67535. private _dofAperture;
  67536. private _dofDarken;
  67537. private _dofPentagon;
  67538. private _blurNoise;
  67539. /**
  67540. * @constructor
  67541. *
  67542. * Effect parameters are as follow:
  67543. * {
  67544. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67545. * edge_blur: number; // from 0 to x (1 for realism)
  67546. * distortion: number; // from 0 to x (1 for realism)
  67547. * grain_amount: number; // from 0 to 1
  67548. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67549. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67550. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67551. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67552. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67553. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67554. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67555. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67556. * }
  67557. * Note: if an effect parameter is unset, effect is disabled
  67558. *
  67559. * @param name The rendering pipeline name
  67560. * @param parameters - An object containing all parameters (see above)
  67561. * @param scene The scene linked to this pipeline
  67562. * @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)
  67563. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67564. */
  67565. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67566. /**
  67567. * Get the class name
  67568. * @returns "LensRenderingPipeline"
  67569. */
  67570. getClassName(): string;
  67571. /**
  67572. * Gets associated scene
  67573. */
  67574. get scene(): Scene;
  67575. /**
  67576. * Gets or sets the edge blur
  67577. */
  67578. get edgeBlur(): number;
  67579. set edgeBlur(value: number);
  67580. /**
  67581. * Gets or sets the grain amount
  67582. */
  67583. get grainAmount(): number;
  67584. set grainAmount(value: number);
  67585. /**
  67586. * Gets or sets the chromatic aberration amount
  67587. */
  67588. get chromaticAberration(): number;
  67589. set chromaticAberration(value: number);
  67590. /**
  67591. * Gets or sets the depth of field aperture
  67592. */
  67593. get dofAperture(): number;
  67594. set dofAperture(value: number);
  67595. /**
  67596. * Gets or sets the edge distortion
  67597. */
  67598. get edgeDistortion(): number;
  67599. set edgeDistortion(value: number);
  67600. /**
  67601. * Gets or sets the depth of field distortion
  67602. */
  67603. get dofDistortion(): number;
  67604. set dofDistortion(value: number);
  67605. /**
  67606. * Gets or sets the darken out of focus amount
  67607. */
  67608. get darkenOutOfFocus(): number;
  67609. set darkenOutOfFocus(value: number);
  67610. /**
  67611. * Gets or sets a boolean indicating if blur noise is enabled
  67612. */
  67613. get blurNoise(): boolean;
  67614. set blurNoise(value: boolean);
  67615. /**
  67616. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67617. */
  67618. get pentagonBokeh(): boolean;
  67619. set pentagonBokeh(value: boolean);
  67620. /**
  67621. * Gets or sets the highlight grain amount
  67622. */
  67623. get highlightsGain(): number;
  67624. set highlightsGain(value: number);
  67625. /**
  67626. * Gets or sets the highlight threshold
  67627. */
  67628. get highlightsThreshold(): number;
  67629. set highlightsThreshold(value: number);
  67630. /**
  67631. * Sets the amount of blur at the edges
  67632. * @param amount blur amount
  67633. */
  67634. setEdgeBlur(amount: number): void;
  67635. /**
  67636. * Sets edge blur to 0
  67637. */
  67638. disableEdgeBlur(): void;
  67639. /**
  67640. * Sets the amout of grain
  67641. * @param amount Amount of grain
  67642. */
  67643. setGrainAmount(amount: number): void;
  67644. /**
  67645. * Set grain amount to 0
  67646. */
  67647. disableGrain(): void;
  67648. /**
  67649. * Sets the chromatic aberration amount
  67650. * @param amount amount of chromatic aberration
  67651. */
  67652. setChromaticAberration(amount: number): void;
  67653. /**
  67654. * Sets chromatic aberration amount to 0
  67655. */
  67656. disableChromaticAberration(): void;
  67657. /**
  67658. * Sets the EdgeDistortion amount
  67659. * @param amount amount of EdgeDistortion
  67660. */
  67661. setEdgeDistortion(amount: number): void;
  67662. /**
  67663. * Sets edge distortion to 0
  67664. */
  67665. disableEdgeDistortion(): void;
  67666. /**
  67667. * Sets the FocusDistance amount
  67668. * @param amount amount of FocusDistance
  67669. */
  67670. setFocusDistance(amount: number): void;
  67671. /**
  67672. * Disables depth of field
  67673. */
  67674. disableDepthOfField(): void;
  67675. /**
  67676. * Sets the Aperture amount
  67677. * @param amount amount of Aperture
  67678. */
  67679. setAperture(amount: number): void;
  67680. /**
  67681. * Sets the DarkenOutOfFocus amount
  67682. * @param amount amount of DarkenOutOfFocus
  67683. */
  67684. setDarkenOutOfFocus(amount: number): void;
  67685. private _pentagonBokehIsEnabled;
  67686. /**
  67687. * Creates a pentagon bokeh effect
  67688. */
  67689. enablePentagonBokeh(): void;
  67690. /**
  67691. * Disables the pentagon bokeh effect
  67692. */
  67693. disablePentagonBokeh(): void;
  67694. /**
  67695. * Enables noise blur
  67696. */
  67697. enableNoiseBlur(): void;
  67698. /**
  67699. * Disables noise blur
  67700. */
  67701. disableNoiseBlur(): void;
  67702. /**
  67703. * Sets the HighlightsGain amount
  67704. * @param amount amount of HighlightsGain
  67705. */
  67706. setHighlightsGain(amount: number): void;
  67707. /**
  67708. * Sets the HighlightsThreshold amount
  67709. * @param amount amount of HighlightsThreshold
  67710. */
  67711. setHighlightsThreshold(amount: number): void;
  67712. /**
  67713. * Disables highlights
  67714. */
  67715. disableHighlights(): void;
  67716. /**
  67717. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67718. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67719. */
  67720. dispose(disableDepthRender?: boolean): void;
  67721. private _createChromaticAberrationPostProcess;
  67722. private _createHighlightsPostProcess;
  67723. private _createDepthOfFieldPostProcess;
  67724. private _createGrainTexture;
  67725. }
  67726. }
  67727. declare module BABYLON {
  67728. /** @hidden */
  67729. export var ssao2PixelShader: {
  67730. name: string;
  67731. shader: string;
  67732. };
  67733. }
  67734. declare module BABYLON {
  67735. /** @hidden */
  67736. export var ssaoCombinePixelShader: {
  67737. name: string;
  67738. shader: string;
  67739. };
  67740. }
  67741. declare module BABYLON {
  67742. /**
  67743. * Render pipeline to produce ssao effect
  67744. */
  67745. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67746. /**
  67747. * @ignore
  67748. * The PassPostProcess id in the pipeline that contains the original scene color
  67749. */
  67750. SSAOOriginalSceneColorEffect: string;
  67751. /**
  67752. * @ignore
  67753. * The SSAO PostProcess id in the pipeline
  67754. */
  67755. SSAORenderEffect: string;
  67756. /**
  67757. * @ignore
  67758. * The horizontal blur PostProcess id in the pipeline
  67759. */
  67760. SSAOBlurHRenderEffect: string;
  67761. /**
  67762. * @ignore
  67763. * The vertical blur PostProcess id in the pipeline
  67764. */
  67765. SSAOBlurVRenderEffect: string;
  67766. /**
  67767. * @ignore
  67768. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67769. */
  67770. SSAOCombineRenderEffect: string;
  67771. /**
  67772. * The output strength of the SSAO post-process. Default value is 1.0.
  67773. */
  67774. totalStrength: number;
  67775. /**
  67776. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67777. */
  67778. maxZ: number;
  67779. /**
  67780. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67781. */
  67782. minZAspect: number;
  67783. private _samples;
  67784. /**
  67785. * Number of samples used for the SSAO calculations. Default value is 8
  67786. */
  67787. set samples(n: number);
  67788. get samples(): number;
  67789. private _textureSamples;
  67790. /**
  67791. * Number of samples to use for antialiasing
  67792. */
  67793. set textureSamples(n: number);
  67794. get textureSamples(): number;
  67795. /**
  67796. * Ratio object used for SSAO ratio and blur ratio
  67797. */
  67798. private _ratio;
  67799. /**
  67800. * Dynamically generated sphere sampler.
  67801. */
  67802. private _sampleSphere;
  67803. /**
  67804. * Blur filter offsets
  67805. */
  67806. private _samplerOffsets;
  67807. private _expensiveBlur;
  67808. /**
  67809. * If bilateral blur should be used
  67810. */
  67811. set expensiveBlur(b: boolean);
  67812. get expensiveBlur(): boolean;
  67813. /**
  67814. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67815. */
  67816. radius: number;
  67817. /**
  67818. * The base color of the SSAO post-process
  67819. * The final result is "base + ssao" between [0, 1]
  67820. */
  67821. base: number;
  67822. /**
  67823. * Support test.
  67824. */
  67825. static get IsSupported(): boolean;
  67826. private _scene;
  67827. private _depthTexture;
  67828. private _normalTexture;
  67829. private _randomTexture;
  67830. private _originalColorPostProcess;
  67831. private _ssaoPostProcess;
  67832. private _blurHPostProcess;
  67833. private _blurVPostProcess;
  67834. private _ssaoCombinePostProcess;
  67835. /**
  67836. * Gets active scene
  67837. */
  67838. get scene(): Scene;
  67839. /**
  67840. * @constructor
  67841. * @param name The rendering pipeline name
  67842. * @param scene The scene linked to this pipeline
  67843. * @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 }
  67844. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67845. */
  67846. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67847. /**
  67848. * Get the class name
  67849. * @returns "SSAO2RenderingPipeline"
  67850. */
  67851. getClassName(): string;
  67852. /**
  67853. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67854. */
  67855. dispose(disableGeometryBufferRenderer?: boolean): void;
  67856. private _createBlurPostProcess;
  67857. /** @hidden */
  67858. _rebuild(): void;
  67859. private _bits;
  67860. private _radicalInverse_VdC;
  67861. private _hammersley;
  67862. private _hemisphereSample_uniform;
  67863. private _generateHemisphere;
  67864. private _createSSAOPostProcess;
  67865. private _createSSAOCombinePostProcess;
  67866. private _createRandomTexture;
  67867. /**
  67868. * Serialize the rendering pipeline (Used when exporting)
  67869. * @returns the serialized object
  67870. */
  67871. serialize(): any;
  67872. /**
  67873. * Parse the serialized pipeline
  67874. * @param source Source pipeline.
  67875. * @param scene The scene to load the pipeline to.
  67876. * @param rootUrl The URL of the serialized pipeline.
  67877. * @returns An instantiated pipeline from the serialized object.
  67878. */
  67879. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67880. }
  67881. }
  67882. declare module BABYLON {
  67883. /** @hidden */
  67884. export var ssaoPixelShader: {
  67885. name: string;
  67886. shader: string;
  67887. };
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * Render pipeline to produce ssao effect
  67892. */
  67893. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67894. /**
  67895. * @ignore
  67896. * The PassPostProcess id in the pipeline that contains the original scene color
  67897. */
  67898. SSAOOriginalSceneColorEffect: string;
  67899. /**
  67900. * @ignore
  67901. * The SSAO PostProcess id in the pipeline
  67902. */
  67903. SSAORenderEffect: string;
  67904. /**
  67905. * @ignore
  67906. * The horizontal blur PostProcess id in the pipeline
  67907. */
  67908. SSAOBlurHRenderEffect: string;
  67909. /**
  67910. * @ignore
  67911. * The vertical blur PostProcess id in the pipeline
  67912. */
  67913. SSAOBlurVRenderEffect: string;
  67914. /**
  67915. * @ignore
  67916. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67917. */
  67918. SSAOCombineRenderEffect: string;
  67919. /**
  67920. * The output strength of the SSAO post-process. Default value is 1.0.
  67921. */
  67922. totalStrength: number;
  67923. /**
  67924. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67925. */
  67926. radius: number;
  67927. /**
  67928. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67929. * Must not be equal to fallOff and superior to fallOff.
  67930. * Default value is 0.0075
  67931. */
  67932. area: number;
  67933. /**
  67934. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67935. * Must not be equal to area and inferior to area.
  67936. * Default value is 0.000001
  67937. */
  67938. fallOff: number;
  67939. /**
  67940. * The base color of the SSAO post-process
  67941. * The final result is "base + ssao" between [0, 1]
  67942. */
  67943. base: number;
  67944. private _scene;
  67945. private _depthTexture;
  67946. private _randomTexture;
  67947. private _originalColorPostProcess;
  67948. private _ssaoPostProcess;
  67949. private _blurHPostProcess;
  67950. private _blurVPostProcess;
  67951. private _ssaoCombinePostProcess;
  67952. private _firstUpdate;
  67953. /**
  67954. * Gets active scene
  67955. */
  67956. get scene(): Scene;
  67957. /**
  67958. * @constructor
  67959. * @param name - The rendering pipeline name
  67960. * @param scene - The scene linked to this pipeline
  67961. * @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 }
  67962. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67963. */
  67964. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67965. /**
  67966. * Get the class name
  67967. * @returns "SSAORenderingPipeline"
  67968. */
  67969. getClassName(): string;
  67970. /**
  67971. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67972. */
  67973. dispose(disableDepthRender?: boolean): void;
  67974. private _createBlurPostProcess;
  67975. /** @hidden */
  67976. _rebuild(): void;
  67977. private _createSSAOPostProcess;
  67978. private _createSSAOCombinePostProcess;
  67979. private _createRandomTexture;
  67980. }
  67981. }
  67982. declare module BABYLON {
  67983. /** @hidden */
  67984. export var screenSpaceReflectionPixelShader: {
  67985. name: string;
  67986. shader: string;
  67987. };
  67988. }
  67989. declare module BABYLON {
  67990. /**
  67991. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  67992. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  67993. */
  67994. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  67995. /**
  67996. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  67997. */
  67998. threshold: number;
  67999. /**
  68000. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68001. */
  68002. strength: number;
  68003. /**
  68004. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68005. */
  68006. reflectionSpecularFalloffExponent: number;
  68007. /**
  68008. * 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]
  68009. */
  68010. step: number;
  68011. /**
  68012. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68013. */
  68014. roughnessFactor: number;
  68015. private _geometryBufferRenderer;
  68016. private _enableSmoothReflections;
  68017. private _reflectionSamples;
  68018. private _smoothSteps;
  68019. /**
  68020. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68021. * @param name The name of the effect.
  68022. * @param scene The scene containing the objects to calculate reflections.
  68023. * @param options The required width/height ratio to downsize to before computing the render pass.
  68024. * @param camera The camera to apply the render pass to.
  68025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68026. * @param engine The engine which the post process will be applied. (default: current engine)
  68027. * @param reusable If the post process can be reused on the same frame. (default: false)
  68028. * @param textureType Type of textures used when performing the post process. (default: 0)
  68029. * @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)
  68030. */
  68031. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68032. /**
  68033. * Gets wether or not smoothing reflections is enabled.
  68034. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68035. */
  68036. get enableSmoothReflections(): boolean;
  68037. /**
  68038. * Sets wether or not smoothing reflections is enabled.
  68039. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68040. */
  68041. set enableSmoothReflections(enabled: boolean);
  68042. /**
  68043. * Gets the number of samples taken while computing reflections. More samples count is high,
  68044. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68045. */
  68046. get reflectionSamples(): number;
  68047. /**
  68048. * Sets the number of samples taken while computing reflections. More samples count is high,
  68049. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68050. */
  68051. set reflectionSamples(samples: number);
  68052. /**
  68053. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68054. * more the post-process will require GPU power and can generate a drop in FPS.
  68055. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68056. */
  68057. get smoothSteps(): number;
  68058. set smoothSteps(steps: number);
  68059. private _updateEffectDefines;
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. /** @hidden */
  68064. export var standardPixelShader: {
  68065. name: string;
  68066. shader: string;
  68067. };
  68068. }
  68069. declare module BABYLON {
  68070. /**
  68071. * Standard rendering pipeline
  68072. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68073. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68074. */
  68075. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68076. /**
  68077. * Public members
  68078. */
  68079. /**
  68080. * Post-process which contains the original scene color before the pipeline applies all the effects
  68081. */
  68082. originalPostProcess: Nullable<PostProcess>;
  68083. /**
  68084. * Post-process used to down scale an image x4
  68085. */
  68086. downSampleX4PostProcess: Nullable<PostProcess>;
  68087. /**
  68088. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68089. */
  68090. brightPassPostProcess: Nullable<PostProcess>;
  68091. /**
  68092. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68093. */
  68094. blurHPostProcesses: PostProcess[];
  68095. /**
  68096. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68097. */
  68098. blurVPostProcesses: PostProcess[];
  68099. /**
  68100. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68101. */
  68102. textureAdderPostProcess: Nullable<PostProcess>;
  68103. /**
  68104. * Post-process used to create volumetric lighting effect
  68105. */
  68106. volumetricLightPostProcess: Nullable<PostProcess>;
  68107. /**
  68108. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68109. */
  68110. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68111. /**
  68112. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68113. */
  68114. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68115. /**
  68116. * Post-process used to merge the volumetric light effect and the real scene color
  68117. */
  68118. volumetricLightMergePostProces: Nullable<PostProcess>;
  68119. /**
  68120. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68121. */
  68122. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68123. /**
  68124. * Base post-process used to calculate the average luminance of the final image for HDR
  68125. */
  68126. luminancePostProcess: Nullable<PostProcess>;
  68127. /**
  68128. * Post-processes used to create down sample post-processes in order to get
  68129. * the average luminance of the final image for HDR
  68130. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68131. */
  68132. luminanceDownSamplePostProcesses: PostProcess[];
  68133. /**
  68134. * Post-process used to create a HDR effect (light adaptation)
  68135. */
  68136. hdrPostProcess: Nullable<PostProcess>;
  68137. /**
  68138. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68139. */
  68140. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68141. /**
  68142. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68143. */
  68144. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68145. /**
  68146. * Post-process used to merge the final HDR post-process and the real scene color
  68147. */
  68148. hdrFinalPostProcess: Nullable<PostProcess>;
  68149. /**
  68150. * Post-process used to create a lens flare effect
  68151. */
  68152. lensFlarePostProcess: Nullable<PostProcess>;
  68153. /**
  68154. * Post-process that merges the result of the lens flare post-process and the real scene color
  68155. */
  68156. lensFlareComposePostProcess: Nullable<PostProcess>;
  68157. /**
  68158. * Post-process used to create a motion blur effect
  68159. */
  68160. motionBlurPostProcess: Nullable<PostProcess>;
  68161. /**
  68162. * Post-process used to create a depth of field effect
  68163. */
  68164. depthOfFieldPostProcess: Nullable<PostProcess>;
  68165. /**
  68166. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68167. */
  68168. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68169. /**
  68170. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  68171. */
  68172. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  68173. /**
  68174. * Represents the brightness threshold in order to configure the illuminated surfaces
  68175. */
  68176. brightThreshold: number;
  68177. /**
  68178. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68179. */
  68180. blurWidth: number;
  68181. /**
  68182. * Sets if the blur for highlighted surfaces must be only horizontal
  68183. */
  68184. horizontalBlur: boolean;
  68185. /**
  68186. * Gets the overall exposure used by the pipeline
  68187. */
  68188. get exposure(): number;
  68189. /**
  68190. * Sets the overall exposure used by the pipeline
  68191. */
  68192. set exposure(value: number);
  68193. /**
  68194. * Texture used typically to simulate "dirty" on camera lens
  68195. */
  68196. lensTexture: Nullable<Texture>;
  68197. /**
  68198. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68199. */
  68200. volumetricLightCoefficient: number;
  68201. /**
  68202. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68203. */
  68204. volumetricLightPower: number;
  68205. /**
  68206. * Used the set the blur intensity to smooth the volumetric lights
  68207. */
  68208. volumetricLightBlurScale: number;
  68209. /**
  68210. * Light (spot or directional) used to generate the volumetric lights rays
  68211. * The source light must have a shadow generate so the pipeline can get its
  68212. * depth map
  68213. */
  68214. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68215. /**
  68216. * For eye adaptation, represents the minimum luminance the eye can see
  68217. */
  68218. hdrMinimumLuminance: number;
  68219. /**
  68220. * For eye adaptation, represents the decrease luminance speed
  68221. */
  68222. hdrDecreaseRate: number;
  68223. /**
  68224. * For eye adaptation, represents the increase luminance speed
  68225. */
  68226. hdrIncreaseRate: number;
  68227. /**
  68228. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68229. */
  68230. get hdrAutoExposure(): boolean;
  68231. /**
  68232. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68233. */
  68234. set hdrAutoExposure(value: boolean);
  68235. /**
  68236. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68237. */
  68238. lensColorTexture: Nullable<Texture>;
  68239. /**
  68240. * The overall strengh for the lens flare effect
  68241. */
  68242. lensFlareStrength: number;
  68243. /**
  68244. * Dispersion coefficient for lens flare ghosts
  68245. */
  68246. lensFlareGhostDispersal: number;
  68247. /**
  68248. * Main lens flare halo width
  68249. */
  68250. lensFlareHaloWidth: number;
  68251. /**
  68252. * Based on the lens distortion effect, defines how much the lens flare result
  68253. * is distorted
  68254. */
  68255. lensFlareDistortionStrength: number;
  68256. /**
  68257. * Configures the blur intensity used for for lens flare (halo)
  68258. */
  68259. lensFlareBlurWidth: number;
  68260. /**
  68261. * Lens star texture must be used to simulate rays on the flares and is available
  68262. * in the documentation
  68263. */
  68264. lensStarTexture: Nullable<Texture>;
  68265. /**
  68266. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68267. * flare effect by taking account of the dirt texture
  68268. */
  68269. lensFlareDirtTexture: Nullable<Texture>;
  68270. /**
  68271. * Represents the focal length for the depth of field effect
  68272. */
  68273. depthOfFieldDistance: number;
  68274. /**
  68275. * Represents the blur intensity for the blurred part of the depth of field effect
  68276. */
  68277. depthOfFieldBlurWidth: number;
  68278. /**
  68279. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68280. */
  68281. get motionStrength(): number;
  68282. /**
  68283. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68284. */
  68285. set motionStrength(strength: number);
  68286. /**
  68287. * Gets wether or not the motion blur post-process is object based or screen based.
  68288. */
  68289. get objectBasedMotionBlur(): boolean;
  68290. /**
  68291. * Sets wether or not the motion blur post-process should be object based or screen based
  68292. */
  68293. set objectBasedMotionBlur(value: boolean);
  68294. /**
  68295. * List of animations for the pipeline (IAnimatable implementation)
  68296. */
  68297. animations: Animation[];
  68298. /**
  68299. * Private members
  68300. */
  68301. private _scene;
  68302. private _currentDepthOfFieldSource;
  68303. private _basePostProcess;
  68304. private _fixedExposure;
  68305. private _currentExposure;
  68306. private _hdrAutoExposure;
  68307. private _hdrCurrentLuminance;
  68308. private _motionStrength;
  68309. private _isObjectBasedMotionBlur;
  68310. private _floatTextureType;
  68311. private _camerasToBeAttached;
  68312. private _ratio;
  68313. private _bloomEnabled;
  68314. private _depthOfFieldEnabled;
  68315. private _vlsEnabled;
  68316. private _lensFlareEnabled;
  68317. private _hdrEnabled;
  68318. private _motionBlurEnabled;
  68319. private _fxaaEnabled;
  68320. private _screenSpaceReflectionsEnabled;
  68321. private _motionBlurSamples;
  68322. private _volumetricLightStepsCount;
  68323. private _samples;
  68324. /**
  68325. * @ignore
  68326. * Specifies if the bloom pipeline is enabled
  68327. */
  68328. get BloomEnabled(): boolean;
  68329. set BloomEnabled(enabled: boolean);
  68330. /**
  68331. * @ignore
  68332. * Specifies if the depth of field pipeline is enabed
  68333. */
  68334. get DepthOfFieldEnabled(): boolean;
  68335. set DepthOfFieldEnabled(enabled: boolean);
  68336. /**
  68337. * @ignore
  68338. * Specifies if the lens flare pipeline is enabed
  68339. */
  68340. get LensFlareEnabled(): boolean;
  68341. set LensFlareEnabled(enabled: boolean);
  68342. /**
  68343. * @ignore
  68344. * Specifies if the HDR pipeline is enabled
  68345. */
  68346. get HDREnabled(): boolean;
  68347. set HDREnabled(enabled: boolean);
  68348. /**
  68349. * @ignore
  68350. * Specifies if the volumetric lights scattering effect is enabled
  68351. */
  68352. get VLSEnabled(): boolean;
  68353. set VLSEnabled(enabled: boolean);
  68354. /**
  68355. * @ignore
  68356. * Specifies if the motion blur effect is enabled
  68357. */
  68358. get MotionBlurEnabled(): boolean;
  68359. set MotionBlurEnabled(enabled: boolean);
  68360. /**
  68361. * Specifies if anti-aliasing is enabled
  68362. */
  68363. get fxaaEnabled(): boolean;
  68364. set fxaaEnabled(enabled: boolean);
  68365. /**
  68366. * Specifies if screen space reflections are enabled.
  68367. */
  68368. get screenSpaceReflectionsEnabled(): boolean;
  68369. set screenSpaceReflectionsEnabled(enabled: boolean);
  68370. /**
  68371. * Specifies the number of steps used to calculate the volumetric lights
  68372. * Typically in interval [50, 200]
  68373. */
  68374. get volumetricLightStepsCount(): number;
  68375. set volumetricLightStepsCount(count: number);
  68376. /**
  68377. * Specifies the number of samples used for the motion blur effect
  68378. * Typically in interval [16, 64]
  68379. */
  68380. get motionBlurSamples(): number;
  68381. set motionBlurSamples(samples: number);
  68382. /**
  68383. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68384. */
  68385. get samples(): number;
  68386. set samples(sampleCount: number);
  68387. /**
  68388. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68389. * @constructor
  68390. * @param name The rendering pipeline name
  68391. * @param scene The scene linked to this pipeline
  68392. * @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)
  68393. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68394. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68395. */
  68396. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68397. private _buildPipeline;
  68398. private _createDownSampleX4PostProcess;
  68399. private _createBrightPassPostProcess;
  68400. private _createBlurPostProcesses;
  68401. private _createTextureAdderPostProcess;
  68402. private _createVolumetricLightPostProcess;
  68403. private _createLuminancePostProcesses;
  68404. private _createHdrPostProcess;
  68405. private _createLensFlarePostProcess;
  68406. private _createDepthOfFieldPostProcess;
  68407. private _createMotionBlurPostProcess;
  68408. private _getDepthTexture;
  68409. private _disposePostProcesses;
  68410. /**
  68411. * Dispose of the pipeline and stop all post processes
  68412. */
  68413. dispose(): void;
  68414. /**
  68415. * Serialize the rendering pipeline (Used when exporting)
  68416. * @returns the serialized object
  68417. */
  68418. serialize(): any;
  68419. /**
  68420. * Parse the serialized pipeline
  68421. * @param source Source pipeline.
  68422. * @param scene The scene to load the pipeline to.
  68423. * @param rootUrl The URL of the serialized pipeline.
  68424. * @returns An instantiated pipeline from the serialized object.
  68425. */
  68426. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68427. /**
  68428. * Luminance steps
  68429. */
  68430. static LuminanceSteps: number;
  68431. }
  68432. }
  68433. declare module BABYLON {
  68434. /** @hidden */
  68435. export var stereoscopicInterlacePixelShader: {
  68436. name: string;
  68437. shader: string;
  68438. };
  68439. }
  68440. declare module BABYLON {
  68441. /**
  68442. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  68443. */
  68444. export class StereoscopicInterlacePostProcessI extends PostProcess {
  68445. private _stepSize;
  68446. private _passedProcess;
  68447. /**
  68448. * Initializes a StereoscopicInterlacePostProcessI
  68449. * @param name The name of the effect.
  68450. * @param rigCameras The rig cameras to be appled to the post process
  68451. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  68452. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  68453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68454. * @param engine The engine which the post process will be applied. (default: current engine)
  68455. * @param reusable If the post process can be reused on the same frame. (default: false)
  68456. */
  68457. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68458. }
  68459. /**
  68460. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  68461. */
  68462. export class StereoscopicInterlacePostProcess extends PostProcess {
  68463. private _stepSize;
  68464. private _passedProcess;
  68465. /**
  68466. * Initializes a StereoscopicInterlacePostProcess
  68467. * @param name The name of the effect.
  68468. * @param rigCameras The rig cameras to be appled to the post process
  68469. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  68470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68471. * @param engine The engine which the post process will be applied. (default: current engine)
  68472. * @param reusable If the post process can be reused on the same frame. (default: false)
  68473. */
  68474. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68475. }
  68476. }
  68477. declare module BABYLON {
  68478. /** @hidden */
  68479. export var tonemapPixelShader: {
  68480. name: string;
  68481. shader: string;
  68482. };
  68483. }
  68484. declare module BABYLON {
  68485. /** Defines operator used for tonemapping */
  68486. export enum TonemappingOperator {
  68487. /** Hable */
  68488. Hable = 0,
  68489. /** Reinhard */
  68490. Reinhard = 1,
  68491. /** HejiDawson */
  68492. HejiDawson = 2,
  68493. /** Photographic */
  68494. Photographic = 3
  68495. }
  68496. /**
  68497. * Defines a post process to apply tone mapping
  68498. */
  68499. export class TonemapPostProcess extends PostProcess {
  68500. private _operator;
  68501. /** Defines the required exposure adjustement */
  68502. exposureAdjustment: number;
  68503. /**
  68504. * Creates a new TonemapPostProcess
  68505. * @param name defines the name of the postprocess
  68506. * @param _operator defines the operator to use
  68507. * @param exposureAdjustment defines the required exposure adjustement
  68508. * @param camera defines the camera to use (can be null)
  68509. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68510. * @param engine defines the hosting engine (can be ignore if camera is set)
  68511. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68512. */
  68513. constructor(name: string, _operator: TonemappingOperator,
  68514. /** Defines the required exposure adjustement */
  68515. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68516. }
  68517. }
  68518. declare module BABYLON {
  68519. /** @hidden */
  68520. export var volumetricLightScatteringPixelShader: {
  68521. name: string;
  68522. shader: string;
  68523. };
  68524. }
  68525. declare module BABYLON {
  68526. /** @hidden */
  68527. export var volumetricLightScatteringPassVertexShader: {
  68528. name: string;
  68529. shader: string;
  68530. };
  68531. }
  68532. declare module BABYLON {
  68533. /** @hidden */
  68534. export var volumetricLightScatteringPassPixelShader: {
  68535. name: string;
  68536. shader: string;
  68537. };
  68538. }
  68539. declare module BABYLON {
  68540. /**
  68541. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68542. */
  68543. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68544. private _volumetricLightScatteringPass;
  68545. private _volumetricLightScatteringRTT;
  68546. private _viewPort;
  68547. private _screenCoordinates;
  68548. private _cachedDefines;
  68549. /**
  68550. * If not undefined, the mesh position is computed from the attached node position
  68551. */
  68552. attachedNode: {
  68553. position: Vector3;
  68554. };
  68555. /**
  68556. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68557. */
  68558. customMeshPosition: Vector3;
  68559. /**
  68560. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68561. */
  68562. useCustomMeshPosition: boolean;
  68563. /**
  68564. * If the post-process should inverse the light scattering direction
  68565. */
  68566. invert: boolean;
  68567. /**
  68568. * The internal mesh used by the post-process
  68569. */
  68570. mesh: Mesh;
  68571. /**
  68572. * @hidden
  68573. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68574. */
  68575. get useDiffuseColor(): boolean;
  68576. set useDiffuseColor(useDiffuseColor: boolean);
  68577. /**
  68578. * Array containing the excluded meshes not rendered in the internal pass
  68579. */
  68580. excludedMeshes: AbstractMesh[];
  68581. /**
  68582. * Controls the overall intensity of the post-process
  68583. */
  68584. exposure: number;
  68585. /**
  68586. * Dissipates each sample's contribution in range [0, 1]
  68587. */
  68588. decay: number;
  68589. /**
  68590. * Controls the overall intensity of each sample
  68591. */
  68592. weight: number;
  68593. /**
  68594. * Controls the density of each sample
  68595. */
  68596. density: number;
  68597. /**
  68598. * @constructor
  68599. * @param name The post-process name
  68600. * @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)
  68601. * @param camera The camera that the post-process will be attached to
  68602. * @param mesh The mesh used to create the light scattering
  68603. * @param samples The post-process quality, default 100
  68604. * @param samplingModeThe post-process filtering mode
  68605. * @param engine The babylon engine
  68606. * @param reusable If the post-process is reusable
  68607. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68608. */
  68609. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68610. /**
  68611. * Returns the string "VolumetricLightScatteringPostProcess"
  68612. * @returns "VolumetricLightScatteringPostProcess"
  68613. */
  68614. getClassName(): string;
  68615. private _isReady;
  68616. /**
  68617. * Sets the new light position for light scattering effect
  68618. * @param position The new custom light position
  68619. */
  68620. setCustomMeshPosition(position: Vector3): void;
  68621. /**
  68622. * Returns the light position for light scattering effect
  68623. * @return Vector3 The custom light position
  68624. */
  68625. getCustomMeshPosition(): Vector3;
  68626. /**
  68627. * Disposes the internal assets and detaches the post-process from the camera
  68628. */
  68629. dispose(camera: Camera): void;
  68630. /**
  68631. * Returns the render target texture used by the post-process
  68632. * @return the render target texture used by the post-process
  68633. */
  68634. getPass(): RenderTargetTexture;
  68635. private _meshExcluded;
  68636. private _createPass;
  68637. private _updateMeshScreenCoordinates;
  68638. /**
  68639. * Creates a default mesh for the Volumeric Light Scattering post-process
  68640. * @param name The mesh name
  68641. * @param scene The scene where to create the mesh
  68642. * @return the default mesh
  68643. */
  68644. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68645. }
  68646. }
  68647. declare module BABYLON {
  68648. interface Scene {
  68649. /** @hidden (Backing field) */
  68650. _boundingBoxRenderer: BoundingBoxRenderer;
  68651. /** @hidden (Backing field) */
  68652. _forceShowBoundingBoxes: boolean;
  68653. /**
  68654. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68655. */
  68656. forceShowBoundingBoxes: boolean;
  68657. /**
  68658. * Gets the bounding box renderer associated with the scene
  68659. * @returns a BoundingBoxRenderer
  68660. */
  68661. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68662. }
  68663. interface AbstractMesh {
  68664. /** @hidden (Backing field) */
  68665. _showBoundingBox: boolean;
  68666. /**
  68667. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68668. */
  68669. showBoundingBox: boolean;
  68670. }
  68671. /**
  68672. * Component responsible of rendering the bounding box of the meshes in a scene.
  68673. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68674. */
  68675. export class BoundingBoxRenderer implements ISceneComponent {
  68676. /**
  68677. * The component name helpfull to identify the component in the list of scene components.
  68678. */
  68679. readonly name: string;
  68680. /**
  68681. * The scene the component belongs to.
  68682. */
  68683. scene: Scene;
  68684. /**
  68685. * Color of the bounding box lines placed in front of an object
  68686. */
  68687. frontColor: Color3;
  68688. /**
  68689. * Color of the bounding box lines placed behind an object
  68690. */
  68691. backColor: Color3;
  68692. /**
  68693. * Defines if the renderer should show the back lines or not
  68694. */
  68695. showBackLines: boolean;
  68696. /**
  68697. * @hidden
  68698. */
  68699. renderList: SmartArray<BoundingBox>;
  68700. private _colorShader;
  68701. private _vertexBuffers;
  68702. private _indexBuffer;
  68703. private _fillIndexBuffer;
  68704. private _fillIndexData;
  68705. /**
  68706. * Instantiates a new bounding box renderer in a scene.
  68707. * @param scene the scene the renderer renders in
  68708. */
  68709. constructor(scene: Scene);
  68710. /**
  68711. * Registers the component in a given scene
  68712. */
  68713. register(): void;
  68714. private _evaluateSubMesh;
  68715. private _activeMesh;
  68716. private _prepareRessources;
  68717. private _createIndexBuffer;
  68718. /**
  68719. * Rebuilds the elements related to this component in case of
  68720. * context lost for instance.
  68721. */
  68722. rebuild(): void;
  68723. /**
  68724. * @hidden
  68725. */
  68726. reset(): void;
  68727. /**
  68728. * Render the bounding boxes of a specific rendering group
  68729. * @param renderingGroupId defines the rendering group to render
  68730. */
  68731. render(renderingGroupId: number): void;
  68732. /**
  68733. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68734. * @param mesh Define the mesh to render the occlusion bounding box for
  68735. */
  68736. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68737. /**
  68738. * Dispose and release the resources attached to this renderer.
  68739. */
  68740. dispose(): void;
  68741. }
  68742. }
  68743. declare module BABYLON {
  68744. interface Scene {
  68745. /** @hidden (Backing field) */
  68746. _depthRenderer: {
  68747. [id: string]: DepthRenderer;
  68748. };
  68749. /**
  68750. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68751. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68752. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68753. * @returns the created depth renderer
  68754. */
  68755. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68756. /**
  68757. * Disables a depth renderer for a given camera
  68758. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68759. */
  68760. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68761. }
  68762. /**
  68763. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68764. * in several rendering techniques.
  68765. */
  68766. export class DepthRendererSceneComponent implements ISceneComponent {
  68767. /**
  68768. * The component name helpfull to identify the component in the list of scene components.
  68769. */
  68770. readonly name: string;
  68771. /**
  68772. * The scene the component belongs to.
  68773. */
  68774. scene: Scene;
  68775. /**
  68776. * Creates a new instance of the component for the given scene
  68777. * @param scene Defines the scene to register the component in
  68778. */
  68779. constructor(scene: Scene);
  68780. /**
  68781. * Registers the component in a given scene
  68782. */
  68783. register(): void;
  68784. /**
  68785. * Rebuilds the elements related to this component in case of
  68786. * context lost for instance.
  68787. */
  68788. rebuild(): void;
  68789. /**
  68790. * Disposes the component and the associated ressources
  68791. */
  68792. dispose(): void;
  68793. private _gatherRenderTargets;
  68794. private _gatherActiveCameraRenderTargets;
  68795. }
  68796. }
  68797. declare module BABYLON {
  68798. /** @hidden */
  68799. export var outlinePixelShader: {
  68800. name: string;
  68801. shader: string;
  68802. };
  68803. }
  68804. declare module BABYLON {
  68805. /** @hidden */
  68806. export var outlineVertexShader: {
  68807. name: string;
  68808. shader: string;
  68809. };
  68810. }
  68811. declare module BABYLON {
  68812. interface Scene {
  68813. /** @hidden */
  68814. _outlineRenderer: OutlineRenderer;
  68815. /**
  68816. * Gets the outline renderer associated with the scene
  68817. * @returns a OutlineRenderer
  68818. */
  68819. getOutlineRenderer(): OutlineRenderer;
  68820. }
  68821. interface AbstractMesh {
  68822. /** @hidden (Backing field) */
  68823. _renderOutline: boolean;
  68824. /**
  68825. * Gets or sets a boolean indicating if the outline must be rendered as well
  68826. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68827. */
  68828. renderOutline: boolean;
  68829. /** @hidden (Backing field) */
  68830. _renderOverlay: boolean;
  68831. /**
  68832. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68833. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68834. */
  68835. renderOverlay: boolean;
  68836. }
  68837. /**
  68838. * This class is responsible to draw bothe outline/overlay of meshes.
  68839. * It should not be used directly but through the available method on mesh.
  68840. */
  68841. export class OutlineRenderer implements ISceneComponent {
  68842. /**
  68843. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68844. */
  68845. private static _StencilReference;
  68846. /**
  68847. * The name of the component. Each component must have a unique name.
  68848. */
  68849. name: string;
  68850. /**
  68851. * The scene the component belongs to.
  68852. */
  68853. scene: Scene;
  68854. /**
  68855. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68856. */
  68857. zOffset: number;
  68858. private _engine;
  68859. private _effect;
  68860. private _cachedDefines;
  68861. private _savedDepthWrite;
  68862. /**
  68863. * Instantiates a new outline renderer. (There could be only one per scene).
  68864. * @param scene Defines the scene it belongs to
  68865. */
  68866. constructor(scene: Scene);
  68867. /**
  68868. * Register the component to one instance of a scene.
  68869. */
  68870. register(): void;
  68871. /**
  68872. * Rebuilds the elements related to this component in case of
  68873. * context lost for instance.
  68874. */
  68875. rebuild(): void;
  68876. /**
  68877. * Disposes the component and the associated ressources.
  68878. */
  68879. dispose(): void;
  68880. /**
  68881. * Renders the outline in the canvas.
  68882. * @param subMesh Defines the sumesh to render
  68883. * @param batch Defines the batch of meshes in case of instances
  68884. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68885. */
  68886. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68887. /**
  68888. * Returns whether or not the outline renderer is ready for a given submesh.
  68889. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68890. * @param subMesh Defines the submesh to check readyness for
  68891. * @param useInstances Defines wheter wee are trying to render instances or not
  68892. * @returns true if ready otherwise false
  68893. */
  68894. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68895. private _beforeRenderingMesh;
  68896. private _afterRenderingMesh;
  68897. }
  68898. }
  68899. declare module BABYLON {
  68900. /**
  68901. * Defines the basic options interface of a Sprite Frame Source Size.
  68902. */
  68903. export interface ISpriteJSONSpriteSourceSize {
  68904. /**
  68905. * number of the original width of the Frame
  68906. */
  68907. w: number;
  68908. /**
  68909. * number of the original height of the Frame
  68910. */
  68911. h: number;
  68912. }
  68913. /**
  68914. * Defines the basic options interface of a Sprite Frame Data.
  68915. */
  68916. export interface ISpriteJSONSpriteFrameData {
  68917. /**
  68918. * number of the x offset of the Frame
  68919. */
  68920. x: number;
  68921. /**
  68922. * number of the y offset of the Frame
  68923. */
  68924. y: number;
  68925. /**
  68926. * number of the width of the Frame
  68927. */
  68928. w: number;
  68929. /**
  68930. * number of the height of the Frame
  68931. */
  68932. h: number;
  68933. }
  68934. /**
  68935. * Defines the basic options interface of a JSON Sprite.
  68936. */
  68937. export interface ISpriteJSONSprite {
  68938. /**
  68939. * string name of the Frame
  68940. */
  68941. filename: string;
  68942. /**
  68943. * ISpriteJSONSpriteFrame basic object of the frame data
  68944. */
  68945. frame: ISpriteJSONSpriteFrameData;
  68946. /**
  68947. * boolean to flag is the frame was rotated.
  68948. */
  68949. rotated: boolean;
  68950. /**
  68951. * boolean to flag is the frame was trimmed.
  68952. */
  68953. trimmed: boolean;
  68954. /**
  68955. * ISpriteJSONSpriteFrame basic object of the source data
  68956. */
  68957. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68958. /**
  68959. * ISpriteJSONSpriteFrame basic object of the source data
  68960. */
  68961. sourceSize: ISpriteJSONSpriteSourceSize;
  68962. }
  68963. /**
  68964. * Defines the basic options interface of a JSON atlas.
  68965. */
  68966. export interface ISpriteJSONAtlas {
  68967. /**
  68968. * Array of objects that contain the frame data.
  68969. */
  68970. frames: Array<ISpriteJSONSprite>;
  68971. /**
  68972. * object basic object containing the sprite meta data.
  68973. */
  68974. meta?: object;
  68975. }
  68976. }
  68977. declare module BABYLON {
  68978. /** @hidden */
  68979. export var spriteMapPixelShader: {
  68980. name: string;
  68981. shader: string;
  68982. };
  68983. }
  68984. declare module BABYLON {
  68985. /** @hidden */
  68986. export var spriteMapVertexShader: {
  68987. name: string;
  68988. shader: string;
  68989. };
  68990. }
  68991. declare module BABYLON {
  68992. /**
  68993. * Defines the basic options interface of a SpriteMap
  68994. */
  68995. export interface ISpriteMapOptions {
  68996. /**
  68997. * Vector2 of the number of cells in the grid.
  68998. */
  68999. stageSize?: Vector2;
  69000. /**
  69001. * Vector2 of the size of the output plane in World Units.
  69002. */
  69003. outputSize?: Vector2;
  69004. /**
  69005. * Vector3 of the position of the output plane in World Units.
  69006. */
  69007. outputPosition?: Vector3;
  69008. /**
  69009. * Vector3 of the rotation of the output plane.
  69010. */
  69011. outputRotation?: Vector3;
  69012. /**
  69013. * number of layers that the system will reserve in resources.
  69014. */
  69015. layerCount?: number;
  69016. /**
  69017. * number of max animation frames a single cell will reserve in resources.
  69018. */
  69019. maxAnimationFrames?: number;
  69020. /**
  69021. * number cell index of the base tile when the system compiles.
  69022. */
  69023. baseTile?: number;
  69024. /**
  69025. * boolean flip the sprite after its been repositioned by the framing data.
  69026. */
  69027. flipU?: boolean;
  69028. /**
  69029. * Vector3 scalar of the global RGB values of the SpriteMap.
  69030. */
  69031. colorMultiply?: Vector3;
  69032. }
  69033. /**
  69034. * Defines the IDisposable interface in order to be cleanable from resources.
  69035. */
  69036. export interface ISpriteMap extends IDisposable {
  69037. /**
  69038. * String name of the SpriteMap.
  69039. */
  69040. name: string;
  69041. /**
  69042. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69043. */
  69044. atlasJSON: ISpriteJSONAtlas;
  69045. /**
  69046. * Texture of the SpriteMap.
  69047. */
  69048. spriteSheet: Texture;
  69049. /**
  69050. * The parameters to initialize the SpriteMap with.
  69051. */
  69052. options: ISpriteMapOptions;
  69053. }
  69054. /**
  69055. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69056. */
  69057. export class SpriteMap implements ISpriteMap {
  69058. /** The Name of the spriteMap */
  69059. name: string;
  69060. /** The JSON file with the frame and meta data */
  69061. atlasJSON: ISpriteJSONAtlas;
  69062. /** The systems Sprite Sheet Texture */
  69063. spriteSheet: Texture;
  69064. /** Arguments passed with the Constructor */
  69065. options: ISpriteMapOptions;
  69066. /** Public Sprite Storage array, parsed from atlasJSON */
  69067. sprites: Array<ISpriteJSONSprite>;
  69068. /** Returns the Number of Sprites in the System */
  69069. get spriteCount(): number;
  69070. /** Returns the Position of Output Plane*/
  69071. get position(): Vector3;
  69072. /** Returns the Position of Output Plane*/
  69073. set position(v: Vector3);
  69074. /** Returns the Rotation of Output Plane*/
  69075. get rotation(): Vector3;
  69076. /** Returns the Rotation of Output Plane*/
  69077. set rotation(v: Vector3);
  69078. /** Sets the AnimationMap*/
  69079. get animationMap(): RawTexture;
  69080. /** Sets the AnimationMap*/
  69081. set animationMap(v: RawTexture);
  69082. /** Scene that the SpriteMap was created in */
  69083. private _scene;
  69084. /** Texture Buffer of Float32 that holds tile frame data*/
  69085. private _frameMap;
  69086. /** Texture Buffers of Float32 that holds tileMap data*/
  69087. private _tileMaps;
  69088. /** Texture Buffer of Float32 that holds Animation Data*/
  69089. private _animationMap;
  69090. /** Custom ShaderMaterial Central to the System*/
  69091. private _material;
  69092. /** Custom ShaderMaterial Central to the System*/
  69093. private _output;
  69094. /** Systems Time Ticker*/
  69095. private _time;
  69096. /**
  69097. * Creates a new SpriteMap
  69098. * @param name defines the SpriteMaps Name
  69099. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69100. * @param spriteSheet is the Texture that the Sprites are on.
  69101. * @param options a basic deployment configuration
  69102. * @param scene The Scene that the map is deployed on
  69103. */
  69104. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69105. /**
  69106. * Returns tileID location
  69107. * @returns Vector2 the cell position ID
  69108. */
  69109. getTileID(): Vector2;
  69110. /**
  69111. * Gets the UV location of the mouse over the SpriteMap.
  69112. * @returns Vector2 the UV position of the mouse interaction
  69113. */
  69114. getMousePosition(): Vector2;
  69115. /**
  69116. * Creates the "frame" texture Buffer
  69117. * -------------------------------------
  69118. * Structure of frames
  69119. * "filename": "Falling-Water-2.png",
  69120. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69121. * "rotated": true,
  69122. * "trimmed": true,
  69123. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69124. * "sourceSize": {"w":32,"h":32}
  69125. * @returns RawTexture of the frameMap
  69126. */
  69127. private _createFrameBuffer;
  69128. /**
  69129. * Creates the tileMap texture Buffer
  69130. * @param buffer normally and array of numbers, or a false to generate from scratch
  69131. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69132. * @returns RawTexture of the tileMap
  69133. */
  69134. private _createTileBuffer;
  69135. /**
  69136. * Modifies the data of the tileMaps
  69137. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69138. * @param pos is the iVector2 Coordinates of the Tile
  69139. * @param tile The SpriteIndex of the new Tile
  69140. */
  69141. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69142. /**
  69143. * Creates the animationMap texture Buffer
  69144. * @param buffer normally and array of numbers, or a false to generate from scratch
  69145. * @returns RawTexture of the animationMap
  69146. */
  69147. private _createTileAnimationBuffer;
  69148. /**
  69149. * Modifies the data of the animationMap
  69150. * @param cellID is the Index of the Sprite
  69151. * @param _frame is the target Animation frame
  69152. * @param toCell is the Target Index of the next frame of the animation
  69153. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69154. * @param speed is a global scalar of the time variable on the map.
  69155. */
  69156. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69157. /**
  69158. * Exports the .tilemaps file
  69159. */
  69160. saveTileMaps(): void;
  69161. /**
  69162. * Imports the .tilemaps file
  69163. * @param url of the .tilemaps file
  69164. */
  69165. loadTileMaps(url: string): void;
  69166. /**
  69167. * Release associated resources
  69168. */
  69169. dispose(): void;
  69170. }
  69171. }
  69172. declare module BABYLON {
  69173. /**
  69174. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69175. * @see http://doc.babylonjs.com/babylon101/sprites
  69176. */
  69177. export class SpritePackedManager extends SpriteManager {
  69178. /** defines the packed manager's name */
  69179. name: string;
  69180. /**
  69181. * Creates a new sprite manager from a packed sprite sheet
  69182. * @param name defines the manager's name
  69183. * @param imgUrl defines the sprite sheet url
  69184. * @param capacity defines the maximum allowed number of sprites
  69185. * @param scene defines the hosting scene
  69186. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69187. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69188. * @param samplingMode defines the smapling mode to use with spritesheet
  69189. * @param fromPacked set to true; do not alter
  69190. */
  69191. constructor(
  69192. /** defines the packed manager's name */
  69193. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69194. }
  69195. }
  69196. declare module BABYLON {
  69197. /**
  69198. * Defines the list of states available for a task inside a AssetsManager
  69199. */
  69200. export enum AssetTaskState {
  69201. /**
  69202. * Initialization
  69203. */
  69204. INIT = 0,
  69205. /**
  69206. * Running
  69207. */
  69208. RUNNING = 1,
  69209. /**
  69210. * Done
  69211. */
  69212. DONE = 2,
  69213. /**
  69214. * Error
  69215. */
  69216. ERROR = 3
  69217. }
  69218. /**
  69219. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69220. */
  69221. export abstract class AbstractAssetTask {
  69222. /**
  69223. * Task name
  69224. */ name: string;
  69225. /**
  69226. * Callback called when the task is successful
  69227. */
  69228. onSuccess: (task: any) => void;
  69229. /**
  69230. * Callback called when the task is not successful
  69231. */
  69232. onError: (task: any, message?: string, exception?: any) => void;
  69233. /**
  69234. * Creates a new AssetsManager
  69235. * @param name defines the name of the task
  69236. */
  69237. constructor(
  69238. /**
  69239. * Task name
  69240. */ name: string);
  69241. private _isCompleted;
  69242. private _taskState;
  69243. private _errorObject;
  69244. /**
  69245. * Get if the task is completed
  69246. */
  69247. get isCompleted(): boolean;
  69248. /**
  69249. * Gets the current state of the task
  69250. */
  69251. get taskState(): AssetTaskState;
  69252. /**
  69253. * Gets the current error object (if task is in error)
  69254. */
  69255. get errorObject(): {
  69256. message?: string;
  69257. exception?: any;
  69258. };
  69259. /**
  69260. * Internal only
  69261. * @hidden
  69262. */
  69263. _setErrorObject(message?: string, exception?: any): void;
  69264. /**
  69265. * Execute the current task
  69266. * @param scene defines the scene where you want your assets to be loaded
  69267. * @param onSuccess is a callback called when the task is successfully executed
  69268. * @param onError is a callback called if an error occurs
  69269. */
  69270. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69271. /**
  69272. * Execute the current task
  69273. * @param scene defines the scene where you want your assets to be loaded
  69274. * @param onSuccess is a callback called when the task is successfully executed
  69275. * @param onError is a callback called if an error occurs
  69276. */
  69277. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69278. /**
  69279. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69280. * This can be used with failed tasks that have the reason for failure fixed.
  69281. */
  69282. reset(): void;
  69283. private onErrorCallback;
  69284. private onDoneCallback;
  69285. }
  69286. /**
  69287. * Define the interface used by progress events raised during assets loading
  69288. */
  69289. export interface IAssetsProgressEvent {
  69290. /**
  69291. * Defines the number of remaining tasks to process
  69292. */
  69293. remainingCount: number;
  69294. /**
  69295. * Defines the total number of tasks
  69296. */
  69297. totalCount: number;
  69298. /**
  69299. * Defines the task that was just processed
  69300. */
  69301. task: AbstractAssetTask;
  69302. }
  69303. /**
  69304. * Class used to share progress information about assets loading
  69305. */
  69306. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69307. /**
  69308. * Defines the number of remaining tasks to process
  69309. */
  69310. remainingCount: number;
  69311. /**
  69312. * Defines the total number of tasks
  69313. */
  69314. totalCount: number;
  69315. /**
  69316. * Defines the task that was just processed
  69317. */
  69318. task: AbstractAssetTask;
  69319. /**
  69320. * Creates a AssetsProgressEvent
  69321. * @param remainingCount defines the number of remaining tasks to process
  69322. * @param totalCount defines the total number of tasks
  69323. * @param task defines the task that was just processed
  69324. */
  69325. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69326. }
  69327. /**
  69328. * Define a task used by AssetsManager to load meshes
  69329. */
  69330. export class MeshAssetTask extends AbstractAssetTask {
  69331. /**
  69332. * Defines the name of the task
  69333. */
  69334. name: string;
  69335. /**
  69336. * Defines the list of mesh's names you want to load
  69337. */
  69338. meshesNames: any;
  69339. /**
  69340. * Defines the root url to use as a base to load your meshes and associated resources
  69341. */
  69342. rootUrl: string;
  69343. /**
  69344. * Defines the filename or File of the scene to load from
  69345. */
  69346. sceneFilename: string | File;
  69347. /**
  69348. * Gets the list of loaded meshes
  69349. */
  69350. loadedMeshes: Array<AbstractMesh>;
  69351. /**
  69352. * Gets the list of loaded particle systems
  69353. */
  69354. loadedParticleSystems: Array<IParticleSystem>;
  69355. /**
  69356. * Gets the list of loaded skeletons
  69357. */
  69358. loadedSkeletons: Array<Skeleton>;
  69359. /**
  69360. * Gets the list of loaded animation groups
  69361. */
  69362. loadedAnimationGroups: Array<AnimationGroup>;
  69363. /**
  69364. * Callback called when the task is successful
  69365. */
  69366. onSuccess: (task: MeshAssetTask) => void;
  69367. /**
  69368. * Callback called when the task is successful
  69369. */
  69370. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69371. /**
  69372. * Creates a new MeshAssetTask
  69373. * @param name defines the name of the task
  69374. * @param meshesNames defines the list of mesh's names you want to load
  69375. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69376. * @param sceneFilename defines the filename or File of the scene to load from
  69377. */
  69378. constructor(
  69379. /**
  69380. * Defines the name of the task
  69381. */
  69382. name: string,
  69383. /**
  69384. * Defines the list of mesh's names you want to load
  69385. */
  69386. meshesNames: any,
  69387. /**
  69388. * Defines the root url to use as a base to load your meshes and associated resources
  69389. */
  69390. rootUrl: string,
  69391. /**
  69392. * Defines the filename or File of the scene to load from
  69393. */
  69394. sceneFilename: string | File);
  69395. /**
  69396. * Execute the current task
  69397. * @param scene defines the scene where you want your assets to be loaded
  69398. * @param onSuccess is a callback called when the task is successfully executed
  69399. * @param onError is a callback called if an error occurs
  69400. */
  69401. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69402. }
  69403. /**
  69404. * Define a task used by AssetsManager to load text content
  69405. */
  69406. export class TextFileAssetTask extends AbstractAssetTask {
  69407. /**
  69408. * Defines the name of the task
  69409. */
  69410. name: string;
  69411. /**
  69412. * Defines the location of the file to load
  69413. */
  69414. url: string;
  69415. /**
  69416. * Gets the loaded text string
  69417. */
  69418. text: string;
  69419. /**
  69420. * Callback called when the task is successful
  69421. */
  69422. onSuccess: (task: TextFileAssetTask) => void;
  69423. /**
  69424. * Callback called when the task is successful
  69425. */
  69426. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69427. /**
  69428. * Creates a new TextFileAssetTask object
  69429. * @param name defines the name of the task
  69430. * @param url defines the location of the file to load
  69431. */
  69432. constructor(
  69433. /**
  69434. * Defines the name of the task
  69435. */
  69436. name: string,
  69437. /**
  69438. * Defines the location of the file to load
  69439. */
  69440. url: string);
  69441. /**
  69442. * Execute the current task
  69443. * @param scene defines the scene where you want your assets to be loaded
  69444. * @param onSuccess is a callback called when the task is successfully executed
  69445. * @param onError is a callback called if an error occurs
  69446. */
  69447. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69448. }
  69449. /**
  69450. * Define a task used by AssetsManager to load binary data
  69451. */
  69452. export class BinaryFileAssetTask extends AbstractAssetTask {
  69453. /**
  69454. * Defines the name of the task
  69455. */
  69456. name: string;
  69457. /**
  69458. * Defines the location of the file to load
  69459. */
  69460. url: string;
  69461. /**
  69462. * Gets the lodaded data (as an array buffer)
  69463. */
  69464. data: ArrayBuffer;
  69465. /**
  69466. * Callback called when the task is successful
  69467. */
  69468. onSuccess: (task: BinaryFileAssetTask) => void;
  69469. /**
  69470. * Callback called when the task is successful
  69471. */
  69472. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69473. /**
  69474. * Creates a new BinaryFileAssetTask object
  69475. * @param name defines the name of the new task
  69476. * @param url defines the location of the file to load
  69477. */
  69478. constructor(
  69479. /**
  69480. * Defines the name of the task
  69481. */
  69482. name: string,
  69483. /**
  69484. * Defines the location of the file to load
  69485. */
  69486. url: string);
  69487. /**
  69488. * Execute the current task
  69489. * @param scene defines the scene where you want your assets to be loaded
  69490. * @param onSuccess is a callback called when the task is successfully executed
  69491. * @param onError is a callback called if an error occurs
  69492. */
  69493. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69494. }
  69495. /**
  69496. * Define a task used by AssetsManager to load images
  69497. */
  69498. export class ImageAssetTask extends AbstractAssetTask {
  69499. /**
  69500. * Defines the name of the task
  69501. */
  69502. name: string;
  69503. /**
  69504. * Defines the location of the image to load
  69505. */
  69506. url: string;
  69507. /**
  69508. * Gets the loaded images
  69509. */
  69510. image: HTMLImageElement;
  69511. /**
  69512. * Callback called when the task is successful
  69513. */
  69514. onSuccess: (task: ImageAssetTask) => void;
  69515. /**
  69516. * Callback called when the task is successful
  69517. */
  69518. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69519. /**
  69520. * Creates a new ImageAssetTask
  69521. * @param name defines the name of the task
  69522. * @param url defines the location of the image to load
  69523. */
  69524. constructor(
  69525. /**
  69526. * Defines the name of the task
  69527. */
  69528. name: string,
  69529. /**
  69530. * Defines the location of the image to load
  69531. */
  69532. url: string);
  69533. /**
  69534. * Execute the current task
  69535. * @param scene defines the scene where you want your assets to be loaded
  69536. * @param onSuccess is a callback called when the task is successfully executed
  69537. * @param onError is a callback called if an error occurs
  69538. */
  69539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69540. }
  69541. /**
  69542. * Defines the interface used by texture loading tasks
  69543. */
  69544. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69545. /**
  69546. * Gets the loaded texture
  69547. */
  69548. texture: TEX;
  69549. }
  69550. /**
  69551. * Define a task used by AssetsManager to load 2D textures
  69552. */
  69553. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69554. /**
  69555. * Defines the name of the task
  69556. */
  69557. name: string;
  69558. /**
  69559. * Defines the location of the file to load
  69560. */
  69561. url: string;
  69562. /**
  69563. * Defines if mipmap should not be generated (default is false)
  69564. */
  69565. noMipmap?: boolean | undefined;
  69566. /**
  69567. * Defines if texture must be inverted on Y axis (default is true)
  69568. */
  69569. invertY: boolean;
  69570. /**
  69571. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69572. */
  69573. samplingMode: number;
  69574. /**
  69575. * Gets the loaded texture
  69576. */
  69577. texture: Texture;
  69578. /**
  69579. * Callback called when the task is successful
  69580. */
  69581. onSuccess: (task: TextureAssetTask) => void;
  69582. /**
  69583. * Callback called when the task is successful
  69584. */
  69585. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69586. /**
  69587. * Creates a new TextureAssetTask object
  69588. * @param name defines the name of the task
  69589. * @param url defines the location of the file to load
  69590. * @param noMipmap defines if mipmap should not be generated (default is false)
  69591. * @param invertY defines if texture must be inverted on Y axis (default is true)
  69592. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69593. */
  69594. constructor(
  69595. /**
  69596. * Defines the name of the task
  69597. */
  69598. name: string,
  69599. /**
  69600. * Defines the location of the file to load
  69601. */
  69602. url: string,
  69603. /**
  69604. * Defines if mipmap should not be generated (default is false)
  69605. */
  69606. noMipmap?: boolean | undefined,
  69607. /**
  69608. * Defines if texture must be inverted on Y axis (default is true)
  69609. */
  69610. invertY?: boolean,
  69611. /**
  69612. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69613. */
  69614. samplingMode?: number);
  69615. /**
  69616. * Execute the current task
  69617. * @param scene defines the scene where you want your assets to be loaded
  69618. * @param onSuccess is a callback called when the task is successfully executed
  69619. * @param onError is a callback called if an error occurs
  69620. */
  69621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69622. }
  69623. /**
  69624. * Define a task used by AssetsManager to load cube textures
  69625. */
  69626. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69627. /**
  69628. * Defines the name of the task
  69629. */
  69630. name: string;
  69631. /**
  69632. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69633. */
  69634. url: string;
  69635. /**
  69636. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69637. */
  69638. extensions?: string[] | undefined;
  69639. /**
  69640. * Defines if mipmaps should not be generated (default is false)
  69641. */
  69642. noMipmap?: boolean | undefined;
  69643. /**
  69644. * Defines the explicit list of files (undefined by default)
  69645. */
  69646. files?: string[] | undefined;
  69647. /**
  69648. * Gets the loaded texture
  69649. */
  69650. texture: CubeTexture;
  69651. /**
  69652. * Callback called when the task is successful
  69653. */
  69654. onSuccess: (task: CubeTextureAssetTask) => void;
  69655. /**
  69656. * Callback called when the task is successful
  69657. */
  69658. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69659. /**
  69660. * Creates a new CubeTextureAssetTask
  69661. * @param name defines the name of the task
  69662. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69663. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69664. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69665. * @param files defines the explicit list of files (undefined by default)
  69666. */
  69667. constructor(
  69668. /**
  69669. * Defines the name of the task
  69670. */
  69671. name: string,
  69672. /**
  69673. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69674. */
  69675. url: string,
  69676. /**
  69677. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69678. */
  69679. extensions?: string[] | undefined,
  69680. /**
  69681. * Defines if mipmaps should not be generated (default is false)
  69682. */
  69683. noMipmap?: boolean | undefined,
  69684. /**
  69685. * Defines the explicit list of files (undefined by default)
  69686. */
  69687. files?: string[] | undefined);
  69688. /**
  69689. * Execute the current task
  69690. * @param scene defines the scene where you want your assets to be loaded
  69691. * @param onSuccess is a callback called when the task is successfully executed
  69692. * @param onError is a callback called if an error occurs
  69693. */
  69694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69695. }
  69696. /**
  69697. * Define a task used by AssetsManager to load HDR cube textures
  69698. */
  69699. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69700. /**
  69701. * Defines the name of the task
  69702. */
  69703. name: string;
  69704. /**
  69705. * Defines the location of the file to load
  69706. */
  69707. url: string;
  69708. /**
  69709. * Defines the desired size (the more it increases the longer the generation will be)
  69710. */
  69711. size: number;
  69712. /**
  69713. * Defines if mipmaps should not be generated (default is false)
  69714. */
  69715. noMipmap: boolean;
  69716. /**
  69717. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69718. */
  69719. generateHarmonics: boolean;
  69720. /**
  69721. * 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)
  69722. */
  69723. gammaSpace: boolean;
  69724. /**
  69725. * Internal Use Only
  69726. */
  69727. reserved: boolean;
  69728. /**
  69729. * Gets the loaded texture
  69730. */
  69731. texture: HDRCubeTexture;
  69732. /**
  69733. * Callback called when the task is successful
  69734. */
  69735. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69736. /**
  69737. * Callback called when the task is successful
  69738. */
  69739. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69740. /**
  69741. * Creates a new HDRCubeTextureAssetTask object
  69742. * @param name defines the name of the task
  69743. * @param url defines the location of the file to load
  69744. * @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.
  69745. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69746. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69747. * @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)
  69748. * @param reserved Internal use only
  69749. */
  69750. constructor(
  69751. /**
  69752. * Defines the name of the task
  69753. */
  69754. name: string,
  69755. /**
  69756. * Defines the location of the file to load
  69757. */
  69758. url: string,
  69759. /**
  69760. * Defines the desired size (the more it increases the longer the generation will be)
  69761. */
  69762. size: number,
  69763. /**
  69764. * Defines if mipmaps should not be generated (default is false)
  69765. */
  69766. noMipmap?: boolean,
  69767. /**
  69768. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69769. */
  69770. generateHarmonics?: boolean,
  69771. /**
  69772. * 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)
  69773. */
  69774. gammaSpace?: boolean,
  69775. /**
  69776. * Internal Use Only
  69777. */
  69778. reserved?: boolean);
  69779. /**
  69780. * Execute the current task
  69781. * @param scene defines the scene where you want your assets to be loaded
  69782. * @param onSuccess is a callback called when the task is successfully executed
  69783. * @param onError is a callback called if an error occurs
  69784. */
  69785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69786. }
  69787. /**
  69788. * Define a task used by AssetsManager to load Equirectangular cube textures
  69789. */
  69790. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69791. /**
  69792. * Defines the name of the task
  69793. */
  69794. name: string;
  69795. /**
  69796. * Defines the location of the file to load
  69797. */
  69798. url: string;
  69799. /**
  69800. * Defines the desired size (the more it increases the longer the generation will be)
  69801. */
  69802. size: number;
  69803. /**
  69804. * Defines if mipmaps should not be generated (default is false)
  69805. */
  69806. noMipmap: boolean;
  69807. /**
  69808. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69809. * but the standard material would require them in Gamma space) (default is true)
  69810. */
  69811. gammaSpace: boolean;
  69812. /**
  69813. * Gets the loaded texture
  69814. */
  69815. texture: EquiRectangularCubeTexture;
  69816. /**
  69817. * Callback called when the task is successful
  69818. */
  69819. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69820. /**
  69821. * Callback called when the task is successful
  69822. */
  69823. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69824. /**
  69825. * Creates a new EquiRectangularCubeTextureAssetTask object
  69826. * @param name defines the name of the task
  69827. * @param url defines the location of the file to load
  69828. * @param size defines the desired size (the more it increases the longer the generation will be)
  69829. * If the size is omitted this implies you are using a preprocessed cubemap.
  69830. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69831. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69832. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69833. * (default is true)
  69834. */
  69835. constructor(
  69836. /**
  69837. * Defines the name of the task
  69838. */
  69839. name: string,
  69840. /**
  69841. * Defines the location of the file to load
  69842. */
  69843. url: string,
  69844. /**
  69845. * Defines the desired size (the more it increases the longer the generation will be)
  69846. */
  69847. size: number,
  69848. /**
  69849. * Defines if mipmaps should not be generated (default is false)
  69850. */
  69851. noMipmap?: boolean,
  69852. /**
  69853. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69854. * but the standard material would require them in Gamma space) (default is true)
  69855. */
  69856. gammaSpace?: boolean);
  69857. /**
  69858. * Execute the current task
  69859. * @param scene defines the scene where you want your assets to be loaded
  69860. * @param onSuccess is a callback called when the task is successfully executed
  69861. * @param onError is a callback called if an error occurs
  69862. */
  69863. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69864. }
  69865. /**
  69866. * This class can be used to easily import assets into a scene
  69867. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69868. */
  69869. export class AssetsManager {
  69870. private _scene;
  69871. private _isLoading;
  69872. protected _tasks: AbstractAssetTask[];
  69873. protected _waitingTasksCount: number;
  69874. protected _totalTasksCount: number;
  69875. /**
  69876. * Callback called when all tasks are processed
  69877. */
  69878. onFinish: (tasks: AbstractAssetTask[]) => void;
  69879. /**
  69880. * Callback called when a task is successful
  69881. */
  69882. onTaskSuccess: (task: AbstractAssetTask) => void;
  69883. /**
  69884. * Callback called when a task had an error
  69885. */
  69886. onTaskError: (task: AbstractAssetTask) => void;
  69887. /**
  69888. * Callback called when a task is done (whatever the result is)
  69889. */
  69890. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69891. /**
  69892. * Observable called when all tasks are processed
  69893. */
  69894. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69895. /**
  69896. * Observable called when a task had an error
  69897. */
  69898. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69899. /**
  69900. * Observable called when all tasks were executed
  69901. */
  69902. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69903. /**
  69904. * Observable called when a task is done (whatever the result is)
  69905. */
  69906. onProgressObservable: Observable<IAssetsProgressEvent>;
  69907. /**
  69908. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69909. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69910. */
  69911. useDefaultLoadingScreen: boolean;
  69912. /**
  69913. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69914. * when all assets have been downloaded.
  69915. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69916. */
  69917. autoHideLoadingUI: boolean;
  69918. /**
  69919. * Creates a new AssetsManager
  69920. * @param scene defines the scene to work on
  69921. */
  69922. constructor(scene: Scene);
  69923. /**
  69924. * Add a MeshAssetTask to the list of active tasks
  69925. * @param taskName defines the name of the new task
  69926. * @param meshesNames defines the name of meshes to load
  69927. * @param rootUrl defines the root url to use to locate files
  69928. * @param sceneFilename defines the filename of the scene file
  69929. * @returns a new MeshAssetTask object
  69930. */
  69931. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69932. /**
  69933. * Add a TextFileAssetTask to the list of active tasks
  69934. * @param taskName defines the name of the new task
  69935. * @param url defines the url of the file to load
  69936. * @returns a new TextFileAssetTask object
  69937. */
  69938. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69939. /**
  69940. * Add a BinaryFileAssetTask to the list of active tasks
  69941. * @param taskName defines the name of the new task
  69942. * @param url defines the url of the file to load
  69943. * @returns a new BinaryFileAssetTask object
  69944. */
  69945. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69946. /**
  69947. * Add a ImageAssetTask to the list of active tasks
  69948. * @param taskName defines the name of the new task
  69949. * @param url defines the url of the file to load
  69950. * @returns a new ImageAssetTask object
  69951. */
  69952. addImageTask(taskName: string, url: string): ImageAssetTask;
  69953. /**
  69954. * Add a TextureAssetTask to the list of active tasks
  69955. * @param taskName defines the name of the new task
  69956. * @param url defines the url of the file to load
  69957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69958. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69959. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69960. * @returns a new TextureAssetTask object
  69961. */
  69962. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69963. /**
  69964. * Add a CubeTextureAssetTask to the list of active tasks
  69965. * @param taskName defines the name of the new task
  69966. * @param url defines the url of the file to load
  69967. * @param extensions defines the extension to use to load the cube map (can be null)
  69968. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69969. * @param files defines the list of files to load (can be null)
  69970. * @returns a new CubeTextureAssetTask object
  69971. */
  69972. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69973. /**
  69974. *
  69975. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69976. * @param taskName defines the name of the new task
  69977. * @param url defines the url of the file to load
  69978. * @param size defines the size you want for the cubemap (can be null)
  69979. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69980. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69981. * @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)
  69982. * @param reserved Internal use only
  69983. * @returns a new HDRCubeTextureAssetTask object
  69984. */
  69985. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69986. /**
  69987. *
  69988. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69989. * @param taskName defines the name of the new task
  69990. * @param url defines the url of the file to load
  69991. * @param size defines the size you want for the cubemap (can be null)
  69992. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69993. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69994. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69995. * @returns a new EquiRectangularCubeTextureAssetTask object
  69996. */
  69997. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69998. /**
  69999. * Remove a task from the assets manager.
  70000. * @param task the task to remove
  70001. */
  70002. removeTask(task: AbstractAssetTask): void;
  70003. private _decreaseWaitingTasksCount;
  70004. private _runTask;
  70005. /**
  70006. * Reset the AssetsManager and remove all tasks
  70007. * @return the current instance of the AssetsManager
  70008. */
  70009. reset(): AssetsManager;
  70010. /**
  70011. * Start the loading process
  70012. * @return the current instance of the AssetsManager
  70013. */
  70014. load(): AssetsManager;
  70015. /**
  70016. * Start the loading process as an async operation
  70017. * @return a promise returning the list of failed tasks
  70018. */
  70019. loadAsync(): Promise<void>;
  70020. }
  70021. }
  70022. declare module BABYLON {
  70023. /**
  70024. * Wrapper class for promise with external resolve and reject.
  70025. */
  70026. export class Deferred<T> {
  70027. /**
  70028. * The promise associated with this deferred object.
  70029. */
  70030. readonly promise: Promise<T>;
  70031. private _resolve;
  70032. private _reject;
  70033. /**
  70034. * The resolve method of the promise associated with this deferred object.
  70035. */
  70036. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70037. /**
  70038. * The reject method of the promise associated with this deferred object.
  70039. */
  70040. get reject(): (reason?: any) => void;
  70041. /**
  70042. * Constructor for this deferred object.
  70043. */
  70044. constructor();
  70045. }
  70046. }
  70047. declare module BABYLON {
  70048. /**
  70049. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70050. */
  70051. export class MeshExploder {
  70052. private _centerMesh;
  70053. private _meshes;
  70054. private _meshesOrigins;
  70055. private _toCenterVectors;
  70056. private _scaledDirection;
  70057. private _newPosition;
  70058. private _centerPosition;
  70059. /**
  70060. * Explodes meshes from a center mesh.
  70061. * @param meshes The meshes to explode.
  70062. * @param centerMesh The mesh to be center of explosion.
  70063. */
  70064. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70065. private _setCenterMesh;
  70066. /**
  70067. * Get class name
  70068. * @returns "MeshExploder"
  70069. */
  70070. getClassName(): string;
  70071. /**
  70072. * "Exploded meshes"
  70073. * @returns Array of meshes with the centerMesh at index 0.
  70074. */
  70075. getMeshes(): Array<Mesh>;
  70076. /**
  70077. * Explodes meshes giving a specific direction
  70078. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70079. */
  70080. explode(direction?: number): void;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /**
  70085. * Class used to help managing file picking and drag'n'drop
  70086. */
  70087. export class FilesInput {
  70088. /**
  70089. * List of files ready to be loaded
  70090. */
  70091. static get FilesToLoad(): {
  70092. [key: string]: File;
  70093. };
  70094. /**
  70095. * Callback called when a file is processed
  70096. */
  70097. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70098. private _engine;
  70099. private _currentScene;
  70100. private _sceneLoadedCallback;
  70101. private _progressCallback;
  70102. private _additionalRenderLoopLogicCallback;
  70103. private _textureLoadingCallback;
  70104. private _startingProcessingFilesCallback;
  70105. private _onReloadCallback;
  70106. private _errorCallback;
  70107. private _elementToMonitor;
  70108. private _sceneFileToLoad;
  70109. private _filesToLoad;
  70110. /**
  70111. * Creates a new FilesInput
  70112. * @param engine defines the rendering engine
  70113. * @param scene defines the hosting scene
  70114. * @param sceneLoadedCallback callback called when scene is loaded
  70115. * @param progressCallback callback called to track progress
  70116. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70117. * @param textureLoadingCallback callback called when a texture is loading
  70118. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70119. * @param onReloadCallback callback called when a reload is requested
  70120. * @param errorCallback callback call if an error occurs
  70121. */
  70122. 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);
  70123. private _dragEnterHandler;
  70124. private _dragOverHandler;
  70125. private _dropHandler;
  70126. /**
  70127. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70128. * @param elementToMonitor defines the DOM element to track
  70129. */
  70130. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70131. /**
  70132. * Release all associated resources
  70133. */
  70134. dispose(): void;
  70135. private renderFunction;
  70136. private drag;
  70137. private drop;
  70138. private _traverseFolder;
  70139. private _processFiles;
  70140. /**
  70141. * Load files from a drop event
  70142. * @param event defines the drop event to use as source
  70143. */
  70144. loadFiles(event: any): void;
  70145. private _processReload;
  70146. /**
  70147. * Reload the current scene from the loaded files
  70148. */
  70149. reload(): void;
  70150. }
  70151. }
  70152. declare module BABYLON {
  70153. /**
  70154. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70156. */
  70157. export class SceneOptimization {
  70158. /**
  70159. * Defines the priority of this optimization (0 by default which means first in the list)
  70160. */
  70161. priority: number;
  70162. /**
  70163. * Gets a string describing the action executed by the current optimization
  70164. * @returns description string
  70165. */
  70166. getDescription(): string;
  70167. /**
  70168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70169. * @param scene defines the current scene where to apply this optimization
  70170. * @param optimizer defines the current optimizer
  70171. * @returns true if everything that can be done was applied
  70172. */
  70173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70174. /**
  70175. * Creates the SceneOptimization object
  70176. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70177. * @param desc defines the description associated with the optimization
  70178. */
  70179. constructor(
  70180. /**
  70181. * Defines the priority of this optimization (0 by default which means first in the list)
  70182. */
  70183. priority?: number);
  70184. }
  70185. /**
  70186. * Defines an optimization used to reduce the size of render target textures
  70187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70188. */
  70189. export class TextureOptimization extends SceneOptimization {
  70190. /**
  70191. * Defines the priority of this optimization (0 by default which means first in the list)
  70192. */
  70193. priority: number;
  70194. /**
  70195. * 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
  70196. */
  70197. maximumSize: number;
  70198. /**
  70199. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70200. */
  70201. step: number;
  70202. /**
  70203. * Gets a string describing the action executed by the current optimization
  70204. * @returns description string
  70205. */
  70206. getDescription(): string;
  70207. /**
  70208. * Creates the TextureOptimization object
  70209. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70210. * @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
  70211. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70212. */
  70213. constructor(
  70214. /**
  70215. * Defines the priority of this optimization (0 by default which means first in the list)
  70216. */
  70217. priority?: number,
  70218. /**
  70219. * 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
  70220. */
  70221. maximumSize?: number,
  70222. /**
  70223. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70224. */
  70225. step?: number);
  70226. /**
  70227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70228. * @param scene defines the current scene where to apply this optimization
  70229. * @param optimizer defines the current optimizer
  70230. * @returns true if everything that can be done was applied
  70231. */
  70232. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70233. }
  70234. /**
  70235. * Defines an optimization used to increase or decrease the rendering resolution
  70236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70237. */
  70238. export class HardwareScalingOptimization extends SceneOptimization {
  70239. /**
  70240. * Defines the priority of this optimization (0 by default which means first in the list)
  70241. */
  70242. priority: number;
  70243. /**
  70244. * Defines the maximum scale to use (2 by default)
  70245. */
  70246. maximumScale: number;
  70247. /**
  70248. * Defines the step to use between two passes (0.5 by default)
  70249. */
  70250. step: number;
  70251. private _currentScale;
  70252. private _directionOffset;
  70253. /**
  70254. * Gets a string describing the action executed by the current optimization
  70255. * @return description string
  70256. */
  70257. getDescription(): string;
  70258. /**
  70259. * Creates the HardwareScalingOptimization object
  70260. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70261. * @param maximumScale defines the maximum scale to use (2 by default)
  70262. * @param step defines the step to use between two passes (0.5 by default)
  70263. */
  70264. constructor(
  70265. /**
  70266. * Defines the priority of this optimization (0 by default which means first in the list)
  70267. */
  70268. priority?: number,
  70269. /**
  70270. * Defines the maximum scale to use (2 by default)
  70271. */
  70272. maximumScale?: number,
  70273. /**
  70274. * Defines the step to use between two passes (0.5 by default)
  70275. */
  70276. step?: number);
  70277. /**
  70278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70279. * @param scene defines the current scene where to apply this optimization
  70280. * @param optimizer defines the current optimizer
  70281. * @returns true if everything that can be done was applied
  70282. */
  70283. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70284. }
  70285. /**
  70286. * Defines an optimization used to remove shadows
  70287. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70288. */
  70289. export class ShadowsOptimization extends SceneOptimization {
  70290. /**
  70291. * Gets a string describing the action executed by the current optimization
  70292. * @return description string
  70293. */
  70294. getDescription(): string;
  70295. /**
  70296. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70297. * @param scene defines the current scene where to apply this optimization
  70298. * @param optimizer defines the current optimizer
  70299. * @returns true if everything that can be done was applied
  70300. */
  70301. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70302. }
  70303. /**
  70304. * Defines an optimization used to turn post-processes off
  70305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70306. */
  70307. export class PostProcessesOptimization extends SceneOptimization {
  70308. /**
  70309. * Gets a string describing the action executed by the current optimization
  70310. * @return 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 lens flares off
  70323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70324. */
  70325. export class LensFlaresOptimization 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 based on user defined callback.
  70341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70342. */
  70343. export class CustomOptimization extends SceneOptimization {
  70344. /**
  70345. * Callback called to apply the custom optimization.
  70346. */
  70347. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70348. /**
  70349. * Callback called to get custom description
  70350. */
  70351. onGetDescription: () => string;
  70352. /**
  70353. * Gets a string describing the action executed by the current optimization
  70354. * @returns description string
  70355. */
  70356. getDescription(): string;
  70357. /**
  70358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70359. * @param scene defines the current scene where to apply this optimization
  70360. * @param optimizer defines the current optimizer
  70361. * @returns true if everything that can be done was applied
  70362. */
  70363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70364. }
  70365. /**
  70366. * Defines an optimization used to turn particles off
  70367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70368. */
  70369. export class ParticlesOptimization extends SceneOptimization {
  70370. /**
  70371. * Gets a string describing the action executed by the current optimization
  70372. * @return description string
  70373. */
  70374. getDescription(): string;
  70375. /**
  70376. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70377. * @param scene defines the current scene where to apply this optimization
  70378. * @param optimizer defines the current optimizer
  70379. * @returns true if everything that can be done was applied
  70380. */
  70381. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70382. }
  70383. /**
  70384. * Defines an optimization used to turn render targets off
  70385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70386. */
  70387. export class RenderTargetsOptimization extends SceneOptimization {
  70388. /**
  70389. * Gets a string describing the action executed by the current optimization
  70390. * @return description string
  70391. */
  70392. getDescription(): string;
  70393. /**
  70394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70395. * @param scene defines the current scene where to apply this optimization
  70396. * @param optimizer defines the current optimizer
  70397. * @returns true if everything that can be done was applied
  70398. */
  70399. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70400. }
  70401. /**
  70402. * Defines an optimization used to merge meshes with compatible materials
  70403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70404. */
  70405. export class MergeMeshesOptimization extends SceneOptimization {
  70406. private static _UpdateSelectionTree;
  70407. /**
  70408. * Gets or sets a boolean which defines if optimization octree has to be updated
  70409. */
  70410. static get UpdateSelectionTree(): boolean;
  70411. /**
  70412. * Gets or sets a boolean which defines if optimization octree has to be updated
  70413. */
  70414. static set UpdateSelectionTree(value: boolean);
  70415. /**
  70416. * Gets a string describing the action executed by the current optimization
  70417. * @return description string
  70418. */
  70419. getDescription(): string;
  70420. private _canBeMerged;
  70421. /**
  70422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70423. * @param scene defines the current scene where to apply this optimization
  70424. * @param optimizer defines the current optimizer
  70425. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70426. * @returns true if everything that can be done was applied
  70427. */
  70428. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70429. }
  70430. /**
  70431. * Defines a list of options used by SceneOptimizer
  70432. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70433. */
  70434. export class SceneOptimizerOptions {
  70435. /**
  70436. * Defines the target frame rate to reach (60 by default)
  70437. */
  70438. targetFrameRate: number;
  70439. /**
  70440. * Defines the interval between two checkes (2000ms by default)
  70441. */
  70442. trackerDuration: number;
  70443. /**
  70444. * Gets the list of optimizations to apply
  70445. */
  70446. optimizations: SceneOptimization[];
  70447. /**
  70448. * Creates a new list of options used by SceneOptimizer
  70449. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70450. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70451. */
  70452. constructor(
  70453. /**
  70454. * Defines the target frame rate to reach (60 by default)
  70455. */
  70456. targetFrameRate?: number,
  70457. /**
  70458. * Defines the interval between two checkes (2000ms by default)
  70459. */
  70460. trackerDuration?: number);
  70461. /**
  70462. * Add a new optimization
  70463. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70464. * @returns the current SceneOptimizerOptions
  70465. */
  70466. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70467. /**
  70468. * Add a new custom optimization
  70469. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70470. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70472. * @returns the current SceneOptimizerOptions
  70473. */
  70474. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70475. /**
  70476. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70477. * @param targetFrameRate defines the target frame rate (60 by default)
  70478. * @returns a SceneOptimizerOptions object
  70479. */
  70480. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70481. /**
  70482. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70483. * @param targetFrameRate defines the target frame rate (60 by default)
  70484. * @returns a SceneOptimizerOptions object
  70485. */
  70486. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70487. /**
  70488. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70489. * @param targetFrameRate defines the target frame rate (60 by default)
  70490. * @returns a SceneOptimizerOptions object
  70491. */
  70492. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70493. }
  70494. /**
  70495. * Class used to run optimizations in order to reach a target frame rate
  70496. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70497. */
  70498. export class SceneOptimizer implements IDisposable {
  70499. private _isRunning;
  70500. private _options;
  70501. private _scene;
  70502. private _currentPriorityLevel;
  70503. private _targetFrameRate;
  70504. private _trackerDuration;
  70505. private _currentFrameRate;
  70506. private _sceneDisposeObserver;
  70507. private _improvementMode;
  70508. /**
  70509. * Defines an observable called when the optimizer reaches the target frame rate
  70510. */
  70511. onSuccessObservable: Observable<SceneOptimizer>;
  70512. /**
  70513. * Defines an observable called when the optimizer enables an optimization
  70514. */
  70515. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70516. /**
  70517. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70518. */
  70519. onFailureObservable: Observable<SceneOptimizer>;
  70520. /**
  70521. * Gets a boolean indicating if the optimizer is in improvement mode
  70522. */
  70523. get isInImprovementMode(): boolean;
  70524. /**
  70525. * Gets the current priority level (0 at start)
  70526. */
  70527. get currentPriorityLevel(): number;
  70528. /**
  70529. * Gets the current frame rate checked by the SceneOptimizer
  70530. */
  70531. get currentFrameRate(): number;
  70532. /**
  70533. * Gets or sets the current target frame rate (60 by default)
  70534. */
  70535. get targetFrameRate(): number;
  70536. /**
  70537. * Gets or sets the current target frame rate (60 by default)
  70538. */
  70539. set targetFrameRate(value: number);
  70540. /**
  70541. * Gets or sets the current interval between two checks (every 2000ms by default)
  70542. */
  70543. get trackerDuration(): number;
  70544. /**
  70545. * Gets or sets the current interval between two checks (every 2000ms by default)
  70546. */
  70547. set trackerDuration(value: number);
  70548. /**
  70549. * Gets the list of active optimizations
  70550. */
  70551. get optimizations(): SceneOptimization[];
  70552. /**
  70553. * Creates a new SceneOptimizer
  70554. * @param scene defines the scene to work on
  70555. * @param options defines the options to use with the SceneOptimizer
  70556. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70557. * @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)
  70558. */
  70559. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70560. /**
  70561. * Stops the current optimizer
  70562. */
  70563. stop(): void;
  70564. /**
  70565. * Reset the optimizer to initial step (current priority level = 0)
  70566. */
  70567. reset(): void;
  70568. /**
  70569. * Start the optimizer. By default it will try to reach a specific framerate
  70570. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70571. */
  70572. start(): void;
  70573. private _checkCurrentState;
  70574. /**
  70575. * Release all resources
  70576. */
  70577. dispose(): void;
  70578. /**
  70579. * Helper function to create a SceneOptimizer with one single line of code
  70580. * @param scene defines the scene to work on
  70581. * @param options defines the options to use with the SceneOptimizer
  70582. * @param onSuccess defines a callback to call on success
  70583. * @param onFailure defines a callback to call on failure
  70584. * @returns the new SceneOptimizer object
  70585. */
  70586. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70587. }
  70588. }
  70589. declare module BABYLON {
  70590. /**
  70591. * Class used to serialize a scene into a string
  70592. */
  70593. export class SceneSerializer {
  70594. /**
  70595. * Clear cache used by a previous serialization
  70596. */
  70597. static ClearCache(): void;
  70598. /**
  70599. * Serialize a scene into a JSON compatible object
  70600. * @param scene defines the scene to serialize
  70601. * @returns a JSON compatible object
  70602. */
  70603. static Serialize(scene: Scene): any;
  70604. /**
  70605. * Serialize a mesh into a JSON compatible object
  70606. * @param toSerialize defines the mesh to serialize
  70607. * @param withParents defines if parents must be serialized as well
  70608. * @param withChildren defines if children must be serialized as well
  70609. * @returns a JSON compatible object
  70610. */
  70611. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70612. }
  70613. }
  70614. declare module BABYLON {
  70615. /**
  70616. * Class used to host texture specific utilities
  70617. */
  70618. export class TextureTools {
  70619. /**
  70620. * Uses the GPU to create a copy texture rescaled at a given size
  70621. * @param texture Texture to copy from
  70622. * @param width defines the desired width
  70623. * @param height defines the desired height
  70624. * @param useBilinearMode defines if bilinear mode has to be used
  70625. * @return the generated texture
  70626. */
  70627. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70628. }
  70629. }
  70630. declare module BABYLON {
  70631. /**
  70632. * This represents the different options available for the video capture.
  70633. */
  70634. export interface VideoRecorderOptions {
  70635. /** Defines the mime type of the video. */
  70636. mimeType: string;
  70637. /** Defines the FPS the video should be recorded at. */
  70638. fps: number;
  70639. /** Defines the chunk size for the recording data. */
  70640. recordChunckSize: number;
  70641. /** The audio tracks to attach to the recording. */
  70642. audioTracks?: MediaStreamTrack[];
  70643. }
  70644. /**
  70645. * This can help with recording videos from BabylonJS.
  70646. * This is based on the available WebRTC functionalities of the browser.
  70647. *
  70648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70649. */
  70650. export class VideoRecorder {
  70651. private static readonly _defaultOptions;
  70652. /**
  70653. * Returns whether or not the VideoRecorder is available in your browser.
  70654. * @param engine Defines the Babylon Engine.
  70655. * @returns true if supported otherwise false.
  70656. */
  70657. static IsSupported(engine: Engine): boolean;
  70658. private readonly _options;
  70659. private _canvas;
  70660. private _mediaRecorder;
  70661. private _recordedChunks;
  70662. private _fileName;
  70663. private _resolve;
  70664. private _reject;
  70665. /**
  70666. * True when a recording is already in progress.
  70667. */
  70668. get isRecording(): boolean;
  70669. /**
  70670. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70671. * @param engine Defines the BabylonJS Engine you wish to record.
  70672. * @param options Defines options that can be used to customize the capture.
  70673. */
  70674. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70675. /**
  70676. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70677. */
  70678. stopRecording(): void;
  70679. /**
  70680. * Starts recording the canvas for a max duration specified in parameters.
  70681. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70682. * If null no automatic download will start and you can rely on the promise to get the data back.
  70683. * @param maxDuration Defines the maximum recording time in seconds.
  70684. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70685. * @return A promise callback at the end of the recording with the video data in Blob.
  70686. */
  70687. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70688. /**
  70689. * Releases internal resources used during the recording.
  70690. */
  70691. dispose(): void;
  70692. private _handleDataAvailable;
  70693. private _handleError;
  70694. private _handleStop;
  70695. }
  70696. }
  70697. declare module BABYLON {
  70698. /**
  70699. * Class containing a set of static utilities functions for screenshots
  70700. */
  70701. export class ScreenshotTools {
  70702. /**
  70703. * Captures a screenshot of the current rendering
  70704. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70705. * @param engine defines the rendering engine
  70706. * @param camera defines the source camera
  70707. * @param size This parameter can be set to a single number or to an object with the
  70708. * following (optional) properties: precision, width, height. If a single number is passed,
  70709. * it will be used for both width and height. If an object is passed, the screenshot size
  70710. * will be derived from the parameters. The precision property is a multiplier allowing
  70711. * rendering at a higher or lower resolution
  70712. * @param successCallback defines the callback receives a single parameter which contains the
  70713. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70714. * src parameter of an <img> to display it
  70715. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70716. * Check your browser for supported MIME types
  70717. */
  70718. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70719. /**
  70720. * Captures a screenshot of the current rendering
  70721. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70722. * @param engine defines the rendering engine
  70723. * @param camera defines the source camera
  70724. * @param size This parameter can be set to a single number or to an object with the
  70725. * following (optional) properties: precision, width, height. If a single number is passed,
  70726. * it will be used for both width and height. If an object is passed, the screenshot size
  70727. * will be derived from the parameters. The precision property is a multiplier allowing
  70728. * rendering at a higher or lower resolution
  70729. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70730. * Check your browser for supported MIME types
  70731. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70732. * to the src parameter of an <img> to display it
  70733. */
  70734. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70735. /**
  70736. * Generates an image screenshot from the specified camera.
  70737. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70738. * @param engine The engine to use for rendering
  70739. * @param camera The camera to use for rendering
  70740. * @param size This parameter can be set to a single number or to an object with the
  70741. * following (optional) properties: precision, width, height. If a single number is passed,
  70742. * it will be used for both width and height. If an object is passed, the screenshot size
  70743. * will be derived from the parameters. The precision property is a multiplier allowing
  70744. * rendering at a higher or lower resolution
  70745. * @param successCallback The callback receives a single parameter which contains the
  70746. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70747. * src parameter of an <img> to display it
  70748. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70749. * Check your browser for supported MIME types
  70750. * @param samples Texture samples (default: 1)
  70751. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70752. * @param fileName A name for for the downloaded file.
  70753. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70754. */
  70755. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  70756. /**
  70757. * Generates an image screenshot from the specified camera.
  70758. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70759. * @param engine The engine to use for rendering
  70760. * @param camera The camera to use for rendering
  70761. * @param size This parameter can be set to a single number or to an object with the
  70762. * following (optional) properties: precision, width, height. If a single number is passed,
  70763. * it will be used for both width and height. If an object is passed, the screenshot size
  70764. * will be derived from the parameters. The precision property is a multiplier allowing
  70765. * rendering at a higher or lower resolution
  70766. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70767. * Check your browser for supported MIME types
  70768. * @param samples Texture samples (default: 1)
  70769. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70770. * @param fileName A name for for the downloaded file.
  70771. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70772. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70773. * to the src parameter of an <img> to display it
  70774. */
  70775. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  70776. /**
  70777. * Gets height and width for screenshot size
  70778. * @private
  70779. */
  70780. private static _getScreenshotSize;
  70781. }
  70782. }
  70783. declare module BABYLON {
  70784. /**
  70785. * Interface for a data buffer
  70786. */
  70787. export interface IDataBuffer {
  70788. /**
  70789. * Reads bytes from the data buffer.
  70790. * @param byteOffset The byte offset to read
  70791. * @param byteLength The byte length to read
  70792. * @returns A promise that resolves when the bytes are read
  70793. */
  70794. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70795. /**
  70796. * The byte length of the buffer.
  70797. */
  70798. readonly byteLength: number;
  70799. }
  70800. /**
  70801. * Utility class for reading from a data buffer
  70802. */
  70803. export class DataReader {
  70804. /**
  70805. * The data buffer associated with this data reader.
  70806. */
  70807. readonly buffer: IDataBuffer;
  70808. /**
  70809. * The current byte offset from the beginning of the data buffer.
  70810. */
  70811. byteOffset: number;
  70812. private _dataView;
  70813. private _dataByteOffset;
  70814. /**
  70815. * Constructor
  70816. * @param buffer The buffer to read
  70817. */
  70818. constructor(buffer: IDataBuffer);
  70819. /**
  70820. * Loads the given byte length.
  70821. * @param byteLength The byte length to load
  70822. * @returns A promise that resolves when the load is complete
  70823. */
  70824. loadAsync(byteLength: number): Promise<void>;
  70825. /**
  70826. * Read a unsigned 32-bit integer from the currently loaded data range.
  70827. * @returns The 32-bit integer read
  70828. */
  70829. readUint32(): number;
  70830. /**
  70831. * Read a byte array from the currently loaded data range.
  70832. * @param byteLength The byte length to read
  70833. * @returns The byte array read
  70834. */
  70835. readUint8Array(byteLength: number): Uint8Array;
  70836. /**
  70837. * Read a string from the currently loaded data range.
  70838. * @param byteLength The byte length to read
  70839. * @returns The string read
  70840. */
  70841. readString(byteLength: number): string;
  70842. /**
  70843. * Skips the given byte length the currently loaded data range.
  70844. * @param byteLength The byte length to skip
  70845. */
  70846. skipBytes(byteLength: number): void;
  70847. }
  70848. }
  70849. declare module BABYLON {
  70850. /**
  70851. * Class for storing data to local storage if available or in-memory storage otherwise
  70852. */
  70853. export class DataStorage {
  70854. private static _Storage;
  70855. private static _GetStorage;
  70856. /**
  70857. * Reads a string from the data storage
  70858. * @param key The key to read
  70859. * @param defaultValue The value if the key doesn't exist
  70860. * @returns The string value
  70861. */
  70862. static ReadString(key: string, defaultValue: string): string;
  70863. /**
  70864. * Writes a string to the data storage
  70865. * @param key The key to write
  70866. * @param value The value to write
  70867. */
  70868. static WriteString(key: string, value: string): void;
  70869. /**
  70870. * Reads a boolean from the data storage
  70871. * @param key The key to read
  70872. * @param defaultValue The value if the key doesn't exist
  70873. * @returns The boolean value
  70874. */
  70875. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  70876. /**
  70877. * Writes a boolean to the data storage
  70878. * @param key The key to write
  70879. * @param value The value to write
  70880. */
  70881. static WriteBoolean(key: string, value: boolean): void;
  70882. /**
  70883. * Reads a number from the data storage
  70884. * @param key The key to read
  70885. * @param defaultValue The value if the key doesn't exist
  70886. * @returns The number value
  70887. */
  70888. static ReadNumber(key: string, defaultValue: number): number;
  70889. /**
  70890. * Writes a number to the data storage
  70891. * @param key The key to write
  70892. * @param value The value to write
  70893. */
  70894. static WriteNumber(key: string, value: number): void;
  70895. }
  70896. }
  70897. declare module BABYLON {
  70898. /**
  70899. * Options used for hit testing
  70900. */
  70901. export interface IWebXRLegacyHitTestOptions {
  70902. /**
  70903. * Only test when user interacted with the scene. Default - hit test every frame
  70904. */
  70905. testOnPointerDownOnly?: boolean;
  70906. /**
  70907. * The node to use to transform the local results to world coordinates
  70908. */
  70909. worldParentNode?: TransformNode;
  70910. }
  70911. /**
  70912. * Interface defining the babylon result of raycasting/hit-test
  70913. */
  70914. export interface IWebXRLegacyHitResult {
  70915. /**
  70916. * Transformation matrix that can be applied to a node that will put it in the hit point location
  70917. */
  70918. transformationMatrix: Matrix;
  70919. /**
  70920. * The native hit test result
  70921. */
  70922. xrHitResult: XRHitResult | XRHitTestResult;
  70923. }
  70924. /**
  70925. * The currently-working hit-test module.
  70926. * Hit test (or Ray-casting) is used to interact with the real world.
  70927. * For further information read here - https://github.com/immersive-web/hit-test
  70928. */
  70929. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  70930. /**
  70931. * options to use when constructing this feature
  70932. */
  70933. readonly options: IWebXRLegacyHitTestOptions;
  70934. private _direction;
  70935. private _mat;
  70936. private _onSelectEnabled;
  70937. private _origin;
  70938. /**
  70939. * The module's name
  70940. */
  70941. static readonly Name: string;
  70942. /**
  70943. * The (Babylon) version of this module.
  70944. * This is an integer representing the implementation version.
  70945. * This number does not correspond to the WebXR specs version
  70946. */
  70947. static readonly Version: number;
  70948. /**
  70949. * Populated with the last native XR Hit Results
  70950. */
  70951. lastNativeXRHitResults: XRHitResult[];
  70952. /**
  70953. * Triggered when new babylon (transformed) hit test results are available
  70954. */
  70955. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  70956. /**
  70957. * Creates a new instance of the (legacy version) hit test feature
  70958. * @param _xrSessionManager an instance of WebXRSessionManager
  70959. * @param options options to use when constructing this feature
  70960. */
  70961. constructor(_xrSessionManager: WebXRSessionManager,
  70962. /**
  70963. * options to use when constructing this feature
  70964. */
  70965. options?: IWebXRLegacyHitTestOptions);
  70966. /**
  70967. * execute a hit test with an XR Ray
  70968. *
  70969. * @param xrSession a native xrSession that will execute this hit test
  70970. * @param xrRay the ray (position and direction) to use for ray-casting
  70971. * @param referenceSpace native XR reference space to use for the hit-test
  70972. * @param filter filter function that will filter the results
  70973. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  70974. */
  70975. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  70976. /**
  70977. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  70978. * @param event the (select) event to use to select with
  70979. * @param referenceSpace the reference space to use for this hit test
  70980. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  70981. */
  70982. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70983. /**
  70984. * attach this feature
  70985. * Will usually be called by the features manager
  70986. *
  70987. * @returns true if successful.
  70988. */
  70989. attach(): boolean;
  70990. /**
  70991. * detach this feature.
  70992. * Will usually be called by the features manager
  70993. *
  70994. * @returns true if successful.
  70995. */
  70996. detach(): boolean;
  70997. /**
  70998. * Dispose this feature and all of the resources attached
  70999. */
  71000. dispose(): void;
  71001. protected _onXRFrame(frame: XRFrame): void;
  71002. private _onHitTestResults;
  71003. private _onSelect;
  71004. }
  71005. }
  71006. declare module BABYLON {
  71007. /**
  71008. * Options used in the plane detector module
  71009. */
  71010. export interface IWebXRPlaneDetectorOptions {
  71011. /**
  71012. * The node to use to transform the local results to world coordinates
  71013. */
  71014. worldParentNode?: TransformNode;
  71015. }
  71016. /**
  71017. * A babylon interface for a WebXR plane.
  71018. * A Plane is actually a polygon, built from N points in space
  71019. *
  71020. * Supported in chrome 79, not supported in canary 81 ATM
  71021. */
  71022. export interface IWebXRPlane {
  71023. /**
  71024. * a babylon-assigned ID for this polygon
  71025. */
  71026. id: number;
  71027. /**
  71028. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  71029. */
  71030. polygonDefinition: Array<Vector3>;
  71031. /**
  71032. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  71033. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  71034. */
  71035. transformationMatrix: Matrix;
  71036. /**
  71037. * the native xr-plane object
  71038. */
  71039. xrPlane: XRPlane;
  71040. }
  71041. /**
  71042. * The plane detector is used to detect planes in the real world when in AR
  71043. * For more information see https://github.com/immersive-web/real-world-geometry/
  71044. */
  71045. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  71046. private _options;
  71047. private _detectedPlanes;
  71048. private _enabled;
  71049. private _lastFrameDetected;
  71050. /**
  71051. * The module's name
  71052. */
  71053. static readonly Name: string;
  71054. /**
  71055. * The (Babylon) version of this module.
  71056. * This is an integer representing the implementation version.
  71057. * This number does not correspond to the WebXR specs version
  71058. */
  71059. static readonly Version: number;
  71060. /**
  71061. * Observers registered here will be executed when a new plane was added to the session
  71062. */
  71063. onPlaneAddedObservable: Observable<IWebXRPlane>;
  71064. /**
  71065. * Observers registered here will be executed when a plane is no longer detected in the session
  71066. */
  71067. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  71068. /**
  71069. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  71070. * This can execute N times every frame
  71071. */
  71072. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  71073. /**
  71074. * construct a new Plane Detector
  71075. * @param _xrSessionManager an instance of xr Session manager
  71076. * @param _options configuration to use when constructing this feature
  71077. */
  71078. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  71079. /**
  71080. * Dispose this feature and all of the resources attached
  71081. */
  71082. dispose(): void;
  71083. protected _onXRFrame(frame: XRFrame): void;
  71084. private _init;
  71085. private _updatePlaneWithXRPlane;
  71086. /**
  71087. * avoiding using Array.find for global support.
  71088. * @param xrPlane the plane to find in the array
  71089. */
  71090. private findIndexInPlaneArray;
  71091. }
  71092. }
  71093. declare module BABYLON {
  71094. /**
  71095. * Configuration options of the anchor system
  71096. */
  71097. export interface IWebXRAnchorSystemOptions {
  71098. /**
  71099. * Should a new anchor be added every time a select event is triggered
  71100. */
  71101. addAnchorOnSelect?: boolean;
  71102. /**
  71103. * should the anchor system use plane detection.
  71104. * If set to true, the plane-detection feature should be set using setPlaneDetector
  71105. */
  71106. usePlaneDetection?: boolean;
  71107. /**
  71108. * a node that will be used to convert local to world coordinates
  71109. */
  71110. worldParentNode?: TransformNode;
  71111. }
  71112. /**
  71113. * A babylon container for an XR Anchor
  71114. */
  71115. export interface IWebXRAnchor {
  71116. /**
  71117. * A babylon-assigned ID for this anchor
  71118. */
  71119. id: number;
  71120. /**
  71121. * Transformation matrix to apply to an object attached to this anchor
  71122. */
  71123. transformationMatrix: Matrix;
  71124. /**
  71125. * The native anchor object
  71126. */
  71127. xrAnchor: XRAnchor;
  71128. }
  71129. /**
  71130. * An implementation of the anchor system of WebXR.
  71131. * Note that the current documented implementation is not available in any browser. Future implementations
  71132. * will use the frame to create an anchor and not the session or a detected plane
  71133. * For further information see https://github.com/immersive-web/anchors/
  71134. */
  71135. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  71136. private _options;
  71137. private _enabled;
  71138. private _hitTestModule;
  71139. private _lastFrameDetected;
  71140. private _onSelect;
  71141. private _planeDetector;
  71142. private _trackedAnchors;
  71143. /**
  71144. * The module's name
  71145. */
  71146. static readonly Name: string;
  71147. /**
  71148. * The (Babylon) version of this module.
  71149. * This is an integer representing the implementation version.
  71150. * This number does not correspond to the WebXR specs version
  71151. */
  71152. static readonly Version: number;
  71153. /**
  71154. * Observers registered here will be executed when a new anchor was added to the session
  71155. */
  71156. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  71157. /**
  71158. * Observers registered here will be executed when an anchor was removed from the session
  71159. */
  71160. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  71161. /**
  71162. * Observers registered here will be executed when an existing anchor updates
  71163. * This can execute N times every frame
  71164. */
  71165. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  71166. /**
  71167. * constructs a new anchor system
  71168. * @param _xrSessionManager an instance of WebXRSessionManager
  71169. * @param _options configuration object for this feature
  71170. */
  71171. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  71172. /**
  71173. * Add anchor at a specific XR point.
  71174. *
  71175. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  71176. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  71177. * @returns a promise the fulfills when the anchor was created
  71178. */
  71179. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  71180. /**
  71181. * attach this feature
  71182. * Will usually be called by the features manager
  71183. *
  71184. * @returns true if successful.
  71185. */
  71186. attach(): boolean;
  71187. /**
  71188. * detach this feature.
  71189. * Will usually be called by the features manager
  71190. *
  71191. * @returns true if successful.
  71192. */
  71193. detach(): boolean;
  71194. /**
  71195. * Dispose this feature and all of the resources attached
  71196. */
  71197. dispose(): void;
  71198. /**
  71199. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  71200. * @param hitTestModule the hit-test module to use.
  71201. */
  71202. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  71203. /**
  71204. * set the plane detector to use in order to create anchors from frames
  71205. * @param planeDetector the plane-detector module to use
  71206. * @param enable enable plane-anchors. default is true
  71207. */
  71208. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  71209. protected _onXRFrame(frame: XRFrame): void;
  71210. /**
  71211. * avoiding using Array.find for global support.
  71212. * @param xrAnchor the plane to find in the array
  71213. */
  71214. private _findIndexInAnchorArray;
  71215. private _updateAnchorWithXRFrame;
  71216. }
  71217. }
  71218. declare module BABYLON {
  71219. /**
  71220. * Options interface for the background remover plugin
  71221. */
  71222. export interface IWebXRBackgroundRemoverOptions {
  71223. /**
  71224. * Further background meshes to disable when entering AR
  71225. */
  71226. backgroundMeshes?: AbstractMesh[];
  71227. /**
  71228. * flags to configure the removal of the environment helper.
  71229. * If not set, the entire background will be removed. If set, flags should be set as well.
  71230. */
  71231. environmentHelperRemovalFlags?: {
  71232. /**
  71233. * Should the skybox be removed (default false)
  71234. */
  71235. skyBox?: boolean;
  71236. /**
  71237. * Should the ground be removed (default false)
  71238. */
  71239. ground?: boolean;
  71240. };
  71241. /**
  71242. * don't disable the environment helper
  71243. */
  71244. ignoreEnvironmentHelper?: boolean;
  71245. }
  71246. /**
  71247. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  71248. */
  71249. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  71250. /**
  71251. * read-only options to be used in this module
  71252. */
  71253. readonly options: IWebXRBackgroundRemoverOptions;
  71254. /**
  71255. * The module's name
  71256. */
  71257. static readonly Name: string;
  71258. /**
  71259. * The (Babylon) version of this module.
  71260. * This is an integer representing the implementation version.
  71261. * This number does not correspond to the WebXR specs version
  71262. */
  71263. static readonly Version: number;
  71264. /**
  71265. * registered observers will be triggered when the background state changes
  71266. */
  71267. onBackgroundStateChangedObservable: Observable<boolean>;
  71268. /**
  71269. * constructs a new background remover module
  71270. * @param _xrSessionManager the session manager for this module
  71271. * @param options read-only options to be used in this module
  71272. */
  71273. constructor(_xrSessionManager: WebXRSessionManager,
  71274. /**
  71275. * read-only options to be used in this module
  71276. */
  71277. options?: IWebXRBackgroundRemoverOptions);
  71278. /**
  71279. * attach this feature
  71280. * Will usually be called by the features manager
  71281. *
  71282. * @returns true if successful.
  71283. */
  71284. attach(): boolean;
  71285. /**
  71286. * detach this feature.
  71287. * Will usually be called by the features manager
  71288. *
  71289. * @returns true if successful.
  71290. */
  71291. detach(): boolean;
  71292. /**
  71293. * Dispose this feature and all of the resources attached
  71294. */
  71295. dispose(): void;
  71296. protected _onXRFrame(_xrFrame: XRFrame): void;
  71297. private _setBackgroundState;
  71298. }
  71299. }
  71300. declare module BABYLON {
  71301. /**
  71302. * Options for the controller physics feature
  71303. */
  71304. export class IWebXRControllerPhysicsOptions {
  71305. /**
  71306. * Should the headset get its own impostor
  71307. */
  71308. enableHeadsetImpostor?: boolean;
  71309. /**
  71310. * Optional parameters for the headset impostor
  71311. */
  71312. headsetImpostorParams?: {
  71313. /**
  71314. * The type of impostor to create. Default is sphere
  71315. */
  71316. impostorType: number;
  71317. /**
  71318. * the size of the impostor. Defaults to 10cm
  71319. */
  71320. impostorSize?: number | {
  71321. width: number;
  71322. height: number;
  71323. depth: number;
  71324. };
  71325. /**
  71326. * Friction definitions
  71327. */
  71328. friction?: number;
  71329. /**
  71330. * Restitution
  71331. */
  71332. restitution?: number;
  71333. };
  71334. /**
  71335. * The physics properties of the future impostors
  71336. */
  71337. physicsProperties?: {
  71338. /**
  71339. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  71340. * Note that this requires a physics engine that supports mesh impostors!
  71341. */
  71342. useControllerMesh?: boolean;
  71343. /**
  71344. * The type of impostor to create. Default is sphere
  71345. */
  71346. impostorType?: number;
  71347. /**
  71348. * the size of the impostor. Defaults to 10cm
  71349. */
  71350. impostorSize?: number | {
  71351. width: number;
  71352. height: number;
  71353. depth: number;
  71354. };
  71355. /**
  71356. * Friction definitions
  71357. */
  71358. friction?: number;
  71359. /**
  71360. * Restitution
  71361. */
  71362. restitution?: number;
  71363. };
  71364. /**
  71365. * the xr input to use with this pointer selection
  71366. */
  71367. xrInput: WebXRInput;
  71368. }
  71369. /**
  71370. * Add physics impostor to your webxr controllers,
  71371. * including naive calculation of their linear and angular velocity
  71372. */
  71373. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  71374. private readonly _options;
  71375. private _attachController;
  71376. private _controllers;
  71377. private _debugMode;
  71378. private _delta;
  71379. private _headsetImpostor?;
  71380. private _headsetMesh?;
  71381. private _lastTimestamp;
  71382. private _tmpQuaternion;
  71383. private _tmpVector;
  71384. /**
  71385. * The module's name
  71386. */
  71387. static readonly Name: string;
  71388. /**
  71389. * The (Babylon) version of this module.
  71390. * This is an integer representing the implementation version.
  71391. * This number does not correspond to the webxr specs version
  71392. */
  71393. static readonly Version: number;
  71394. /**
  71395. * Construct a new Controller Physics Feature
  71396. * @param _xrSessionManager the corresponding xr session manager
  71397. * @param _options options to create this feature with
  71398. */
  71399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  71400. /**
  71401. * @hidden
  71402. * enable debugging - will show console outputs and the impostor mesh
  71403. */
  71404. _enablePhysicsDebug(): void;
  71405. /**
  71406. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  71407. * @param xrController the controller to add
  71408. */
  71409. addController(xrController: WebXRInputSource): void;
  71410. /**
  71411. * attach this feature
  71412. * Will usually be called by the features manager
  71413. *
  71414. * @returns true if successful.
  71415. */
  71416. attach(): boolean;
  71417. /**
  71418. * detach this feature.
  71419. * Will usually be called by the features manager
  71420. *
  71421. * @returns true if successful.
  71422. */
  71423. detach(): boolean;
  71424. /**
  71425. * Get the headset impostor, if enabled
  71426. * @returns the impostor
  71427. */
  71428. getHeadsetImpostor(): PhysicsImpostor | undefined;
  71429. /**
  71430. * Get the physics impostor of a specific controller.
  71431. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  71432. * @param controller the controller or the controller id of which to get the impostor
  71433. * @returns the impostor or null
  71434. */
  71435. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  71436. /**
  71437. * Update the physics properties provided in the constructor
  71438. * @param newProperties the new properties object
  71439. */
  71440. setPhysicsProperties(newProperties: {
  71441. impostorType?: number;
  71442. impostorSize?: number | {
  71443. width: number;
  71444. height: number;
  71445. depth: number;
  71446. };
  71447. friction?: number;
  71448. restitution?: number;
  71449. }): void;
  71450. protected _onXRFrame(_xrFrame: any): void;
  71451. private _detachController;
  71452. }
  71453. }
  71454. declare module BABYLON {
  71455. /**
  71456. * Options used for hit testing (version 2)
  71457. */
  71458. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  71459. /**
  71460. * Do not create a permanent hit test. Will usually be used when only
  71461. * transient inputs are needed.
  71462. */
  71463. disablePermanentHitTest?: boolean;
  71464. /**
  71465. * Enable transient (for example touch-based) hit test inspections
  71466. */
  71467. enableTransientHitTest?: boolean;
  71468. /**
  71469. * Offset ray for the permanent hit test
  71470. */
  71471. offsetRay?: Vector3;
  71472. /**
  71473. * Offset ray for the transient hit test
  71474. */
  71475. transientOffsetRay?: Vector3;
  71476. /**
  71477. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  71478. */
  71479. useReferenceSpace?: boolean;
  71480. }
  71481. /**
  71482. * Interface defining the babylon result of hit-test
  71483. */
  71484. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  71485. /**
  71486. * The input source that generated this hit test (if transient)
  71487. */
  71488. inputSource?: XRInputSource;
  71489. /**
  71490. * Is this a transient hit test
  71491. */
  71492. isTransient?: boolean;
  71493. /**
  71494. * Position of the hit test result
  71495. */
  71496. position: Vector3;
  71497. /**
  71498. * Rotation of the hit test result
  71499. */
  71500. rotationQuaternion: Quaternion;
  71501. }
  71502. /**
  71503. * The currently-working hit-test module.
  71504. * Hit test (or Ray-casting) is used to interact with the real world.
  71505. * For further information read here - https://github.com/immersive-web/hit-test
  71506. *
  71507. * Tested on chrome (mobile) 80.
  71508. */
  71509. export class WebXRHitTest extends WebXRAbstractFeature {
  71510. /**
  71511. * options to use when constructing this feature
  71512. */
  71513. readonly options: IWebXRHitTestOptions;
  71514. private _tmpMat;
  71515. private _tmpPos;
  71516. private _tmpQuat;
  71517. private _transientXrHitTestSource;
  71518. private _xrHitTestSource;
  71519. private initHitTestSource;
  71520. /**
  71521. * The module's name
  71522. */
  71523. static readonly Name: string;
  71524. /**
  71525. * The (Babylon) version of this module.
  71526. * This is an integer representing the implementation version.
  71527. * This number does not correspond to the WebXR specs version
  71528. */
  71529. static readonly Version: number;
  71530. /**
  71531. * When set to true, each hit test will have its own position/rotation objects
  71532. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  71533. * the developers will clone them or copy them as they see fit.
  71534. */
  71535. autoCloneTransformation: boolean;
  71536. /**
  71537. * Populated with the last native XR Hit Results
  71538. */
  71539. lastNativeXRHitResults: XRHitResult[];
  71540. /**
  71541. * Triggered when new babylon (transformed) hit test results are available
  71542. */
  71543. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  71544. /**
  71545. * Use this to temporarily pause hit test checks.
  71546. */
  71547. paused: boolean;
  71548. /**
  71549. * Creates a new instance of the hit test feature
  71550. * @param _xrSessionManager an instance of WebXRSessionManager
  71551. * @param options options to use when constructing this feature
  71552. */
  71553. constructor(_xrSessionManager: WebXRSessionManager,
  71554. /**
  71555. * options to use when constructing this feature
  71556. */
  71557. options?: IWebXRHitTestOptions);
  71558. /**
  71559. * attach this feature
  71560. * Will usually be called by the features manager
  71561. *
  71562. * @returns true if successful.
  71563. */
  71564. attach(): boolean;
  71565. /**
  71566. * detach this feature.
  71567. * Will usually be called by the features manager
  71568. *
  71569. * @returns true if successful.
  71570. */
  71571. detach(): boolean;
  71572. /**
  71573. * Dispose this feature and all of the resources attached
  71574. */
  71575. dispose(): void;
  71576. protected _onXRFrame(frame: XRFrame): void;
  71577. private _processWebXRHitTestResult;
  71578. }
  71579. }
  71580. declare module BABYLON {
  71581. /**
  71582. * The motion controller class for all microsoft mixed reality controllers
  71583. */
  71584. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  71585. protected readonly _mapping: {
  71586. defaultButton: {
  71587. valueNodeName: string;
  71588. unpressedNodeName: string;
  71589. pressedNodeName: string;
  71590. };
  71591. defaultAxis: {
  71592. valueNodeName: string;
  71593. minNodeName: string;
  71594. maxNodeName: string;
  71595. };
  71596. buttons: {
  71597. "xr-standard-trigger": {
  71598. rootNodeName: string;
  71599. componentProperty: string;
  71600. states: string[];
  71601. };
  71602. "xr-standard-squeeze": {
  71603. rootNodeName: string;
  71604. componentProperty: string;
  71605. states: string[];
  71606. };
  71607. "xr-standard-touchpad": {
  71608. rootNodeName: string;
  71609. labelAnchorNodeName: string;
  71610. touchPointNodeName: string;
  71611. };
  71612. "xr-standard-thumbstick": {
  71613. rootNodeName: string;
  71614. componentProperty: string;
  71615. states: string[];
  71616. };
  71617. };
  71618. axes: {
  71619. "xr-standard-touchpad": {
  71620. "x-axis": {
  71621. rootNodeName: string;
  71622. };
  71623. "y-axis": {
  71624. rootNodeName: string;
  71625. };
  71626. };
  71627. "xr-standard-thumbstick": {
  71628. "x-axis": {
  71629. rootNodeName: string;
  71630. };
  71631. "y-axis": {
  71632. rootNodeName: string;
  71633. };
  71634. };
  71635. };
  71636. };
  71637. /**
  71638. * The base url used to load the left and right controller models
  71639. */
  71640. static MODEL_BASE_URL: string;
  71641. /**
  71642. * The name of the left controller model file
  71643. */
  71644. static MODEL_LEFT_FILENAME: string;
  71645. /**
  71646. * The name of the right controller model file
  71647. */
  71648. static MODEL_RIGHT_FILENAME: string;
  71649. profileId: string;
  71650. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71651. protected _getFilenameAndPath(): {
  71652. filename: string;
  71653. path: string;
  71654. };
  71655. protected _getModelLoadingConstraints(): boolean;
  71656. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71657. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71658. protected _updateModel(): void;
  71659. }
  71660. }
  71661. declare module BABYLON {
  71662. /**
  71663. * The motion controller class for oculus touch (quest, rift).
  71664. * This class supports legacy mapping as well the standard xr mapping
  71665. */
  71666. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  71667. private _forceLegacyControllers;
  71668. private _modelRootNode;
  71669. /**
  71670. * The base url used to load the left and right controller models
  71671. */
  71672. static MODEL_BASE_URL: string;
  71673. /**
  71674. * The name of the left controller model file
  71675. */
  71676. static MODEL_LEFT_FILENAME: string;
  71677. /**
  71678. * The name of the right controller model file
  71679. */
  71680. static MODEL_RIGHT_FILENAME: string;
  71681. /**
  71682. * Base Url for the Quest controller model.
  71683. */
  71684. static QUEST_MODEL_BASE_URL: string;
  71685. profileId: string;
  71686. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  71687. protected _getFilenameAndPath(): {
  71688. filename: string;
  71689. path: string;
  71690. };
  71691. protected _getModelLoadingConstraints(): boolean;
  71692. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71693. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71694. protected _updateModel(): void;
  71695. /**
  71696. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  71697. * between the touch and touch 2.
  71698. */
  71699. private _isQuest;
  71700. }
  71701. }
  71702. declare module BABYLON {
  71703. /**
  71704. * The motion controller class for the standard HTC-Vive controllers
  71705. */
  71706. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  71707. private _modelRootNode;
  71708. /**
  71709. * The base url used to load the left and right controller models
  71710. */
  71711. static MODEL_BASE_URL: string;
  71712. /**
  71713. * File name for the controller model.
  71714. */
  71715. static MODEL_FILENAME: string;
  71716. profileId: string;
  71717. /**
  71718. * Create a new Vive motion controller object
  71719. * @param scene the scene to use to create this controller
  71720. * @param gamepadObject the corresponding gamepad object
  71721. * @param handedness the handedness of the controller
  71722. */
  71723. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71724. protected _getFilenameAndPath(): {
  71725. filename: string;
  71726. path: string;
  71727. };
  71728. protected _getModelLoadingConstraints(): boolean;
  71729. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71730. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71731. protected _updateModel(): void;
  71732. }
  71733. }
  71734. declare module BABYLON {
  71735. /**
  71736. * A cursor which tracks a point on a path
  71737. */
  71738. export class PathCursor {
  71739. private path;
  71740. /**
  71741. * Stores path cursor callbacks for when an onchange event is triggered
  71742. */
  71743. private _onchange;
  71744. /**
  71745. * The value of the path cursor
  71746. */
  71747. value: number;
  71748. /**
  71749. * The animation array of the path cursor
  71750. */
  71751. animations: Animation[];
  71752. /**
  71753. * Initializes the path cursor
  71754. * @param path The path to track
  71755. */
  71756. constructor(path: Path2);
  71757. /**
  71758. * Gets the cursor point on the path
  71759. * @returns A point on the path cursor at the cursor location
  71760. */
  71761. getPoint(): Vector3;
  71762. /**
  71763. * Moves the cursor ahead by the step amount
  71764. * @param step The amount to move the cursor forward
  71765. * @returns This path cursor
  71766. */
  71767. moveAhead(step?: number): PathCursor;
  71768. /**
  71769. * Moves the cursor behind by the step amount
  71770. * @param step The amount to move the cursor back
  71771. * @returns This path cursor
  71772. */
  71773. moveBack(step?: number): PathCursor;
  71774. /**
  71775. * Moves the cursor by the step amount
  71776. * If the step amount is greater than one, an exception is thrown
  71777. * @param step The amount to move the cursor
  71778. * @returns This path cursor
  71779. */
  71780. move(step: number): PathCursor;
  71781. /**
  71782. * Ensures that the value is limited between zero and one
  71783. * @returns This path cursor
  71784. */
  71785. private ensureLimits;
  71786. /**
  71787. * Runs onchange callbacks on change (used by the animation engine)
  71788. * @returns This path cursor
  71789. */
  71790. private raiseOnChange;
  71791. /**
  71792. * Executes a function on change
  71793. * @param f A path cursor onchange callback
  71794. * @returns This path cursor
  71795. */
  71796. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71797. }
  71798. }
  71799. declare module BABYLON {
  71800. /** @hidden */
  71801. export var blurPixelShader: {
  71802. name: string;
  71803. shader: string;
  71804. };
  71805. }
  71806. declare module BABYLON {
  71807. /** @hidden */
  71808. export var pointCloudVertexDeclaration: {
  71809. name: string;
  71810. shader: string;
  71811. };
  71812. }
  71813. // Mixins
  71814. interface Window {
  71815. mozIndexedDB: IDBFactory;
  71816. webkitIndexedDB: IDBFactory;
  71817. msIndexedDB: IDBFactory;
  71818. webkitURL: typeof URL;
  71819. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  71820. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  71821. WebGLRenderingContext: WebGLRenderingContext;
  71822. MSGesture: MSGesture;
  71823. CANNON: any;
  71824. AudioContext: AudioContext;
  71825. webkitAudioContext: AudioContext;
  71826. PointerEvent: any;
  71827. Math: Math;
  71828. Uint8Array: Uint8ArrayConstructor;
  71829. Float32Array: Float32ArrayConstructor;
  71830. mozURL: typeof URL;
  71831. msURL: typeof URL;
  71832. VRFrameData: any; // WebVR, from specs 1.1
  71833. DracoDecoderModule: any;
  71834. setImmediate(handler: (...args: any[]) => void): number;
  71835. }
  71836. interface HTMLCanvasElement {
  71837. requestPointerLock(): void;
  71838. msRequestPointerLock?(): void;
  71839. mozRequestPointerLock?(): void;
  71840. webkitRequestPointerLock?(): void;
  71841. /** Track wether a record is in progress */
  71842. isRecording: boolean;
  71843. /** Capture Stream method defined by some browsers */
  71844. captureStream(fps?: number): MediaStream;
  71845. }
  71846. interface CanvasRenderingContext2D {
  71847. msImageSmoothingEnabled: boolean;
  71848. }
  71849. interface MouseEvent {
  71850. mozMovementX: number;
  71851. mozMovementY: number;
  71852. webkitMovementX: number;
  71853. webkitMovementY: number;
  71854. msMovementX: number;
  71855. msMovementY: number;
  71856. }
  71857. interface Navigator {
  71858. mozGetVRDevices: (any: any) => any;
  71859. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71860. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71861. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71862. webkitGetGamepads(): Gamepad[];
  71863. msGetGamepads(): Gamepad[];
  71864. webkitGamepads(): Gamepad[];
  71865. }
  71866. interface HTMLVideoElement {
  71867. mozSrcObject: any;
  71868. }
  71869. interface Math {
  71870. fround(x: number): number;
  71871. imul(a: number, b: number): number;
  71872. }
  71873. interface WebGLRenderingContext {
  71874. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  71875. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  71876. vertexAttribDivisor(index: number, divisor: number): void;
  71877. createVertexArray(): any;
  71878. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  71879. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  71880. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  71881. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  71882. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  71883. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  71884. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  71885. // Queries
  71886. createQuery(): WebGLQuery;
  71887. deleteQuery(query: WebGLQuery): void;
  71888. beginQuery(target: number, query: WebGLQuery): void;
  71889. endQuery(target: number): void;
  71890. getQueryParameter(query: WebGLQuery, pname: number): any;
  71891. getQuery(target: number, pname: number): any;
  71892. MAX_SAMPLES: number;
  71893. RGBA8: number;
  71894. READ_FRAMEBUFFER: number;
  71895. DRAW_FRAMEBUFFER: number;
  71896. UNIFORM_BUFFER: number;
  71897. HALF_FLOAT_OES: number;
  71898. RGBA16F: number;
  71899. RGBA32F: number;
  71900. R32F: number;
  71901. RG32F: number;
  71902. RGB32F: number;
  71903. R16F: number;
  71904. RG16F: number;
  71905. RGB16F: number;
  71906. RED: number;
  71907. RG: number;
  71908. R8: number;
  71909. RG8: number;
  71910. UNSIGNED_INT_24_8: number;
  71911. DEPTH24_STENCIL8: number;
  71912. MIN: number;
  71913. MAX: number;
  71914. /* Multiple Render Targets */
  71915. drawBuffers(buffers: number[]): void;
  71916. readBuffer(src: number): void;
  71917. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  71918. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  71919. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  71920. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  71921. // Occlusion Query
  71922. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  71923. ANY_SAMPLES_PASSED: number;
  71924. QUERY_RESULT_AVAILABLE: number;
  71925. QUERY_RESULT: number;
  71926. }
  71927. interface WebGLProgram {
  71928. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  71929. }
  71930. interface EXT_disjoint_timer_query {
  71931. QUERY_COUNTER_BITS_EXT: number;
  71932. TIME_ELAPSED_EXT: number;
  71933. TIMESTAMP_EXT: number;
  71934. GPU_DISJOINT_EXT: number;
  71935. QUERY_RESULT_EXT: number;
  71936. QUERY_RESULT_AVAILABLE_EXT: number;
  71937. queryCounterEXT(query: WebGLQuery, target: number): void;
  71938. createQueryEXT(): WebGLQuery;
  71939. beginQueryEXT(target: number, query: WebGLQuery): void;
  71940. endQueryEXT(target: number): void;
  71941. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  71942. deleteQueryEXT(query: WebGLQuery): void;
  71943. }
  71944. interface WebGLUniformLocation {
  71945. _currentState: any;
  71946. }
  71947. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  71948. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  71949. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  71950. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  71951. interface WebGLRenderingContext {
  71952. readonly RASTERIZER_DISCARD: number;
  71953. readonly DEPTH_COMPONENT24: number;
  71954. readonly TEXTURE_3D: number;
  71955. readonly TEXTURE_2D_ARRAY: number;
  71956. readonly TEXTURE_COMPARE_FUNC: number;
  71957. readonly TEXTURE_COMPARE_MODE: number;
  71958. readonly COMPARE_REF_TO_TEXTURE: number;
  71959. readonly TEXTURE_WRAP_R: number;
  71960. readonly HALF_FLOAT: number;
  71961. readonly RGB8: number;
  71962. readonly RED_INTEGER: number;
  71963. readonly RG_INTEGER: number;
  71964. readonly RGB_INTEGER: number;
  71965. readonly RGBA_INTEGER: number;
  71966. readonly R8_SNORM: number;
  71967. readonly RG8_SNORM: number;
  71968. readonly RGB8_SNORM: number;
  71969. readonly RGBA8_SNORM: number;
  71970. readonly R8I: number;
  71971. readonly RG8I: number;
  71972. readonly RGB8I: number;
  71973. readonly RGBA8I: number;
  71974. readonly R8UI: number;
  71975. readonly RG8UI: number;
  71976. readonly RGB8UI: number;
  71977. readonly RGBA8UI: number;
  71978. readonly R16I: number;
  71979. readonly RG16I: number;
  71980. readonly RGB16I: number;
  71981. readonly RGBA16I: number;
  71982. readonly R16UI: number;
  71983. readonly RG16UI: number;
  71984. readonly RGB16UI: number;
  71985. readonly RGBA16UI: number;
  71986. readonly R32I: number;
  71987. readonly RG32I: number;
  71988. readonly RGB32I: number;
  71989. readonly RGBA32I: number;
  71990. readonly R32UI: number;
  71991. readonly RG32UI: number;
  71992. readonly RGB32UI: number;
  71993. readonly RGBA32UI: number;
  71994. readonly RGB10_A2UI: number;
  71995. readonly R11F_G11F_B10F: number;
  71996. readonly RGB9_E5: number;
  71997. readonly RGB10_A2: number;
  71998. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  71999. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72000. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72001. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72002. readonly DEPTH_COMPONENT32F: number;
  72003. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72004. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72005. 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;
  72006. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72007. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72008. readonly TRANSFORM_FEEDBACK: number;
  72009. readonly INTERLEAVED_ATTRIBS: number;
  72010. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72011. createTransformFeedback(): WebGLTransformFeedback;
  72012. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72013. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72014. beginTransformFeedback(primitiveMode: number): void;
  72015. endTransformFeedback(): void;
  72016. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72017. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72018. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72019. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72020. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  72021. }
  72022. interface ImageBitmap {
  72023. readonly width: number;
  72024. readonly height: number;
  72025. close(): void;
  72026. }
  72027. interface WebGLQuery extends WebGLObject {
  72028. }
  72029. declare var WebGLQuery: {
  72030. prototype: WebGLQuery;
  72031. new(): WebGLQuery;
  72032. };
  72033. interface WebGLSampler extends WebGLObject {
  72034. }
  72035. declare var WebGLSampler: {
  72036. prototype: WebGLSampler;
  72037. new(): WebGLSampler;
  72038. };
  72039. interface WebGLSync extends WebGLObject {
  72040. }
  72041. declare var WebGLSync: {
  72042. prototype: WebGLSync;
  72043. new(): WebGLSync;
  72044. };
  72045. interface WebGLTransformFeedback extends WebGLObject {
  72046. }
  72047. declare var WebGLTransformFeedback: {
  72048. prototype: WebGLTransformFeedback;
  72049. new(): WebGLTransformFeedback;
  72050. };
  72051. interface WebGLVertexArrayObject extends WebGLObject {
  72052. }
  72053. declare var WebGLVertexArrayObject: {
  72054. prototype: WebGLVertexArrayObject;
  72055. new(): WebGLVertexArrayObject;
  72056. };
  72057. // Type definitions for WebVR API
  72058. // Project: https://w3c.github.io/webvr/
  72059. // Definitions by: six a <https://github.com/lostfictions>
  72060. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72061. interface VRDisplay extends EventTarget {
  72062. /**
  72063. * Dictionary of capabilities describing the VRDisplay.
  72064. */
  72065. readonly capabilities: VRDisplayCapabilities;
  72066. /**
  72067. * z-depth defining the far plane of the eye view frustum
  72068. * enables mapping of values in the render target depth
  72069. * attachment to scene coordinates. Initially set to 10000.0.
  72070. */
  72071. depthFar: number;
  72072. /**
  72073. * z-depth defining the near plane of the eye view frustum
  72074. * enables mapping of values in the render target depth
  72075. * attachment to scene coordinates. Initially set to 0.01.
  72076. */
  72077. depthNear: number;
  72078. /**
  72079. * An identifier for this distinct VRDisplay. Used as an
  72080. * association point in the Gamepad API.
  72081. */
  72082. readonly displayId: number;
  72083. /**
  72084. * A display name, a user-readable name identifying it.
  72085. */
  72086. readonly displayName: string;
  72087. readonly isConnected: boolean;
  72088. readonly isPresenting: boolean;
  72089. /**
  72090. * If this VRDisplay supports room-scale experiences, the optional
  72091. * stage attribute contains details on the room-scale parameters.
  72092. */
  72093. readonly stageParameters: VRStageParameters | null;
  72094. /**
  72095. * Passing the value returned by `requestAnimationFrame` to
  72096. * `cancelAnimationFrame` will unregister the callback.
  72097. * @param handle Define the hanle of the request to cancel
  72098. */
  72099. cancelAnimationFrame(handle: number): void;
  72100. /**
  72101. * Stops presenting to the VRDisplay.
  72102. * @returns a promise to know when it stopped
  72103. */
  72104. exitPresent(): Promise<void>;
  72105. /**
  72106. * Return the current VREyeParameters for the given eye.
  72107. * @param whichEye Define the eye we want the parameter for
  72108. * @returns the eye parameters
  72109. */
  72110. getEyeParameters(whichEye: string): VREyeParameters;
  72111. /**
  72112. * Populates the passed VRFrameData with the information required to render
  72113. * the current frame.
  72114. * @param frameData Define the data structure to populate
  72115. * @returns true if ok otherwise false
  72116. */
  72117. getFrameData(frameData: VRFrameData): boolean;
  72118. /**
  72119. * Get the layers currently being presented.
  72120. * @returns the list of VR layers
  72121. */
  72122. getLayers(): VRLayer[];
  72123. /**
  72124. * Return a VRPose containing the future predicted pose of the VRDisplay
  72125. * when the current frame will be presented. The value returned will not
  72126. * change until JavaScript has returned control to the browser.
  72127. *
  72128. * The VRPose will contain the position, orientation, velocity,
  72129. * and acceleration of each of these properties.
  72130. * @returns the pose object
  72131. */
  72132. getPose(): VRPose;
  72133. /**
  72134. * Return the current instantaneous pose of the VRDisplay, with no
  72135. * prediction applied.
  72136. * @returns the current instantaneous pose
  72137. */
  72138. getImmediatePose(): VRPose;
  72139. /**
  72140. * The callback passed to `requestAnimationFrame` will be called
  72141. * any time a new frame should be rendered. When the VRDisplay is
  72142. * presenting the callback will be called at the native refresh
  72143. * rate of the HMD. When not presenting this function acts
  72144. * identically to how window.requestAnimationFrame acts. Content should
  72145. * make no assumptions of frame rate or vsync behavior as the HMD runs
  72146. * asynchronously from other displays and at differing refresh rates.
  72147. * @param callback Define the eaction to run next frame
  72148. * @returns the request handle it
  72149. */
  72150. requestAnimationFrame(callback: FrameRequestCallback): number;
  72151. /**
  72152. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  72153. * Repeat calls while already presenting will update the VRLayers being displayed.
  72154. * @param layers Define the list of layer to present
  72155. * @returns a promise to know when the request has been fulfilled
  72156. */
  72157. requestPresent(layers: VRLayer[]): Promise<void>;
  72158. /**
  72159. * Reset the pose for this display, treating its current position and
  72160. * orientation as the "origin/zero" values. VRPose.position,
  72161. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  72162. * updated when calling resetPose(). This should be called in only
  72163. * sitting-space experiences.
  72164. */
  72165. resetPose(): void;
  72166. /**
  72167. * The VRLayer provided to the VRDisplay will be captured and presented
  72168. * in the HMD. Calling this function has the same effect on the source
  72169. * canvas as any other operation that uses its source image, and canvases
  72170. * created without preserveDrawingBuffer set to true will be cleared.
  72171. * @param pose Define the pose to submit
  72172. */
  72173. submitFrame(pose?: VRPose): void;
  72174. }
  72175. declare var VRDisplay: {
  72176. prototype: VRDisplay;
  72177. new(): VRDisplay;
  72178. };
  72179. interface VRLayer {
  72180. leftBounds?: number[] | Float32Array | null;
  72181. rightBounds?: number[] | Float32Array | null;
  72182. source?: HTMLCanvasElement | null;
  72183. }
  72184. interface VRDisplayCapabilities {
  72185. readonly canPresent: boolean;
  72186. readonly hasExternalDisplay: boolean;
  72187. readonly hasOrientation: boolean;
  72188. readonly hasPosition: boolean;
  72189. readonly maxLayers: number;
  72190. }
  72191. interface VREyeParameters {
  72192. /** @deprecated */
  72193. readonly fieldOfView: VRFieldOfView;
  72194. readonly offset: Float32Array;
  72195. readonly renderHeight: number;
  72196. readonly renderWidth: number;
  72197. }
  72198. interface VRFieldOfView {
  72199. readonly downDegrees: number;
  72200. readonly leftDegrees: number;
  72201. readonly rightDegrees: number;
  72202. readonly upDegrees: number;
  72203. }
  72204. interface VRFrameData {
  72205. readonly leftProjectionMatrix: Float32Array;
  72206. readonly leftViewMatrix: Float32Array;
  72207. readonly pose: VRPose;
  72208. readonly rightProjectionMatrix: Float32Array;
  72209. readonly rightViewMatrix: Float32Array;
  72210. readonly timestamp: number;
  72211. }
  72212. interface VRPose {
  72213. readonly angularAcceleration: Float32Array | null;
  72214. readonly angularVelocity: Float32Array | null;
  72215. readonly linearAcceleration: Float32Array | null;
  72216. readonly linearVelocity: Float32Array | null;
  72217. readonly orientation: Float32Array | null;
  72218. readonly position: Float32Array | null;
  72219. readonly timestamp: number;
  72220. }
  72221. interface VRStageParameters {
  72222. sittingToStandingTransform?: Float32Array;
  72223. sizeX?: number;
  72224. sizeY?: number;
  72225. }
  72226. interface Navigator {
  72227. getVRDisplays(): Promise<VRDisplay[]>;
  72228. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  72229. }
  72230. interface Window {
  72231. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  72232. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  72233. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  72234. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72235. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72236. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  72237. }
  72238. interface Gamepad {
  72239. readonly displayId: number;
  72240. }
  72241. type XRSessionMode =
  72242. | "inline"
  72243. | "immersive-vr"
  72244. | "immersive-ar";
  72245. type XRReferenceSpaceType =
  72246. | "viewer"
  72247. | "local"
  72248. | "local-floor"
  72249. | "bounded-floor"
  72250. | "unbounded";
  72251. type XREnvironmentBlendMode =
  72252. | "opaque"
  72253. | "additive"
  72254. | "alpha-blend";
  72255. type XRVisibilityState =
  72256. | "visible"
  72257. | "visible-blurred"
  72258. | "hidden";
  72259. type XRHandedness =
  72260. | "none"
  72261. | "left"
  72262. | "right";
  72263. type XRTargetRayMode =
  72264. | "gaze"
  72265. | "tracked-pointer"
  72266. | "screen";
  72267. type XREye =
  72268. | "none"
  72269. | "left"
  72270. | "right";
  72271. type XREventType =
  72272. | "devicechange"
  72273. | "visibilitychange"
  72274. | "end"
  72275. | "inputsourceschange"
  72276. | "select"
  72277. | "selectstart"
  72278. | "selectend"
  72279. | "squeeze"
  72280. | "squeezestart"
  72281. | "squeezeend"
  72282. | "reset";
  72283. interface XRSpace extends EventTarget {
  72284. }
  72285. interface XRRenderState {
  72286. depthNear?: number;
  72287. depthFar?: number;
  72288. inlineVerticalFieldOfView?: number;
  72289. baseLayer?: XRWebGLLayer;
  72290. }
  72291. interface XRInputSource {
  72292. handedness: XRHandedness;
  72293. targetRayMode: XRTargetRayMode;
  72294. targetRaySpace: XRSpace;
  72295. gripSpace: XRSpace | undefined;
  72296. gamepad: Gamepad | undefined;
  72297. profiles: Array<string>;
  72298. }
  72299. interface XRSessionInit {
  72300. optionalFeatures?: string[];
  72301. requiredFeatures?: string[];
  72302. }
  72303. interface XRSession extends XRAnchorCreator {
  72304. addEventListener: Function;
  72305. removeEventListener: Function;
  72306. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  72307. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  72308. requestAnimationFrame: Function;
  72309. end(): Promise<void>;
  72310. renderState: XRRenderState;
  72311. inputSources: Array<XRInputSource>;
  72312. // hit test
  72313. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  72314. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  72315. // legacy AR hit test
  72316. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72317. // legacy plane detection
  72318. updateWorldTrackingState(options: {
  72319. planeDetectionState?: { enabled: boolean; }
  72320. }): void;
  72321. }
  72322. interface XRReferenceSpace extends XRSpace {
  72323. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  72324. onreset: any;
  72325. }
  72326. type XRPlaneSet = Set<XRPlane>;
  72327. type XRAnchorSet = Set<XRAnchor>;
  72328. interface XRFrame {
  72329. session: XRSession;
  72330. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  72331. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  72332. // AR
  72333. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  72334. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  72335. // Anchors
  72336. trackedAnchors?: XRAnchorSet;
  72337. // Planes
  72338. worldInformation: {
  72339. detectedPlanes?: XRPlaneSet;
  72340. };
  72341. }
  72342. interface XRViewerPose extends XRPose {
  72343. views: Array<XRView>;
  72344. }
  72345. interface XRPose {
  72346. transform: XRRigidTransform;
  72347. emulatedPosition: boolean;
  72348. }
  72349. interface XRWebGLLayerOptions {
  72350. antialias?: boolean;
  72351. depth?: boolean;
  72352. stencil?: boolean;
  72353. alpha?: boolean;
  72354. multiview?: boolean;
  72355. framebufferScaleFactor?: number;
  72356. }
  72357. declare var XRWebGLLayer: {
  72358. prototype: XRWebGLLayer;
  72359. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  72360. };
  72361. interface XRWebGLLayer {
  72362. framebuffer: WebGLFramebuffer;
  72363. framebufferWidth: number;
  72364. framebufferHeight: number;
  72365. getViewport: Function;
  72366. }
  72367. declare class XRRigidTransform {
  72368. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  72369. position: DOMPointReadOnly;
  72370. orientation: DOMPointReadOnly;
  72371. matrix: Float32Array;
  72372. inverse: XRRigidTransform;
  72373. }
  72374. interface XRView {
  72375. eye: XREye;
  72376. projectionMatrix: Float32Array;
  72377. transform: XRRigidTransform;
  72378. }
  72379. interface XRInputSourceChangeEvent {
  72380. session: XRSession;
  72381. removed: Array<XRInputSource>;
  72382. added: Array<XRInputSource>;
  72383. }
  72384. interface XRInputSourceEvent extends Event {
  72385. readonly frame: XRFrame;
  72386. readonly inputSource: XRInputSource;
  72387. }
  72388. // Experimental(er) features
  72389. declare class XRRay {
  72390. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  72391. origin: DOMPointReadOnly;
  72392. direction: DOMPointReadOnly;
  72393. matrix: Float32Array;
  72394. }
  72395. declare enum XRHitTestTrackableType {
  72396. "point",
  72397. "plane"
  72398. }
  72399. interface XRHitResult {
  72400. hitMatrix: Float32Array;
  72401. }
  72402. interface XRTransientInputHitTestResult {
  72403. readonly inputSource: XRInputSource;
  72404. readonly results: Array<XRHitTestResult>;
  72405. }
  72406. interface XRHitTestResult {
  72407. getPose(baseSpace: XRSpace): XRPose | undefined;
  72408. }
  72409. interface XRHitTestSource {
  72410. cancel(): void;
  72411. }
  72412. interface XRTransientInputHitTestSource {
  72413. cancel(): void;
  72414. }
  72415. interface XRHitTestOptionsInit {
  72416. space: XRSpace;
  72417. entityTypes?: Array<XRHitTestTrackableType>;
  72418. offsetRay?: XRRay;
  72419. }
  72420. interface XRTransientInputHitTestOptionsInit {
  72421. profile: string;
  72422. entityTypes?: Array<XRHitTestTrackableType>;
  72423. offsetRay?: XRRay;
  72424. }
  72425. interface XRAnchor {
  72426. // remove?
  72427. id?: string;
  72428. anchorSpace: XRSpace;
  72429. lastChangedTime: number;
  72430. detach(): void;
  72431. }
  72432. interface XRPlane extends XRAnchorCreator {
  72433. orientation: "Horizontal" | "Vertical";
  72434. planeSpace: XRSpace;
  72435. polygon: Array<DOMPointReadOnly>;
  72436. lastChangedTime: number;
  72437. }
  72438. interface XRAnchorCreator {
  72439. // AR Anchors
  72440. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  72441. }
  72442. /**
  72443. * @ignore
  72444. */
  72445. declare module BABYLON.GLTF2.Exporter {
  72446. }
  72447. /**
  72448. * @ignore
  72449. */
  72450. declare module BABYLON.GLTF1 {
  72451. }
  72452. declare module BABYLON.GUI {
  72453. /**
  72454. * Class used to specific a value and its associated unit
  72455. */
  72456. export class ValueAndUnit {
  72457. /** defines the unit to store */
  72458. unit: number;
  72459. /** defines a boolean indicating if the value can be negative */
  72460. negativeValueAllowed: boolean;
  72461. private _value;
  72462. private _originalUnit;
  72463. /**
  72464. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  72465. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72466. */
  72467. ignoreAdaptiveScaling: boolean;
  72468. /**
  72469. * Creates a new ValueAndUnit
  72470. * @param value defines the value to store
  72471. * @param unit defines the unit to store
  72472. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  72473. */
  72474. constructor(value: number,
  72475. /** defines the unit to store */
  72476. unit?: number,
  72477. /** defines a boolean indicating if the value can be negative */
  72478. negativeValueAllowed?: boolean);
  72479. /** Gets a boolean indicating if the value is a percentage */
  72480. get isPercentage(): boolean;
  72481. /** Gets a boolean indicating if the value is store as pixel */
  72482. get isPixel(): boolean;
  72483. /** Gets direct internal value */
  72484. get internalValue(): number;
  72485. /**
  72486. * Gets value as pixel
  72487. * @param host defines the root host
  72488. * @param refValue defines the reference value for percentages
  72489. * @returns the value as pixel
  72490. */
  72491. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  72492. /**
  72493. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  72494. * @param value defines the value to store
  72495. * @param unit defines the unit to store
  72496. * @returns the current ValueAndUnit
  72497. */
  72498. updateInPlace(value: number, unit?: number): ValueAndUnit;
  72499. /**
  72500. * Gets the value accordingly to its unit
  72501. * @param host defines the root host
  72502. * @returns the value
  72503. */
  72504. getValue(host: AdvancedDynamicTexture): number;
  72505. /**
  72506. * Gets a string representation of the value
  72507. * @param host defines the root host
  72508. * @param decimals defines an optional number of decimals to display
  72509. * @returns a string
  72510. */
  72511. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  72512. /**
  72513. * Store a value parsed from a string
  72514. * @param source defines the source string
  72515. * @returns true if the value was successfully parsed
  72516. */
  72517. fromString(source: string | number): boolean;
  72518. private static _Regex;
  72519. private static _UNITMODE_PERCENTAGE;
  72520. private static _UNITMODE_PIXEL;
  72521. /** UNITMODE_PERCENTAGE */
  72522. static get UNITMODE_PERCENTAGE(): number;
  72523. /** UNITMODE_PIXEL */
  72524. static get UNITMODE_PIXEL(): number;
  72525. }
  72526. }
  72527. declare module BABYLON.GUI {
  72528. /**
  72529. * Define a style used by control to automatically setup properties based on a template.
  72530. * Only support font related properties so far
  72531. */
  72532. export class Style implements BABYLON.IDisposable {
  72533. private _fontFamily;
  72534. private _fontStyle;
  72535. private _fontWeight;
  72536. /** @hidden */
  72537. _host: AdvancedDynamicTexture;
  72538. /** @hidden */
  72539. _fontSize: ValueAndUnit;
  72540. /**
  72541. * BABYLON.Observable raised when the style values are changed
  72542. */
  72543. onChangedObservable: BABYLON.Observable<Style>;
  72544. /**
  72545. * Creates a new style object
  72546. * @param host defines the AdvancedDynamicTexture which hosts this style
  72547. */
  72548. constructor(host: AdvancedDynamicTexture);
  72549. /**
  72550. * Gets or sets the font size
  72551. */
  72552. get fontSize(): string | number;
  72553. set fontSize(value: string | number);
  72554. /**
  72555. * Gets or sets the font family
  72556. */
  72557. get fontFamily(): string;
  72558. set fontFamily(value: string);
  72559. /**
  72560. * Gets or sets the font style
  72561. */
  72562. get fontStyle(): string;
  72563. set fontStyle(value: string);
  72564. /** Gets or sets font weight */
  72565. get fontWeight(): string;
  72566. set fontWeight(value: string);
  72567. /** Dispose all associated resources */
  72568. dispose(): void;
  72569. }
  72570. }
  72571. declare module BABYLON.GUI {
  72572. /**
  72573. * Class used to transport BABYLON.Vector2 information for pointer events
  72574. */
  72575. export class Vector2WithInfo extends BABYLON.Vector2 {
  72576. /** defines the current mouse button index */
  72577. buttonIndex: number;
  72578. /**
  72579. * Creates a new Vector2WithInfo
  72580. * @param source defines the vector2 data to transport
  72581. * @param buttonIndex defines the current mouse button index
  72582. */
  72583. constructor(source: BABYLON.Vector2,
  72584. /** defines the current mouse button index */
  72585. buttonIndex?: number);
  72586. }
  72587. /** Class used to provide 2D matrix features */
  72588. export class Matrix2D {
  72589. /** Gets the internal array of 6 floats used to store matrix data */
  72590. m: Float32Array;
  72591. /**
  72592. * Creates a new matrix
  72593. * @param m00 defines value for (0, 0)
  72594. * @param m01 defines value for (0, 1)
  72595. * @param m10 defines value for (1, 0)
  72596. * @param m11 defines value for (1, 1)
  72597. * @param m20 defines value for (2, 0)
  72598. * @param m21 defines value for (2, 1)
  72599. */
  72600. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  72601. /**
  72602. * Fills the matrix from direct values
  72603. * @param m00 defines value for (0, 0)
  72604. * @param m01 defines value for (0, 1)
  72605. * @param m10 defines value for (1, 0)
  72606. * @param m11 defines value for (1, 1)
  72607. * @param m20 defines value for (2, 0)
  72608. * @param m21 defines value for (2, 1)
  72609. * @returns the current modified matrix
  72610. */
  72611. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  72612. /**
  72613. * Gets matrix determinant
  72614. * @returns the determinant
  72615. */
  72616. determinant(): number;
  72617. /**
  72618. * Inverses the matrix and stores it in a target matrix
  72619. * @param result defines the target matrix
  72620. * @returns the current matrix
  72621. */
  72622. invertToRef(result: Matrix2D): Matrix2D;
  72623. /**
  72624. * Multiplies the current matrix with another one
  72625. * @param other defines the second operand
  72626. * @param result defines the target matrix
  72627. * @returns the current matrix
  72628. */
  72629. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  72630. /**
  72631. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  72632. * @param x defines the x coordinate to transform
  72633. * @param y defines the x coordinate to transform
  72634. * @param result defines the target vector2
  72635. * @returns the current matrix
  72636. */
  72637. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  72638. /**
  72639. * Creates an identity matrix
  72640. * @returns a new matrix
  72641. */
  72642. static Identity(): Matrix2D;
  72643. /**
  72644. * Creates a translation matrix and stores it in a target matrix
  72645. * @param x defines the x coordinate of the translation
  72646. * @param y defines the y coordinate of the translation
  72647. * @param result defines the target matrix
  72648. */
  72649. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  72650. /**
  72651. * Creates a scaling matrix and stores it in a target matrix
  72652. * @param x defines the x coordinate of the scaling
  72653. * @param y defines the y coordinate of the scaling
  72654. * @param result defines the target matrix
  72655. */
  72656. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  72657. /**
  72658. * Creates a rotation matrix and stores it in a target matrix
  72659. * @param angle defines the rotation angle
  72660. * @param result defines the target matrix
  72661. */
  72662. static RotationToRef(angle: number, result: Matrix2D): void;
  72663. private static _TempPreTranslationMatrix;
  72664. private static _TempPostTranslationMatrix;
  72665. private static _TempRotationMatrix;
  72666. private static _TempScalingMatrix;
  72667. private static _TempCompose0;
  72668. private static _TempCompose1;
  72669. private static _TempCompose2;
  72670. /**
  72671. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  72672. * @param tx defines the x coordinate of the translation
  72673. * @param ty defines the y coordinate of the translation
  72674. * @param angle defines the rotation angle
  72675. * @param scaleX defines the x coordinate of the scaling
  72676. * @param scaleY defines the y coordinate of the scaling
  72677. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  72678. * @param result defines the target matrix
  72679. */
  72680. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  72681. }
  72682. }
  72683. declare module BABYLON.GUI {
  72684. /**
  72685. * Class used to store 2D control sizes
  72686. */
  72687. export class Measure {
  72688. /** defines left coordinate */
  72689. left: number;
  72690. /** defines top coordinate */
  72691. top: number;
  72692. /** defines width dimension */
  72693. width: number;
  72694. /** defines height dimension */
  72695. height: number;
  72696. /**
  72697. * Creates a new measure
  72698. * @param left defines left coordinate
  72699. * @param top defines top coordinate
  72700. * @param width defines width dimension
  72701. * @param height defines height dimension
  72702. */
  72703. constructor(
  72704. /** defines left coordinate */
  72705. left: number,
  72706. /** defines top coordinate */
  72707. top: number,
  72708. /** defines width dimension */
  72709. width: number,
  72710. /** defines height dimension */
  72711. height: number);
  72712. /**
  72713. * Copy from another measure
  72714. * @param other defines the other measure to copy from
  72715. */
  72716. copyFrom(other: Measure): void;
  72717. /**
  72718. * Copy from a group of 4 floats
  72719. * @param left defines left coordinate
  72720. * @param top defines top coordinate
  72721. * @param width defines width dimension
  72722. * @param height defines height dimension
  72723. */
  72724. copyFromFloats(left: number, top: number, width: number, height: number): void;
  72725. /**
  72726. * Computes the axis aligned bounding box measure for two given measures
  72727. * @param a Input measure
  72728. * @param b Input measure
  72729. * @param result the resulting bounding measure
  72730. */
  72731. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  72732. /**
  72733. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  72734. * @param transform the matrix to transform the measure before computing the AABB
  72735. * @param result the resulting AABB
  72736. */
  72737. transformToRef(transform: Matrix2D, result: Measure): void;
  72738. /**
  72739. * Check equality between this measure and another one
  72740. * @param other defines the other measures
  72741. * @returns true if both measures are equals
  72742. */
  72743. isEqualsTo(other: Measure): boolean;
  72744. /**
  72745. * Creates an empty measure
  72746. * @returns a new measure
  72747. */
  72748. static Empty(): Measure;
  72749. }
  72750. }
  72751. declare module BABYLON.GUI {
  72752. /**
  72753. * Interface used to define a control that can receive focus
  72754. */
  72755. export interface IFocusableControl {
  72756. /**
  72757. * Function called when the control receives the focus
  72758. */
  72759. onFocus(): void;
  72760. /**
  72761. * Function called when the control loses the focus
  72762. */
  72763. onBlur(): void;
  72764. /**
  72765. * Function called to let the control handle keyboard events
  72766. * @param evt defines the current keyboard event
  72767. */
  72768. processKeyboard(evt: KeyboardEvent): void;
  72769. /**
  72770. * Function called to get the list of controls that should not steal the focus from this control
  72771. * @returns an array of controls
  72772. */
  72773. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72774. }
  72775. /**
  72776. * Class used to create texture to support 2D GUI elements
  72777. * @see http://doc.babylonjs.com/how_to/gui
  72778. */
  72779. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  72780. private _isDirty;
  72781. private _renderObserver;
  72782. private _resizeObserver;
  72783. private _preKeyboardObserver;
  72784. private _pointerMoveObserver;
  72785. private _pointerObserver;
  72786. private _canvasPointerOutObserver;
  72787. private _background;
  72788. /** @hidden */
  72789. _rootContainer: Container;
  72790. /** @hidden */
  72791. _lastPickedControl: Control;
  72792. /** @hidden */
  72793. _lastControlOver: {
  72794. [pointerId: number]: Control;
  72795. };
  72796. /** @hidden */
  72797. _lastControlDown: {
  72798. [pointerId: number]: Control;
  72799. };
  72800. /** @hidden */
  72801. _capturingControl: {
  72802. [pointerId: number]: Control;
  72803. };
  72804. /** @hidden */
  72805. _shouldBlockPointer: boolean;
  72806. /** @hidden */
  72807. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  72808. /** @hidden */
  72809. _linkedControls: Control[];
  72810. private _isFullscreen;
  72811. private _fullscreenViewport;
  72812. private _idealWidth;
  72813. private _idealHeight;
  72814. private _useSmallestIdeal;
  72815. private _renderAtIdealSize;
  72816. private _focusedControl;
  72817. private _blockNextFocusCheck;
  72818. private _renderScale;
  72819. private _rootElement;
  72820. private _cursorChanged;
  72821. private _defaultMousePointerId;
  72822. /** @hidden */
  72823. _numLayoutCalls: number;
  72824. /** Gets the number of layout calls made the last time the ADT has been rendered */
  72825. get numLayoutCalls(): number;
  72826. /** @hidden */
  72827. _numRenderCalls: number;
  72828. /** Gets the number of render calls made the last time the ADT has been rendered */
  72829. get numRenderCalls(): number;
  72830. /**
  72831. * Define type to string to ensure compatibility across browsers
  72832. * Safari doesn't support DataTransfer constructor
  72833. */
  72834. private _clipboardData;
  72835. /**
  72836. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  72837. */
  72838. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  72839. /**
  72840. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  72841. */
  72842. onControlPickedObservable: BABYLON.Observable<Control>;
  72843. /**
  72844. * BABYLON.Observable event triggered before layout is evaluated
  72845. */
  72846. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72847. /**
  72848. * BABYLON.Observable event triggered after the layout was evaluated
  72849. */
  72850. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72851. /**
  72852. * BABYLON.Observable event triggered before the texture is rendered
  72853. */
  72854. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72855. /**
  72856. * BABYLON.Observable event triggered after the texture was rendered
  72857. */
  72858. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72859. /**
  72860. * Gets or sets a boolean defining if alpha is stored as premultiplied
  72861. */
  72862. premulAlpha: boolean;
  72863. /**
  72864. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  72865. * Useful when you want more antialiasing
  72866. */
  72867. get renderScale(): number;
  72868. set renderScale(value: number);
  72869. /** Gets or sets the background color */
  72870. get background(): string;
  72871. set background(value: string);
  72872. /**
  72873. * Gets or sets the ideal width used to design controls.
  72874. * The GUI will then rescale everything accordingly
  72875. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72876. */
  72877. get idealWidth(): number;
  72878. set idealWidth(value: number);
  72879. /**
  72880. * Gets or sets the ideal height used to design controls.
  72881. * The GUI will then rescale everything accordingly
  72882. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72883. */
  72884. get idealHeight(): number;
  72885. set idealHeight(value: number);
  72886. /**
  72887. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  72888. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72889. */
  72890. get useSmallestIdeal(): boolean;
  72891. set useSmallestIdeal(value: boolean);
  72892. /**
  72893. * Gets or sets a boolean indicating if adaptive scaling must be used
  72894. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72895. */
  72896. get renderAtIdealSize(): boolean;
  72897. set renderAtIdealSize(value: boolean);
  72898. /**
  72899. * Gets the ratio used when in "ideal mode"
  72900. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72901. * */
  72902. get idealRatio(): number;
  72903. /**
  72904. * Gets the underlying layer used to render the texture when in fullscreen mode
  72905. */
  72906. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  72907. /**
  72908. * Gets the root container control
  72909. */
  72910. get rootContainer(): Container;
  72911. /**
  72912. * Returns an array containing the root container.
  72913. * This is mostly used to let the Inspector introspects the ADT
  72914. * @returns an array containing the rootContainer
  72915. */
  72916. getChildren(): Array<Container>;
  72917. /**
  72918. * Will return all controls that are inside this texture
  72919. * @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
  72920. * @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
  72921. * @return all child controls
  72922. */
  72923. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72924. /**
  72925. * Gets or sets the current focused control
  72926. */
  72927. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  72928. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  72929. /**
  72930. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  72931. */
  72932. get isForeground(): boolean;
  72933. set isForeground(value: boolean);
  72934. /**
  72935. * Gets or set information about clipboardData
  72936. */
  72937. get clipboardData(): string;
  72938. set clipboardData(value: string);
  72939. /**
  72940. * Creates a new AdvancedDynamicTexture
  72941. * @param name defines the name of the texture
  72942. * @param width defines the width of the texture
  72943. * @param height defines the height of the texture
  72944. * @param scene defines the hosting scene
  72945. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  72946. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  72947. */
  72948. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  72949. /**
  72950. * Get the current class name of the texture useful for serialization or dynamic coding.
  72951. * @returns "AdvancedDynamicTexture"
  72952. */
  72953. getClassName(): string;
  72954. /**
  72955. * Function used to execute a function on all controls
  72956. * @param func defines the function to execute
  72957. * @param container defines the container where controls belong. If null the root container will be used
  72958. */
  72959. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  72960. private _useInvalidateRectOptimization;
  72961. /**
  72962. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  72963. */
  72964. get useInvalidateRectOptimization(): boolean;
  72965. set useInvalidateRectOptimization(value: boolean);
  72966. private _invalidatedRectangle;
  72967. /**
  72968. * Invalidates a rectangle area on the gui texture
  72969. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  72970. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  72971. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  72972. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  72973. */
  72974. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  72975. /**
  72976. * Marks the texture as dirty forcing a complete update
  72977. */
  72978. markAsDirty(): void;
  72979. /**
  72980. * Helper function used to create a new style
  72981. * @returns a new style
  72982. * @see http://doc.babylonjs.com/how_to/gui#styles
  72983. */
  72984. createStyle(): Style;
  72985. /**
  72986. * Adds a new control to the root container
  72987. * @param control defines the control to add
  72988. * @returns the current texture
  72989. */
  72990. addControl(control: Control): AdvancedDynamicTexture;
  72991. /**
  72992. * Removes a control from the root container
  72993. * @param control defines the control to remove
  72994. * @returns the current texture
  72995. */
  72996. removeControl(control: Control): AdvancedDynamicTexture;
  72997. /**
  72998. * Release all resources
  72999. */
  73000. dispose(): void;
  73001. private _onResize;
  73002. /** @hidden */
  73003. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73004. /**
  73005. * Get screen coordinates for a vector3
  73006. * @param position defines the position to project
  73007. * @param worldMatrix defines the world matrix to use
  73008. * @returns the projected position
  73009. */
  73010. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73011. private _checkUpdate;
  73012. private _clearMeasure;
  73013. private _render;
  73014. /** @hidden */
  73015. _changeCursor(cursor: string): void;
  73016. /** @hidden */
  73017. _registerLastControlDown(control: Control, pointerId: number): void;
  73018. private _doPicking;
  73019. /** @hidden */
  73020. _cleanControlAfterRemovalFromList(list: {
  73021. [pointerId: number]: Control;
  73022. }, control: Control): void;
  73023. /** @hidden */
  73024. _cleanControlAfterRemoval(control: Control): void;
  73025. /** Attach to all scene events required to support pointer events */
  73026. attach(): void;
  73027. /** @hidden */
  73028. private onClipboardCopy;
  73029. /** @hidden */
  73030. private onClipboardCut;
  73031. /** @hidden */
  73032. private onClipboardPaste;
  73033. /**
  73034. * Register the clipboard Events onto the canvas
  73035. */
  73036. registerClipboardEvents(): void;
  73037. /**
  73038. * Unregister the clipboard Events from the canvas
  73039. */
  73040. unRegisterClipboardEvents(): void;
  73041. /**
  73042. * Connect the texture to a hosting mesh to enable interactions
  73043. * @param mesh defines the mesh to attach to
  73044. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  73045. */
  73046. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  73047. /**
  73048. * Move the focus to a specific control
  73049. * @param control defines the control which will receive the focus
  73050. */
  73051. moveFocusToControl(control: IFocusableControl): void;
  73052. private _manageFocus;
  73053. private _attachToOnPointerOut;
  73054. /**
  73055. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  73056. * @param mesh defines the mesh which will receive the texture
  73057. * @param width defines the texture width (1024 by default)
  73058. * @param height defines the texture height (1024 by default)
  73059. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  73060. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  73061. * @returns a new AdvancedDynamicTexture
  73062. */
  73063. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  73064. /**
  73065. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  73066. * In this mode the texture will rely on a layer for its rendering.
  73067. * This allows it to be treated like any other layer.
  73068. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  73069. * LayerMask is set through advancedTexture.layer.layerMask
  73070. * @param name defines name for the texture
  73071. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  73072. * @param scene defines the hsoting scene
  73073. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  73074. * @returns a new AdvancedDynamicTexture
  73075. */
  73076. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  73077. }
  73078. }
  73079. declare module BABYLON.GUI {
  73080. /**
  73081. * Root class used for all 2D controls
  73082. * @see http://doc.babylonjs.com/how_to/gui#controls
  73083. */
  73084. export class Control {
  73085. /** defines the name of the control */
  73086. name?: string | undefined;
  73087. /**
  73088. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  73089. */
  73090. static AllowAlphaInheritance: boolean;
  73091. private _alpha;
  73092. private _alphaSet;
  73093. private _zIndex;
  73094. /** @hidden */
  73095. _host: AdvancedDynamicTexture;
  73096. /** Gets or sets the control parent */
  73097. parent: BABYLON.Nullable<Container>;
  73098. /** @hidden */
  73099. _currentMeasure: Measure;
  73100. private _fontFamily;
  73101. private _fontStyle;
  73102. private _fontWeight;
  73103. private _fontSize;
  73104. private _font;
  73105. /** @hidden */
  73106. _width: ValueAndUnit;
  73107. /** @hidden */
  73108. _height: ValueAndUnit;
  73109. /** @hidden */
  73110. protected _fontOffset: {
  73111. ascent: number;
  73112. height: number;
  73113. descent: number;
  73114. };
  73115. private _color;
  73116. private _style;
  73117. private _styleObserver;
  73118. /** @hidden */
  73119. protected _horizontalAlignment: number;
  73120. /** @hidden */
  73121. protected _verticalAlignment: number;
  73122. /** @hidden */
  73123. protected _isDirty: boolean;
  73124. /** @hidden */
  73125. protected _wasDirty: boolean;
  73126. /** @hidden */
  73127. _tempParentMeasure: Measure;
  73128. /** @hidden */
  73129. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  73130. /** @hidden */
  73131. protected _cachedParentMeasure: Measure;
  73132. private _paddingLeft;
  73133. private _paddingRight;
  73134. private _paddingTop;
  73135. private _paddingBottom;
  73136. /** @hidden */
  73137. _left: ValueAndUnit;
  73138. /** @hidden */
  73139. _top: ValueAndUnit;
  73140. private _scaleX;
  73141. private _scaleY;
  73142. private _rotation;
  73143. private _transformCenterX;
  73144. private _transformCenterY;
  73145. /** @hidden */
  73146. _transformMatrix: Matrix2D;
  73147. /** @hidden */
  73148. protected _invertTransformMatrix: Matrix2D;
  73149. /** @hidden */
  73150. protected _transformedPosition: BABYLON.Vector2;
  73151. private _isMatrixDirty;
  73152. private _cachedOffsetX;
  73153. private _cachedOffsetY;
  73154. private _isVisible;
  73155. private _isHighlighted;
  73156. /** @hidden */
  73157. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  73158. private _fontSet;
  73159. private _dummyVector2;
  73160. private _downCount;
  73161. private _enterCount;
  73162. private _doNotRender;
  73163. private _downPointerIds;
  73164. protected _isEnabled: boolean;
  73165. protected _disabledColor: string;
  73166. protected _disabledColorItem: string;
  73167. /** @hidden */
  73168. protected _rebuildLayout: boolean;
  73169. /** @hidden */
  73170. _customData: any;
  73171. /** @hidden */
  73172. _isClipped: boolean;
  73173. /** @hidden */
  73174. _automaticSize: boolean;
  73175. /** @hidden */
  73176. _tag: any;
  73177. /**
  73178. * 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
  73179. */
  73180. uniqueId: number;
  73181. /**
  73182. * Gets or sets an object used to store user defined information for the node
  73183. */
  73184. metadata: any;
  73185. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  73186. isHitTestVisible: boolean;
  73187. /** Gets or sets a boolean indicating if the control can block pointer events */
  73188. isPointerBlocker: boolean;
  73189. /** Gets or sets a boolean indicating if the control can be focusable */
  73190. isFocusInvisible: boolean;
  73191. /**
  73192. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  73193. * 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
  73194. */
  73195. clipChildren: boolean;
  73196. /**
  73197. * Gets or sets a boolean indicating that control content must be clipped
  73198. * 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
  73199. */
  73200. clipContent: boolean;
  73201. /**
  73202. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  73203. */
  73204. useBitmapCache: boolean;
  73205. private _cacheData;
  73206. private _shadowOffsetX;
  73207. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  73208. get shadowOffsetX(): number;
  73209. set shadowOffsetX(value: number);
  73210. private _shadowOffsetY;
  73211. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  73212. get shadowOffsetY(): number;
  73213. set shadowOffsetY(value: number);
  73214. private _shadowBlur;
  73215. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  73216. get shadowBlur(): number;
  73217. set shadowBlur(value: number);
  73218. private _shadowColor;
  73219. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  73220. get shadowColor(): string;
  73221. set shadowColor(value: string);
  73222. /** Gets or sets the cursor to use when the control is hovered */
  73223. hoverCursor: string;
  73224. /** @hidden */
  73225. protected _linkOffsetX: ValueAndUnit;
  73226. /** @hidden */
  73227. protected _linkOffsetY: ValueAndUnit;
  73228. /** Gets the control type name */
  73229. get typeName(): string;
  73230. /**
  73231. * Get the current class name of the control.
  73232. * @returns current class name
  73233. */
  73234. getClassName(): string;
  73235. /**
  73236. * An event triggered when pointer wheel is scrolled
  73237. */
  73238. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  73239. /**
  73240. * An event triggered when the pointer move over the control.
  73241. */
  73242. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  73243. /**
  73244. * An event triggered when the pointer move out of the control.
  73245. */
  73246. onPointerOutObservable: BABYLON.Observable<Control>;
  73247. /**
  73248. * An event triggered when the pointer taps the control
  73249. */
  73250. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  73251. /**
  73252. * An event triggered when pointer up
  73253. */
  73254. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  73255. /**
  73256. * An event triggered when a control is clicked on
  73257. */
  73258. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  73259. /**
  73260. * An event triggered when pointer enters the control
  73261. */
  73262. onPointerEnterObservable: BABYLON.Observable<Control>;
  73263. /**
  73264. * An event triggered when the control is marked as dirty
  73265. */
  73266. onDirtyObservable: BABYLON.Observable<Control>;
  73267. /**
  73268. * An event triggered before drawing the control
  73269. */
  73270. onBeforeDrawObservable: BABYLON.Observable<Control>;
  73271. /**
  73272. * An event triggered after the control was drawn
  73273. */
  73274. onAfterDrawObservable: BABYLON.Observable<Control>;
  73275. /**
  73276. * An event triggered when the control has been disposed
  73277. */
  73278. onDisposeObservable: BABYLON.Observable<Control>;
  73279. /**
  73280. * Get the hosting AdvancedDynamicTexture
  73281. */
  73282. get host(): AdvancedDynamicTexture;
  73283. /** Gets or set information about font offsets (used to render and align text) */
  73284. get fontOffset(): {
  73285. ascent: number;
  73286. height: number;
  73287. descent: number;
  73288. };
  73289. set fontOffset(offset: {
  73290. ascent: number;
  73291. height: number;
  73292. descent: number;
  73293. });
  73294. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  73295. get alpha(): number;
  73296. set alpha(value: number);
  73297. /**
  73298. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  73299. */
  73300. get isHighlighted(): boolean;
  73301. set isHighlighted(value: boolean);
  73302. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  73303. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73304. */
  73305. get scaleX(): number;
  73306. set scaleX(value: number);
  73307. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  73308. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73309. */
  73310. get scaleY(): number;
  73311. set scaleY(value: number);
  73312. /** Gets or sets the rotation angle (0 by default)
  73313. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73314. */
  73315. get rotation(): number;
  73316. set rotation(value: number);
  73317. /** Gets or sets the transformation center on Y axis (0 by default)
  73318. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73319. */
  73320. get transformCenterY(): number;
  73321. set transformCenterY(value: number);
  73322. /** Gets or sets the transformation center on X axis (0 by default)
  73323. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73324. */
  73325. get transformCenterX(): number;
  73326. set transformCenterX(value: number);
  73327. /**
  73328. * Gets or sets the horizontal alignment
  73329. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73330. */
  73331. get horizontalAlignment(): number;
  73332. set horizontalAlignment(value: number);
  73333. /**
  73334. * Gets or sets the vertical alignment
  73335. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73336. */
  73337. get verticalAlignment(): number;
  73338. set verticalAlignment(value: number);
  73339. /**
  73340. * Gets or sets control width
  73341. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73342. */
  73343. get width(): string | number;
  73344. set width(value: string | number);
  73345. /**
  73346. * Gets or sets the control width in pixel
  73347. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73348. */
  73349. get widthInPixels(): number;
  73350. set widthInPixels(value: number);
  73351. /**
  73352. * Gets or sets control height
  73353. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73354. */
  73355. get height(): string | number;
  73356. set height(value: string | number);
  73357. /**
  73358. * Gets or sets control height in pixel
  73359. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73360. */
  73361. get heightInPixels(): number;
  73362. set heightInPixels(value: number);
  73363. /** Gets or set font family */
  73364. get fontFamily(): string;
  73365. set fontFamily(value: string);
  73366. /** Gets or sets font style */
  73367. get fontStyle(): string;
  73368. set fontStyle(value: string);
  73369. /** Gets or sets font weight */
  73370. get fontWeight(): string;
  73371. set fontWeight(value: string);
  73372. /**
  73373. * Gets or sets style
  73374. * @see http://doc.babylonjs.com/how_to/gui#styles
  73375. */
  73376. get style(): BABYLON.Nullable<Style>;
  73377. set style(value: BABYLON.Nullable<Style>);
  73378. /** @hidden */
  73379. get _isFontSizeInPercentage(): boolean;
  73380. /** Gets or sets font size in pixels */
  73381. get fontSizeInPixels(): number;
  73382. set fontSizeInPixels(value: number);
  73383. /** Gets or sets font size */
  73384. get fontSize(): string | number;
  73385. set fontSize(value: string | number);
  73386. /** Gets or sets foreground color */
  73387. get color(): string;
  73388. set color(value: string);
  73389. /** Gets or sets z index which is used to reorder controls on the z axis */
  73390. get zIndex(): number;
  73391. set zIndex(value: number);
  73392. /** Gets or sets a boolean indicating if the control can be rendered */
  73393. get notRenderable(): boolean;
  73394. set notRenderable(value: boolean);
  73395. /** Gets or sets a boolean indicating if the control is visible */
  73396. get isVisible(): boolean;
  73397. set isVisible(value: boolean);
  73398. /** Gets a boolean indicating that the control needs to update its rendering */
  73399. get isDirty(): boolean;
  73400. /**
  73401. * Gets the current linked mesh (or null if none)
  73402. */
  73403. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73404. /**
  73405. * Gets or sets a value indicating the padding to use on the left of the control
  73406. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73407. */
  73408. get paddingLeft(): string | number;
  73409. set paddingLeft(value: string | number);
  73410. /**
  73411. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  73412. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73413. */
  73414. get paddingLeftInPixels(): number;
  73415. set paddingLeftInPixels(value: number);
  73416. /**
  73417. * Gets or sets a value indicating the padding to use on the right of the control
  73418. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73419. */
  73420. get paddingRight(): string | number;
  73421. set paddingRight(value: string | number);
  73422. /**
  73423. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  73424. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73425. */
  73426. get paddingRightInPixels(): number;
  73427. set paddingRightInPixels(value: number);
  73428. /**
  73429. * Gets or sets a value indicating the padding to use on the top of the control
  73430. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73431. */
  73432. get paddingTop(): string | number;
  73433. set paddingTop(value: string | number);
  73434. /**
  73435. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  73436. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73437. */
  73438. get paddingTopInPixels(): number;
  73439. set paddingTopInPixels(value: number);
  73440. /**
  73441. * Gets or sets a value indicating the padding to use on the bottom of the control
  73442. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73443. */
  73444. get paddingBottom(): string | number;
  73445. set paddingBottom(value: string | number);
  73446. /**
  73447. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  73448. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73449. */
  73450. get paddingBottomInPixels(): number;
  73451. set paddingBottomInPixels(value: number);
  73452. /**
  73453. * Gets or sets a value indicating the left coordinate of the control
  73454. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73455. */
  73456. get left(): string | number;
  73457. set left(value: string | number);
  73458. /**
  73459. * Gets or sets a value indicating the left coordinate in pixels of the control
  73460. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73461. */
  73462. get leftInPixels(): number;
  73463. set leftInPixels(value: number);
  73464. /**
  73465. * Gets or sets a value indicating the top coordinate of the control
  73466. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73467. */
  73468. get top(): string | number;
  73469. set top(value: string | number);
  73470. /**
  73471. * Gets or sets a value indicating the top coordinate in pixels of the control
  73472. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73473. */
  73474. get topInPixels(): number;
  73475. set topInPixels(value: number);
  73476. /**
  73477. * Gets or sets a value indicating the offset on X axis to the linked mesh
  73478. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73479. */
  73480. get linkOffsetX(): string | number;
  73481. set linkOffsetX(value: string | number);
  73482. /**
  73483. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  73484. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73485. */
  73486. get linkOffsetXInPixels(): number;
  73487. set linkOffsetXInPixels(value: number);
  73488. /**
  73489. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  73490. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73491. */
  73492. get linkOffsetY(): string | number;
  73493. set linkOffsetY(value: string | number);
  73494. /**
  73495. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  73496. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73497. */
  73498. get linkOffsetYInPixels(): number;
  73499. set linkOffsetYInPixels(value: number);
  73500. /** Gets the center coordinate on X axis */
  73501. get centerX(): number;
  73502. /** Gets the center coordinate on Y axis */
  73503. get centerY(): number;
  73504. /** Gets or sets if control is Enabled*/
  73505. get isEnabled(): boolean;
  73506. set isEnabled(value: boolean);
  73507. /** Gets or sets background color of control if it's disabled*/
  73508. get disabledColor(): string;
  73509. set disabledColor(value: string);
  73510. /** Gets or sets front color of control if it's disabled*/
  73511. get disabledColorItem(): string;
  73512. set disabledColorItem(value: string);
  73513. /**
  73514. * Creates a new control
  73515. * @param name defines the name of the control
  73516. */
  73517. constructor(
  73518. /** defines the name of the control */
  73519. name?: string | undefined);
  73520. /** @hidden */
  73521. protected _getTypeName(): string;
  73522. /**
  73523. * Gets the first ascendant in the hierarchy of the given type
  73524. * @param className defines the required type
  73525. * @returns the ascendant or null if not found
  73526. */
  73527. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  73528. /** @hidden */
  73529. _resetFontCache(): void;
  73530. /**
  73531. * Determines if a container is an ascendant of the current control
  73532. * @param container defines the container to look for
  73533. * @returns true if the container is one of the ascendant of the control
  73534. */
  73535. isAscendant(container: Control): boolean;
  73536. /**
  73537. * Gets coordinates in local control space
  73538. * @param globalCoordinates defines the coordinates to transform
  73539. * @returns the new coordinates in local space
  73540. */
  73541. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73542. /**
  73543. * Gets coordinates in local control space
  73544. * @param globalCoordinates defines the coordinates to transform
  73545. * @param result defines the target vector2 where to store the result
  73546. * @returns the current control
  73547. */
  73548. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  73549. /**
  73550. * Gets coordinates in parent local control space
  73551. * @param globalCoordinates defines the coordinates to transform
  73552. * @returns the new coordinates in parent local space
  73553. */
  73554. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73555. /**
  73556. * Move the current control to a vector3 position projected onto the screen.
  73557. * @param position defines the target position
  73558. * @param scene defines the hosting scene
  73559. */
  73560. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  73561. /**
  73562. * Will store all controls that have this control as ascendant in a given array
  73563. * @param results defines the array where to store the descendants
  73564. * @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
  73565. * @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
  73566. */
  73567. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73568. /**
  73569. * Will return all controls that have this control as ascendant
  73570. * @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
  73571. * @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
  73572. * @return all child controls
  73573. */
  73574. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73575. /**
  73576. * Link current control with a target mesh
  73577. * @param mesh defines the mesh to link with
  73578. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73579. */
  73580. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  73581. /** @hidden */
  73582. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  73583. /** @hidden */
  73584. _offsetLeft(offset: number): void;
  73585. /** @hidden */
  73586. _offsetTop(offset: number): void;
  73587. /** @hidden */
  73588. _markMatrixAsDirty(): void;
  73589. /** @hidden */
  73590. _flagDescendantsAsMatrixDirty(): void;
  73591. /** @hidden */
  73592. _intersectsRect(rect: Measure): boolean;
  73593. /** @hidden */
  73594. protected invalidateRect(): void;
  73595. /** @hidden */
  73596. _markAsDirty(force?: boolean): void;
  73597. /** @hidden */
  73598. _markAllAsDirty(): void;
  73599. /** @hidden */
  73600. _link(host: AdvancedDynamicTexture): void;
  73601. /** @hidden */
  73602. protected _transform(context?: CanvasRenderingContext2D): void;
  73603. /** @hidden */
  73604. _renderHighlight(context: CanvasRenderingContext2D): void;
  73605. /** @hidden */
  73606. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73607. /** @hidden */
  73608. protected _applyStates(context: CanvasRenderingContext2D): void;
  73609. /** @hidden */
  73610. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73611. /** @hidden */
  73612. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73613. protected _evaluateClippingState(parentMeasure: Measure): void;
  73614. /** @hidden */
  73615. _measure(): void;
  73616. /** @hidden */
  73617. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73618. /** @hidden */
  73619. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73620. /** @hidden */
  73621. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73622. /** @hidden */
  73623. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73624. private static _ClipMeasure;
  73625. private _tmpMeasureA;
  73626. private _clip;
  73627. /** @hidden */
  73628. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  73629. /** @hidden */
  73630. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73631. /**
  73632. * Tests if a given coordinates belong to the current control
  73633. * @param x defines x coordinate to test
  73634. * @param y defines y coordinate to test
  73635. * @returns true if the coordinates are inside the control
  73636. */
  73637. contains(x: number, y: number): boolean;
  73638. /** @hidden */
  73639. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73640. /** @hidden */
  73641. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73642. /** @hidden */
  73643. _onPointerEnter(target: Control): boolean;
  73644. /** @hidden */
  73645. _onPointerOut(target: Control, force?: boolean): void;
  73646. /** @hidden */
  73647. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73648. /** @hidden */
  73649. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73650. /** @hidden */
  73651. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73652. /** @hidden */
  73653. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  73654. /** @hidden */
  73655. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73656. private _prepareFont;
  73657. /** Releases associated resources */
  73658. dispose(): void;
  73659. private static _HORIZONTAL_ALIGNMENT_LEFT;
  73660. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  73661. private static _HORIZONTAL_ALIGNMENT_CENTER;
  73662. private static _VERTICAL_ALIGNMENT_TOP;
  73663. private static _VERTICAL_ALIGNMENT_BOTTOM;
  73664. private static _VERTICAL_ALIGNMENT_CENTER;
  73665. /** HORIZONTAL_ALIGNMENT_LEFT */
  73666. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  73667. /** HORIZONTAL_ALIGNMENT_RIGHT */
  73668. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  73669. /** HORIZONTAL_ALIGNMENT_CENTER */
  73670. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  73671. /** VERTICAL_ALIGNMENT_TOP */
  73672. static get VERTICAL_ALIGNMENT_TOP(): number;
  73673. /** VERTICAL_ALIGNMENT_BOTTOM */
  73674. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  73675. /** VERTICAL_ALIGNMENT_CENTER */
  73676. static get VERTICAL_ALIGNMENT_CENTER(): number;
  73677. private static _FontHeightSizes;
  73678. /** @hidden */
  73679. static _GetFontOffset(font: string): {
  73680. ascent: number;
  73681. height: number;
  73682. descent: number;
  73683. };
  73684. /**
  73685. * Creates a stack panel that can be used to render headers
  73686. * @param control defines the control to associate with the header
  73687. * @param text defines the text of the header
  73688. * @param size defines the size of the header
  73689. * @param options defines options used to configure the header
  73690. * @returns a new StackPanel
  73691. * @ignore
  73692. * @hidden
  73693. */
  73694. static AddHeader: (control: Control, text: string, size: string | number, options: {
  73695. isHorizontal: boolean;
  73696. controlFirst: boolean;
  73697. }) => any;
  73698. /** @hidden */
  73699. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  73700. }
  73701. }
  73702. declare module BABYLON.GUI {
  73703. /**
  73704. * Root class for 2D containers
  73705. * @see http://doc.babylonjs.com/how_to/gui#containers
  73706. */
  73707. export class Container extends Control {
  73708. name?: string | undefined;
  73709. /** @hidden */
  73710. _children: Control[];
  73711. /** @hidden */
  73712. protected _measureForChildren: Measure;
  73713. /** @hidden */
  73714. protected _background: string;
  73715. /** @hidden */
  73716. protected _adaptWidthToChildren: boolean;
  73717. /** @hidden */
  73718. protected _adaptHeightToChildren: boolean;
  73719. /**
  73720. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  73721. */
  73722. logLayoutCycleErrors: boolean;
  73723. /**
  73724. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  73725. */
  73726. maxLayoutCycle: number;
  73727. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  73728. get adaptHeightToChildren(): boolean;
  73729. set adaptHeightToChildren(value: boolean);
  73730. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  73731. get adaptWidthToChildren(): boolean;
  73732. set adaptWidthToChildren(value: boolean);
  73733. /** Gets or sets background color */
  73734. get background(): string;
  73735. set background(value: string);
  73736. /** Gets the list of children */
  73737. get children(): Control[];
  73738. /**
  73739. * Creates a new Container
  73740. * @param name defines the name of the container
  73741. */
  73742. constructor(name?: string | undefined);
  73743. protected _getTypeName(): string;
  73744. _flagDescendantsAsMatrixDirty(): void;
  73745. /**
  73746. * Gets a child using its name
  73747. * @param name defines the child name to look for
  73748. * @returns the child control if found
  73749. */
  73750. getChildByName(name: string): BABYLON.Nullable<Control>;
  73751. /**
  73752. * Gets a child using its type and its name
  73753. * @param name defines the child name to look for
  73754. * @param type defines the child type to look for
  73755. * @returns the child control if found
  73756. */
  73757. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  73758. /**
  73759. * Search for a specific control in children
  73760. * @param control defines the control to look for
  73761. * @returns true if the control is in child list
  73762. */
  73763. containsControl(control: Control): boolean;
  73764. /**
  73765. * Adds a new control to the current container
  73766. * @param control defines the control to add
  73767. * @returns the current container
  73768. */
  73769. addControl(control: BABYLON.Nullable<Control>): Container;
  73770. /**
  73771. * Removes all controls from the current container
  73772. * @returns the current container
  73773. */
  73774. clearControls(): Container;
  73775. /**
  73776. * Removes a control from the current container
  73777. * @param control defines the control to remove
  73778. * @returns the current container
  73779. */
  73780. removeControl(control: Control): Container;
  73781. /** @hidden */
  73782. _reOrderControl(control: Control): void;
  73783. /** @hidden */
  73784. _offsetLeft(offset: number): void;
  73785. /** @hidden */
  73786. _offsetTop(offset: number): void;
  73787. /** @hidden */
  73788. _markAllAsDirty(): void;
  73789. /** @hidden */
  73790. protected _localDraw(context: CanvasRenderingContext2D): void;
  73791. /** @hidden */
  73792. _link(host: AdvancedDynamicTexture): void;
  73793. /** @hidden */
  73794. protected _beforeLayout(): void;
  73795. /** @hidden */
  73796. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73797. /** @hidden */
  73798. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73799. protected _postMeasure(): void;
  73800. /** @hidden */
  73801. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73802. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73803. /** @hidden */
  73804. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73805. /** @hidden */
  73806. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73807. /** Releases associated resources */
  73808. dispose(): void;
  73809. }
  73810. }
  73811. declare module BABYLON.GUI {
  73812. /** Class used to create rectangle container */
  73813. export class Rectangle extends Container {
  73814. name?: string | undefined;
  73815. private _thickness;
  73816. private _cornerRadius;
  73817. /** Gets or sets border thickness */
  73818. get thickness(): number;
  73819. set thickness(value: number);
  73820. /** Gets or sets the corner radius angle */
  73821. get cornerRadius(): number;
  73822. set cornerRadius(value: number);
  73823. /**
  73824. * Creates a new Rectangle
  73825. * @param name defines the control name
  73826. */
  73827. constructor(name?: string | undefined);
  73828. protected _getTypeName(): string;
  73829. protected _localDraw(context: CanvasRenderingContext2D): void;
  73830. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73831. private _drawRoundedRect;
  73832. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73833. }
  73834. }
  73835. declare module BABYLON.GUI {
  73836. /**
  73837. * Enum that determines the text-wrapping mode to use.
  73838. */
  73839. export enum TextWrapping {
  73840. /**
  73841. * Clip the text when it's larger than Control.width; this is the default mode.
  73842. */
  73843. Clip = 0,
  73844. /**
  73845. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  73846. */
  73847. WordWrap = 1,
  73848. /**
  73849. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  73850. */
  73851. Ellipsis = 2
  73852. }
  73853. /**
  73854. * Class used to create text block control
  73855. */
  73856. export class TextBlock extends Control {
  73857. /**
  73858. * Defines the name of the control
  73859. */
  73860. name?: string | undefined;
  73861. private _text;
  73862. private _textWrapping;
  73863. private _textHorizontalAlignment;
  73864. private _textVerticalAlignment;
  73865. private _lines;
  73866. private _resizeToFit;
  73867. private _lineSpacing;
  73868. private _outlineWidth;
  73869. private _outlineColor;
  73870. /**
  73871. * An event triggered after the text is changed
  73872. */
  73873. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  73874. /**
  73875. * An event triggered after the text was broken up into lines
  73876. */
  73877. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  73878. /**
  73879. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  73880. */
  73881. get lines(): any[];
  73882. /**
  73883. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  73884. */
  73885. get resizeToFit(): boolean;
  73886. /**
  73887. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  73888. */
  73889. set resizeToFit(value: boolean);
  73890. /**
  73891. * Gets or sets a boolean indicating if text must be wrapped
  73892. */
  73893. get textWrapping(): TextWrapping | boolean;
  73894. /**
  73895. * Gets or sets a boolean indicating if text must be wrapped
  73896. */
  73897. set textWrapping(value: TextWrapping | boolean);
  73898. /**
  73899. * Gets or sets text to display
  73900. */
  73901. get text(): string;
  73902. /**
  73903. * Gets or sets text to display
  73904. */
  73905. set text(value: string);
  73906. /**
  73907. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  73908. */
  73909. get textHorizontalAlignment(): number;
  73910. /**
  73911. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  73912. */
  73913. set textHorizontalAlignment(value: number);
  73914. /**
  73915. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  73916. */
  73917. get textVerticalAlignment(): number;
  73918. /**
  73919. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  73920. */
  73921. set textVerticalAlignment(value: number);
  73922. /**
  73923. * Gets or sets line spacing value
  73924. */
  73925. set lineSpacing(value: string | number);
  73926. /**
  73927. * Gets or sets line spacing value
  73928. */
  73929. get lineSpacing(): string | number;
  73930. /**
  73931. * Gets or sets outlineWidth of the text to display
  73932. */
  73933. get outlineWidth(): number;
  73934. /**
  73935. * Gets or sets outlineWidth of the text to display
  73936. */
  73937. set outlineWidth(value: number);
  73938. /**
  73939. * Gets or sets outlineColor of the text to display
  73940. */
  73941. get outlineColor(): string;
  73942. /**
  73943. * Gets or sets outlineColor of the text to display
  73944. */
  73945. set outlineColor(value: string);
  73946. /**
  73947. * Creates a new TextBlock object
  73948. * @param name defines the name of the control
  73949. * @param text defines the text to display (emptry string by default)
  73950. */
  73951. constructor(
  73952. /**
  73953. * Defines the name of the control
  73954. */
  73955. name?: string | undefined, text?: string);
  73956. protected _getTypeName(): string;
  73957. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73958. private _drawText;
  73959. /** @hidden */
  73960. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73961. protected _applyStates(context: CanvasRenderingContext2D): void;
  73962. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  73963. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  73964. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  73965. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  73966. protected _renderLines(context: CanvasRenderingContext2D): void;
  73967. /**
  73968. * Given a width constraint applied on the text block, find the expected height
  73969. * @returns expected height
  73970. */
  73971. computeExpectedHeight(): number;
  73972. dispose(): void;
  73973. }
  73974. }
  73975. declare module BABYLON.GUI {
  73976. /**
  73977. * Class used to create 2D images
  73978. */
  73979. export class Image extends Control {
  73980. name?: string | undefined;
  73981. private _workingCanvas;
  73982. private _domImage;
  73983. private _imageWidth;
  73984. private _imageHeight;
  73985. private _loaded;
  73986. private _stretch;
  73987. private _source;
  73988. private _autoScale;
  73989. private _sourceLeft;
  73990. private _sourceTop;
  73991. private _sourceWidth;
  73992. private _sourceHeight;
  73993. private _svgAttributesComputationCompleted;
  73994. private _isSVG;
  73995. private _cellWidth;
  73996. private _cellHeight;
  73997. private _cellId;
  73998. private _populateNinePatchSlicesFromImage;
  73999. private _sliceLeft;
  74000. private _sliceRight;
  74001. private _sliceTop;
  74002. private _sliceBottom;
  74003. private _detectPointerOnOpaqueOnly;
  74004. /**
  74005. * BABYLON.Observable notified when the content is loaded
  74006. */
  74007. onImageLoadedObservable: BABYLON.Observable<Image>;
  74008. /**
  74009. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74010. */
  74011. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74012. /**
  74013. * Gets a boolean indicating that the content is loaded
  74014. */
  74015. get isLoaded(): boolean;
  74016. /**
  74017. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74018. */
  74019. get populateNinePatchSlicesFromImage(): boolean;
  74020. set populateNinePatchSlicesFromImage(value: boolean);
  74021. /**
  74022. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  74023. * Beware using this as this will comsume more memory as the image has to be stored twice
  74024. */
  74025. get detectPointerOnOpaqueOnly(): boolean;
  74026. set detectPointerOnOpaqueOnly(value: boolean);
  74027. /**
  74028. * Gets or sets the left value for slicing (9-patch)
  74029. */
  74030. get sliceLeft(): number;
  74031. set sliceLeft(value: number);
  74032. /**
  74033. * Gets or sets the right value for slicing (9-patch)
  74034. */
  74035. get sliceRight(): number;
  74036. set sliceRight(value: number);
  74037. /**
  74038. * Gets or sets the top value for slicing (9-patch)
  74039. */
  74040. get sliceTop(): number;
  74041. set sliceTop(value: number);
  74042. /**
  74043. * Gets or sets the bottom value for slicing (9-patch)
  74044. */
  74045. get sliceBottom(): number;
  74046. set sliceBottom(value: number);
  74047. /**
  74048. * Gets or sets the left coordinate in the source image
  74049. */
  74050. get sourceLeft(): number;
  74051. set sourceLeft(value: number);
  74052. /**
  74053. * Gets or sets the top coordinate in the source image
  74054. */
  74055. get sourceTop(): number;
  74056. set sourceTop(value: number);
  74057. /**
  74058. * Gets or sets the width to capture in the source image
  74059. */
  74060. get sourceWidth(): number;
  74061. set sourceWidth(value: number);
  74062. /**
  74063. * Gets or sets the height to capture in the source image
  74064. */
  74065. get sourceHeight(): number;
  74066. set sourceHeight(value: number);
  74067. /** Indicates if the format of the image is SVG */
  74068. get isSVG(): boolean;
  74069. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  74070. get svgAttributesComputationCompleted(): boolean;
  74071. /**
  74072. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  74073. * @see http://doc.babylonjs.com/how_to/gui#image
  74074. */
  74075. get autoScale(): boolean;
  74076. set autoScale(value: boolean);
  74077. /** Gets or sets the streching mode used by the image */
  74078. get stretch(): number;
  74079. set stretch(value: number);
  74080. /** @hidden */
  74081. _rotate90(n: number, preserveProperties?: boolean): Image;
  74082. private _handleRotationForSVGImage;
  74083. private _rotate90SourceProperties;
  74084. /**
  74085. * Gets or sets the internal DOM image used to render the control
  74086. */
  74087. set domImage(value: HTMLImageElement);
  74088. get domImage(): HTMLImageElement;
  74089. private _onImageLoaded;
  74090. private _extractNinePatchSliceDataFromImage;
  74091. /**
  74092. * Gets or sets image source url
  74093. */
  74094. set source(value: BABYLON.Nullable<string>);
  74095. /**
  74096. * Checks for svg document with icon id present
  74097. */
  74098. private _svgCheck;
  74099. /**
  74100. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  74101. * given external svg file and icon id
  74102. */
  74103. private _getSVGAttribs;
  74104. /**
  74105. * Gets or sets the cell width to use when animation sheet is enabled
  74106. * @see http://doc.babylonjs.com/how_to/gui#image
  74107. */
  74108. get cellWidth(): number;
  74109. set cellWidth(value: number);
  74110. /**
  74111. * Gets or sets the cell height to use when animation sheet is enabled
  74112. * @see http://doc.babylonjs.com/how_to/gui#image
  74113. */
  74114. get cellHeight(): number;
  74115. set cellHeight(value: number);
  74116. /**
  74117. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  74118. * @see http://doc.babylonjs.com/how_to/gui#image
  74119. */
  74120. get cellId(): number;
  74121. set cellId(value: number);
  74122. /**
  74123. * Creates a new Image
  74124. * @param name defines the control name
  74125. * @param url defines the image url
  74126. */
  74127. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  74128. /**
  74129. * Tests if a given coordinates belong to the current control
  74130. * @param x defines x coordinate to test
  74131. * @param y defines y coordinate to test
  74132. * @returns true if the coordinates are inside the control
  74133. */
  74134. contains(x: number, y: number): boolean;
  74135. protected _getTypeName(): string;
  74136. /** Force the control to synchronize with its content */
  74137. synchronizeSizeWithContent(): void;
  74138. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74139. private _prepareWorkingCanvasForOpaqueDetection;
  74140. private _drawImage;
  74141. _draw(context: CanvasRenderingContext2D): void;
  74142. private _renderCornerPatch;
  74143. private _renderNinePatch;
  74144. dispose(): void;
  74145. /** STRETCH_NONE */
  74146. static readonly STRETCH_NONE: number;
  74147. /** STRETCH_FILL */
  74148. static readonly STRETCH_FILL: number;
  74149. /** STRETCH_UNIFORM */
  74150. static readonly STRETCH_UNIFORM: number;
  74151. /** STRETCH_EXTEND */
  74152. static readonly STRETCH_EXTEND: number;
  74153. /** NINE_PATCH */
  74154. static readonly STRETCH_NINE_PATCH: number;
  74155. }
  74156. }
  74157. declare module BABYLON.GUI {
  74158. /**
  74159. * Class used to create 2D buttons
  74160. */
  74161. export class Button extends Rectangle {
  74162. name?: string | undefined;
  74163. /**
  74164. * Function called to generate a pointer enter animation
  74165. */
  74166. pointerEnterAnimation: () => void;
  74167. /**
  74168. * Function called to generate a pointer out animation
  74169. */
  74170. pointerOutAnimation: () => void;
  74171. /**
  74172. * Function called to generate a pointer down animation
  74173. */
  74174. pointerDownAnimation: () => void;
  74175. /**
  74176. * Function called to generate a pointer up animation
  74177. */
  74178. pointerUpAnimation: () => void;
  74179. /**
  74180. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  74181. */
  74182. delegatePickingToChildren: boolean;
  74183. private _image;
  74184. /**
  74185. * Returns the image part of the button (if any)
  74186. */
  74187. get image(): BABYLON.Nullable<Image>;
  74188. private _textBlock;
  74189. /**
  74190. * Returns the image part of the button (if any)
  74191. */
  74192. get textBlock(): BABYLON.Nullable<TextBlock>;
  74193. /**
  74194. * Creates a new Button
  74195. * @param name defines the name of the button
  74196. */
  74197. constructor(name?: string | undefined);
  74198. protected _getTypeName(): string;
  74199. /** @hidden */
  74200. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74201. /** @hidden */
  74202. _onPointerEnter(target: Control): boolean;
  74203. /** @hidden */
  74204. _onPointerOut(target: Control, force?: boolean): void;
  74205. /** @hidden */
  74206. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74207. /** @hidden */
  74208. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74209. /**
  74210. * Creates a new button made with an image and a text
  74211. * @param name defines the name of the button
  74212. * @param text defines the text of the button
  74213. * @param imageUrl defines the url of the image
  74214. * @returns a new Button
  74215. */
  74216. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  74217. /**
  74218. * Creates a new button made with an image
  74219. * @param name defines the name of the button
  74220. * @param imageUrl defines the url of the image
  74221. * @returns a new Button
  74222. */
  74223. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  74224. /**
  74225. * Creates a new button made with a text
  74226. * @param name defines the name of the button
  74227. * @param text defines the text of the button
  74228. * @returns a new Button
  74229. */
  74230. static CreateSimpleButton(name: string, text: string): Button;
  74231. /**
  74232. * Creates a new button made with an image and a centered text
  74233. * @param name defines the name of the button
  74234. * @param text defines the text of the button
  74235. * @param imageUrl defines the url of the image
  74236. * @returns a new Button
  74237. */
  74238. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  74239. }
  74240. }
  74241. declare module BABYLON.GUI {
  74242. /**
  74243. * Class used to create a 2D stack panel container
  74244. */
  74245. export class StackPanel extends Container {
  74246. name?: string | undefined;
  74247. private _isVertical;
  74248. private _manualWidth;
  74249. private _manualHeight;
  74250. private _doNotTrackManualChanges;
  74251. /**
  74252. * Gets or sets a boolean indicating that layou warnings should be ignored
  74253. */
  74254. ignoreLayoutWarnings: boolean;
  74255. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  74256. get isVertical(): boolean;
  74257. set isVertical(value: boolean);
  74258. /**
  74259. * Gets or sets panel width.
  74260. * This value should not be set when in horizontal mode as it will be computed automatically
  74261. */
  74262. set width(value: string | number);
  74263. get width(): string | number;
  74264. /**
  74265. * Gets or sets panel height.
  74266. * This value should not be set when in vertical mode as it will be computed automatically
  74267. */
  74268. set height(value: string | number);
  74269. get height(): string | number;
  74270. /**
  74271. * Creates a new StackPanel
  74272. * @param name defines control name
  74273. */
  74274. constructor(name?: string | undefined);
  74275. protected _getTypeName(): string;
  74276. /** @hidden */
  74277. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74278. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74279. protected _postMeasure(): void;
  74280. }
  74281. }
  74282. declare module BABYLON.GUI {
  74283. /**
  74284. * Class used to represent a 2D checkbox
  74285. */
  74286. export class Checkbox extends Control {
  74287. name?: string | undefined;
  74288. private _isChecked;
  74289. private _background;
  74290. private _checkSizeRatio;
  74291. private _thickness;
  74292. /** Gets or sets border thickness */
  74293. get thickness(): number;
  74294. set thickness(value: number);
  74295. /**
  74296. * BABYLON.Observable raised when isChecked property changes
  74297. */
  74298. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74299. /** Gets or sets a value indicating the ratio between overall size and check size */
  74300. get checkSizeRatio(): number;
  74301. set checkSizeRatio(value: number);
  74302. /** Gets or sets background color */
  74303. get background(): string;
  74304. set background(value: string);
  74305. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74306. get isChecked(): boolean;
  74307. set isChecked(value: boolean);
  74308. /**
  74309. * Creates a new CheckBox
  74310. * @param name defines the control name
  74311. */
  74312. constructor(name?: string | undefined);
  74313. protected _getTypeName(): string;
  74314. /** @hidden */
  74315. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74316. /** @hidden */
  74317. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74318. /**
  74319. * Utility function to easily create a checkbox with a header
  74320. * @param title defines the label to use for the header
  74321. * @param onValueChanged defines the callback to call when value changes
  74322. * @returns a StackPanel containing the checkbox and a textBlock
  74323. */
  74324. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  74325. }
  74326. }
  74327. declare module BABYLON.GUI {
  74328. /**
  74329. * Class used to store key control properties
  74330. */
  74331. export class KeyPropertySet {
  74332. /** Width */
  74333. width?: string;
  74334. /** Height */
  74335. height?: string;
  74336. /** Left padding */
  74337. paddingLeft?: string;
  74338. /** Right padding */
  74339. paddingRight?: string;
  74340. /** Top padding */
  74341. paddingTop?: string;
  74342. /** Bottom padding */
  74343. paddingBottom?: string;
  74344. /** Foreground color */
  74345. color?: string;
  74346. /** Background color */
  74347. background?: string;
  74348. }
  74349. /**
  74350. * Class used to create virtual keyboard
  74351. */
  74352. export class VirtualKeyboard extends StackPanel {
  74353. /** BABYLON.Observable raised when a key is pressed */
  74354. onKeyPressObservable: BABYLON.Observable<string>;
  74355. /** Gets or sets default key button width */
  74356. defaultButtonWidth: string;
  74357. /** Gets or sets default key button height */
  74358. defaultButtonHeight: string;
  74359. /** Gets or sets default key button left padding */
  74360. defaultButtonPaddingLeft: string;
  74361. /** Gets or sets default key button right padding */
  74362. defaultButtonPaddingRight: string;
  74363. /** Gets or sets default key button top padding */
  74364. defaultButtonPaddingTop: string;
  74365. /** Gets or sets default key button bottom padding */
  74366. defaultButtonPaddingBottom: string;
  74367. /** Gets or sets default key button foreground color */
  74368. defaultButtonColor: string;
  74369. /** Gets or sets default key button background color */
  74370. defaultButtonBackground: string;
  74371. /** Gets or sets shift button foreground color */
  74372. shiftButtonColor: string;
  74373. /** Gets or sets shift button thickness*/
  74374. selectedShiftThickness: number;
  74375. /** Gets shift key state */
  74376. shiftState: number;
  74377. protected _getTypeName(): string;
  74378. private _createKey;
  74379. /**
  74380. * Adds a new row of keys
  74381. * @param keys defines the list of keys to add
  74382. * @param propertySets defines the associated property sets
  74383. */
  74384. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  74385. /**
  74386. * Set the shift key to a specific state
  74387. * @param shiftState defines the new shift state
  74388. */
  74389. applyShiftState(shiftState: number): void;
  74390. private _currentlyConnectedInputText;
  74391. private _connectedInputTexts;
  74392. private _onKeyPressObserver;
  74393. /** Gets the input text control currently attached to the keyboard */
  74394. get connectedInputText(): BABYLON.Nullable<InputText>;
  74395. /**
  74396. * Connects the keyboard with an input text control
  74397. *
  74398. * @param input defines the target control
  74399. */
  74400. connect(input: InputText): void;
  74401. /**
  74402. * Disconnects the keyboard from connected InputText controls
  74403. *
  74404. * @param input optionally defines a target control, otherwise all are disconnected
  74405. */
  74406. disconnect(input?: InputText): void;
  74407. private _removeConnectedInputObservables;
  74408. /**
  74409. * Release all resources
  74410. */
  74411. dispose(): void;
  74412. /**
  74413. * Creates a new keyboard using a default layout
  74414. *
  74415. * @param name defines control name
  74416. * @returns a new VirtualKeyboard
  74417. */
  74418. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  74419. }
  74420. }
  74421. declare module BABYLON.GUI {
  74422. /**
  74423. * Class used to create input text control
  74424. */
  74425. export class InputText extends Control implements IFocusableControl {
  74426. name?: string | undefined;
  74427. private _text;
  74428. private _placeholderText;
  74429. private _background;
  74430. private _focusedBackground;
  74431. private _focusedColor;
  74432. private _placeholderColor;
  74433. private _thickness;
  74434. private _margin;
  74435. private _autoStretchWidth;
  74436. private _maxWidth;
  74437. private _isFocused;
  74438. private _blinkTimeout;
  74439. private _blinkIsEven;
  74440. private _cursorOffset;
  74441. private _scrollLeft;
  74442. private _textWidth;
  74443. private _clickedCoordinate;
  74444. private _deadKey;
  74445. private _addKey;
  74446. private _currentKey;
  74447. private _isTextHighlightOn;
  74448. private _textHighlightColor;
  74449. private _highligherOpacity;
  74450. private _highlightedText;
  74451. private _startHighlightIndex;
  74452. private _endHighlightIndex;
  74453. private _cursorIndex;
  74454. private _onFocusSelectAll;
  74455. private _isPointerDown;
  74456. private _onClipboardObserver;
  74457. private _onPointerDblTapObserver;
  74458. /** @hidden */
  74459. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  74460. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  74461. promptMessage: string;
  74462. /** Force disable prompt on mobile device */
  74463. disableMobilePrompt: boolean;
  74464. /** BABYLON.Observable raised when the text changes */
  74465. onTextChangedObservable: BABYLON.Observable<InputText>;
  74466. /** BABYLON.Observable raised just before an entered character is to be added */
  74467. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  74468. /** BABYLON.Observable raised when the control gets the focus */
  74469. onFocusObservable: BABYLON.Observable<InputText>;
  74470. /** BABYLON.Observable raised when the control loses the focus */
  74471. onBlurObservable: BABYLON.Observable<InputText>;
  74472. /**Observable raised when the text is highlighted */
  74473. onTextHighlightObservable: BABYLON.Observable<InputText>;
  74474. /**Observable raised when copy event is triggered */
  74475. onTextCopyObservable: BABYLON.Observable<InputText>;
  74476. /** BABYLON.Observable raised when cut event is triggered */
  74477. onTextCutObservable: BABYLON.Observable<InputText>;
  74478. /** BABYLON.Observable raised when paste event is triggered */
  74479. onTextPasteObservable: BABYLON.Observable<InputText>;
  74480. /** BABYLON.Observable raised when a key event was processed */
  74481. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  74482. /** Gets or sets the maximum width allowed by the control */
  74483. get maxWidth(): string | number;
  74484. /** Gets the maximum width allowed by the control in pixels */
  74485. get maxWidthInPixels(): number;
  74486. set maxWidth(value: string | number);
  74487. /** Gets or sets the text highlighter transparency; default: 0.4 */
  74488. get highligherOpacity(): number;
  74489. set highligherOpacity(value: number);
  74490. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  74491. get onFocusSelectAll(): boolean;
  74492. set onFocusSelectAll(value: boolean);
  74493. /** Gets or sets the text hightlight color */
  74494. get textHighlightColor(): string;
  74495. set textHighlightColor(value: string);
  74496. /** Gets or sets control margin */
  74497. get margin(): string;
  74498. /** Gets control margin in pixels */
  74499. get marginInPixels(): number;
  74500. set margin(value: string);
  74501. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  74502. get autoStretchWidth(): boolean;
  74503. set autoStretchWidth(value: boolean);
  74504. /** Gets or sets border thickness */
  74505. get thickness(): number;
  74506. set thickness(value: number);
  74507. /** Gets or sets the background color when focused */
  74508. get focusedBackground(): string;
  74509. set focusedBackground(value: string);
  74510. /** Gets or sets the background color when focused */
  74511. get focusedColor(): string;
  74512. set focusedColor(value: string);
  74513. /** Gets or sets the background color */
  74514. get background(): string;
  74515. set background(value: string);
  74516. /** Gets or sets the placeholder color */
  74517. get placeholderColor(): string;
  74518. set placeholderColor(value: string);
  74519. /** Gets or sets the text displayed when the control is empty */
  74520. get placeholderText(): string;
  74521. set placeholderText(value: string);
  74522. /** Gets or sets the dead key flag */
  74523. get deadKey(): boolean;
  74524. set deadKey(flag: boolean);
  74525. /** Gets or sets the highlight text */
  74526. get highlightedText(): string;
  74527. set highlightedText(text: string);
  74528. /** Gets or sets if the current key should be added */
  74529. get addKey(): boolean;
  74530. set addKey(flag: boolean);
  74531. /** Gets or sets the value of the current key being entered */
  74532. get currentKey(): string;
  74533. set currentKey(key: string);
  74534. /** Gets or sets the text displayed in the control */
  74535. get text(): string;
  74536. set text(value: string);
  74537. /** Gets or sets control width */
  74538. get width(): string | number;
  74539. set width(value: string | number);
  74540. /**
  74541. * Creates a new InputText
  74542. * @param name defines the control name
  74543. * @param text defines the text of the control
  74544. */
  74545. constructor(name?: string | undefined, text?: string);
  74546. /** @hidden */
  74547. onBlur(): void;
  74548. /** @hidden */
  74549. onFocus(): void;
  74550. protected _getTypeName(): string;
  74551. /**
  74552. * Function called to get the list of controls that should not steal the focus from this control
  74553. * @returns an array of controls
  74554. */
  74555. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74556. /** @hidden */
  74557. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  74558. /** @hidden */
  74559. private _updateValueFromCursorIndex;
  74560. /** @hidden */
  74561. private _processDblClick;
  74562. /** @hidden */
  74563. private _selectAllText;
  74564. /**
  74565. * Handles the keyboard event
  74566. * @param evt Defines the KeyboardEvent
  74567. */
  74568. processKeyboard(evt: KeyboardEvent): void;
  74569. /** @hidden */
  74570. private _onCopyText;
  74571. /** @hidden */
  74572. private _onCutText;
  74573. /** @hidden */
  74574. private _onPasteText;
  74575. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74576. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74577. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74578. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74579. protected _beforeRenderText(text: string): string;
  74580. dispose(): void;
  74581. }
  74582. }
  74583. declare module BABYLON.GUI {
  74584. /**
  74585. * Class used to create a 2D grid container
  74586. */
  74587. export class Grid extends Container {
  74588. name?: string | undefined;
  74589. private _rowDefinitions;
  74590. private _columnDefinitions;
  74591. private _cells;
  74592. private _childControls;
  74593. /**
  74594. * Gets the number of columns
  74595. */
  74596. get columnCount(): number;
  74597. /**
  74598. * Gets the number of rows
  74599. */
  74600. get rowCount(): number;
  74601. /** Gets the list of children */
  74602. get children(): Control[];
  74603. /** Gets the list of cells (e.g. the containers) */
  74604. get cells(): {
  74605. [key: string]: Container;
  74606. };
  74607. /**
  74608. * Gets the definition of a specific row
  74609. * @param index defines the index of the row
  74610. * @returns the row definition
  74611. */
  74612. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74613. /**
  74614. * Gets the definition of a specific column
  74615. * @param index defines the index of the column
  74616. * @returns the column definition
  74617. */
  74618. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74619. /**
  74620. * Adds a new row to the grid
  74621. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74622. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  74623. * @returns the current grid
  74624. */
  74625. addRowDefinition(height: number, isPixel?: boolean): Grid;
  74626. /**
  74627. * Adds a new column to the grid
  74628. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74629. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74630. * @returns the current grid
  74631. */
  74632. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  74633. /**
  74634. * Update a row definition
  74635. * @param index defines the index of the row to update
  74636. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74637. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  74638. * @returns the current grid
  74639. */
  74640. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  74641. /**
  74642. * Update a column definition
  74643. * @param index defines the index of the column to update
  74644. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74645. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74646. * @returns the current grid
  74647. */
  74648. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  74649. /**
  74650. * Gets the list of children stored in a specific cell
  74651. * @param row defines the row to check
  74652. * @param column defines the column to check
  74653. * @returns the list of controls
  74654. */
  74655. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  74656. /**
  74657. * Gets a string representing the child cell info (row x column)
  74658. * @param child defines the control to get info from
  74659. * @returns a string containing the child cell info (row x column)
  74660. */
  74661. getChildCellInfo(child: Control): string;
  74662. private _removeCell;
  74663. private _offsetCell;
  74664. /**
  74665. * Remove a column definition at specified index
  74666. * @param index defines the index of the column to remove
  74667. * @returns the current grid
  74668. */
  74669. removeColumnDefinition(index: number): Grid;
  74670. /**
  74671. * Remove a row definition at specified index
  74672. * @param index defines the index of the row to remove
  74673. * @returns the current grid
  74674. */
  74675. removeRowDefinition(index: number): Grid;
  74676. /**
  74677. * Adds a new control to the current grid
  74678. * @param control defines the control to add
  74679. * @param row defines the row where to add the control (0 by default)
  74680. * @param column defines the column where to add the control (0 by default)
  74681. * @returns the current grid
  74682. */
  74683. addControl(control: Control, row?: number, column?: number): Grid;
  74684. /**
  74685. * Removes a control from the current container
  74686. * @param control defines the control to remove
  74687. * @returns the current container
  74688. */
  74689. removeControl(control: Control): Container;
  74690. /**
  74691. * Creates a new Grid
  74692. * @param name defines control name
  74693. */
  74694. constructor(name?: string | undefined);
  74695. protected _getTypeName(): string;
  74696. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  74697. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74698. _flagDescendantsAsMatrixDirty(): void;
  74699. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74700. /** Releases associated resources */
  74701. dispose(): void;
  74702. }
  74703. }
  74704. declare module BABYLON.GUI {
  74705. /** Class used to create color pickers */
  74706. export class ColorPicker extends Control {
  74707. name?: string | undefined;
  74708. private static _Epsilon;
  74709. private _colorWheelCanvas;
  74710. private _value;
  74711. private _tmpColor;
  74712. private _pointerStartedOnSquare;
  74713. private _pointerStartedOnWheel;
  74714. private _squareLeft;
  74715. private _squareTop;
  74716. private _squareSize;
  74717. private _h;
  74718. private _s;
  74719. private _v;
  74720. private _lastPointerDownID;
  74721. /**
  74722. * BABYLON.Observable raised when the value changes
  74723. */
  74724. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  74725. /** Gets or sets the color of the color picker */
  74726. get value(): BABYLON.Color3;
  74727. set value(value: BABYLON.Color3);
  74728. /**
  74729. * Gets or sets control width
  74730. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74731. */
  74732. get width(): string | number;
  74733. set width(value: string | number);
  74734. /**
  74735. * Gets or sets control height
  74736. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74737. */
  74738. get height(): string | number;
  74739. /** Gets or sets control height */
  74740. set height(value: string | number);
  74741. /** Gets or sets control size */
  74742. get size(): string | number;
  74743. set size(value: string | number);
  74744. /**
  74745. * Creates a new ColorPicker
  74746. * @param name defines the control name
  74747. */
  74748. constructor(name?: string | undefined);
  74749. protected _getTypeName(): string;
  74750. /** @hidden */
  74751. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74752. private _updateSquareProps;
  74753. private _drawGradientSquare;
  74754. private _drawCircle;
  74755. private _createColorWheelCanvas;
  74756. /** @hidden */
  74757. _draw(context: CanvasRenderingContext2D): void;
  74758. private _pointerIsDown;
  74759. private _updateValueFromPointer;
  74760. private _isPointOnSquare;
  74761. private _isPointOnWheel;
  74762. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74763. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74764. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74765. /**
  74766. * This function expands the color picker by creating a color picker dialog with manual
  74767. * color value input and the ability to save colors into an array to be used later in
  74768. * subsequent launches of the dialogue.
  74769. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  74770. * @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.
  74771. * @returns picked color as a hex string and the saved colors array as hex strings.
  74772. */
  74773. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  74774. pickerWidth?: string;
  74775. pickerHeight?: string;
  74776. headerHeight?: string;
  74777. lastColor?: string;
  74778. swatchLimit?: number;
  74779. numSwatchesPerLine?: number;
  74780. savedColors?: Array<string>;
  74781. }): Promise<{
  74782. savedColors?: string[];
  74783. pickedColor: string;
  74784. }>;
  74785. }
  74786. }
  74787. declare module BABYLON.GUI {
  74788. /** Class used to create 2D ellipse containers */
  74789. export class Ellipse extends Container {
  74790. name?: string | undefined;
  74791. private _thickness;
  74792. /** Gets or sets border thickness */
  74793. get thickness(): number;
  74794. set thickness(value: number);
  74795. /**
  74796. * Creates a new Ellipse
  74797. * @param name defines the control name
  74798. */
  74799. constructor(name?: string | undefined);
  74800. protected _getTypeName(): string;
  74801. protected _localDraw(context: CanvasRenderingContext2D): void;
  74802. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74803. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74804. }
  74805. }
  74806. declare module BABYLON.GUI {
  74807. /**
  74808. * Class used to create a password control
  74809. */
  74810. export class InputPassword extends InputText {
  74811. protected _beforeRenderText(text: string): string;
  74812. }
  74813. }
  74814. declare module BABYLON.GUI {
  74815. /** Class used to render 2D lines */
  74816. export class Line extends Control {
  74817. name?: string | undefined;
  74818. private _lineWidth;
  74819. private _x1;
  74820. private _y1;
  74821. private _x2;
  74822. private _y2;
  74823. private _dash;
  74824. private _connectedControl;
  74825. private _connectedControlDirtyObserver;
  74826. /** Gets or sets the dash pattern */
  74827. get dash(): Array<number>;
  74828. set dash(value: Array<number>);
  74829. /** Gets or sets the control connected with the line end */
  74830. get connectedControl(): Control;
  74831. set connectedControl(value: Control);
  74832. /** Gets or sets start coordinates on X axis */
  74833. get x1(): string | number;
  74834. set x1(value: string | number);
  74835. /** Gets or sets start coordinates on Y axis */
  74836. get y1(): string | number;
  74837. set y1(value: string | number);
  74838. /** Gets or sets end coordinates on X axis */
  74839. get x2(): string | number;
  74840. set x2(value: string | number);
  74841. /** Gets or sets end coordinates on Y axis */
  74842. get y2(): string | number;
  74843. set y2(value: string | number);
  74844. /** Gets or sets line width */
  74845. get lineWidth(): number;
  74846. set lineWidth(value: number);
  74847. /** Gets or sets horizontal alignment */
  74848. set horizontalAlignment(value: number);
  74849. /** Gets or sets vertical alignment */
  74850. set verticalAlignment(value: number);
  74851. private get _effectiveX2();
  74852. private get _effectiveY2();
  74853. /**
  74854. * Creates a new Line
  74855. * @param name defines the control name
  74856. */
  74857. constructor(name?: string | undefined);
  74858. protected _getTypeName(): string;
  74859. _draw(context: CanvasRenderingContext2D): void;
  74860. _measure(): void;
  74861. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74862. /**
  74863. * Move one end of the line given 3D cartesian coordinates.
  74864. * @param position Targeted world position
  74865. * @param scene BABYLON.Scene
  74866. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  74867. */
  74868. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  74869. /**
  74870. * Move one end of the line to a position in screen absolute space.
  74871. * @param projectedPosition Position in screen absolute space (X, Y)
  74872. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  74873. */
  74874. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  74875. }
  74876. }
  74877. declare module BABYLON.GUI {
  74878. /**
  74879. * Class used to store a point for a MultiLine object.
  74880. * The point can be pure 2D coordinates, a mesh or a control
  74881. */
  74882. export class MultiLinePoint {
  74883. private _multiLine;
  74884. private _x;
  74885. private _y;
  74886. private _control;
  74887. private _mesh;
  74888. private _controlObserver;
  74889. private _meshObserver;
  74890. /** @hidden */
  74891. _point: BABYLON.Vector2;
  74892. /**
  74893. * Creates a new MultiLinePoint
  74894. * @param multiLine defines the source MultiLine object
  74895. */
  74896. constructor(multiLine: MultiLine);
  74897. /** Gets or sets x coordinate */
  74898. get x(): string | number;
  74899. set x(value: string | number);
  74900. /** Gets or sets y coordinate */
  74901. get y(): string | number;
  74902. set y(value: string | number);
  74903. /** Gets or sets the control associated with this point */
  74904. get control(): BABYLON.Nullable<Control>;
  74905. set control(value: BABYLON.Nullable<Control>);
  74906. /** Gets or sets the mesh associated with this point */
  74907. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74908. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  74909. /** Resets links */
  74910. resetLinks(): void;
  74911. /**
  74912. * Gets a translation vector
  74913. * @returns the translation vector
  74914. */
  74915. translate(): BABYLON.Vector2;
  74916. private _translatePoint;
  74917. /** Release associated resources */
  74918. dispose(): void;
  74919. }
  74920. }
  74921. declare module BABYLON.GUI {
  74922. /**
  74923. * Class used to create multi line control
  74924. */
  74925. export class MultiLine extends Control {
  74926. name?: string | undefined;
  74927. private _lineWidth;
  74928. private _dash;
  74929. private _points;
  74930. private _minX;
  74931. private _minY;
  74932. private _maxX;
  74933. private _maxY;
  74934. /**
  74935. * Creates a new MultiLine
  74936. * @param name defines the control name
  74937. */
  74938. constructor(name?: string | undefined);
  74939. /** Gets or sets dash pattern */
  74940. get dash(): Array<number>;
  74941. set dash(value: Array<number>);
  74942. /**
  74943. * Gets point stored at specified index
  74944. * @param index defines the index to look for
  74945. * @returns the requested point if found
  74946. */
  74947. getAt(index: number): MultiLinePoint;
  74948. /** Function called when a point is updated */
  74949. onPointUpdate: () => void;
  74950. /**
  74951. * Adds new points to the point collection
  74952. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  74953. * @returns the list of created MultiLinePoint
  74954. */
  74955. add(...items: (AbstractMesh | Control | {
  74956. x: string | number;
  74957. y: string | number;
  74958. })[]): MultiLinePoint[];
  74959. /**
  74960. * Adds a new point to the point collection
  74961. * @param item defines the item (mesh, control or 2d coordiantes) to add
  74962. * @returns the created MultiLinePoint
  74963. */
  74964. push(item?: (AbstractMesh | Control | {
  74965. x: string | number;
  74966. y: string | number;
  74967. })): MultiLinePoint;
  74968. /**
  74969. * Remove a specific value or point from the active point collection
  74970. * @param value defines the value or point to remove
  74971. */
  74972. remove(value: number | MultiLinePoint): void;
  74973. /**
  74974. * Resets this object to initial state (no point)
  74975. */
  74976. reset(): void;
  74977. /**
  74978. * Resets all links
  74979. */
  74980. resetLinks(): void;
  74981. /** Gets or sets line width */
  74982. get lineWidth(): number;
  74983. set lineWidth(value: number);
  74984. set horizontalAlignment(value: number);
  74985. set verticalAlignment(value: number);
  74986. protected _getTypeName(): string;
  74987. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74988. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74989. _measure(): void;
  74990. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74991. dispose(): void;
  74992. }
  74993. }
  74994. declare module BABYLON.GUI {
  74995. /**
  74996. * Class used to create radio button controls
  74997. */
  74998. export class RadioButton extends Control {
  74999. name?: string | undefined;
  75000. private _isChecked;
  75001. private _background;
  75002. private _checkSizeRatio;
  75003. private _thickness;
  75004. /** Gets or sets border thickness */
  75005. get thickness(): number;
  75006. set thickness(value: number);
  75007. /** Gets or sets group name */
  75008. group: string;
  75009. /** BABYLON.Observable raised when isChecked is changed */
  75010. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75011. /** Gets or sets a value indicating the ratio between overall size and check size */
  75012. get checkSizeRatio(): number;
  75013. set checkSizeRatio(value: number);
  75014. /** Gets or sets background color */
  75015. get background(): string;
  75016. set background(value: string);
  75017. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75018. get isChecked(): boolean;
  75019. set isChecked(value: boolean);
  75020. /**
  75021. * Creates a new RadioButton
  75022. * @param name defines the control name
  75023. */
  75024. constructor(name?: string | undefined);
  75025. protected _getTypeName(): string;
  75026. _draw(context: CanvasRenderingContext2D): void;
  75027. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75028. /**
  75029. * Utility function to easily create a radio button with a header
  75030. * @param title defines the label to use for the header
  75031. * @param group defines the group to use for the radio button
  75032. * @param isChecked defines the initial state of the radio button
  75033. * @param onValueChanged defines the callback to call when value changes
  75034. * @returns a StackPanel containing the radio button and a textBlock
  75035. */
  75036. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  75037. }
  75038. }
  75039. declare module BABYLON.GUI {
  75040. /**
  75041. * Class used to create slider controls
  75042. */
  75043. export class BaseSlider extends Control {
  75044. name?: string | undefined;
  75045. protected _thumbWidth: ValueAndUnit;
  75046. private _minimum;
  75047. private _maximum;
  75048. private _value;
  75049. private _isVertical;
  75050. protected _barOffset: ValueAndUnit;
  75051. private _isThumbClamped;
  75052. protected _displayThumb: boolean;
  75053. private _step;
  75054. private _lastPointerDownID;
  75055. protected _effectiveBarOffset: number;
  75056. protected _renderLeft: number;
  75057. protected _renderTop: number;
  75058. protected _renderWidth: number;
  75059. protected _renderHeight: number;
  75060. protected _backgroundBoxLength: number;
  75061. protected _backgroundBoxThickness: number;
  75062. protected _effectiveThumbThickness: number;
  75063. /** BABYLON.Observable raised when the sldier value changes */
  75064. onValueChangedObservable: BABYLON.Observable<number>;
  75065. /** Gets or sets a boolean indicating if the thumb must be rendered */
  75066. get displayThumb(): boolean;
  75067. set displayThumb(value: boolean);
  75068. /** Gets or sets a step to apply to values (0 by default) */
  75069. get step(): number;
  75070. set step(value: number);
  75071. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  75072. get barOffset(): string | number;
  75073. /** Gets main bar offset in pixels*/
  75074. get barOffsetInPixels(): number;
  75075. set barOffset(value: string | number);
  75076. /** Gets or sets thumb width */
  75077. get thumbWidth(): string | number;
  75078. /** Gets thumb width in pixels */
  75079. get thumbWidthInPixels(): number;
  75080. set thumbWidth(value: string | number);
  75081. /** Gets or sets minimum value */
  75082. get minimum(): number;
  75083. set minimum(value: number);
  75084. /** Gets or sets maximum value */
  75085. get maximum(): number;
  75086. set maximum(value: number);
  75087. /** Gets or sets current value */
  75088. get value(): number;
  75089. set value(value: number);
  75090. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  75091. get isVertical(): boolean;
  75092. set isVertical(value: boolean);
  75093. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  75094. get isThumbClamped(): boolean;
  75095. set isThumbClamped(value: boolean);
  75096. /**
  75097. * Creates a new BaseSlider
  75098. * @param name defines the control name
  75099. */
  75100. constructor(name?: string | undefined);
  75101. protected _getTypeName(): string;
  75102. protected _getThumbPosition(): number;
  75103. protected _getThumbThickness(type: string): number;
  75104. protected _prepareRenderingData(type: string): void;
  75105. private _pointerIsDown;
  75106. /** @hidden */
  75107. protected _updateValueFromPointer(x: number, y: number): void;
  75108. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75109. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75110. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75111. }
  75112. }
  75113. declare module BABYLON.GUI {
  75114. /**
  75115. * Class used to create slider controls
  75116. */
  75117. export class Slider extends BaseSlider {
  75118. name?: string | undefined;
  75119. private _background;
  75120. private _borderColor;
  75121. private _isThumbCircle;
  75122. protected _displayValueBar: boolean;
  75123. /** Gets or sets a boolean indicating if the value bar must be rendered */
  75124. get displayValueBar(): boolean;
  75125. set displayValueBar(value: boolean);
  75126. /** Gets or sets border color */
  75127. get borderColor(): string;
  75128. set borderColor(value: string);
  75129. /** Gets or sets background color */
  75130. get background(): string;
  75131. set background(value: string);
  75132. /** Gets or sets a boolean indicating if the thumb should be round or square */
  75133. get isThumbCircle(): boolean;
  75134. set isThumbCircle(value: boolean);
  75135. /**
  75136. * Creates a new Slider
  75137. * @param name defines the control name
  75138. */
  75139. constructor(name?: string | undefined);
  75140. protected _getTypeName(): string;
  75141. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75142. }
  75143. }
  75144. declare module BABYLON.GUI {
  75145. /** Class used to create a RadioGroup
  75146. * which contains groups of radio buttons
  75147. */
  75148. export class SelectorGroup {
  75149. /** name of SelectorGroup */
  75150. name: string;
  75151. private _groupPanel;
  75152. private _selectors;
  75153. private _groupHeader;
  75154. /**
  75155. * Creates a new SelectorGroup
  75156. * @param name of group, used as a group heading
  75157. */
  75158. constructor(
  75159. /** name of SelectorGroup */
  75160. name: string);
  75161. /** Gets the groupPanel of the SelectorGroup */
  75162. get groupPanel(): StackPanel;
  75163. /** Gets the selectors array */
  75164. get selectors(): StackPanel[];
  75165. /** Gets and sets the group header */
  75166. get header(): string;
  75167. set header(label: string);
  75168. /** @hidden */
  75169. private _addGroupHeader;
  75170. /** @hidden*/
  75171. _getSelector(selectorNb: number): StackPanel | undefined;
  75172. /** Removes the selector at the given position
  75173. * @param selectorNb the position of the selector within the group
  75174. */
  75175. removeSelector(selectorNb: number): void;
  75176. }
  75177. /** Class used to create a CheckboxGroup
  75178. * which contains groups of checkbox buttons
  75179. */
  75180. export class CheckboxGroup extends SelectorGroup {
  75181. /** Adds a checkbox as a control
  75182. * @param text is the label for the selector
  75183. * @param func is the function called when the Selector is checked
  75184. * @param checked is true when Selector is checked
  75185. */
  75186. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): 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 create a RadioGroup
  75197. * which contains groups of radio buttons
  75198. */
  75199. export class RadioGroup extends SelectorGroup {
  75200. private _selectNb;
  75201. /** Adds a radio button as a control
  75202. * @param label is the label for the selector
  75203. * @param func is the function called when the Selector is checked
  75204. * @param checked is true when Selector is checked
  75205. */
  75206. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  75207. /** @hidden */
  75208. _setSelectorLabel(selectorNb: number, label: string): void;
  75209. /** @hidden */
  75210. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75211. /** @hidden */
  75212. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75213. /** @hidden */
  75214. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75215. }
  75216. /** Class used to create a SliderGroup
  75217. * which contains groups of slider buttons
  75218. */
  75219. export class SliderGroup extends SelectorGroup {
  75220. /**
  75221. * Adds a slider to the SelectorGroup
  75222. * @param label is the label for the SliderBar
  75223. * @param func is the function called when the Slider moves
  75224. * @param unit is a string describing the units used, eg degrees or metres
  75225. * @param min is the minimum value for the Slider
  75226. * @param max is the maximum value for the Slider
  75227. * @param value is the start value for the Slider between min and max
  75228. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  75229. */
  75230. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  75231. /** @hidden */
  75232. _setSelectorLabel(selectorNb: number, label: string): void;
  75233. /** @hidden */
  75234. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75235. /** @hidden */
  75236. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75237. /** @hidden */
  75238. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75239. }
  75240. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  75241. * @see http://doc.babylonjs.com/how_to/selector
  75242. */
  75243. export class SelectionPanel extends Rectangle {
  75244. /** name of SelectionPanel */
  75245. name: string;
  75246. /** an array of SelectionGroups */
  75247. groups: SelectorGroup[];
  75248. private _panel;
  75249. private _buttonColor;
  75250. private _buttonBackground;
  75251. private _headerColor;
  75252. private _barColor;
  75253. private _barHeight;
  75254. private _spacerHeight;
  75255. private _labelColor;
  75256. private _groups;
  75257. private _bars;
  75258. /**
  75259. * Creates a new SelectionPanel
  75260. * @param name of SelectionPanel
  75261. * @param groups is an array of SelectionGroups
  75262. */
  75263. constructor(
  75264. /** name of SelectionPanel */
  75265. name: string,
  75266. /** an array of SelectionGroups */
  75267. groups?: SelectorGroup[]);
  75268. protected _getTypeName(): string;
  75269. /** Gets or sets the headerColor */
  75270. get headerColor(): string;
  75271. set headerColor(color: string);
  75272. private _setHeaderColor;
  75273. /** Gets or sets the button color */
  75274. get buttonColor(): string;
  75275. set buttonColor(color: string);
  75276. private _setbuttonColor;
  75277. /** Gets or sets the label color */
  75278. get labelColor(): string;
  75279. set labelColor(color: string);
  75280. private _setLabelColor;
  75281. /** Gets or sets the button background */
  75282. get buttonBackground(): string;
  75283. set buttonBackground(color: string);
  75284. private _setButtonBackground;
  75285. /** Gets or sets the color of separator bar */
  75286. get barColor(): string;
  75287. set barColor(color: string);
  75288. private _setBarColor;
  75289. /** Gets or sets the height of separator bar */
  75290. get barHeight(): string;
  75291. set barHeight(value: string);
  75292. private _setBarHeight;
  75293. /** Gets or sets the height of spacers*/
  75294. get spacerHeight(): string;
  75295. set spacerHeight(value: string);
  75296. private _setSpacerHeight;
  75297. /** Adds a bar between groups */
  75298. private _addSpacer;
  75299. /** Add a group to the selection panel
  75300. * @param group is the selector group to add
  75301. */
  75302. addGroup(group: SelectorGroup): void;
  75303. /** Remove the group from the given position
  75304. * @param groupNb is the position of the group in the list
  75305. */
  75306. removeGroup(groupNb: number): void;
  75307. /** Change a group header label
  75308. * @param label is the new group header label
  75309. * @param groupNb is the number of the group to relabel
  75310. * */
  75311. setHeaderName(label: string, groupNb: number): void;
  75312. /** Change selector label to the one given
  75313. * @param label is the new selector label
  75314. * @param groupNb is the number of the groupcontaining the selector
  75315. * @param selectorNb is the number of the selector within a group to relabel
  75316. * */
  75317. relabel(label: string, groupNb: number, selectorNb: number): void;
  75318. /** For a given group position remove the selector at the given position
  75319. * @param groupNb is the number of the group to remove the selector from
  75320. * @param selectorNb is the number of the selector within the group
  75321. */
  75322. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  75323. /** For a given group position of correct type add a checkbox button
  75324. * @param groupNb is the number of the group to remove the selector from
  75325. * @param label is the label for the selector
  75326. * @param func is the function called when the Selector is checked
  75327. * @param checked is true when Selector is checked
  75328. */
  75329. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75330. /** For a given group position of correct type add a radio button
  75331. * @param groupNb is the number of the group to remove the selector from
  75332. * @param label is the label for the selector
  75333. * @param func is the function called when the Selector is checked
  75334. * @param checked is true when Selector is checked
  75335. */
  75336. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75337. /**
  75338. * For a given slider group add a slider
  75339. * @param groupNb is the number of the group to add the slider to
  75340. * @param label is the label for the Slider
  75341. * @param func is the function called when the Slider moves
  75342. * @param unit is a string describing the units used, eg degrees or metres
  75343. * @param min is the minimum value for the Slider
  75344. * @param max is the maximum value for the Slider
  75345. * @param value is the start value for the Slider between min and max
  75346. * @param onVal is the function used to format the value displayed, eg radians to degrees
  75347. */
  75348. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  75349. }
  75350. }
  75351. declare module BABYLON.GUI {
  75352. /**
  75353. * Class used to hold a the container for ScrollViewer
  75354. * @hidden
  75355. */
  75356. export class _ScrollViewerWindow extends Container {
  75357. parentClientWidth: number;
  75358. parentClientHeight: number;
  75359. private _freezeControls;
  75360. private _parentMeasure;
  75361. private _oldLeft;
  75362. private _oldTop;
  75363. get freezeControls(): boolean;
  75364. set freezeControls(value: boolean);
  75365. private _bucketWidth;
  75366. private _bucketHeight;
  75367. private _buckets;
  75368. private _bucketLen;
  75369. get bucketWidth(): number;
  75370. get bucketHeight(): number;
  75371. setBucketSizes(width: number, height: number): void;
  75372. private _useBuckets;
  75373. private _makeBuckets;
  75374. private _dispatchInBuckets;
  75375. private _updateMeasures;
  75376. private _updateChildrenMeasures;
  75377. private _restoreMeasures;
  75378. /**
  75379. * Creates a new ScrollViewerWindow
  75380. * @param name of ScrollViewerWindow
  75381. */
  75382. constructor(name?: string);
  75383. protected _getTypeName(): string;
  75384. /** @hidden */
  75385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75386. /** @hidden */
  75387. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75388. private _scrollChildren;
  75389. private _scrollChildrenWithBuckets;
  75390. /** @hidden */
  75391. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75392. protected _postMeasure(): void;
  75393. }
  75394. }
  75395. declare module BABYLON.GUI {
  75396. /**
  75397. * Class used to create slider controls
  75398. */
  75399. export class ScrollBar extends BaseSlider {
  75400. name?: string | undefined;
  75401. private _background;
  75402. private _borderColor;
  75403. private _tempMeasure;
  75404. /** Gets or sets border color */
  75405. get borderColor(): string;
  75406. set borderColor(value: string);
  75407. /** Gets or sets background color */
  75408. get background(): string;
  75409. set background(value: string);
  75410. /**
  75411. * Creates a new Slider
  75412. * @param name defines the control name
  75413. */
  75414. constructor(name?: string | undefined);
  75415. protected _getTypeName(): string;
  75416. protected _getThumbThickness(): number;
  75417. _draw(context: CanvasRenderingContext2D): void;
  75418. private _first;
  75419. private _originX;
  75420. private _originY;
  75421. /** @hidden */
  75422. protected _updateValueFromPointer(x: number, y: number): void;
  75423. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75424. }
  75425. }
  75426. declare module BABYLON.GUI {
  75427. /**
  75428. * Class used to create slider controls
  75429. */
  75430. export class ImageScrollBar extends BaseSlider {
  75431. name?: string | undefined;
  75432. private _backgroundBaseImage;
  75433. private _backgroundImage;
  75434. private _thumbImage;
  75435. private _thumbBaseImage;
  75436. private _thumbLength;
  75437. private _thumbHeight;
  75438. private _barImageHeight;
  75439. private _tempMeasure;
  75440. /** Number of 90° rotation to apply on the images when in vertical mode */
  75441. num90RotationInVerticalMode: number;
  75442. /**
  75443. * Gets or sets the image used to render the background for horizontal bar
  75444. */
  75445. get backgroundImage(): Image;
  75446. set backgroundImage(value: Image);
  75447. /**
  75448. * Gets or sets the image used to render the thumb
  75449. */
  75450. get thumbImage(): Image;
  75451. set thumbImage(value: Image);
  75452. /**
  75453. * Gets or sets the length of the thumb
  75454. */
  75455. get thumbLength(): number;
  75456. set thumbLength(value: number);
  75457. /**
  75458. * Gets or sets the height of the thumb
  75459. */
  75460. get thumbHeight(): number;
  75461. set thumbHeight(value: number);
  75462. /**
  75463. * Gets or sets the height of the bar image
  75464. */
  75465. get barImageHeight(): number;
  75466. set barImageHeight(value: number);
  75467. /**
  75468. * Creates a new ImageScrollBar
  75469. * @param name defines the control name
  75470. */
  75471. constructor(name?: string | undefined);
  75472. protected _getTypeName(): string;
  75473. protected _getThumbThickness(): number;
  75474. _draw(context: CanvasRenderingContext2D): void;
  75475. private _first;
  75476. private _originX;
  75477. private _originY;
  75478. /** @hidden */
  75479. protected _updateValueFromPointer(x: number, y: number): void;
  75480. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75481. }
  75482. }
  75483. declare module BABYLON.GUI {
  75484. /**
  75485. * Class used to hold a viewer window and sliders in a grid
  75486. */
  75487. export class ScrollViewer extends Rectangle {
  75488. private _grid;
  75489. private _horizontalBarSpace;
  75490. private _verticalBarSpace;
  75491. private _dragSpace;
  75492. private _horizontalBar;
  75493. private _verticalBar;
  75494. private _barColor;
  75495. private _barBackground;
  75496. private _barImage;
  75497. private _horizontalBarImage;
  75498. private _verticalBarImage;
  75499. private _barBackgroundImage;
  75500. private _horizontalBarBackgroundImage;
  75501. private _verticalBarBackgroundImage;
  75502. private _barSize;
  75503. private _window;
  75504. private _pointerIsOver;
  75505. private _wheelPrecision;
  75506. private _onWheelObserver;
  75507. private _clientWidth;
  75508. private _clientHeight;
  75509. private _useImageBar;
  75510. private _thumbLength;
  75511. private _thumbHeight;
  75512. private _barImageHeight;
  75513. private _horizontalBarImageHeight;
  75514. private _verticalBarImageHeight;
  75515. private _oldWindowContentsWidth;
  75516. private _oldWindowContentsHeight;
  75517. /**
  75518. * Gets the horizontal scrollbar
  75519. */
  75520. get horizontalBar(): ScrollBar | ImageScrollBar;
  75521. /**
  75522. * Gets the vertical scrollbar
  75523. */
  75524. get verticalBar(): ScrollBar | ImageScrollBar;
  75525. /**
  75526. * Adds a new control to the current container
  75527. * @param control defines the control to add
  75528. * @returns the current container
  75529. */
  75530. addControl(control: BABYLON.Nullable<Control>): Container;
  75531. /**
  75532. * Removes a control from the current container
  75533. * @param control defines the control to remove
  75534. * @returns the current container
  75535. */
  75536. removeControl(control: Control): Container;
  75537. /** Gets the list of children */
  75538. get children(): Control[];
  75539. _flagDescendantsAsMatrixDirty(): void;
  75540. /**
  75541. * Freezes or unfreezes the controls in the window.
  75542. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  75543. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  75544. */
  75545. get freezeControls(): boolean;
  75546. set freezeControls(value: boolean);
  75547. /** Gets the bucket width */
  75548. get bucketWidth(): number;
  75549. /** Gets the bucket height */
  75550. get bucketHeight(): number;
  75551. /**
  75552. * Sets the bucket sizes.
  75553. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  75554. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  75555. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  75556. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  75557. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  75558. * used), that's why it is not enabled by default.
  75559. * @param width width of the bucket
  75560. * @param height height of the bucket
  75561. */
  75562. setBucketSizes(width: number, height: number): void;
  75563. private _forceHorizontalBar;
  75564. private _forceVerticalBar;
  75565. /**
  75566. * Forces the horizontal scroll bar to be displayed
  75567. */
  75568. get forceHorizontalBar(): boolean;
  75569. set forceHorizontalBar(value: boolean);
  75570. /**
  75571. * Forces the vertical scroll bar to be displayed
  75572. */
  75573. get forceVerticalBar(): boolean;
  75574. set forceVerticalBar(value: boolean);
  75575. /**
  75576. * Creates a new ScrollViewer
  75577. * @param name of ScrollViewer
  75578. */
  75579. constructor(name?: string, isImageBased?: boolean);
  75580. /** Reset the scroll viewer window to initial size */
  75581. resetWindow(): void;
  75582. protected _getTypeName(): string;
  75583. private _buildClientSizes;
  75584. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75585. protected _postMeasure(): void;
  75586. /**
  75587. * Gets or sets the mouse wheel precision
  75588. * from 0 to 1 with a default value of 0.05
  75589. * */
  75590. get wheelPrecision(): number;
  75591. set wheelPrecision(value: number);
  75592. /** Gets or sets the scroll bar container background color */
  75593. get scrollBackground(): string;
  75594. set scrollBackground(color: string);
  75595. /** Gets or sets the bar color */
  75596. get barColor(): string;
  75597. set barColor(color: string);
  75598. /** Gets or sets the bar image */
  75599. get thumbImage(): Image;
  75600. set thumbImage(value: Image);
  75601. /** Gets or sets the horizontal bar image */
  75602. get horizontalThumbImage(): Image;
  75603. set horizontalThumbImage(value: Image);
  75604. /** Gets or sets the vertical bar image */
  75605. get verticalThumbImage(): Image;
  75606. set verticalThumbImage(value: Image);
  75607. /** Gets or sets the size of the bar */
  75608. get barSize(): number;
  75609. set barSize(value: number);
  75610. /** Gets or sets the length of the thumb */
  75611. get thumbLength(): number;
  75612. set thumbLength(value: number);
  75613. /** Gets or sets the height of the thumb */
  75614. get thumbHeight(): number;
  75615. set thumbHeight(value: number);
  75616. /** Gets or sets the height of the bar image */
  75617. get barImageHeight(): number;
  75618. set barImageHeight(value: number);
  75619. /** Gets or sets the height of the horizontal bar image */
  75620. get horizontalBarImageHeight(): number;
  75621. set horizontalBarImageHeight(value: number);
  75622. /** Gets or sets the height of the vertical bar image */
  75623. get verticalBarImageHeight(): number;
  75624. set verticalBarImageHeight(value: number);
  75625. /** Gets or sets the bar background */
  75626. get barBackground(): string;
  75627. set barBackground(color: string);
  75628. /** Gets or sets the bar background image */
  75629. get barImage(): Image;
  75630. set barImage(value: Image);
  75631. /** Gets or sets the horizontal bar background image */
  75632. get horizontalBarImage(): Image;
  75633. set horizontalBarImage(value: Image);
  75634. /** Gets or sets the vertical bar background image */
  75635. get verticalBarImage(): Image;
  75636. set verticalBarImage(value: Image);
  75637. private _setWindowPosition;
  75638. /** @hidden */
  75639. private _updateScroller;
  75640. _link(host: AdvancedDynamicTexture): void;
  75641. /** @hidden */
  75642. private _addBar;
  75643. /** @hidden */
  75644. private _attachWheel;
  75645. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75646. /** Releases associated resources */
  75647. dispose(): void;
  75648. }
  75649. }
  75650. declare module BABYLON.GUI {
  75651. /** Class used to render a grid */
  75652. export class DisplayGrid extends Control {
  75653. name?: string | undefined;
  75654. private _cellWidth;
  75655. private _cellHeight;
  75656. private _minorLineTickness;
  75657. private _minorLineColor;
  75658. private _majorLineTickness;
  75659. private _majorLineColor;
  75660. private _majorLineFrequency;
  75661. private _background;
  75662. private _displayMajorLines;
  75663. private _displayMinorLines;
  75664. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  75665. get displayMinorLines(): boolean;
  75666. set displayMinorLines(value: boolean);
  75667. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  75668. get displayMajorLines(): boolean;
  75669. set displayMajorLines(value: boolean);
  75670. /** Gets or sets background color (Black by default) */
  75671. get background(): string;
  75672. set background(value: string);
  75673. /** Gets or sets the width of each cell (20 by default) */
  75674. get cellWidth(): number;
  75675. set cellWidth(value: number);
  75676. /** Gets or sets the height of each cell (20 by default) */
  75677. get cellHeight(): number;
  75678. set cellHeight(value: number);
  75679. /** Gets or sets the tickness of minor lines (1 by default) */
  75680. get minorLineTickness(): number;
  75681. set minorLineTickness(value: number);
  75682. /** Gets or sets the color of minor lines (DarkGray by default) */
  75683. get minorLineColor(): string;
  75684. set minorLineColor(value: string);
  75685. /** Gets or sets the tickness of major lines (2 by default) */
  75686. get majorLineTickness(): number;
  75687. set majorLineTickness(value: number);
  75688. /** Gets or sets the color of major lines (White by default) */
  75689. get majorLineColor(): string;
  75690. set majorLineColor(value: string);
  75691. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  75692. get majorLineFrequency(): number;
  75693. set majorLineFrequency(value: number);
  75694. /**
  75695. * Creates a new GridDisplayRectangle
  75696. * @param name defines the control name
  75697. */
  75698. constructor(name?: string | undefined);
  75699. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75700. protected _getTypeName(): string;
  75701. }
  75702. }
  75703. declare module BABYLON.GUI {
  75704. /**
  75705. * Class used to create slider controls based on images
  75706. */
  75707. export class ImageBasedSlider extends BaseSlider {
  75708. name?: string | undefined;
  75709. private _backgroundImage;
  75710. private _thumbImage;
  75711. private _valueBarImage;
  75712. private _tempMeasure;
  75713. get displayThumb(): boolean;
  75714. set displayThumb(value: boolean);
  75715. /**
  75716. * Gets or sets the image used to render the background
  75717. */
  75718. get backgroundImage(): Image;
  75719. set backgroundImage(value: Image);
  75720. /**
  75721. * Gets or sets the image used to render the value bar
  75722. */
  75723. get valueBarImage(): Image;
  75724. set valueBarImage(value: Image);
  75725. /**
  75726. * Gets or sets the image used to render the thumb
  75727. */
  75728. get thumbImage(): Image;
  75729. set thumbImage(value: Image);
  75730. /**
  75731. * Creates a new ImageBasedSlider
  75732. * @param name defines the control name
  75733. */
  75734. constructor(name?: string | undefined);
  75735. protected _getTypeName(): string;
  75736. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75737. }
  75738. }
  75739. declare module BABYLON.GUI {
  75740. /**
  75741. * Forcing an export so that this code will execute
  75742. * @hidden
  75743. */
  75744. const name = "Statics";
  75745. }
  75746. declare module BABYLON.GUI {
  75747. /**
  75748. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  75749. */
  75750. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  75751. /**
  75752. * Define the instrumented AdvancedDynamicTexture.
  75753. */
  75754. texture: AdvancedDynamicTexture;
  75755. private _captureRenderTime;
  75756. private _renderTime;
  75757. private _captureLayoutTime;
  75758. private _layoutTime;
  75759. private _onBeginRenderObserver;
  75760. private _onEndRenderObserver;
  75761. private _onBeginLayoutObserver;
  75762. private _onEndLayoutObserver;
  75763. /**
  75764. * Gets the perf counter used to capture render time
  75765. */
  75766. get renderTimeCounter(): BABYLON.PerfCounter;
  75767. /**
  75768. * Gets the perf counter used to capture layout time
  75769. */
  75770. get layoutTimeCounter(): BABYLON.PerfCounter;
  75771. /**
  75772. * Enable or disable the render time capture
  75773. */
  75774. get captureRenderTime(): boolean;
  75775. set captureRenderTime(value: boolean);
  75776. /**
  75777. * Enable or disable the layout time capture
  75778. */
  75779. get captureLayoutTime(): boolean;
  75780. set captureLayoutTime(value: boolean);
  75781. /**
  75782. * Instantiates a new advanced dynamic texture instrumentation.
  75783. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  75784. * @param texture Defines the AdvancedDynamicTexture to instrument
  75785. */
  75786. constructor(
  75787. /**
  75788. * Define the instrumented AdvancedDynamicTexture.
  75789. */
  75790. texture: AdvancedDynamicTexture);
  75791. /**
  75792. * Dispose and release associated resources.
  75793. */
  75794. dispose(): void;
  75795. }
  75796. }
  75797. declare module BABYLON.GUI {
  75798. /**
  75799. * Class used to load GUI via XML.
  75800. */
  75801. export class XmlLoader {
  75802. private _nodes;
  75803. private _nodeTypes;
  75804. private _isLoaded;
  75805. private _objectAttributes;
  75806. private _parentClass;
  75807. /**
  75808. * Create a new xml loader
  75809. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  75810. */
  75811. constructor(parentClass?: null);
  75812. private _getChainElement;
  75813. private _getClassAttribute;
  75814. private _createGuiElement;
  75815. private _parseGrid;
  75816. private _parseElement;
  75817. private _prepareSourceElement;
  75818. private _parseElementsFromSource;
  75819. private _parseXml;
  75820. /**
  75821. * Gets if the loading has finished.
  75822. * @returns whether the loading has finished or not
  75823. */
  75824. isLoaded(): boolean;
  75825. /**
  75826. * Gets a loaded node / control by id.
  75827. * @param id the Controls id set in the xml
  75828. * @returns element of type Control
  75829. */
  75830. getNodeById(id: string): any;
  75831. /**
  75832. * Gets all loaded nodes / controls
  75833. * @returns Array of controls
  75834. */
  75835. getNodes(): any;
  75836. /**
  75837. * Initiates the xml layout loading
  75838. * @param xmlFile defines the xml layout to load
  75839. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  75840. * @param callback defines the callback called on layout load.
  75841. */
  75842. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  75843. }
  75844. }
  75845. declare module BABYLON.GUI {
  75846. /**
  75847. * Class used to create containers for controls
  75848. */
  75849. export class Container3D extends Control3D {
  75850. private _blockLayout;
  75851. /**
  75852. * Gets the list of child controls
  75853. */
  75854. protected _children: Control3D[];
  75855. /**
  75856. * Gets the list of child controls
  75857. */
  75858. get children(): Array<Control3D>;
  75859. /**
  75860. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  75861. * This is helpful to optimize layout operation when adding multiple children in a row
  75862. */
  75863. get blockLayout(): boolean;
  75864. set blockLayout(value: boolean);
  75865. /**
  75866. * Creates a new container
  75867. * @param name defines the container name
  75868. */
  75869. constructor(name?: string);
  75870. /**
  75871. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  75872. * @returns the current container
  75873. */
  75874. updateLayout(): Container3D;
  75875. /**
  75876. * Gets a boolean indicating if the given control is in the children of this control
  75877. * @param control defines the control to check
  75878. * @returns true if the control is in the child list
  75879. */
  75880. containsControl(control: Control3D): boolean;
  75881. /**
  75882. * Adds a control to the children of this control
  75883. * @param control defines the control to add
  75884. * @returns the current container
  75885. */
  75886. addControl(control: Control3D): Container3D;
  75887. /**
  75888. * This function will be called everytime a new control is added
  75889. */
  75890. protected _arrangeChildren(): void;
  75891. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  75892. /**
  75893. * Removes a control from the children of this control
  75894. * @param control defines the control to remove
  75895. * @returns the current container
  75896. */
  75897. removeControl(control: Control3D): Container3D;
  75898. protected _getTypeName(): string;
  75899. /**
  75900. * Releases all associated resources
  75901. */
  75902. dispose(): void;
  75903. /** Control rotation will remain unchanged */
  75904. static readonly UNSET_ORIENTATION: number;
  75905. /** Control will rotate to make it look at sphere central axis */
  75906. static readonly FACEORIGIN_ORIENTATION: number;
  75907. /** Control will rotate to make it look back at sphere central axis */
  75908. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  75909. /** Control will rotate to look at z axis (0, 0, 1) */
  75910. static readonly FACEFORWARD_ORIENTATION: number;
  75911. /** Control will rotate to look at negative z axis (0, 0, -1) */
  75912. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  75913. }
  75914. }
  75915. declare module BABYLON.GUI {
  75916. /**
  75917. * Class used to manage 3D user interface
  75918. * @see http://doc.babylonjs.com/how_to/gui3d
  75919. */
  75920. export class GUI3DManager implements BABYLON.IDisposable {
  75921. private _scene;
  75922. private _sceneDisposeObserver;
  75923. private _utilityLayer;
  75924. private _rootContainer;
  75925. private _pointerObserver;
  75926. private _pointerOutObserver;
  75927. /** @hidden */
  75928. _lastPickedControl: Control3D;
  75929. /** @hidden */
  75930. _lastControlOver: {
  75931. [pointerId: number]: Control3D;
  75932. };
  75933. /** @hidden */
  75934. _lastControlDown: {
  75935. [pointerId: number]: Control3D;
  75936. };
  75937. /**
  75938. * BABYLON.Observable raised when the point picked by the pointer events changed
  75939. */
  75940. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  75941. /** @hidden */
  75942. _sharedMaterials: {
  75943. [key: string]: BABYLON.Material;
  75944. };
  75945. /** Gets the hosting scene */
  75946. get scene(): BABYLON.Scene;
  75947. /** Gets associated utility layer */
  75948. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  75949. /**
  75950. * Creates a new GUI3DManager
  75951. * @param scene
  75952. */
  75953. constructor(scene?: BABYLON.Scene);
  75954. private _handlePointerOut;
  75955. private _doPicking;
  75956. /**
  75957. * Gets the root container
  75958. */
  75959. get rootContainer(): Container3D;
  75960. /**
  75961. * Gets a boolean indicating if the given control is in the root child list
  75962. * @param control defines the control to check
  75963. * @returns true if the control is in the root child list
  75964. */
  75965. containsControl(control: Control3D): boolean;
  75966. /**
  75967. * Adds a control to the root child list
  75968. * @param control defines the control to add
  75969. * @returns the current manager
  75970. */
  75971. addControl(control: Control3D): GUI3DManager;
  75972. /**
  75973. * Removes a control from the root child list
  75974. * @param control defines the control to remove
  75975. * @returns the current container
  75976. */
  75977. removeControl(control: Control3D): GUI3DManager;
  75978. /**
  75979. * Releases all associated resources
  75980. */
  75981. dispose(): void;
  75982. }
  75983. }
  75984. declare module BABYLON.GUI {
  75985. /**
  75986. * Class used to transport BABYLON.Vector3 information for pointer events
  75987. */
  75988. export class Vector3WithInfo extends BABYLON.Vector3 {
  75989. /** defines the current mouse button index */
  75990. buttonIndex: number;
  75991. /**
  75992. * Creates a new Vector3WithInfo
  75993. * @param source defines the vector3 data to transport
  75994. * @param buttonIndex defines the current mouse button index
  75995. */
  75996. constructor(source: BABYLON.Vector3,
  75997. /** defines the current mouse button index */
  75998. buttonIndex?: number);
  75999. }
  76000. }
  76001. declare module BABYLON.GUI {
  76002. /**
  76003. * Class used as base class for controls
  76004. */
  76005. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76006. /** Defines the control name */
  76007. name?: string | undefined;
  76008. /** @hidden */
  76009. _host: GUI3DManager;
  76010. private _node;
  76011. private _downCount;
  76012. private _enterCount;
  76013. private _downPointerIds;
  76014. private _isVisible;
  76015. /** Gets or sets the control position in world space */
  76016. get position(): BABYLON.Vector3;
  76017. set position(value: BABYLON.Vector3);
  76018. /** Gets or sets the control scaling in world space */
  76019. get scaling(): BABYLON.Vector3;
  76020. set scaling(value: BABYLON.Vector3);
  76021. /** Callback used to start pointer enter animation */
  76022. pointerEnterAnimation: () => void;
  76023. /** Callback used to start pointer out animation */
  76024. pointerOutAnimation: () => void;
  76025. /** Callback used to start pointer down animation */
  76026. pointerDownAnimation: () => void;
  76027. /** Callback used to start pointer up animation */
  76028. pointerUpAnimation: () => void;
  76029. /**
  76030. * An event triggered when the pointer move over the control
  76031. */
  76032. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  76033. /**
  76034. * An event triggered when the pointer move out of the control
  76035. */
  76036. onPointerOutObservable: BABYLON.Observable<Control3D>;
  76037. /**
  76038. * An event triggered when the pointer taps the control
  76039. */
  76040. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  76041. /**
  76042. * An event triggered when pointer is up
  76043. */
  76044. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  76045. /**
  76046. * An event triggered when a control is clicked on (with a mouse)
  76047. */
  76048. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  76049. /**
  76050. * An event triggered when pointer enters the control
  76051. */
  76052. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  76053. /**
  76054. * Gets or sets the parent container
  76055. */
  76056. parent: BABYLON.Nullable<Container3D>;
  76057. private _behaviors;
  76058. /**
  76059. * Gets the list of attached behaviors
  76060. * @see http://doc.babylonjs.com/features/behaviour
  76061. */
  76062. get behaviors(): BABYLON.Behavior<Control3D>[];
  76063. /**
  76064. * Attach a behavior to the control
  76065. * @see http://doc.babylonjs.com/features/behaviour
  76066. * @param behavior defines the behavior to attach
  76067. * @returns the current control
  76068. */
  76069. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76070. /**
  76071. * Remove an attached behavior
  76072. * @see http://doc.babylonjs.com/features/behaviour
  76073. * @param behavior defines the behavior to attach
  76074. * @returns the current control
  76075. */
  76076. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76077. /**
  76078. * Gets an attached behavior by name
  76079. * @param name defines the name of the behavior to look for
  76080. * @see http://doc.babylonjs.com/features/behaviour
  76081. * @returns null if behavior was not found else the requested behavior
  76082. */
  76083. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  76084. /** Gets or sets a boolean indicating if the control is visible */
  76085. get isVisible(): boolean;
  76086. set isVisible(value: boolean);
  76087. /**
  76088. * Creates a new control
  76089. * @param name defines the control name
  76090. */
  76091. constructor(
  76092. /** Defines the control name */
  76093. name?: string | undefined);
  76094. /**
  76095. * Gets a string representing the class name
  76096. */
  76097. get typeName(): string;
  76098. /**
  76099. * Get the current class name of the control.
  76100. * @returns current class name
  76101. */
  76102. getClassName(): string;
  76103. protected _getTypeName(): string;
  76104. /**
  76105. * Gets the transform node used by this control
  76106. */
  76107. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  76108. /**
  76109. * Gets the mesh used to render this control
  76110. */
  76111. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76112. /**
  76113. * Link the control as child of the given node
  76114. * @param node defines the node to link to. Use null to unlink the control
  76115. * @returns the current control
  76116. */
  76117. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  76118. /** @hidden **/
  76119. _prepareNode(scene: BABYLON.Scene): void;
  76120. /**
  76121. * Node creation.
  76122. * Can be overriden by children
  76123. * @param scene defines the scene where the node must be attached
  76124. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  76125. */
  76126. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76127. /**
  76128. * Affect a material to the given mesh
  76129. * @param mesh defines the mesh which will represent the control
  76130. */
  76131. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76132. /** @hidden */
  76133. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  76134. /** @hidden */
  76135. _onPointerEnter(target: Control3D): boolean;
  76136. /** @hidden */
  76137. _onPointerOut(target: Control3D): void;
  76138. /** @hidden */
  76139. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76140. /** @hidden */
  76141. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76142. /** @hidden */
  76143. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76144. /** @hidden */
  76145. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76146. /** @hidden */
  76147. _disposeNode(): void;
  76148. /**
  76149. * Releases all associated resources
  76150. */
  76151. dispose(): void;
  76152. }
  76153. }
  76154. declare module BABYLON.GUI {
  76155. /**
  76156. * Class used as a root to all buttons
  76157. */
  76158. export class AbstractButton3D extends Control3D {
  76159. /**
  76160. * Creates a new button
  76161. * @param name defines the control name
  76162. */
  76163. constructor(name?: string);
  76164. protected _getTypeName(): string;
  76165. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76166. }
  76167. }
  76168. declare module BABYLON.GUI {
  76169. /**
  76170. * Class used to create a button in 3D
  76171. */
  76172. export class Button3D extends AbstractButton3D {
  76173. /** @hidden */
  76174. protected _currentMaterial: BABYLON.Material;
  76175. private _facadeTexture;
  76176. private _content;
  76177. private _contentResolution;
  76178. private _contentScaleRatio;
  76179. /**
  76180. * Gets or sets the texture resolution used to render content (512 by default)
  76181. */
  76182. get contentResolution(): BABYLON.int;
  76183. set contentResolution(value: BABYLON.int);
  76184. /**
  76185. * Gets or sets the texture scale ratio used to render content (2 by default)
  76186. */
  76187. get contentScaleRatio(): number;
  76188. set contentScaleRatio(value: number);
  76189. protected _disposeFacadeTexture(): void;
  76190. protected _resetContent(): void;
  76191. /**
  76192. * Creates a new button
  76193. * @param name defines the control name
  76194. */
  76195. constructor(name?: string);
  76196. /**
  76197. * Gets or sets the GUI 2D content used to display the button's facade
  76198. */
  76199. get content(): Control;
  76200. set content(value: Control);
  76201. /**
  76202. * Apply the facade texture (created from the content property).
  76203. * This function can be overloaded by child classes
  76204. * @param facadeTexture defines the AdvancedDynamicTexture to use
  76205. */
  76206. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76207. protected _getTypeName(): string;
  76208. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76209. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76210. /**
  76211. * Releases all associated resources
  76212. */
  76213. dispose(): void;
  76214. }
  76215. }
  76216. declare module BABYLON.GUI {
  76217. /**
  76218. * Abstract class used to create a container panel deployed on the surface of a volume
  76219. */
  76220. export abstract class VolumeBasedPanel extends Container3D {
  76221. private _columns;
  76222. private _rows;
  76223. private _rowThenColum;
  76224. private _orientation;
  76225. protected _cellWidth: number;
  76226. protected _cellHeight: number;
  76227. /**
  76228. * Gets or sets the distance between elements
  76229. */
  76230. margin: number;
  76231. /**
  76232. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  76233. * | Value | Type | Description |
  76234. * | ----- | ----------------------------------- | ----------- |
  76235. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  76236. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  76237. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  76238. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  76239. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  76240. */
  76241. get orientation(): number;
  76242. set orientation(value: number);
  76243. /**
  76244. * Gets or sets the number of columns requested (10 by default).
  76245. * The panel will automatically compute the number of rows based on number of child controls.
  76246. */
  76247. get columns(): BABYLON.int;
  76248. set columns(value: BABYLON.int);
  76249. /**
  76250. * Gets or sets a the number of rows requested.
  76251. * The panel will automatically compute the number of columns based on number of child controls.
  76252. */
  76253. get rows(): BABYLON.int;
  76254. set rows(value: BABYLON.int);
  76255. /**
  76256. * Creates new VolumeBasedPanel
  76257. */
  76258. constructor();
  76259. protected _arrangeChildren(): void;
  76260. /** Child classes must implement this function to provide correct control positioning */
  76261. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76262. /** Child classes can implement this function to provide additional processing */
  76263. protected _finalProcessing(): void;
  76264. }
  76265. }
  76266. declare module BABYLON.GUI {
  76267. /**
  76268. * Class used to create a container panel deployed on the surface of a cylinder
  76269. */
  76270. export class CylinderPanel extends VolumeBasedPanel {
  76271. private _radius;
  76272. /**
  76273. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  76274. */
  76275. get radius(): BABYLON.float;
  76276. set radius(value: BABYLON.float);
  76277. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76278. private _cylindricalMapping;
  76279. }
  76280. }
  76281. declare module BABYLON.GUI {
  76282. /** @hidden */
  76283. export var fluentVertexShader: {
  76284. name: string;
  76285. shader: string;
  76286. };
  76287. }
  76288. declare module BABYLON.GUI {
  76289. /** @hidden */
  76290. export var fluentPixelShader: {
  76291. name: string;
  76292. shader: string;
  76293. };
  76294. }
  76295. declare module BABYLON.GUI {
  76296. /** @hidden */
  76297. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  76298. INNERGLOW: boolean;
  76299. BORDER: boolean;
  76300. HOVERLIGHT: boolean;
  76301. TEXTURE: boolean;
  76302. constructor();
  76303. }
  76304. /**
  76305. * Class used to render controls with fluent desgin
  76306. */
  76307. export class FluentMaterial extends BABYLON.PushMaterial {
  76308. /**
  76309. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  76310. */
  76311. innerGlowColorIntensity: number;
  76312. /**
  76313. * Gets or sets the inner glow color (white by default)
  76314. */
  76315. innerGlowColor: BABYLON.Color3;
  76316. /**
  76317. * Gets or sets alpha value (default is 1.0)
  76318. */
  76319. alpha: number;
  76320. /**
  76321. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  76322. */
  76323. albedoColor: BABYLON.Color3;
  76324. /**
  76325. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  76326. */
  76327. renderBorders: boolean;
  76328. /**
  76329. * Gets or sets border width (default is 0.5)
  76330. */
  76331. borderWidth: number;
  76332. /**
  76333. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  76334. */
  76335. edgeSmoothingValue: number;
  76336. /**
  76337. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  76338. */
  76339. borderMinValue: number;
  76340. /**
  76341. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  76342. */
  76343. renderHoverLight: boolean;
  76344. /**
  76345. * Gets or sets the radius used to render the hover light (default is 1.0)
  76346. */
  76347. hoverRadius: number;
  76348. /**
  76349. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  76350. */
  76351. hoverColor: BABYLON.Color4;
  76352. /**
  76353. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  76354. */
  76355. hoverPosition: BABYLON.Vector3;
  76356. private _albedoTexture;
  76357. /** Gets or sets the texture to use for albedo color */
  76358. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76359. /**
  76360. * Creates a new Fluent material
  76361. * @param name defines the name of the material
  76362. * @param scene defines the hosting scene
  76363. */
  76364. constructor(name: string, scene: BABYLON.Scene);
  76365. needAlphaBlending(): boolean;
  76366. needAlphaTesting(): boolean;
  76367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76370. getActiveTextures(): BABYLON.BaseTexture[];
  76371. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76372. dispose(forceDisposeEffect?: boolean): void;
  76373. clone(name: string): FluentMaterial;
  76374. serialize(): any;
  76375. getClassName(): string;
  76376. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  76377. }
  76378. }
  76379. declare module BABYLON.GUI {
  76380. /**
  76381. * Class used to create a holographic button in 3D
  76382. */
  76383. export class HolographicButton extends Button3D {
  76384. private _backPlate;
  76385. private _textPlate;
  76386. private _frontPlate;
  76387. private _text;
  76388. private _imageUrl;
  76389. private _shareMaterials;
  76390. private _frontMaterial;
  76391. private _backMaterial;
  76392. private _plateMaterial;
  76393. private _pickedPointObserver;
  76394. private _tooltipFade;
  76395. private _tooltipTextBlock;
  76396. private _tooltipTexture;
  76397. private _tooltipMesh;
  76398. private _tooltipHoverObserver;
  76399. private _tooltipOutObserver;
  76400. private _disposeTooltip;
  76401. /**
  76402. * Rendering ground id of all the mesh in the button
  76403. */
  76404. set renderingGroupId(id: number);
  76405. get renderingGroupId(): number;
  76406. /**
  76407. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  76408. */
  76409. set tooltipText(text: BABYLON.Nullable<string>);
  76410. get tooltipText(): BABYLON.Nullable<string>;
  76411. /**
  76412. * Gets or sets text for the button
  76413. */
  76414. get text(): string;
  76415. set text(value: string);
  76416. /**
  76417. * Gets or sets the image url for the button
  76418. */
  76419. get imageUrl(): string;
  76420. set imageUrl(value: string);
  76421. /**
  76422. * Gets the back material used by this button
  76423. */
  76424. get backMaterial(): FluentMaterial;
  76425. /**
  76426. * Gets the front material used by this button
  76427. */
  76428. get frontMaterial(): FluentMaterial;
  76429. /**
  76430. * Gets the plate material used by this button
  76431. */
  76432. get plateMaterial(): BABYLON.StandardMaterial;
  76433. /**
  76434. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  76435. */
  76436. get shareMaterials(): boolean;
  76437. /**
  76438. * Creates a new button
  76439. * @param name defines the control name
  76440. */
  76441. constructor(name?: string, shareMaterials?: boolean);
  76442. protected _getTypeName(): string;
  76443. private _rebuildContent;
  76444. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76445. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76446. private _createBackMaterial;
  76447. private _createFrontMaterial;
  76448. private _createPlateMaterial;
  76449. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  76450. /**
  76451. * Releases all associated resources
  76452. */
  76453. dispose(): void;
  76454. }
  76455. }
  76456. declare module BABYLON.GUI {
  76457. /**
  76458. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  76459. */
  76460. export class MeshButton3D extends Button3D {
  76461. /** @hidden */
  76462. protected _currentMesh: BABYLON.Mesh;
  76463. /**
  76464. * Creates a new 3D button based on a mesh
  76465. * @param mesh mesh to become a 3D button
  76466. * @param name defines the control name
  76467. */
  76468. constructor(mesh: BABYLON.Mesh, name?: string);
  76469. protected _getTypeName(): string;
  76470. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76471. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76472. }
  76473. }
  76474. declare module BABYLON.GUI {
  76475. /**
  76476. * Class used to create a container panel deployed on the surface of a plane
  76477. */
  76478. export class PlanePanel extends VolumeBasedPanel {
  76479. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76480. }
  76481. }
  76482. declare module BABYLON.GUI {
  76483. /**
  76484. * Class used to create a container panel where items get randomized planar mapping
  76485. */
  76486. export class ScatterPanel extends VolumeBasedPanel {
  76487. private _iteration;
  76488. /**
  76489. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  76490. */
  76491. get iteration(): BABYLON.float;
  76492. set iteration(value: BABYLON.float);
  76493. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76494. private _scatterMapping;
  76495. protected _finalProcessing(): void;
  76496. }
  76497. }
  76498. declare module BABYLON.GUI {
  76499. /**
  76500. * Class used to create a container panel deployed on the surface of a sphere
  76501. */
  76502. export class SpherePanel extends VolumeBasedPanel {
  76503. private _radius;
  76504. /**
  76505. * Gets or sets the radius of the sphere where to project controls (5 by default)
  76506. */
  76507. get radius(): BABYLON.float;
  76508. set radius(value: BABYLON.float);
  76509. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76510. private _sphericalMapping;
  76511. }
  76512. }
  76513. declare module BABYLON.GUI {
  76514. /**
  76515. * Class used to create a stack panel in 3D on XY plane
  76516. */
  76517. export class StackPanel3D extends Container3D {
  76518. private _isVertical;
  76519. /**
  76520. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  76521. */
  76522. get isVertical(): boolean;
  76523. set isVertical(value: boolean);
  76524. /**
  76525. * Gets or sets the distance between elements
  76526. */
  76527. margin: number;
  76528. /**
  76529. * Creates new StackPanel
  76530. * @param isVertical
  76531. */
  76532. constructor(isVertical?: boolean);
  76533. protected _arrangeChildren(): void;
  76534. }
  76535. }
  76536. declare module BABYLON {
  76537. /**
  76538. * Configuration for glTF validation
  76539. */
  76540. export interface IGLTFValidationConfiguration {
  76541. /**
  76542. * The url of the glTF validator.
  76543. */
  76544. url: string;
  76545. }
  76546. /**
  76547. * glTF validation
  76548. */
  76549. export class GLTFValidation {
  76550. /**
  76551. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  76552. */
  76553. static Configuration: IGLTFValidationConfiguration;
  76554. private static _LoadScriptPromise;
  76555. /**
  76556. * Validate a glTF asset using the glTF-Validator.
  76557. * @param data The JSON of a glTF or the array buffer of a binary glTF
  76558. * @param rootUrl The root url for the glTF
  76559. * @param fileName The file name for the glTF
  76560. * @param getExternalResource The callback to get external resources for the glTF validator
  76561. * @returns A promise that resolves with the glTF validation results once complete
  76562. */
  76563. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  76564. }
  76565. }
  76566. declare module BABYLON {
  76567. /**
  76568. * Mode that determines the coordinate system to use.
  76569. */
  76570. export enum GLTFLoaderCoordinateSystemMode {
  76571. /**
  76572. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  76573. */
  76574. AUTO = 0,
  76575. /**
  76576. * Sets the useRightHandedSystem flag on the scene.
  76577. */
  76578. FORCE_RIGHT_HANDED = 1
  76579. }
  76580. /**
  76581. * Mode that determines what animations will start.
  76582. */
  76583. export enum GLTFLoaderAnimationStartMode {
  76584. /**
  76585. * No animation will start.
  76586. */
  76587. NONE = 0,
  76588. /**
  76589. * The first animation will start.
  76590. */
  76591. FIRST = 1,
  76592. /**
  76593. * All animations will start.
  76594. */
  76595. ALL = 2
  76596. }
  76597. /**
  76598. * Interface that contains the data for the glTF asset.
  76599. */
  76600. export interface IGLTFLoaderData {
  76601. /**
  76602. * The object that represents the glTF JSON.
  76603. */
  76604. json: Object;
  76605. /**
  76606. * The BIN chunk of a binary glTF.
  76607. */
  76608. bin: Nullable<IDataBuffer>;
  76609. }
  76610. /**
  76611. * Interface for extending the loader.
  76612. */
  76613. export interface IGLTFLoaderExtension {
  76614. /**
  76615. * The name of this extension.
  76616. */
  76617. readonly name: string;
  76618. /**
  76619. * Defines whether this extension is enabled.
  76620. */
  76621. enabled: boolean;
  76622. /**
  76623. * Defines the order of this extension.
  76624. * The loader sorts the extensions using these values when loading.
  76625. */
  76626. order?: number;
  76627. }
  76628. /**
  76629. * Loader state.
  76630. */
  76631. export enum GLTFLoaderState {
  76632. /**
  76633. * The asset is loading.
  76634. */
  76635. LOADING = 0,
  76636. /**
  76637. * The asset is ready for rendering.
  76638. */
  76639. READY = 1,
  76640. /**
  76641. * The asset is completely loaded.
  76642. */
  76643. COMPLETE = 2
  76644. }
  76645. /** @hidden */
  76646. export interface IImportMeshAsyncOutput {
  76647. meshes: AbstractMesh[];
  76648. particleSystems: IParticleSystem[];
  76649. skeletons: Skeleton[];
  76650. animationGroups: AnimationGroup[];
  76651. lights: Light[];
  76652. transformNodes: TransformNode[];
  76653. }
  76654. /** @hidden */
  76655. export interface IGLTFLoader extends IDisposable {
  76656. readonly state: Nullable<GLTFLoaderState>;
  76657. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  76658. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  76659. }
  76660. /**
  76661. * File loader for loading glTF files into a scene.
  76662. */
  76663. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76664. /** @hidden */
  76665. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76666. /** @hidden */
  76667. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76668. /**
  76669. * Raised when the asset has been parsed
  76670. */
  76671. onParsedObservable: Observable<IGLTFLoaderData>;
  76672. private _onParsedObserver;
  76673. /**
  76674. * Raised when the asset has been parsed
  76675. */
  76676. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  76677. /**
  76678. * 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.
  76679. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  76680. * Defaults to true.
  76681. * @hidden
  76682. */
  76683. static IncrementalLoading: boolean;
  76684. /**
  76685. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  76686. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  76687. * @hidden
  76688. */
  76689. static HomogeneousCoordinates: boolean;
  76690. /**
  76691. * The coordinate system mode. Defaults to AUTO.
  76692. */
  76693. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  76694. /**
  76695. * The animation start mode. Defaults to FIRST.
  76696. */
  76697. animationStartMode: GLTFLoaderAnimationStartMode;
  76698. /**
  76699. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  76700. */
  76701. compileMaterials: boolean;
  76702. /**
  76703. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  76704. */
  76705. useClipPlane: boolean;
  76706. /**
  76707. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  76708. */
  76709. compileShadowGenerators: boolean;
  76710. /**
  76711. * Defines if the Alpha blended materials are only applied as coverage.
  76712. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  76713. * If true, no extra effects are applied to transparent pixels.
  76714. */
  76715. transparencyAsCoverage: boolean;
  76716. /**
  76717. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  76718. * Enabling will disable offline support and glTF validator.
  76719. * Defaults to false.
  76720. */
  76721. useRangeRequests: boolean;
  76722. /**
  76723. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  76724. */
  76725. createInstances: boolean;
  76726. /**
  76727. * Function called before loading a url referenced by the asset.
  76728. */
  76729. preprocessUrlAsync: (url: string) => Promise<string>;
  76730. /**
  76731. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76732. */
  76733. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  76734. private _onMeshLoadedObserver;
  76735. /**
  76736. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76737. */
  76738. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  76739. /**
  76740. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  76741. */
  76742. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  76743. private _onTextureLoadedObserver;
  76744. /**
  76745. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  76746. */
  76747. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  76748. /**
  76749. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  76750. */
  76751. readonly onMaterialLoadedObservable: Observable<Material>;
  76752. private _onMaterialLoadedObserver;
  76753. /**
  76754. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  76755. */
  76756. set onMaterialLoaded(callback: (material: Material) => void);
  76757. /**
  76758. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  76759. */
  76760. readonly onCameraLoadedObservable: Observable<Camera>;
  76761. private _onCameraLoadedObserver;
  76762. /**
  76763. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  76764. */
  76765. set onCameraLoaded(callback: (camera: Camera) => void);
  76766. /**
  76767. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  76768. * For assets with LODs, raised when all of the LODs are complete.
  76769. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76770. */
  76771. readonly onCompleteObservable: Observable<void>;
  76772. private _onCompleteObserver;
  76773. /**
  76774. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  76775. * For assets with LODs, raised when all of the LODs are complete.
  76776. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76777. */
  76778. set onComplete(callback: () => void);
  76779. /**
  76780. * Observable raised when an error occurs.
  76781. */
  76782. readonly onErrorObservable: Observable<any>;
  76783. private _onErrorObserver;
  76784. /**
  76785. * Callback raised when an error occurs.
  76786. */
  76787. set onError(callback: (reason: any) => void);
  76788. /**
  76789. * Observable raised after the loader is disposed.
  76790. */
  76791. readonly onDisposeObservable: Observable<void>;
  76792. private _onDisposeObserver;
  76793. /**
  76794. * Callback raised after the loader is disposed.
  76795. */
  76796. set onDispose(callback: () => void);
  76797. /**
  76798. * Observable raised after a loader extension is created.
  76799. * Set additional options for a loader extension in this event.
  76800. */
  76801. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  76802. private _onExtensionLoadedObserver;
  76803. /**
  76804. * Callback raised after a loader extension is created.
  76805. */
  76806. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  76807. /**
  76808. * Defines if the loader logging is enabled.
  76809. */
  76810. get loggingEnabled(): boolean;
  76811. set loggingEnabled(value: boolean);
  76812. /**
  76813. * Defines if the loader should capture performance counters.
  76814. */
  76815. get capturePerformanceCounters(): boolean;
  76816. set capturePerformanceCounters(value: boolean);
  76817. /**
  76818. * Defines if the loader should validate the asset.
  76819. */
  76820. validate: boolean;
  76821. /**
  76822. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  76823. */
  76824. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  76825. private _onValidatedObserver;
  76826. /**
  76827. * Callback raised after a loader extension is created.
  76828. */
  76829. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  76830. private _loader;
  76831. /**
  76832. * Name of the loader ("gltf")
  76833. */
  76834. name: string;
  76835. /** @hidden */
  76836. extensions: ISceneLoaderPluginExtensions;
  76837. /**
  76838. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  76839. */
  76840. dispose(): void;
  76841. /** @hidden */
  76842. _clear(): void;
  76843. /** @hidden */
  76844. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76845. /** @hidden */
  76846. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76847. /** @hidden */
  76848. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76849. meshes: AbstractMesh[];
  76850. particleSystems: IParticleSystem[];
  76851. skeletons: Skeleton[];
  76852. animationGroups: AnimationGroup[];
  76853. }>;
  76854. /** @hidden */
  76855. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76856. /** @hidden */
  76857. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76858. /** @hidden */
  76859. canDirectLoad(data: string): boolean;
  76860. /** @hidden */
  76861. directLoad(scene: Scene, data: string): any;
  76862. /**
  76863. * The callback that allows custom handling of the root url based on the response url.
  76864. * @param rootUrl the original root url
  76865. * @param responseURL the response url if available
  76866. * @returns the new root url
  76867. */
  76868. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  76869. /** @hidden */
  76870. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  76871. /**
  76872. * The loader state or null if the loader is not active.
  76873. */
  76874. get loaderState(): Nullable<GLTFLoaderState>;
  76875. /**
  76876. * Returns a promise that resolves when the asset is completely loaded.
  76877. * @returns a promise that resolves when the asset is completely loaded.
  76878. */
  76879. whenCompleteAsync(): Promise<void>;
  76880. private _validate;
  76881. private _getLoader;
  76882. private _parseJson;
  76883. private _unpackBinaryAsync;
  76884. private _unpackBinaryV1Async;
  76885. private _unpackBinaryV2Async;
  76886. private static _parseVersion;
  76887. private static _compareVersion;
  76888. private static readonly _logSpaces;
  76889. private _logIndentLevel;
  76890. private _loggingEnabled;
  76891. /** @hidden */
  76892. _log: (message: string) => void;
  76893. /** @hidden */
  76894. _logOpen(message: string): void;
  76895. /** @hidden */
  76896. _logClose(): void;
  76897. private _logEnabled;
  76898. private _logDisabled;
  76899. private _capturePerformanceCounters;
  76900. /** @hidden */
  76901. _startPerformanceCounter: (counterName: string) => void;
  76902. /** @hidden */
  76903. _endPerformanceCounter: (counterName: string) => void;
  76904. private _startPerformanceCounterEnabled;
  76905. private _startPerformanceCounterDisabled;
  76906. private _endPerformanceCounterEnabled;
  76907. private _endPerformanceCounterDisabled;
  76908. }
  76909. }
  76910. declare module BABYLON.GLTF1 {
  76911. /**
  76912. * Enums
  76913. * @hidden
  76914. */
  76915. export enum EComponentType {
  76916. BYTE = 5120,
  76917. UNSIGNED_BYTE = 5121,
  76918. SHORT = 5122,
  76919. UNSIGNED_SHORT = 5123,
  76920. FLOAT = 5126
  76921. }
  76922. /** @hidden */
  76923. export enum EShaderType {
  76924. FRAGMENT = 35632,
  76925. VERTEX = 35633
  76926. }
  76927. /** @hidden */
  76928. export enum EParameterType {
  76929. BYTE = 5120,
  76930. UNSIGNED_BYTE = 5121,
  76931. SHORT = 5122,
  76932. UNSIGNED_SHORT = 5123,
  76933. INT = 5124,
  76934. UNSIGNED_INT = 5125,
  76935. FLOAT = 5126,
  76936. FLOAT_VEC2 = 35664,
  76937. FLOAT_VEC3 = 35665,
  76938. FLOAT_VEC4 = 35666,
  76939. INT_VEC2 = 35667,
  76940. INT_VEC3 = 35668,
  76941. INT_VEC4 = 35669,
  76942. BOOL = 35670,
  76943. BOOL_VEC2 = 35671,
  76944. BOOL_VEC3 = 35672,
  76945. BOOL_VEC4 = 35673,
  76946. FLOAT_MAT2 = 35674,
  76947. FLOAT_MAT3 = 35675,
  76948. FLOAT_MAT4 = 35676,
  76949. SAMPLER_2D = 35678
  76950. }
  76951. /** @hidden */
  76952. export enum ETextureWrapMode {
  76953. CLAMP_TO_EDGE = 33071,
  76954. MIRRORED_REPEAT = 33648,
  76955. REPEAT = 10497
  76956. }
  76957. /** @hidden */
  76958. export enum ETextureFilterType {
  76959. NEAREST = 9728,
  76960. LINEAR = 9728,
  76961. NEAREST_MIPMAP_NEAREST = 9984,
  76962. LINEAR_MIPMAP_NEAREST = 9985,
  76963. NEAREST_MIPMAP_LINEAR = 9986,
  76964. LINEAR_MIPMAP_LINEAR = 9987
  76965. }
  76966. /** @hidden */
  76967. export enum ETextureFormat {
  76968. ALPHA = 6406,
  76969. RGB = 6407,
  76970. RGBA = 6408,
  76971. LUMINANCE = 6409,
  76972. LUMINANCE_ALPHA = 6410
  76973. }
  76974. /** @hidden */
  76975. export enum ECullingType {
  76976. FRONT = 1028,
  76977. BACK = 1029,
  76978. FRONT_AND_BACK = 1032
  76979. }
  76980. /** @hidden */
  76981. export enum EBlendingFunction {
  76982. ZERO = 0,
  76983. ONE = 1,
  76984. SRC_COLOR = 768,
  76985. ONE_MINUS_SRC_COLOR = 769,
  76986. DST_COLOR = 774,
  76987. ONE_MINUS_DST_COLOR = 775,
  76988. SRC_ALPHA = 770,
  76989. ONE_MINUS_SRC_ALPHA = 771,
  76990. DST_ALPHA = 772,
  76991. ONE_MINUS_DST_ALPHA = 773,
  76992. CONSTANT_COLOR = 32769,
  76993. ONE_MINUS_CONSTANT_COLOR = 32770,
  76994. CONSTANT_ALPHA = 32771,
  76995. ONE_MINUS_CONSTANT_ALPHA = 32772,
  76996. SRC_ALPHA_SATURATE = 776
  76997. }
  76998. /** @hidden */
  76999. export interface IGLTFProperty {
  77000. extensions?: {
  77001. [key: string]: any;
  77002. };
  77003. extras?: Object;
  77004. }
  77005. /** @hidden */
  77006. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77007. name?: string;
  77008. }
  77009. /** @hidden */
  77010. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77011. bufferView: string;
  77012. byteOffset: number;
  77013. byteStride: number;
  77014. count: number;
  77015. type: string;
  77016. componentType: EComponentType;
  77017. max?: number[];
  77018. min?: number[];
  77019. name?: string;
  77020. }
  77021. /** @hidden */
  77022. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  77023. buffer: string;
  77024. byteOffset: number;
  77025. byteLength: number;
  77026. byteStride: number;
  77027. target?: number;
  77028. }
  77029. /** @hidden */
  77030. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  77031. uri: string;
  77032. byteLength?: number;
  77033. type?: string;
  77034. }
  77035. /** @hidden */
  77036. export interface IGLTFShader extends IGLTFChildRootProperty {
  77037. uri: string;
  77038. type: EShaderType;
  77039. }
  77040. /** @hidden */
  77041. export interface IGLTFProgram extends IGLTFChildRootProperty {
  77042. attributes: string[];
  77043. fragmentShader: string;
  77044. vertexShader: string;
  77045. }
  77046. /** @hidden */
  77047. export interface IGLTFTechniqueParameter {
  77048. type: number;
  77049. count?: number;
  77050. semantic?: string;
  77051. node?: string;
  77052. value?: number | boolean | string | Array<any>;
  77053. source?: string;
  77054. babylonValue?: any;
  77055. }
  77056. /** @hidden */
  77057. export interface IGLTFTechniqueCommonProfile {
  77058. lightingModel: string;
  77059. texcoordBindings: Object;
  77060. parameters?: Array<any>;
  77061. }
  77062. /** @hidden */
  77063. export interface IGLTFTechniqueStatesFunctions {
  77064. blendColor?: number[];
  77065. blendEquationSeparate?: number[];
  77066. blendFuncSeparate?: number[];
  77067. colorMask: boolean[];
  77068. cullFace: number[];
  77069. }
  77070. /** @hidden */
  77071. export interface IGLTFTechniqueStates {
  77072. enable: number[];
  77073. functions: IGLTFTechniqueStatesFunctions;
  77074. }
  77075. /** @hidden */
  77076. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  77077. parameters: {
  77078. [key: string]: IGLTFTechniqueParameter;
  77079. };
  77080. program: string;
  77081. attributes: {
  77082. [key: string]: string;
  77083. };
  77084. uniforms: {
  77085. [key: string]: string;
  77086. };
  77087. states: IGLTFTechniqueStates;
  77088. }
  77089. /** @hidden */
  77090. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  77091. technique?: string;
  77092. values: string[];
  77093. }
  77094. /** @hidden */
  77095. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  77096. attributes: {
  77097. [key: string]: string;
  77098. };
  77099. indices: string;
  77100. material: string;
  77101. mode?: number;
  77102. }
  77103. /** @hidden */
  77104. export interface IGLTFMesh extends IGLTFChildRootProperty {
  77105. primitives: IGLTFMeshPrimitive[];
  77106. }
  77107. /** @hidden */
  77108. export interface IGLTFImage extends IGLTFChildRootProperty {
  77109. uri: string;
  77110. }
  77111. /** @hidden */
  77112. export interface IGLTFSampler extends IGLTFChildRootProperty {
  77113. magFilter?: number;
  77114. minFilter?: number;
  77115. wrapS?: number;
  77116. wrapT?: number;
  77117. }
  77118. /** @hidden */
  77119. export interface IGLTFTexture extends IGLTFChildRootProperty {
  77120. sampler: string;
  77121. source: string;
  77122. format?: ETextureFormat;
  77123. internalFormat?: ETextureFormat;
  77124. target?: number;
  77125. type?: number;
  77126. babylonTexture?: Texture;
  77127. }
  77128. /** @hidden */
  77129. export interface IGLTFAmbienLight {
  77130. color?: number[];
  77131. }
  77132. /** @hidden */
  77133. export interface IGLTFDirectionalLight {
  77134. color?: number[];
  77135. }
  77136. /** @hidden */
  77137. export interface IGLTFPointLight {
  77138. color?: number[];
  77139. constantAttenuation?: number;
  77140. linearAttenuation?: number;
  77141. quadraticAttenuation?: number;
  77142. }
  77143. /** @hidden */
  77144. export interface IGLTFSpotLight {
  77145. color?: number[];
  77146. constantAttenuation?: number;
  77147. fallOfAngle?: number;
  77148. fallOffExponent?: number;
  77149. linearAttenuation?: number;
  77150. quadraticAttenuation?: number;
  77151. }
  77152. /** @hidden */
  77153. export interface IGLTFLight extends IGLTFChildRootProperty {
  77154. type: string;
  77155. }
  77156. /** @hidden */
  77157. export interface IGLTFCameraOrthographic {
  77158. xmag: number;
  77159. ymag: number;
  77160. zfar: number;
  77161. znear: number;
  77162. }
  77163. /** @hidden */
  77164. export interface IGLTFCameraPerspective {
  77165. aspectRatio: number;
  77166. yfov: number;
  77167. zfar: number;
  77168. znear: number;
  77169. }
  77170. /** @hidden */
  77171. export interface IGLTFCamera extends IGLTFChildRootProperty {
  77172. type: string;
  77173. }
  77174. /** @hidden */
  77175. export interface IGLTFAnimationChannelTarget {
  77176. id: string;
  77177. path: string;
  77178. }
  77179. /** @hidden */
  77180. export interface IGLTFAnimationChannel {
  77181. sampler: string;
  77182. target: IGLTFAnimationChannelTarget;
  77183. }
  77184. /** @hidden */
  77185. export interface IGLTFAnimationSampler {
  77186. input: string;
  77187. output: string;
  77188. interpolation?: string;
  77189. }
  77190. /** @hidden */
  77191. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  77192. channels?: IGLTFAnimationChannel[];
  77193. parameters?: {
  77194. [key: string]: string;
  77195. };
  77196. samplers?: {
  77197. [key: string]: IGLTFAnimationSampler;
  77198. };
  77199. }
  77200. /** @hidden */
  77201. export interface IGLTFNodeInstanceSkin {
  77202. skeletons: string[];
  77203. skin: string;
  77204. meshes: string[];
  77205. }
  77206. /** @hidden */
  77207. export interface IGLTFSkins extends IGLTFChildRootProperty {
  77208. bindShapeMatrix: number[];
  77209. inverseBindMatrices: string;
  77210. jointNames: string[];
  77211. babylonSkeleton?: Skeleton;
  77212. }
  77213. /** @hidden */
  77214. export interface IGLTFNode extends IGLTFChildRootProperty {
  77215. camera?: string;
  77216. children: string[];
  77217. skin?: string;
  77218. jointName?: string;
  77219. light?: string;
  77220. matrix: number[];
  77221. mesh?: string;
  77222. meshes?: string[];
  77223. rotation?: number[];
  77224. scale?: number[];
  77225. translation?: number[];
  77226. babylonNode?: Node;
  77227. }
  77228. /** @hidden */
  77229. export interface IGLTFScene extends IGLTFChildRootProperty {
  77230. nodes: string[];
  77231. }
  77232. /** @hidden */
  77233. export interface IGLTFRuntime {
  77234. extensions: {
  77235. [key: string]: any;
  77236. };
  77237. accessors: {
  77238. [key: string]: IGLTFAccessor;
  77239. };
  77240. buffers: {
  77241. [key: string]: IGLTFBuffer;
  77242. };
  77243. bufferViews: {
  77244. [key: string]: IGLTFBufferView;
  77245. };
  77246. meshes: {
  77247. [key: string]: IGLTFMesh;
  77248. };
  77249. lights: {
  77250. [key: string]: IGLTFLight;
  77251. };
  77252. cameras: {
  77253. [key: string]: IGLTFCamera;
  77254. };
  77255. nodes: {
  77256. [key: string]: IGLTFNode;
  77257. };
  77258. images: {
  77259. [key: string]: IGLTFImage;
  77260. };
  77261. textures: {
  77262. [key: string]: IGLTFTexture;
  77263. };
  77264. shaders: {
  77265. [key: string]: IGLTFShader;
  77266. };
  77267. programs: {
  77268. [key: string]: IGLTFProgram;
  77269. };
  77270. samplers: {
  77271. [key: string]: IGLTFSampler;
  77272. };
  77273. techniques: {
  77274. [key: string]: IGLTFTechnique;
  77275. };
  77276. materials: {
  77277. [key: string]: IGLTFMaterial;
  77278. };
  77279. animations: {
  77280. [key: string]: IGLTFAnimation;
  77281. };
  77282. skins: {
  77283. [key: string]: IGLTFSkins;
  77284. };
  77285. currentScene?: Object;
  77286. scenes: {
  77287. [key: string]: IGLTFScene;
  77288. };
  77289. extensionsUsed: string[];
  77290. extensionsRequired?: string[];
  77291. buffersCount: number;
  77292. shaderscount: number;
  77293. scene: Scene;
  77294. rootUrl: string;
  77295. loadedBufferCount: number;
  77296. loadedBufferViews: {
  77297. [name: string]: ArrayBufferView;
  77298. };
  77299. loadedShaderCount: number;
  77300. importOnlyMeshes: boolean;
  77301. importMeshesNames?: string[];
  77302. dummyNodes: Node[];
  77303. forAssetContainer: boolean;
  77304. }
  77305. /** @hidden */
  77306. export interface INodeToRoot {
  77307. bone: Bone;
  77308. node: IGLTFNode;
  77309. id: string;
  77310. }
  77311. /** @hidden */
  77312. export interface IJointNode {
  77313. node: IGLTFNode;
  77314. id: string;
  77315. }
  77316. }
  77317. declare module BABYLON.GLTF1 {
  77318. /**
  77319. * Utils functions for GLTF
  77320. * @hidden
  77321. */
  77322. export class GLTFUtils {
  77323. /**
  77324. * Sets the given "parameter" matrix
  77325. * @param scene: the Scene object
  77326. * @param source: the source node where to pick the matrix
  77327. * @param parameter: the GLTF technique parameter
  77328. * @param uniformName: the name of the shader's uniform
  77329. * @param shaderMaterial: the shader material
  77330. */
  77331. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  77332. /**
  77333. * Sets the given "parameter" matrix
  77334. * @param shaderMaterial: the shader material
  77335. * @param uniform: the name of the shader's uniform
  77336. * @param value: the value of the uniform
  77337. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  77338. */
  77339. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  77340. /**
  77341. * Returns the wrap mode of the texture
  77342. * @param mode: the mode value
  77343. */
  77344. static GetWrapMode(mode: number): number;
  77345. /**
  77346. * Returns the byte stride giving an accessor
  77347. * @param accessor: the GLTF accessor objet
  77348. */
  77349. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  77350. /**
  77351. * Returns the texture filter mode giving a mode value
  77352. * @param mode: the filter mode value
  77353. */
  77354. static GetTextureFilterMode(mode: number): ETextureFilterType;
  77355. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  77356. /**
  77357. * Returns a buffer from its accessor
  77358. * @param gltfRuntime: the GLTF runtime
  77359. * @param accessor: the GLTF accessor
  77360. */
  77361. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  77362. /**
  77363. * Decodes a buffer view into a string
  77364. * @param view: the buffer view
  77365. */
  77366. static DecodeBufferToText(view: ArrayBufferView): string;
  77367. /**
  77368. * Returns the default material of gltf. Related to
  77369. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  77370. * @param scene: the Babylon.js scene
  77371. */
  77372. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  77373. private static _DefaultMaterial;
  77374. }
  77375. }
  77376. declare module BABYLON.GLTF1 {
  77377. /**
  77378. * Implementation of the base glTF spec
  77379. * @hidden
  77380. */
  77381. export class GLTFLoaderBase {
  77382. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  77383. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77384. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  77385. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77386. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  77387. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77388. }
  77389. /**
  77390. * glTF V1 Loader
  77391. * @hidden
  77392. */
  77393. export class GLTFLoader implements IGLTFLoader {
  77394. static Extensions: {
  77395. [name: string]: GLTFLoaderExtension;
  77396. };
  77397. static RegisterExtension(extension: GLTFLoaderExtension): void;
  77398. state: Nullable<GLTFLoaderState>;
  77399. dispose(): void;
  77400. private _importMeshAsync;
  77401. /**
  77402. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  77403. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77404. * @param scene the scene the meshes should be added to
  77405. * @param forAssetContainer defines if the entities must be stored in the scene
  77406. * @param data gltf data containing information of the meshes in a loaded file
  77407. * @param rootUrl root url to load from
  77408. * @param onProgress event that fires when loading progress has occured
  77409. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77410. */
  77411. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  77412. private _loadAsync;
  77413. /**
  77414. * Imports all objects from a loaded gltf file and adds them to the scene
  77415. * @param scene the scene the objects should be added to
  77416. * @param data gltf data containing information of the meshes in a loaded file
  77417. * @param rootUrl root url to load from
  77418. * @param onProgress event that fires when loading progress has occured
  77419. * @returns a promise which completes when objects have been loaded to the scene
  77420. */
  77421. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  77422. private _loadShadersAsync;
  77423. private _loadBuffersAsync;
  77424. private _createNodes;
  77425. }
  77426. /** @hidden */
  77427. export abstract class GLTFLoaderExtension {
  77428. private _name;
  77429. constructor(name: string);
  77430. get name(): string;
  77431. /**
  77432. * Defines an override for loading the runtime
  77433. * Return true to stop further extensions from loading the runtime
  77434. */
  77435. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  77436. /**
  77437. * Defines an onverride for creating gltf runtime
  77438. * Return true to stop further extensions from creating the runtime
  77439. */
  77440. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  77441. /**
  77442. * Defines an override for loading buffers
  77443. * Return true to stop further extensions from loading this buffer
  77444. */
  77445. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  77446. /**
  77447. * Defines an override for loading texture buffers
  77448. * Return true to stop further extensions from loading this texture data
  77449. */
  77450. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77451. /**
  77452. * Defines an override for creating textures
  77453. * Return true to stop further extensions from loading this texture
  77454. */
  77455. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  77456. /**
  77457. * Defines an override for loading shader strings
  77458. * Return true to stop further extensions from loading this shader data
  77459. */
  77460. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77461. /**
  77462. * Defines an override for loading materials
  77463. * Return true to stop further extensions from loading this material
  77464. */
  77465. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77466. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  77467. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  77468. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77469. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77470. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  77471. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77472. private static LoadTextureBufferAsync;
  77473. private static CreateTextureAsync;
  77474. private static ApplyExtensions;
  77475. }
  77476. }
  77477. declare module BABYLON.GLTF1 {
  77478. /** @hidden */
  77479. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  77480. private _bin;
  77481. constructor();
  77482. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  77483. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77484. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77485. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77486. }
  77487. }
  77488. declare module BABYLON.GLTF1 {
  77489. /** @hidden */
  77490. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  77491. constructor();
  77492. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  77493. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77494. private _loadTexture;
  77495. }
  77496. }
  77497. declare module BABYLON.GLTF2.Loader {
  77498. /**
  77499. * Loader interface with an index field.
  77500. */
  77501. export interface IArrayItem {
  77502. /**
  77503. * The index of this item in the array.
  77504. */
  77505. index: number;
  77506. }
  77507. /**
  77508. * Loader interface with additional members.
  77509. */
  77510. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  77511. /** @hidden */
  77512. _data?: Promise<ArrayBufferView>;
  77513. /** @hidden */
  77514. _babylonVertexBuffer?: Promise<VertexBuffer>;
  77515. }
  77516. /**
  77517. * Loader interface with additional members.
  77518. */
  77519. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  77520. }
  77521. /** @hidden */
  77522. export interface _IAnimationSamplerData {
  77523. input: Float32Array;
  77524. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  77525. output: Float32Array;
  77526. }
  77527. /**
  77528. * Loader interface with additional members.
  77529. */
  77530. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  77531. /** @hidden */
  77532. _data?: Promise<_IAnimationSamplerData>;
  77533. }
  77534. /**
  77535. * Loader interface with additional members.
  77536. */
  77537. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  77538. channels: IAnimationChannel[];
  77539. samplers: IAnimationSampler[];
  77540. /** @hidden */
  77541. _babylonAnimationGroup?: AnimationGroup;
  77542. }
  77543. /**
  77544. * Loader interface with additional members.
  77545. */
  77546. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  77547. /** @hidden */
  77548. _data?: Promise<ArrayBufferView>;
  77549. }
  77550. /**
  77551. * Loader interface with additional members.
  77552. */
  77553. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  77554. /** @hidden */
  77555. _data?: Promise<ArrayBufferView>;
  77556. /** @hidden */
  77557. _babylonBuffer?: Promise<Buffer>;
  77558. }
  77559. /**
  77560. * Loader interface with additional members.
  77561. */
  77562. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  77563. }
  77564. /**
  77565. * Loader interface with additional members.
  77566. */
  77567. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  77568. /** @hidden */
  77569. _data?: Promise<ArrayBufferView>;
  77570. }
  77571. /**
  77572. * Loader interface with additional members.
  77573. */
  77574. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  77575. }
  77576. /**
  77577. * Loader interface with additional members.
  77578. */
  77579. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  77580. }
  77581. /**
  77582. * Loader interface with additional members.
  77583. */
  77584. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  77585. baseColorTexture?: ITextureInfo;
  77586. metallicRoughnessTexture?: ITextureInfo;
  77587. }
  77588. /**
  77589. * Loader interface with additional members.
  77590. */
  77591. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  77592. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77593. normalTexture?: IMaterialNormalTextureInfo;
  77594. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77595. emissiveTexture?: ITextureInfo;
  77596. /** @hidden */
  77597. _data?: {
  77598. [babylonDrawMode: number]: {
  77599. babylonMaterial: Material;
  77600. babylonMeshes: AbstractMesh[];
  77601. promise: Promise<void>;
  77602. };
  77603. };
  77604. }
  77605. /**
  77606. * Loader interface with additional members.
  77607. */
  77608. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  77609. primitives: IMeshPrimitive[];
  77610. }
  77611. /**
  77612. * Loader interface with additional members.
  77613. */
  77614. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  77615. /** @hidden */
  77616. _instanceData?: {
  77617. babylonSourceMesh: Mesh;
  77618. promise: Promise<any>;
  77619. };
  77620. }
  77621. /**
  77622. * Loader interface with additional members.
  77623. */
  77624. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  77625. /**
  77626. * The parent glTF node.
  77627. */
  77628. parent?: INode;
  77629. /** @hidden */
  77630. _babylonTransformNode?: TransformNode;
  77631. /** @hidden */
  77632. _primitiveBabylonMeshes?: AbstractMesh[];
  77633. /** @hidden */
  77634. _babylonBones?: Bone[];
  77635. /** @hidden */
  77636. _numMorphTargets?: number;
  77637. }
  77638. /** @hidden */
  77639. export interface _ISamplerData {
  77640. noMipMaps: boolean;
  77641. samplingMode: number;
  77642. wrapU: number;
  77643. wrapV: number;
  77644. }
  77645. /**
  77646. * Loader interface with additional members.
  77647. */
  77648. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  77649. /** @hidden */
  77650. _data?: _ISamplerData;
  77651. }
  77652. /**
  77653. * Loader interface with additional members.
  77654. */
  77655. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  77656. }
  77657. /**
  77658. * Loader interface with additional members.
  77659. */
  77660. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  77661. /** @hidden */
  77662. _data?: {
  77663. babylonSkeleton: Skeleton;
  77664. promise: Promise<void>;
  77665. };
  77666. }
  77667. /**
  77668. * Loader interface with additional members.
  77669. */
  77670. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  77671. }
  77672. /**
  77673. * Loader interface with additional members.
  77674. */
  77675. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  77676. }
  77677. /**
  77678. * Loader interface with additional members.
  77679. */
  77680. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  77681. accessors?: IAccessor[];
  77682. animations?: IAnimation[];
  77683. buffers?: IBuffer[];
  77684. bufferViews?: IBufferView[];
  77685. cameras?: ICamera[];
  77686. images?: IImage[];
  77687. materials?: IMaterial[];
  77688. meshes?: IMesh[];
  77689. nodes?: INode[];
  77690. samplers?: ISampler[];
  77691. scenes?: IScene[];
  77692. skins?: ISkin[];
  77693. textures?: ITexture[];
  77694. }
  77695. }
  77696. declare module BABYLON.GLTF2 {
  77697. /**
  77698. * Interface for a glTF loader extension.
  77699. */
  77700. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  77701. /**
  77702. * Called after the loader state changes to LOADING.
  77703. */
  77704. onLoading?(): void;
  77705. /**
  77706. * Called after the loader state changes to READY.
  77707. */
  77708. onReady?(): void;
  77709. /**
  77710. * Define this method to modify the default behavior when loading scenes.
  77711. * @param context The context when loading the asset
  77712. * @param scene The glTF scene property
  77713. * @returns A promise that resolves when the load is complete or null if not handled
  77714. */
  77715. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  77716. /**
  77717. * Define this method to modify the default behavior when loading nodes.
  77718. * @param context The context when loading the asset
  77719. * @param node The glTF node property
  77720. * @param assign A function called synchronously after parsing the glTF properties
  77721. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  77722. */
  77723. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77724. /**
  77725. * Define this method to modify the default behavior when loading cameras.
  77726. * @param context The context when loading the asset
  77727. * @param camera The glTF camera property
  77728. * @param assign A function called synchronously after parsing the glTF properties
  77729. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  77730. */
  77731. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77732. /**
  77733. * @hidden
  77734. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  77735. * @param context The context when loading the asset
  77736. * @param primitive The glTF mesh primitive property
  77737. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  77738. */
  77739. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77740. /**
  77741. * @hidden
  77742. * Define this method to modify the default behavior when loading data for mesh primitives.
  77743. * @param context The context when loading the asset
  77744. * @param name The mesh name when loading the asset
  77745. * @param node The glTF node when loading the asset
  77746. * @param mesh The glTF mesh when loading the asset
  77747. * @param primitive The glTF mesh primitive property
  77748. * @param assign A function called synchronously after parsing the glTF properties
  77749. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77750. */
  77751. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77752. /**
  77753. * @hidden
  77754. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  77755. * @param context The context when loading the asset
  77756. * @param material The glTF material property
  77757. * @param assign A function called synchronously after parsing the glTF properties
  77758. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  77759. */
  77760. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77761. /**
  77762. * Define this method to modify the default behavior when creating materials.
  77763. * @param context The context when loading the asset
  77764. * @param material The glTF material property
  77765. * @param babylonDrawMode The draw mode for the Babylon material
  77766. * @returns The Babylon material or null if not handled
  77767. */
  77768. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77769. /**
  77770. * Define this method to modify the default behavior when loading material properties.
  77771. * @param context The context when loading the asset
  77772. * @param material The glTF material property
  77773. * @param babylonMaterial The Babylon material
  77774. * @returns A promise that resolves when the load is complete or null if not handled
  77775. */
  77776. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77777. /**
  77778. * Define this method to modify the default behavior when loading texture infos.
  77779. * @param context The context when loading the asset
  77780. * @param textureInfo The glTF texture info property
  77781. * @param assign A function called synchronously after parsing the glTF properties
  77782. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77783. */
  77784. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77785. /**
  77786. * @hidden
  77787. * Define this method to modify the default behavior when loading textures.
  77788. * @param context The context when loading the asset
  77789. * @param texture The glTF texture property
  77790. * @param assign A function called synchronously after parsing the glTF properties
  77791. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77792. */
  77793. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77794. /**
  77795. * Define this method to modify the default behavior when loading animations.
  77796. * @param context The context when loading the asset
  77797. * @param animation The glTF animation property
  77798. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  77799. */
  77800. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77801. /**
  77802. * @hidden
  77803. * Define this method to modify the default behavior when loading skins.
  77804. * @param context The context when loading the asset
  77805. * @param node The glTF node property
  77806. * @param skin The glTF skin property
  77807. * @returns A promise that resolves when the load is complete or null if not handled
  77808. */
  77809. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  77810. /**
  77811. * @hidden
  77812. * Define this method to modify the default behavior when loading uris.
  77813. * @param context The context when loading the asset
  77814. * @param property The glTF property associated with the uri
  77815. * @param uri The uri to load
  77816. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77817. */
  77818. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77819. /**
  77820. * Define this method to modify the default behavior when loading buffer views.
  77821. * @param context The context when loading the asset
  77822. * @param bufferView The glTF buffer view property
  77823. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77824. */
  77825. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  77826. /**
  77827. * Define this method to modify the default behavior when loading buffers.
  77828. * @param context The context when loading the asset
  77829. * @param buffer The glTF buffer property
  77830. * @param byteOffset The byte offset to load
  77831. * @param byteLength The byte length to load
  77832. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77833. */
  77834. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77835. }
  77836. }
  77837. declare module BABYLON.GLTF2 {
  77838. /**
  77839. * Helper class for working with arrays when loading the glTF asset
  77840. */
  77841. export class ArrayItem {
  77842. /**
  77843. * Gets an item from the given array.
  77844. * @param context The context when loading the asset
  77845. * @param array The array to get the item from
  77846. * @param index The index to the array
  77847. * @returns The array item
  77848. */
  77849. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  77850. /**
  77851. * Assign an `index` field to each item of the given array.
  77852. * @param array The array of items
  77853. */
  77854. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  77855. }
  77856. /**
  77857. * The glTF 2.0 loader
  77858. */
  77859. export class GLTFLoader implements IGLTFLoader {
  77860. /** @hidden */
  77861. _completePromises: Promise<any>[];
  77862. /** @hidden */
  77863. _forAssetContainer: boolean;
  77864. /** Storage */
  77865. _babylonLights: Light[];
  77866. private _disposed;
  77867. private _parent;
  77868. private _state;
  77869. private _extensions;
  77870. private _rootUrl;
  77871. private _fileName;
  77872. private _uniqueRootUrl;
  77873. private _gltf;
  77874. private _bin;
  77875. private _babylonScene;
  77876. private _rootBabylonMesh;
  77877. private _defaultBabylonMaterialData;
  77878. private _progressCallback?;
  77879. private _requests;
  77880. private static _RegisteredExtensions;
  77881. /**
  77882. * The default glTF sampler.
  77883. */
  77884. static readonly DefaultSampler: ISampler;
  77885. /**
  77886. * Registers a loader extension.
  77887. * @param name The name of the loader extension.
  77888. * @param factory The factory function that creates the loader extension.
  77889. */
  77890. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  77891. /**
  77892. * Unregisters a loader extension.
  77893. * @param name The name of the loader extension.
  77894. * @returns A boolean indicating whether the extension has been unregistered
  77895. */
  77896. static UnregisterExtension(name: string): boolean;
  77897. /**
  77898. * The loader state.
  77899. */
  77900. get state(): Nullable<GLTFLoaderState>;
  77901. /**
  77902. * The object that represents the glTF JSON.
  77903. */
  77904. get gltf(): IGLTF;
  77905. /**
  77906. * The BIN chunk of a binary glTF.
  77907. */
  77908. get bin(): Nullable<IDataBuffer>;
  77909. /**
  77910. * The parent file loader.
  77911. */
  77912. get parent(): GLTFFileLoader;
  77913. /**
  77914. * The Babylon scene when loading the asset.
  77915. */
  77916. get babylonScene(): Scene;
  77917. /**
  77918. * The root Babylon mesh when loading the asset.
  77919. */
  77920. get rootBabylonMesh(): Mesh;
  77921. /** @hidden */
  77922. constructor(parent: GLTFFileLoader);
  77923. /** @hidden */
  77924. dispose(): void;
  77925. /** @hidden */
  77926. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  77927. /** @hidden */
  77928. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77929. private _loadAsync;
  77930. private _loadData;
  77931. private _setupData;
  77932. private _loadExtensions;
  77933. private _checkExtensions;
  77934. private _setState;
  77935. private _createRootNode;
  77936. /**
  77937. * Loads a glTF scene.
  77938. * @param context The context when loading the asset
  77939. * @param scene The glTF scene property
  77940. * @returns A promise that resolves when the load is complete
  77941. */
  77942. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  77943. private _forEachPrimitive;
  77944. private _getMeshes;
  77945. private _getTransformNodes;
  77946. private _getSkeletons;
  77947. private _getAnimationGroups;
  77948. private _startAnimations;
  77949. /**
  77950. * Loads a glTF node.
  77951. * @param context The context when loading the asset
  77952. * @param node The glTF node property
  77953. * @param assign A function called synchronously after parsing the glTF properties
  77954. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  77955. */
  77956. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  77957. private _loadMeshAsync;
  77958. /**
  77959. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  77960. * @param context The context when loading the asset
  77961. * @param name The mesh name when loading the asset
  77962. * @param node The glTF node when loading the asset
  77963. * @param mesh The glTF mesh when loading the asset
  77964. * @param primitive The glTF mesh primitive property
  77965. * @param assign A function called synchronously after parsing the glTF properties
  77966. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77967. */
  77968. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77969. private _loadVertexDataAsync;
  77970. private _createMorphTargets;
  77971. private _loadMorphTargetsAsync;
  77972. private _loadMorphTargetVertexDataAsync;
  77973. private static _LoadTransform;
  77974. private _loadSkinAsync;
  77975. private _loadBones;
  77976. private _loadBone;
  77977. private _loadSkinInverseBindMatricesDataAsync;
  77978. private _updateBoneMatrices;
  77979. private _getNodeMatrix;
  77980. /**
  77981. * Loads a glTF camera.
  77982. * @param context The context when loading the asset
  77983. * @param camera The glTF camera property
  77984. * @param assign A function called synchronously after parsing the glTF properties
  77985. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  77986. */
  77987. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  77988. private _loadAnimationsAsync;
  77989. /**
  77990. * Loads a glTF animation.
  77991. * @param context The context when loading the asset
  77992. * @param animation The glTF animation property
  77993. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  77994. */
  77995. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  77996. /**
  77997. * @hidden Loads a glTF animation channel.
  77998. * @param context The context when loading the asset
  77999. * @param animationContext The context of the animation when loading the asset
  78000. * @param animation The glTF animation property
  78001. * @param channel The glTF animation channel property
  78002. * @param babylonAnimationGroup The babylon animation group property
  78003. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78004. * @returns A void promise when the channel load is complete
  78005. */
  78006. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78007. private _loadAnimationSamplerAsync;
  78008. private _loadBufferAsync;
  78009. /**
  78010. * Loads a glTF buffer view.
  78011. * @param context The context when loading the asset
  78012. * @param bufferView The glTF buffer view property
  78013. * @returns A promise that resolves with the loaded data when the load is complete
  78014. */
  78015. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78016. private _loadAccessorAsync;
  78017. /** @hidden */
  78018. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78019. private _loadIndicesAccessorAsync;
  78020. private _loadVertexBufferViewAsync;
  78021. private _loadVertexAccessorAsync;
  78022. private _loadMaterialMetallicRoughnessPropertiesAsync;
  78023. /** @hidden */
  78024. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  78025. private _createDefaultMaterial;
  78026. /**
  78027. * Creates a Babylon material from a glTF material.
  78028. * @param context The context when loading the asset
  78029. * @param material The glTF material property
  78030. * @param babylonDrawMode The draw mode for the Babylon material
  78031. * @returns The Babylon material
  78032. */
  78033. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  78034. /**
  78035. * Loads properties from a glTF material into a Babylon material.
  78036. * @param context The context when loading the asset
  78037. * @param material The glTF material property
  78038. * @param babylonMaterial The Babylon material
  78039. * @returns A promise that resolves when the load is complete
  78040. */
  78041. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78042. /**
  78043. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  78044. * @param context The context when loading the asset
  78045. * @param material The glTF material property
  78046. * @param babylonMaterial The Babylon material
  78047. * @returns A promise that resolves when the load is complete
  78048. */
  78049. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78050. /**
  78051. * Loads the alpha properties from a glTF material into a Babylon material.
  78052. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  78053. * @param context The context when loading the asset
  78054. * @param material The glTF material property
  78055. * @param babylonMaterial The Babylon material
  78056. */
  78057. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  78058. /**
  78059. * Loads a glTF texture info.
  78060. * @param context The context when loading the asset
  78061. * @param textureInfo The glTF texture info property
  78062. * @param assign A function called synchronously after parsing the glTF properties
  78063. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  78064. */
  78065. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78066. /** @hidden */
  78067. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78068. /** @hidden */
  78069. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78070. private _loadSampler;
  78071. /**
  78072. * Loads a glTF image.
  78073. * @param context The context when loading the asset
  78074. * @param image The glTF image property
  78075. * @returns A promise that resolves with the loaded data when the load is complete
  78076. */
  78077. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  78078. /**
  78079. * Loads a glTF uri.
  78080. * @param context The context when loading the asset
  78081. * @param property The glTF property associated with the uri
  78082. * @param uri The base64 or relative uri
  78083. * @returns A promise that resolves with the loaded data when the load is complete
  78084. */
  78085. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  78086. private _onProgress;
  78087. /**
  78088. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  78089. * @param babylonObject the Babylon object with metadata
  78090. * @param pointer the JSON pointer
  78091. */
  78092. static AddPointerMetadata(babylonObject: {
  78093. metadata: any;
  78094. }, pointer: string): void;
  78095. private static _GetTextureWrapMode;
  78096. private static _GetTextureSamplingMode;
  78097. private static _GetTypedArrayConstructor;
  78098. private static _GetTypedArray;
  78099. private static _GetNumComponents;
  78100. private static _ValidateUri;
  78101. private static _GetDrawMode;
  78102. private _compileMaterialsAsync;
  78103. private _compileShadowGeneratorsAsync;
  78104. private _forEachExtensions;
  78105. private _applyExtensions;
  78106. private _extensionsOnLoading;
  78107. private _extensionsOnReady;
  78108. private _extensionsLoadSceneAsync;
  78109. private _extensionsLoadNodeAsync;
  78110. private _extensionsLoadCameraAsync;
  78111. private _extensionsLoadVertexDataAsync;
  78112. private _extensionsLoadMeshPrimitiveAsync;
  78113. private _extensionsLoadMaterialAsync;
  78114. private _extensionsCreateMaterial;
  78115. private _extensionsLoadMaterialPropertiesAsync;
  78116. private _extensionsLoadTextureInfoAsync;
  78117. private _extensionsLoadTextureAsync;
  78118. private _extensionsLoadAnimationAsync;
  78119. private _extensionsLoadSkinAsync;
  78120. private _extensionsLoadUriAsync;
  78121. private _extensionsLoadBufferViewAsync;
  78122. private _extensionsLoadBufferAsync;
  78123. /**
  78124. * Helper method called by a loader extension to load an glTF extension.
  78125. * @param context The context when loading the asset
  78126. * @param property The glTF property to load the extension from
  78127. * @param extensionName The name of the extension to load
  78128. * @param actionAsync The action to run
  78129. * @returns The promise returned by actionAsync or null if the extension does not exist
  78130. */
  78131. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78132. /**
  78133. * Helper method called by a loader extension to load a glTF extra.
  78134. * @param context The context when loading the asset
  78135. * @param property The glTF property to load the extra from
  78136. * @param extensionName The name of the extension to load
  78137. * @param actionAsync The action to run
  78138. * @returns The promise returned by actionAsync or null if the extra does not exist
  78139. */
  78140. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78141. /**
  78142. * Checks for presence of an extension.
  78143. * @param name The name of the extension to check
  78144. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  78145. */
  78146. isExtensionUsed(name: string): boolean;
  78147. /**
  78148. * Increments the indentation level and logs a message.
  78149. * @param message The message to log
  78150. */
  78151. logOpen(message: string): void;
  78152. /**
  78153. * Decrements the indentation level.
  78154. */
  78155. logClose(): void;
  78156. /**
  78157. * Logs a message
  78158. * @param message The message to log
  78159. */
  78160. log(message: string): void;
  78161. /**
  78162. * Starts a performance counter.
  78163. * @param counterName The name of the performance counter
  78164. */
  78165. startPerformanceCounter(counterName: string): void;
  78166. /**
  78167. * Ends a performance counter.
  78168. * @param counterName The name of the performance counter
  78169. */
  78170. endPerformanceCounter(counterName: string): void;
  78171. }
  78172. }
  78173. declare module BABYLON.GLTF2.Loader.Extensions {
  78174. /**
  78175. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  78176. */
  78177. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  78178. /**
  78179. * The name of this extension.
  78180. */
  78181. readonly name: string;
  78182. /**
  78183. * Defines whether this extension is enabled.
  78184. */
  78185. enabled: boolean;
  78186. private _loader;
  78187. private _lights?;
  78188. /** @hidden */
  78189. constructor(loader: GLTFLoader);
  78190. /** @hidden */
  78191. dispose(): void;
  78192. /** @hidden */
  78193. onLoading(): void;
  78194. /** @hidden */
  78195. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78196. private _loadLightAsync;
  78197. }
  78198. }
  78199. declare module BABYLON.GLTF2.Loader.Extensions {
  78200. /**
  78201. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  78202. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  78203. * !!! Experimental Extension Subject to Changes !!!
  78204. */
  78205. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  78206. /**
  78207. * The name of this extension.
  78208. */
  78209. readonly name: string;
  78210. /**
  78211. * Defines whether this extension is enabled.
  78212. */
  78213. enabled: boolean;
  78214. private _loader;
  78215. /** @hidden */
  78216. constructor(loader: GLTFLoader);
  78217. /** @hidden */
  78218. dispose(): void;
  78219. /** @hidden */
  78220. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78221. }
  78222. }
  78223. declare module BABYLON.GLTF2.Loader.Extensions {
  78224. /**
  78225. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  78226. */
  78227. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  78228. /**
  78229. * The name of this extension.
  78230. */
  78231. readonly name: string;
  78232. /**
  78233. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  78234. */
  78235. dracoCompression?: DracoCompression;
  78236. /**
  78237. * Defines whether this extension is enabled.
  78238. */
  78239. enabled: boolean;
  78240. private _loader;
  78241. /** @hidden */
  78242. constructor(loader: GLTFLoader);
  78243. /** @hidden */
  78244. dispose(): void;
  78245. /** @hidden */
  78246. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78247. }
  78248. }
  78249. declare module BABYLON.GLTF2.Loader.Extensions {
  78250. /**
  78251. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  78252. */
  78253. export class KHR_lights implements IGLTFLoaderExtension {
  78254. /**
  78255. * The name of this extension.
  78256. */
  78257. readonly name: string;
  78258. /**
  78259. * Defines whether this extension is enabled.
  78260. */
  78261. enabled: boolean;
  78262. private _loader;
  78263. private _lights?;
  78264. /** @hidden */
  78265. constructor(loader: GLTFLoader);
  78266. /** @hidden */
  78267. dispose(): void;
  78268. /** @hidden */
  78269. onLoading(): void;
  78270. /** @hidden */
  78271. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78272. }
  78273. }
  78274. declare module BABYLON.GLTF2.Loader.Extensions {
  78275. /**
  78276. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  78277. */
  78278. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  78279. /**
  78280. * The name of this extension.
  78281. */
  78282. readonly name: string;
  78283. /**
  78284. * Defines whether this extension is enabled.
  78285. */
  78286. enabled: boolean;
  78287. /**
  78288. * Defines a number that determines the order the extensions are applied.
  78289. */
  78290. order: number;
  78291. private _loader;
  78292. /** @hidden */
  78293. constructor(loader: GLTFLoader);
  78294. /** @hidden */
  78295. dispose(): void;
  78296. /** @hidden */
  78297. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78298. private _loadSpecularGlossinessPropertiesAsync;
  78299. }
  78300. }
  78301. declare module BABYLON.GLTF2.Loader.Extensions {
  78302. /**
  78303. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  78304. */
  78305. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  78306. /**
  78307. * The name of this extension.
  78308. */
  78309. readonly name: string;
  78310. /**
  78311. * Defines whether this extension is enabled.
  78312. */
  78313. enabled: boolean;
  78314. /**
  78315. * Defines a number that determines the order the extensions are applied.
  78316. */
  78317. order: number;
  78318. private _loader;
  78319. /** @hidden */
  78320. constructor(loader: GLTFLoader);
  78321. /** @hidden */
  78322. dispose(): void;
  78323. /** @hidden */
  78324. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78325. private _loadUnlitPropertiesAsync;
  78326. }
  78327. }
  78328. declare module BABYLON.GLTF2.Loader.Extensions {
  78329. /**
  78330. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78331. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  78332. * !!! Experimental Extension Subject to Changes !!!
  78333. */
  78334. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  78335. /**
  78336. * The name of this extension.
  78337. */
  78338. readonly name: string;
  78339. /**
  78340. * Defines whether this extension is enabled.
  78341. */
  78342. enabled: boolean;
  78343. /**
  78344. * Defines a number that determines the order the extensions are applied.
  78345. */
  78346. order: number;
  78347. private _loader;
  78348. /** @hidden */
  78349. constructor(loader: GLTFLoader);
  78350. /** @hidden */
  78351. dispose(): void;
  78352. /** @hidden */
  78353. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78354. private _loadClearCoatPropertiesAsync;
  78355. }
  78356. }
  78357. declare module BABYLON.GLTF2.Loader.Extensions {
  78358. /**
  78359. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  78360. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78361. * !!! Experimental Extension Subject to Changes !!!
  78362. */
  78363. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  78364. /**
  78365. * The name of this extension.
  78366. */
  78367. readonly name: string;
  78368. /**
  78369. * Defines whether this extension is enabled.
  78370. */
  78371. enabled: boolean;
  78372. /**
  78373. * Defines a number that determines the order the extensions are applied.
  78374. */
  78375. order: number;
  78376. private _loader;
  78377. /** @hidden */
  78378. constructor(loader: GLTFLoader);
  78379. /** @hidden */
  78380. dispose(): void;
  78381. /** @hidden */
  78382. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78383. private _loadSheenPropertiesAsync;
  78384. }
  78385. }
  78386. declare module BABYLON.GLTF2.Loader.Extensions {
  78387. /**
  78388. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78389. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78390. * !!! Experimental Extension Subject to Changes !!!
  78391. */
  78392. export class KHR_materials_specular implements IGLTFLoaderExtension {
  78393. /**
  78394. * The name of this extension.
  78395. */
  78396. readonly name: string;
  78397. /**
  78398. * Defines whether this extension is enabled.
  78399. */
  78400. enabled: boolean;
  78401. /**
  78402. * Defines a number that determines the order the extensions are applied.
  78403. */
  78404. order: number;
  78405. private _loader;
  78406. /** @hidden */
  78407. constructor(loader: GLTFLoader);
  78408. /** @hidden */
  78409. dispose(): void;
  78410. /** @hidden */
  78411. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78412. private _loadSpecularPropertiesAsync;
  78413. }
  78414. }
  78415. declare module BABYLON.GLTF2.Loader.Extensions {
  78416. /**
  78417. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  78418. */
  78419. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  78420. /**
  78421. * The name of this extension.
  78422. */
  78423. readonly name: string;
  78424. /**
  78425. * Defines whether this extension is enabled.
  78426. */
  78427. enabled: boolean;
  78428. /** @hidden */
  78429. constructor(loader: GLTFLoader);
  78430. /** @hidden */
  78431. dispose(): void;
  78432. }
  78433. }
  78434. declare module BABYLON.GLTF2.Loader.Extensions {
  78435. /**
  78436. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  78437. * !!! Experimental Extension Subject to Changes !!!
  78438. */
  78439. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  78440. /** The name of this extension. */
  78441. readonly name: string;
  78442. /** Defines whether this extension is enabled. */
  78443. enabled: boolean;
  78444. private _loader;
  78445. /** @hidden */
  78446. constructor(loader: GLTFLoader);
  78447. /** @hidden */
  78448. dispose(): void;
  78449. /** @hidden */
  78450. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78451. }
  78452. }
  78453. declare module BABYLON.GLTF2.Loader.Extensions {
  78454. /**
  78455. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  78456. */
  78457. export class KHR_texture_transform implements IGLTFLoaderExtension {
  78458. /**
  78459. * The name of this extension.
  78460. */
  78461. readonly name: string;
  78462. /**
  78463. * Defines whether this extension is enabled.
  78464. */
  78465. enabled: boolean;
  78466. private _loader;
  78467. /** @hidden */
  78468. constructor(loader: GLTFLoader);
  78469. /** @hidden */
  78470. dispose(): void;
  78471. /** @hidden */
  78472. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78473. }
  78474. }
  78475. declare module BABYLON.GLTF2.Loader.Extensions {
  78476. /**
  78477. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  78478. */
  78479. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  78480. /**
  78481. * The name of this extension.
  78482. */
  78483. readonly name: string;
  78484. /**
  78485. * Defines whether this extension is enabled.
  78486. */
  78487. enabled: boolean;
  78488. private _loader;
  78489. private _clips;
  78490. private _emitters;
  78491. /** @hidden */
  78492. constructor(loader: GLTFLoader);
  78493. /** @hidden */
  78494. dispose(): void;
  78495. /** @hidden */
  78496. onLoading(): void;
  78497. /** @hidden */
  78498. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78499. /** @hidden */
  78500. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78501. /** @hidden */
  78502. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78503. private _loadClipAsync;
  78504. private _loadEmitterAsync;
  78505. private _getEventAction;
  78506. private _loadAnimationEventAsync;
  78507. }
  78508. }
  78509. declare module BABYLON.GLTF2.Loader.Extensions {
  78510. /**
  78511. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  78512. */
  78513. export class MSFT_lod implements IGLTFLoaderExtension {
  78514. /**
  78515. * The name of this extension.
  78516. */
  78517. readonly name: string;
  78518. /**
  78519. * Defines whether this extension is enabled.
  78520. */
  78521. enabled: boolean;
  78522. /**
  78523. * Defines a number that determines the order the extensions are applied.
  78524. */
  78525. order: number;
  78526. /**
  78527. * Maximum number of LODs to load, starting from the lowest LOD.
  78528. */
  78529. maxLODsToLoad: number;
  78530. /**
  78531. * Observable raised when all node LODs of one level are loaded.
  78532. * The event data is the index of the loaded LOD starting from zero.
  78533. * Dispose the loader to cancel the loading of the next level of LODs.
  78534. */
  78535. onNodeLODsLoadedObservable: Observable<number>;
  78536. /**
  78537. * Observable raised when all material LODs of one level are loaded.
  78538. * The event data is the index of the loaded LOD starting from zero.
  78539. * Dispose the loader to cancel the loading of the next level of LODs.
  78540. */
  78541. onMaterialLODsLoadedObservable: Observable<number>;
  78542. private _loader;
  78543. private _nodeIndexLOD;
  78544. private _nodeSignalLODs;
  78545. private _nodePromiseLODs;
  78546. private _materialIndexLOD;
  78547. private _materialSignalLODs;
  78548. private _materialPromiseLODs;
  78549. private _indexLOD;
  78550. private _bufferLODs;
  78551. /** @hidden */
  78552. constructor(loader: GLTFLoader);
  78553. /** @hidden */
  78554. dispose(): void;
  78555. /** @hidden */
  78556. onReady(): void;
  78557. /** @hidden */
  78558. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78559. /** @hidden */
  78560. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78561. /** @hidden */
  78562. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78563. /** @hidden */
  78564. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78565. /** @hidden */
  78566. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78567. private _loadBufferLOD;
  78568. /**
  78569. * Gets an array of LOD properties from lowest to highest.
  78570. */
  78571. private _getLODs;
  78572. private _disposeTransformNode;
  78573. private _disposeMaterials;
  78574. }
  78575. }
  78576. declare module BABYLON.GLTF2.Loader.Extensions {
  78577. /** @hidden */
  78578. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  78579. readonly name: string;
  78580. enabled: boolean;
  78581. private _loader;
  78582. constructor(loader: GLTFLoader);
  78583. dispose(): void;
  78584. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78585. }
  78586. }
  78587. declare module BABYLON.GLTF2.Loader.Extensions {
  78588. /** @hidden */
  78589. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  78590. readonly name: string;
  78591. enabled: boolean;
  78592. private _loader;
  78593. constructor(loader: GLTFLoader);
  78594. dispose(): void;
  78595. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78596. }
  78597. }
  78598. declare module BABYLON.GLTF2.Loader.Extensions {
  78599. /**
  78600. * Store glTF extras (if present) in BJS objects' metadata
  78601. */
  78602. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  78603. /**
  78604. * The name of this extension.
  78605. */
  78606. readonly name: string;
  78607. /**
  78608. * Defines whether this extension is enabled.
  78609. */
  78610. enabled: boolean;
  78611. private _loader;
  78612. private _assignExtras;
  78613. /** @hidden */
  78614. constructor(loader: GLTFLoader);
  78615. /** @hidden */
  78616. dispose(): void;
  78617. /** @hidden */
  78618. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78619. /** @hidden */
  78620. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78621. /** @hidden */
  78622. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78623. }
  78624. }
  78625. declare module BABYLON {
  78626. /**
  78627. * Class reading and parsing the MTL file bundled with the obj file.
  78628. */
  78629. export class MTLFileLoader {
  78630. /**
  78631. * Invert Y-Axis of referenced textures on load
  78632. */
  78633. static INVERT_TEXTURE_Y: boolean;
  78634. /**
  78635. * All material loaded from the mtl will be set here
  78636. */
  78637. materials: StandardMaterial[];
  78638. /**
  78639. * This function will read the mtl file and create each material described inside
  78640. * This function could be improve by adding :
  78641. * -some component missing (Ni, Tf...)
  78642. * -including the specific options available
  78643. *
  78644. * @param scene defines the scene the material will be created in
  78645. * @param data defines the mtl data to parse
  78646. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  78647. * @param forAssetContainer defines if the material should be registered in the scene
  78648. */
  78649. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  78650. /**
  78651. * Gets the texture for the material.
  78652. *
  78653. * If the material is imported from input file,
  78654. * We sanitize the url to ensure it takes the textre from aside the material.
  78655. *
  78656. * @param rootUrl The root url to load from
  78657. * @param value The value stored in the mtl
  78658. * @return The Texture
  78659. */
  78660. private static _getTexture;
  78661. }
  78662. }
  78663. declare module BABYLON {
  78664. /**
  78665. * Options for loading OBJ/MTL files
  78666. */
  78667. type MeshLoadOptions = {
  78668. /**
  78669. * Defines if UVs are optimized by default during load.
  78670. */
  78671. OptimizeWithUV: boolean;
  78672. /**
  78673. * Defines custom scaling of UV coordinates of loaded meshes.
  78674. */
  78675. UVScaling: Vector2;
  78676. /**
  78677. * Invert model on y-axis (does a model scaling inversion)
  78678. */
  78679. InvertY: boolean;
  78680. /**
  78681. * Invert Y-Axis of referenced textures on load
  78682. */
  78683. InvertTextureY: boolean;
  78684. /**
  78685. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78686. */
  78687. ImportVertexColors: boolean;
  78688. /**
  78689. * Compute the normals for the model, even if normals are present in the file.
  78690. */
  78691. ComputeNormals: boolean;
  78692. /**
  78693. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78694. */
  78695. SkipMaterials: boolean;
  78696. /**
  78697. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78698. */
  78699. MaterialLoadingFailsSilently: boolean;
  78700. };
  78701. /**
  78702. * OBJ file type loader.
  78703. * This is a babylon scene loader plugin.
  78704. */
  78705. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78706. /**
  78707. * Defines if UVs are optimized by default during load.
  78708. */
  78709. static OPTIMIZE_WITH_UV: boolean;
  78710. /**
  78711. * Invert model on y-axis (does a model scaling inversion)
  78712. */
  78713. static INVERT_Y: boolean;
  78714. /**
  78715. * Invert Y-Axis of referenced textures on load
  78716. */
  78717. static get INVERT_TEXTURE_Y(): boolean;
  78718. static set INVERT_TEXTURE_Y(value: boolean);
  78719. /**
  78720. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78721. */
  78722. static IMPORT_VERTEX_COLORS: boolean;
  78723. /**
  78724. * Compute the normals for the model, even if normals are present in the file.
  78725. */
  78726. static COMPUTE_NORMALS: boolean;
  78727. /**
  78728. * Defines custom scaling of UV coordinates of loaded meshes.
  78729. */
  78730. static UV_SCALING: Vector2;
  78731. /**
  78732. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78733. */
  78734. static SKIP_MATERIALS: boolean;
  78735. /**
  78736. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78737. *
  78738. * Defaults to true for backwards compatibility.
  78739. */
  78740. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  78741. /**
  78742. * Defines the name of the plugin.
  78743. */
  78744. name: string;
  78745. /**
  78746. * Defines the extension the plugin is able to load.
  78747. */
  78748. extensions: string;
  78749. /** @hidden */
  78750. obj: RegExp;
  78751. /** @hidden */
  78752. group: RegExp;
  78753. /** @hidden */
  78754. mtllib: RegExp;
  78755. /** @hidden */
  78756. usemtl: RegExp;
  78757. /** @hidden */
  78758. smooth: RegExp;
  78759. /** @hidden */
  78760. vertexPattern: RegExp;
  78761. /** @hidden */
  78762. normalPattern: RegExp;
  78763. /** @hidden */
  78764. uvPattern: RegExp;
  78765. /** @hidden */
  78766. facePattern1: RegExp;
  78767. /** @hidden */
  78768. facePattern2: RegExp;
  78769. /** @hidden */
  78770. facePattern3: RegExp;
  78771. /** @hidden */
  78772. facePattern4: RegExp;
  78773. /** @hidden */
  78774. facePattern5: RegExp;
  78775. private _forAssetContainer;
  78776. private _meshLoadOptions;
  78777. /**
  78778. * Creates loader for .OBJ files
  78779. *
  78780. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  78781. */
  78782. constructor(meshLoadOptions?: MeshLoadOptions);
  78783. private static get currentMeshLoadOptions();
  78784. /**
  78785. * Calls synchronously the MTL file attached to this obj.
  78786. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  78787. * Without this function materials are not displayed in the first frame (but displayed after).
  78788. * In consequence it is impossible to get material information in your HTML file
  78789. *
  78790. * @param url The URL of the MTL file
  78791. * @param rootUrl
  78792. * @param onSuccess Callback function to be called when the MTL file is loaded
  78793. * @private
  78794. */
  78795. private _loadMTL;
  78796. /**
  78797. * Instantiates a OBJ file loader plugin.
  78798. * @returns the created plugin
  78799. */
  78800. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  78801. /**
  78802. * If the data string can be loaded directly.
  78803. *
  78804. * @param data string containing the file data
  78805. * @returns if the data can be loaded directly
  78806. */
  78807. canDirectLoad(data: string): boolean;
  78808. /**
  78809. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  78810. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78811. * @param scene the scene the meshes should be added to
  78812. * @param data the OBJ data to load
  78813. * @param rootUrl root url to load from
  78814. * @param onProgress event that fires when loading progress has occured
  78815. * @param fileName Defines the name of the file to load
  78816. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78817. */
  78818. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78819. meshes: AbstractMesh[];
  78820. particleSystems: IParticleSystem[];
  78821. skeletons: Skeleton[];
  78822. animationGroups: AnimationGroup[];
  78823. }>;
  78824. /**
  78825. * Imports all objects from the loaded OBJ data and adds them to the scene
  78826. * @param scene the scene the objects should be added to
  78827. * @param data the OBJ data to load
  78828. * @param rootUrl root url to load from
  78829. * @param onProgress event that fires when loading progress has occured
  78830. * @param fileName Defines the name of the file to load
  78831. * @returns a promise which completes when objects have been loaded to the scene
  78832. */
  78833. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78834. /**
  78835. * Load into an asset container.
  78836. * @param scene The scene to load into
  78837. * @param data The data to import
  78838. * @param rootUrl The root url for scene and resources
  78839. * @param onProgress The callback when the load progresses
  78840. * @param fileName Defines the name of the file to load
  78841. * @returns The loaded asset container
  78842. */
  78843. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78844. /**
  78845. * Read the OBJ file and create an Array of meshes.
  78846. * Each mesh contains all information given by the OBJ and the MTL file.
  78847. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  78848. *
  78849. * @param meshesNames
  78850. * @param scene Scene The scene where are displayed the data
  78851. * @param data String The content of the obj file
  78852. * @param rootUrl String The path to the folder
  78853. * @returns Array<AbstractMesh>
  78854. * @private
  78855. */
  78856. private _parseSolid;
  78857. }
  78858. }
  78859. declare module BABYLON {
  78860. /**
  78861. * STL file type loader.
  78862. * This is a babylon scene loader plugin.
  78863. */
  78864. export class STLFileLoader implements ISceneLoaderPlugin {
  78865. /** @hidden */
  78866. solidPattern: RegExp;
  78867. /** @hidden */
  78868. facetsPattern: RegExp;
  78869. /** @hidden */
  78870. normalPattern: RegExp;
  78871. /** @hidden */
  78872. vertexPattern: RegExp;
  78873. /**
  78874. * Defines the name of the plugin.
  78875. */
  78876. name: string;
  78877. /**
  78878. * Defines the extensions the stl loader is able to load.
  78879. * force data to come in as an ArrayBuffer
  78880. * we'll convert to string if it looks like it's an ASCII .stl
  78881. */
  78882. extensions: ISceneLoaderPluginExtensions;
  78883. /**
  78884. * Import meshes into a scene.
  78885. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  78886. * @param scene The scene to import into
  78887. * @param data The data to import
  78888. * @param rootUrl The root url for scene and resources
  78889. * @param meshes The meshes array to import into
  78890. * @param particleSystems The particle systems array to import into
  78891. * @param skeletons The skeletons array to import into
  78892. * @param onError The callback when import fails
  78893. * @returns True if successful or false otherwise
  78894. */
  78895. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  78896. /**
  78897. * Load into a scene.
  78898. * @param scene The scene to load into
  78899. * @param data The data to import
  78900. * @param rootUrl The root url for scene and resources
  78901. * @param onError The callback when import fails
  78902. * @returns true if successful or false otherwise
  78903. */
  78904. load(scene: Scene, data: any, rootUrl: string): boolean;
  78905. /**
  78906. * Load into an asset container.
  78907. * @param scene The scene to load into
  78908. * @param data The data to import
  78909. * @param rootUrl The root url for scene and resources
  78910. * @param onError The callback when import fails
  78911. * @returns The loaded asset container
  78912. */
  78913. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  78914. private _isBinary;
  78915. private _parseBinary;
  78916. private _parseASCII;
  78917. }
  78918. }
  78919. declare module BABYLON {
  78920. /**
  78921. * Class for generating OBJ data from a Babylon scene.
  78922. */
  78923. export class OBJExport {
  78924. /**
  78925. * Exports the geometry of a Mesh array in .OBJ file format (text)
  78926. * @param mesh defines the list of meshes to serialize
  78927. * @param materials defines if materials should be exported
  78928. * @param matlibname defines the name of the associated mtl file
  78929. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  78930. * @returns the OBJ content
  78931. */
  78932. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  78933. /**
  78934. * Exports the material(s) of a mesh in .MTL file format (text)
  78935. * @param mesh defines the mesh to extract the material from
  78936. * @returns the mtl content
  78937. */
  78938. static MTL(mesh: Mesh): string;
  78939. }
  78940. }
  78941. declare module BABYLON {
  78942. /** @hidden */
  78943. export var __IGLTFExporterExtension: number;
  78944. /**
  78945. * Interface for extending the exporter
  78946. * @hidden
  78947. */
  78948. export interface IGLTFExporterExtension {
  78949. /**
  78950. * The name of this extension
  78951. */
  78952. readonly name: string;
  78953. /**
  78954. * Defines whether this extension is enabled
  78955. */
  78956. enabled: boolean;
  78957. /**
  78958. * Defines whether this extension is required
  78959. */
  78960. required: boolean;
  78961. }
  78962. }
  78963. declare module BABYLON.GLTF2.Exporter {
  78964. /** @hidden */
  78965. export var __IGLTFExporterExtensionV2: number;
  78966. /**
  78967. * Interface for a glTF exporter extension
  78968. * @hidden
  78969. */
  78970. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  78971. /**
  78972. * Define this method to modify the default behavior before exporting a texture
  78973. * @param context The context when loading the asset
  78974. * @param babylonTexture The Babylon.js texture
  78975. * @param mimeType The mime-type of the generated image
  78976. * @returns A promise that resolves with the exported texture
  78977. */
  78978. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  78979. /**
  78980. * Define this method to get notified when a texture info is created
  78981. * @param context The context when loading the asset
  78982. * @param textureInfo The glTF texture info
  78983. * @param babylonTexture The Babylon.js texture
  78984. */
  78985. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78986. /**
  78987. * Define this method to modify the default behavior when exporting texture info
  78988. * @param context The context when loading the asset
  78989. * @param meshPrimitive glTF mesh primitive
  78990. * @param babylonSubMesh Babylon submesh
  78991. * @param binaryWriter glTF serializer binary writer instance
  78992. * @returns nullable IMeshPrimitive promise
  78993. */
  78994. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  78995. /**
  78996. * Define this method to modify the default behavior when exporting a node
  78997. * @param context The context when exporting the node
  78998. * @param node glTF node
  78999. * @param babylonNode BabylonJS node
  79000. * @returns nullable INode promise
  79001. */
  79002. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79003. [key: number]: number;
  79004. }): Promise<Nullable<INode>>;
  79005. /**
  79006. * Define this method to modify the default behavior when exporting a material
  79007. * @param material glTF material
  79008. * @param babylonMaterial BabylonJS material
  79009. * @returns nullable IMaterial promise
  79010. */
  79011. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  79012. /**
  79013. * Define this method to return additional textures to export from a material
  79014. * @param material glTF material
  79015. * @param babylonMaterial BabylonJS material
  79016. * @returns List of textures
  79017. */
  79018. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  79019. /** Gets a boolean indicating that this extension was used */
  79020. wasUsed: boolean;
  79021. /** Gets a boolean indicating that this extension is required for the file to work */
  79022. required: boolean;
  79023. /**
  79024. * Called after the exporter state changes to EXPORTING
  79025. */
  79026. onExporting?(): void;
  79027. }
  79028. }
  79029. declare module BABYLON.GLTF2.Exporter {
  79030. /**
  79031. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  79032. * @hidden
  79033. */
  79034. export class _GLTFMaterialExporter {
  79035. /**
  79036. * Represents the dielectric specular values for R, G and B
  79037. */
  79038. private static readonly _DielectricSpecular;
  79039. /**
  79040. * Allows the maximum specular power to be defined for material calculations
  79041. */
  79042. private static readonly _MaxSpecularPower;
  79043. /**
  79044. * Mapping to store textures
  79045. */
  79046. private _textureMap;
  79047. /**
  79048. * Numeric tolerance value
  79049. */
  79050. private static readonly _Epsilon;
  79051. /**
  79052. * Reference to the glTF Exporter
  79053. */
  79054. private _exporter;
  79055. constructor(exporter: _Exporter);
  79056. /**
  79057. * Specifies if two colors are approximately equal in value
  79058. * @param color1 first color to compare to
  79059. * @param color2 second color to compare to
  79060. * @param epsilon threshold value
  79061. */
  79062. private static FuzzyEquals;
  79063. /**
  79064. * Gets the materials from a Babylon scene and converts them to glTF materials
  79065. * @param scene babylonjs scene
  79066. * @param mimeType texture mime type
  79067. * @param images array of images
  79068. * @param textures array of textures
  79069. * @param materials array of materials
  79070. * @param imageData mapping of texture names to base64 textures
  79071. * @param hasTextureCoords specifies if texture coordinates are present on the material
  79072. */
  79073. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  79074. /**
  79075. * Makes a copy of the glTF material without the texture parameters
  79076. * @param originalMaterial original glTF material
  79077. * @returns glTF material without texture parameters
  79078. */
  79079. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  79080. /**
  79081. * Specifies if the material has any texture parameters present
  79082. * @param material glTF Material
  79083. * @returns boolean specifying if texture parameters are present
  79084. */
  79085. _hasTexturesPresent(material: IMaterial): boolean;
  79086. /**
  79087. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  79088. * @param babylonStandardMaterial
  79089. * @returns glTF Metallic Roughness Material representation
  79090. */
  79091. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  79092. /**
  79093. * Computes the metallic factor
  79094. * @param diffuse diffused value
  79095. * @param specular specular value
  79096. * @param oneMinusSpecularStrength one minus the specular strength
  79097. * @returns metallic value
  79098. */
  79099. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  79100. /**
  79101. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  79102. * @param glTFMaterial glTF material
  79103. * @param babylonMaterial Babylon material
  79104. */
  79105. private static _SetAlphaMode;
  79106. /**
  79107. * Converts a Babylon Standard Material to a glTF Material
  79108. * @param babylonStandardMaterial BJS Standard Material
  79109. * @param mimeType mime type to use for the textures
  79110. * @param images array of glTF image interfaces
  79111. * @param textures array of glTF texture interfaces
  79112. * @param materials array of glTF material interfaces
  79113. * @param imageData map of image file name to data
  79114. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79115. */
  79116. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79117. private _finishMaterial;
  79118. /**
  79119. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79120. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  79121. * @param mimeType mime type to use for the textures
  79122. * @param images array of glTF image interfaces
  79123. * @param textures array of glTF texture interfaces
  79124. * @param materials array of glTF material interfaces
  79125. * @param imageData map of image file name to data
  79126. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79127. */
  79128. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79129. /**
  79130. * Converts an image typed array buffer to a base64 image
  79131. * @param buffer typed array buffer
  79132. * @param width width of the image
  79133. * @param height height of the image
  79134. * @param mimeType mimetype of the image
  79135. * @returns base64 image string
  79136. */
  79137. private _createBase64FromCanvasAsync;
  79138. /**
  79139. * Generates a white texture based on the specified width and height
  79140. * @param width width of the texture in pixels
  79141. * @param height height of the texture in pixels
  79142. * @param scene babylonjs scene
  79143. * @returns white texture
  79144. */
  79145. private _createWhiteTexture;
  79146. /**
  79147. * 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
  79148. * @param texture1 first texture to resize
  79149. * @param texture2 second texture to resize
  79150. * @param scene babylonjs scene
  79151. * @returns resized textures or null
  79152. */
  79153. private _resizeTexturesToSameDimensions;
  79154. /**
  79155. * Converts an array of pixels to a Float32Array
  79156. * Throws an error if the pixel format is not supported
  79157. * @param pixels - array buffer containing pixel values
  79158. * @returns Float32 of pixels
  79159. */
  79160. private _convertPixelArrayToFloat32;
  79161. /**
  79162. * Convert Specular Glossiness Textures to Metallic Roughness
  79163. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  79164. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  79165. * @param diffuseTexture texture used to store diffuse information
  79166. * @param specularGlossinessTexture texture used to store specular and glossiness information
  79167. * @param factors specular glossiness material factors
  79168. * @param mimeType the mime type to use for the texture
  79169. * @returns pbr metallic roughness interface or null
  79170. */
  79171. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  79172. /**
  79173. * Converts specular glossiness material properties to metallic roughness
  79174. * @param specularGlossiness interface with specular glossiness material properties
  79175. * @returns interface with metallic roughness material properties
  79176. */
  79177. private _convertSpecularGlossinessToMetallicRoughness;
  79178. /**
  79179. * Calculates the surface reflectance, independent of lighting conditions
  79180. * @param color Color source to calculate brightness from
  79181. * @returns number representing the perceived brightness, or zero if color is undefined
  79182. */
  79183. private _getPerceivedBrightness;
  79184. /**
  79185. * Returns the maximum color component value
  79186. * @param color
  79187. * @returns maximum color component value, or zero if color is null or undefined
  79188. */
  79189. private _getMaxComponent;
  79190. /**
  79191. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  79192. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79193. * @param mimeType mime type to use for the textures
  79194. * @param images array of glTF image interfaces
  79195. * @param textures array of glTF texture interfaces
  79196. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79197. * @param imageData map of image file name to data
  79198. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79199. * @returns glTF PBR Metallic Roughness factors
  79200. */
  79201. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  79202. private _getGLTFTextureSampler;
  79203. private _getGLTFTextureWrapMode;
  79204. private _getGLTFTextureWrapModesSampler;
  79205. /**
  79206. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  79207. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79208. * @param mimeType mime type to use for the textures
  79209. * @param images array of glTF image interfaces
  79210. * @param textures array of glTF texture interfaces
  79211. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79212. * @param imageData map of image file name to data
  79213. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79214. * @returns glTF PBR Metallic Roughness factors
  79215. */
  79216. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  79217. /**
  79218. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79219. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79220. * @param mimeType mime type to use for the textures
  79221. * @param images array of glTF image interfaces
  79222. * @param textures array of glTF texture interfaces
  79223. * @param materials array of glTF material interfaces
  79224. * @param imageData map of image file name to data
  79225. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79226. */
  79227. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79228. private setMetallicRoughnessPbrMaterial;
  79229. private getPixelsFromTexture;
  79230. /**
  79231. * Extracts a texture from a Babylon texture into file data and glTF data
  79232. * @param babylonTexture Babylon texture to extract
  79233. * @param mimeType Mime Type of the babylonTexture
  79234. * @return glTF texture info, or null if the texture format is not supported
  79235. */
  79236. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79237. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79238. /**
  79239. * Builds a texture from base64 string
  79240. * @param base64Texture base64 texture string
  79241. * @param baseTextureName Name to use for the texture
  79242. * @param mimeType image mime type for the texture
  79243. * @param images array of images
  79244. * @param textures array of textures
  79245. * @param imageData map of image data
  79246. * @returns glTF texture info, or null if the texture format is not supported
  79247. */
  79248. private _getTextureInfoFromBase64;
  79249. }
  79250. }
  79251. declare module BABYLON {
  79252. /**
  79253. * Class for holding and downloading glTF file data
  79254. */
  79255. export class GLTFData {
  79256. /**
  79257. * Object which contains the file name as the key and its data as the value
  79258. */
  79259. glTFFiles: {
  79260. [fileName: string]: string | Blob;
  79261. };
  79262. /**
  79263. * Initializes the glTF file object
  79264. */
  79265. constructor();
  79266. /**
  79267. * Downloads the glTF data as files based on their names and data
  79268. */
  79269. downloadFiles(): void;
  79270. }
  79271. }
  79272. declare module BABYLON {
  79273. /**
  79274. * Holds a collection of exporter options and parameters
  79275. */
  79276. export interface IExportOptions {
  79277. /**
  79278. * Function which indicates whether a babylon node should be exported or not
  79279. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  79280. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  79281. */
  79282. shouldExportNode?(node: Node): boolean;
  79283. /**
  79284. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  79285. * @param metadata source metadata to read from
  79286. * @returns the data to store to glTF node extras
  79287. */
  79288. metadataSelector?(metadata: any): any;
  79289. /**
  79290. * The sample rate to bake animation curves
  79291. */
  79292. animationSampleRate?: number;
  79293. /**
  79294. * Begin serialization without waiting for the scene to be ready
  79295. */
  79296. exportWithoutWaitingForScene?: boolean;
  79297. /**
  79298. * Indicates if coordinate system swapping root nodes should be included in export
  79299. */
  79300. includeCoordinateSystemConversionNodes?: boolean;
  79301. }
  79302. /**
  79303. * Class for generating glTF data from a Babylon scene.
  79304. */
  79305. export class GLTF2Export {
  79306. /**
  79307. * Exports the geometry of the scene to .gltf file format asynchronously
  79308. * @param scene Babylon scene with scene hierarchy information
  79309. * @param filePrefix File prefix to use when generating the glTF file
  79310. * @param options Exporter options
  79311. * @returns Returns an object with a .gltf file and associates texture names
  79312. * as keys and their data and paths as values
  79313. */
  79314. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79315. private static _PreExportAsync;
  79316. private static _PostExportAsync;
  79317. /**
  79318. * Exports the geometry of the scene to .glb file format asychronously
  79319. * @param scene Babylon scene with scene hierarchy information
  79320. * @param filePrefix File prefix to use when generating glb file
  79321. * @param options Exporter options
  79322. * @returns Returns an object with a .glb filename as key and data as value
  79323. */
  79324. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79325. }
  79326. }
  79327. declare module BABYLON.GLTF2.Exporter {
  79328. /**
  79329. * @hidden
  79330. */
  79331. export class _GLTFUtilities {
  79332. /**
  79333. * Creates a buffer view based on the supplied arguments
  79334. * @param bufferIndex index value of the specified buffer
  79335. * @param byteOffset byte offset value
  79336. * @param byteLength byte length of the bufferView
  79337. * @param byteStride byte distance between conequential elements
  79338. * @param name name of the buffer view
  79339. * @returns bufferView for glTF
  79340. */
  79341. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  79342. /**
  79343. * Creates an accessor based on the supplied arguments
  79344. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  79345. * @param name The name of the accessor
  79346. * @param type The type of the accessor
  79347. * @param componentType The datatype of components in the attribute
  79348. * @param count The number of attributes referenced by this accessor
  79349. * @param byteOffset The offset relative to the start of the bufferView in bytes
  79350. * @param min Minimum value of each component in this attribute
  79351. * @param max Maximum value of each component in this attribute
  79352. * @returns accessor for glTF
  79353. */
  79354. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  79355. /**
  79356. * Calculates the minimum and maximum values of an array of position floats
  79357. * @param positions Positions array of a mesh
  79358. * @param vertexStart Starting vertex offset to calculate min and max values
  79359. * @param vertexCount Number of vertices to check for min and max values
  79360. * @returns min number array and max number array
  79361. */
  79362. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  79363. min: number[];
  79364. max: number[];
  79365. };
  79366. /**
  79367. * Converts a new right-handed Vector3
  79368. * @param vector vector3 array
  79369. * @returns right-handed Vector3
  79370. */
  79371. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  79372. /**
  79373. * Converts a Vector3 to right-handed
  79374. * @param vector Vector3 to convert to right-handed
  79375. */
  79376. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  79377. /**
  79378. * Converts a three element number array to right-handed
  79379. * @param vector number array to convert to right-handed
  79380. */
  79381. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  79382. /**
  79383. * Converts a new right-handed Vector3
  79384. * @param vector vector3 array
  79385. * @returns right-handed Vector3
  79386. */
  79387. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  79388. /**
  79389. * Converts a Vector3 to right-handed
  79390. * @param vector Vector3 to convert to right-handed
  79391. */
  79392. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  79393. /**
  79394. * Converts a three element number array to right-handed
  79395. * @param vector number array to convert to right-handed
  79396. */
  79397. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  79398. /**
  79399. * Converts a Vector4 to right-handed
  79400. * @param vector Vector4 to convert to right-handed
  79401. */
  79402. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  79403. /**
  79404. * Converts a Vector4 to right-handed
  79405. * @param vector Vector4 to convert to right-handed
  79406. */
  79407. static _GetRightHandedArray4FromRef(vector: number[]): void;
  79408. /**
  79409. * Converts a Quaternion to right-handed
  79410. * @param quaternion Source quaternion to convert to right-handed
  79411. */
  79412. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  79413. /**
  79414. * Converts a Quaternion to right-handed
  79415. * @param quaternion Source quaternion to convert to right-handed
  79416. */
  79417. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  79418. static _NormalizeTangentFromRef(tangent: Vector4): void;
  79419. }
  79420. }
  79421. declare module BABYLON.GLTF2.Exporter {
  79422. /**
  79423. * Converts Babylon Scene into glTF 2.0.
  79424. * @hidden
  79425. */
  79426. export class _Exporter {
  79427. /**
  79428. * Stores the glTF to export
  79429. */
  79430. _glTF: IGLTF;
  79431. /**
  79432. * Stores all generated buffer views, which represents views into the main glTF buffer data
  79433. */
  79434. _bufferViews: IBufferView[];
  79435. /**
  79436. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  79437. */
  79438. _accessors: IAccessor[];
  79439. /**
  79440. * Stores all the generated nodes, which contains transform and/or mesh information per node
  79441. */
  79442. _nodes: INode[];
  79443. /**
  79444. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  79445. */
  79446. private _scenes;
  79447. /**
  79448. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  79449. */
  79450. private _meshes;
  79451. /**
  79452. * Stores all the generated material information, which represents the appearance of each primitive
  79453. */
  79454. _materials: IMaterial[];
  79455. _materialMap: {
  79456. [materialID: number]: number;
  79457. };
  79458. /**
  79459. * Stores all the generated texture information, which is referenced by glTF materials
  79460. */
  79461. _textures: ITexture[];
  79462. /**
  79463. * Stores all the generated image information, which is referenced by glTF textures
  79464. */
  79465. _images: IImage[];
  79466. /**
  79467. * Stores all the texture samplers
  79468. */
  79469. _samplers: ISampler[];
  79470. /**
  79471. * Stores all the generated animation samplers, which is referenced by glTF animations
  79472. */
  79473. /**
  79474. * Stores the animations for glTF models
  79475. */
  79476. private _animations;
  79477. /**
  79478. * Stores the total amount of bytes stored in the glTF buffer
  79479. */
  79480. private _totalByteLength;
  79481. /**
  79482. * Stores a reference to the Babylon scene containing the source geometry and material information
  79483. */
  79484. _babylonScene: Scene;
  79485. /**
  79486. * Stores a map of the image data, where the key is the file name and the value
  79487. * is the image data
  79488. */
  79489. _imageData: {
  79490. [fileName: string]: {
  79491. data: Uint8Array;
  79492. mimeType: ImageMimeType;
  79493. };
  79494. };
  79495. /**
  79496. * Stores a map of the unique id of a node to its index in the node array
  79497. */
  79498. _nodeMap: {
  79499. [key: number]: number;
  79500. };
  79501. /**
  79502. * Specifies if the source Babylon scene was left handed, and needed conversion.
  79503. */
  79504. _convertToRightHandedSystem: boolean;
  79505. /**
  79506. * Specifies if a Babylon node should be converted to right-handed on export
  79507. */
  79508. _convertToRightHandedSystemMap: {
  79509. [nodeId: number]: boolean;
  79510. };
  79511. _includeCoordinateSystemConversionNodes: boolean;
  79512. /**
  79513. * Baked animation sample rate
  79514. */
  79515. private _animationSampleRate;
  79516. private _options;
  79517. private _localEngine;
  79518. _glTFMaterialExporter: _GLTFMaterialExporter;
  79519. private _extensions;
  79520. private static _ExtensionNames;
  79521. private static _ExtensionFactories;
  79522. private _applyExtension;
  79523. private _applyExtensions;
  79524. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  79525. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  79526. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79527. [key: number]: number;
  79528. }): Promise<Nullable<INode>>;
  79529. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  79530. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  79531. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79532. private _forEachExtensions;
  79533. private _extensionsOnExporting;
  79534. /**
  79535. * Load glTF serializer extensions
  79536. */
  79537. private _loadExtensions;
  79538. /**
  79539. * Creates a glTF Exporter instance, which can accept optional exporter options
  79540. * @param babylonScene Babylon scene object
  79541. * @param options Options to modify the behavior of the exporter
  79542. */
  79543. constructor(babylonScene: Scene, options?: IExportOptions);
  79544. dispose(): void;
  79545. /**
  79546. * Registers a glTF exporter extension
  79547. * @param name Name of the extension to export
  79548. * @param factory The factory function that creates the exporter extension
  79549. */
  79550. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  79551. /**
  79552. * Un-registers an exporter extension
  79553. * @param name The name fo the exporter extension
  79554. * @returns A boolean indicating whether the extension has been un-registered
  79555. */
  79556. static UnregisterExtension(name: string): boolean;
  79557. /**
  79558. * Lazy load a local engine
  79559. */
  79560. _getLocalEngine(): Engine;
  79561. private reorderIndicesBasedOnPrimitiveMode;
  79562. /**
  79563. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  79564. * clock-wise during export to glTF
  79565. * @param submesh BabylonJS submesh
  79566. * @param primitiveMode Primitive mode of the mesh
  79567. * @param sideOrientation the winding order of the submesh
  79568. * @param vertexBufferKind The type of vertex attribute
  79569. * @param meshAttributeArray The vertex attribute data
  79570. * @param byteOffset The offset to the binary data
  79571. * @param binaryWriter The binary data for the glTF file
  79572. * @param convertToRightHandedSystem Converts the values to right-handed
  79573. */
  79574. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  79575. /**
  79576. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  79577. * clock-wise during export to glTF
  79578. * @param submesh BabylonJS submesh
  79579. * @param primitiveMode Primitive mode of the mesh
  79580. * @param sideOrientation the winding order of the submesh
  79581. * @param vertexBufferKind The type of vertex attribute
  79582. * @param meshAttributeArray The vertex attribute data
  79583. * @param byteOffset The offset to the binary data
  79584. * @param binaryWriter The binary data for the glTF file
  79585. * @param convertToRightHandedSystem Converts the values to right-handed
  79586. */
  79587. private reorderTriangleFillMode;
  79588. /**
  79589. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  79590. * clock-wise during export to glTF
  79591. * @param submesh BabylonJS submesh
  79592. * @param primitiveMode Primitive mode of the mesh
  79593. * @param sideOrientation the winding order of the submesh
  79594. * @param vertexBufferKind The type of vertex attribute
  79595. * @param meshAttributeArray The vertex attribute data
  79596. * @param byteOffset The offset to the binary data
  79597. * @param binaryWriter The binary data for the glTF file
  79598. * @param convertToRightHandedSystem Converts the values to right-handed
  79599. */
  79600. private reorderTriangleStripDrawMode;
  79601. /**
  79602. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  79603. * clock-wise during export to glTF
  79604. * @param submesh BabylonJS submesh
  79605. * @param primitiveMode Primitive mode of the mesh
  79606. * @param sideOrientation the winding order of the submesh
  79607. * @param vertexBufferKind The type of vertex attribute
  79608. * @param meshAttributeArray The vertex attribute data
  79609. * @param byteOffset The offset to the binary data
  79610. * @param binaryWriter The binary data for the glTF file
  79611. * @param convertToRightHandedSystem Converts the values to right-handed
  79612. */
  79613. private reorderTriangleFanMode;
  79614. /**
  79615. * Writes the vertex attribute data to binary
  79616. * @param vertices The vertices to write to the binary writer
  79617. * @param byteOffset The offset into the binary writer to overwrite binary data
  79618. * @param vertexAttributeKind The vertex attribute type
  79619. * @param meshAttributeArray The vertex attribute data
  79620. * @param binaryWriter The writer containing the binary data
  79621. * @param convertToRightHandedSystem Converts the values to right-handed
  79622. */
  79623. private writeVertexAttributeData;
  79624. /**
  79625. * Writes mesh attribute data to a data buffer
  79626. * Returns the bytelength of the data
  79627. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  79628. * @param meshAttributeArray Array containing the attribute data
  79629. * @param binaryWriter The buffer to write the binary data to
  79630. * @param indices Used to specify the order of the vertex data
  79631. * @param convertToRightHandedSystem Converts the values to right-handed
  79632. */
  79633. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  79634. /**
  79635. * Generates glTF json data
  79636. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  79637. * @param glTFPrefix Text to use when prefixing a glTF file
  79638. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  79639. * @returns json data as string
  79640. */
  79641. private generateJSON;
  79642. /**
  79643. * Generates data for .gltf and .bin files based on the glTF prefix string
  79644. * @param glTFPrefix Text to use when prefixing a glTF file
  79645. * @param dispose Dispose the exporter
  79646. * @returns GLTFData with glTF file data
  79647. */
  79648. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79649. /**
  79650. * Creates a binary buffer for glTF
  79651. * @returns array buffer for binary data
  79652. */
  79653. private _generateBinaryAsync;
  79654. /**
  79655. * Pads the number to a multiple of 4
  79656. * @param num number to pad
  79657. * @returns padded number
  79658. */
  79659. private _getPadding;
  79660. /**
  79661. * @hidden
  79662. */
  79663. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79664. /**
  79665. * Sets the TRS for each node
  79666. * @param node glTF Node for storing the transformation data
  79667. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  79668. * @param convertToRightHandedSystem Converts the values to right-handed
  79669. */
  79670. private setNodeTransformation;
  79671. private getVertexBufferFromMesh;
  79672. /**
  79673. * Creates a bufferview based on the vertices type for the Babylon mesh
  79674. * @param kind Indicates the type of vertices data
  79675. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  79676. * @param binaryWriter The buffer to write the bufferview data to
  79677. * @param convertToRightHandedSystem Converts the values to right-handed
  79678. */
  79679. private createBufferViewKind;
  79680. /**
  79681. * The primitive mode of the Babylon mesh
  79682. * @param babylonMesh The BabylonJS mesh
  79683. */
  79684. private getMeshPrimitiveMode;
  79685. /**
  79686. * Sets the primitive mode of the glTF mesh primitive
  79687. * @param meshPrimitive glTF mesh primitive
  79688. * @param primitiveMode The primitive mode
  79689. */
  79690. private setPrimitiveMode;
  79691. /**
  79692. * Sets the vertex attribute accessor based of the glTF mesh primitive
  79693. * @param meshPrimitive glTF mesh primitive
  79694. * @param attributeKind vertex attribute
  79695. * @returns boolean specifying if uv coordinates are present
  79696. */
  79697. private setAttributeKind;
  79698. /**
  79699. * Sets data for the primitive attributes of each submesh
  79700. * @param mesh glTF Mesh object to store the primitive attribute information
  79701. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  79702. * @param binaryWriter Buffer to write the attribute data to
  79703. * @param convertToRightHandedSystem Converts the values to right-handed
  79704. */
  79705. private setPrimitiveAttributesAsync;
  79706. /**
  79707. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  79708. * @param node The node to check
  79709. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  79710. */
  79711. private isBabylonCoordinateSystemConvertingNode;
  79712. /**
  79713. * Creates a glTF scene based on the array of meshes
  79714. * Returns the the total byte offset
  79715. * @param babylonScene Babylon scene to get the mesh data from
  79716. * @param binaryWriter Buffer to write binary data to
  79717. */
  79718. private createSceneAsync;
  79719. /**
  79720. * Creates a mapping of Node unique id to node index and handles animations
  79721. * @param babylonScene Babylon Scene
  79722. * @param nodes Babylon transform nodes
  79723. * @param binaryWriter Buffer to write binary data to
  79724. * @returns Node mapping of unique id to index
  79725. */
  79726. private createNodeMapAndAnimationsAsync;
  79727. /**
  79728. * Creates a glTF node from a Babylon mesh
  79729. * @param babylonMesh Source Babylon mesh
  79730. * @param binaryWriter Buffer for storing geometry data
  79731. * @param convertToRightHandedSystem Converts the values to right-handed
  79732. * @param nodeMap Node mapping of unique id to glTF node index
  79733. * @returns glTF node
  79734. */
  79735. private createNodeAsync;
  79736. }
  79737. /**
  79738. * @hidden
  79739. *
  79740. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  79741. */
  79742. export class _BinaryWriter {
  79743. /**
  79744. * Array buffer which stores all binary data
  79745. */
  79746. private _arrayBuffer;
  79747. /**
  79748. * View of the array buffer
  79749. */
  79750. private _dataView;
  79751. /**
  79752. * byte offset of data in array buffer
  79753. */
  79754. private _byteOffset;
  79755. /**
  79756. * Initialize binary writer with an initial byte length
  79757. * @param byteLength Initial byte length of the array buffer
  79758. */
  79759. constructor(byteLength: number);
  79760. /**
  79761. * Resize the array buffer to the specified byte length
  79762. * @param byteLength
  79763. */
  79764. private resizeBuffer;
  79765. /**
  79766. * Get an array buffer with the length of the byte offset
  79767. * @returns ArrayBuffer resized to the byte offset
  79768. */
  79769. getArrayBuffer(): ArrayBuffer;
  79770. /**
  79771. * Get the byte offset of the array buffer
  79772. * @returns byte offset
  79773. */
  79774. getByteOffset(): number;
  79775. /**
  79776. * Stores an UInt8 in the array buffer
  79777. * @param entry
  79778. * @param byteOffset If defined, specifies where to set the value as an offset.
  79779. */
  79780. setUInt8(entry: number, byteOffset?: number): void;
  79781. /**
  79782. * Gets an UInt32 in the array buffer
  79783. * @param entry
  79784. * @param byteOffset If defined, specifies where to set the value as an offset.
  79785. */
  79786. getUInt32(byteOffset: number): number;
  79787. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79788. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79789. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79790. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79791. /**
  79792. * Stores a Float32 in the array buffer
  79793. * @param entry
  79794. */
  79795. setFloat32(entry: number, byteOffset?: number): void;
  79796. /**
  79797. * Stores an UInt32 in the array buffer
  79798. * @param entry
  79799. * @param byteOffset If defined, specifies where to set the value as an offset.
  79800. */
  79801. setUInt32(entry: number, byteOffset?: number): void;
  79802. }
  79803. }
  79804. declare module BABYLON.GLTF2.Exporter {
  79805. /**
  79806. * @hidden
  79807. * Interface to store animation data.
  79808. */
  79809. export interface _IAnimationData {
  79810. /**
  79811. * Keyframe data.
  79812. */
  79813. inputs: number[];
  79814. /**
  79815. * Value data.
  79816. */
  79817. outputs: number[][];
  79818. /**
  79819. * Animation interpolation data.
  79820. */
  79821. samplerInterpolation: AnimationSamplerInterpolation;
  79822. /**
  79823. * Minimum keyframe value.
  79824. */
  79825. inputsMin: number;
  79826. /**
  79827. * Maximum keyframe value.
  79828. */
  79829. inputsMax: number;
  79830. }
  79831. /**
  79832. * @hidden
  79833. */
  79834. export interface _IAnimationInfo {
  79835. /**
  79836. * The target channel for the animation
  79837. */
  79838. animationChannelTargetPath: AnimationChannelTargetPath;
  79839. /**
  79840. * The glTF accessor type for the data.
  79841. */
  79842. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  79843. /**
  79844. * Specifies if quaternions should be used.
  79845. */
  79846. useQuaternion: boolean;
  79847. }
  79848. /**
  79849. * @hidden
  79850. * Utility class for generating glTF animation data from BabylonJS.
  79851. */
  79852. export class _GLTFAnimation {
  79853. /**
  79854. * @ignore
  79855. *
  79856. * Creates glTF channel animation from BabylonJS animation.
  79857. * @param babylonTransformNode - BabylonJS mesh.
  79858. * @param animation - animation.
  79859. * @param animationChannelTargetPath - The target animation channel.
  79860. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  79861. * @param useQuaternion - Specifies if quaternions are used.
  79862. * @returns nullable IAnimationData
  79863. */
  79864. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  79865. private static _DeduceAnimationInfo;
  79866. /**
  79867. * @ignore
  79868. * Create node animations from the transform node animations
  79869. * @param babylonNode
  79870. * @param runtimeGLTFAnimation
  79871. * @param idleGLTFAnimations
  79872. * @param nodeMap
  79873. * @param nodes
  79874. * @param binaryWriter
  79875. * @param bufferViews
  79876. * @param accessors
  79877. * @param convertToRightHandedSystem
  79878. * @param animationSampleRate
  79879. */
  79880. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  79881. [key: number]: number;
  79882. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  79883. /**
  79884. * @ignore
  79885. * Create node animations from the animation groups
  79886. * @param babylonScene
  79887. * @param glTFAnimations
  79888. * @param nodeMap
  79889. * @param nodes
  79890. * @param binaryWriter
  79891. * @param bufferViews
  79892. * @param accessors
  79893. * @param convertToRightHandedSystemMap
  79894. * @param animationSampleRate
  79895. */
  79896. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  79897. [key: number]: number;
  79898. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  79899. [nodeId: number]: boolean;
  79900. }, animationSampleRate: number): void;
  79901. private static AddAnimation;
  79902. /**
  79903. * Create a baked animation
  79904. * @param babylonTransformNode BabylonJS mesh
  79905. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  79906. * @param animationChannelTargetPath animation target channel
  79907. * @param minFrame minimum animation frame
  79908. * @param maxFrame maximum animation frame
  79909. * @param fps frames per second of the animation
  79910. * @param inputs input key frames of the animation
  79911. * @param outputs output key frame data of the animation
  79912. * @param convertToRightHandedSystem converts the values to right-handed
  79913. * @param useQuaternion specifies if quaternions should be used
  79914. */
  79915. private static _CreateBakedAnimation;
  79916. private static _ConvertFactorToVector3OrQuaternion;
  79917. private static _SetInterpolatedValue;
  79918. /**
  79919. * Creates linear animation from the animation key frames
  79920. * @param babylonTransformNode BabylonJS mesh
  79921. * @param animation BabylonJS animation
  79922. * @param animationChannelTargetPath The target animation channel
  79923. * @param frameDelta The difference between the last and first frame of the animation
  79924. * @param inputs Array to store the key frame times
  79925. * @param outputs Array to store the key frame data
  79926. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  79927. * @param useQuaternion Specifies if quaternions are used in the animation
  79928. */
  79929. private static _CreateLinearOrStepAnimation;
  79930. /**
  79931. * Creates cubic spline animation from the animation key frames
  79932. * @param babylonTransformNode BabylonJS mesh
  79933. * @param animation BabylonJS animation
  79934. * @param animationChannelTargetPath The target animation channel
  79935. * @param frameDelta The difference between the last and first frame of the animation
  79936. * @param inputs Array to store the key frame times
  79937. * @param outputs Array to store the key frame data
  79938. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  79939. * @param useQuaternion Specifies if quaternions are used in the animation
  79940. */
  79941. private static _CreateCubicSplineAnimation;
  79942. private static _GetBasePositionRotationOrScale;
  79943. /**
  79944. * Adds a key frame value
  79945. * @param keyFrame
  79946. * @param animation
  79947. * @param outputs
  79948. * @param animationChannelTargetPath
  79949. * @param basePositionRotationOrScale
  79950. * @param convertToRightHandedSystem
  79951. * @param useQuaternion
  79952. */
  79953. private static _AddKeyframeValue;
  79954. /**
  79955. * Determine the interpolation based on the key frames
  79956. * @param keyFrames
  79957. * @param animationChannelTargetPath
  79958. * @param useQuaternion
  79959. */
  79960. private static _DeduceInterpolation;
  79961. /**
  79962. * Adds an input tangent or output tangent to the output data
  79963. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  79964. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  79965. * @param outputs The animation data by keyframe
  79966. * @param animationChannelTargetPath The target animation channel
  79967. * @param interpolation The interpolation type
  79968. * @param keyFrame The key frame with the animation data
  79969. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  79970. * @param useQuaternion Specifies if quaternions are used
  79971. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  79972. */
  79973. private static AddSplineTangent;
  79974. /**
  79975. * Get the minimum and maximum key frames' frame values
  79976. * @param keyFrames animation key frames
  79977. * @returns the minimum and maximum key frame value
  79978. */
  79979. private static calculateMinMaxKeyFrames;
  79980. }
  79981. }
  79982. declare module BABYLON.GLTF2.Exporter {
  79983. /** @hidden */
  79984. export var textureTransformPixelShader: {
  79985. name: string;
  79986. shader: string;
  79987. };
  79988. }
  79989. declare module BABYLON.GLTF2.Exporter.Extensions {
  79990. /**
  79991. * @hidden
  79992. */
  79993. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  79994. private _recordedTextures;
  79995. /** Name of this extension */
  79996. readonly name: string;
  79997. /** Defines whether this extension is enabled */
  79998. enabled: boolean;
  79999. /** Defines whether this extension is required */
  80000. required: boolean;
  80001. /** Reference to the glTF exporter */
  80002. private _wasUsed;
  80003. constructor(exporter: _Exporter);
  80004. dispose(): void;
  80005. /** @hidden */
  80006. get wasUsed(): boolean;
  80007. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80008. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  80009. /**
  80010. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  80011. * @param babylonTexture
  80012. * @param offset
  80013. * @param rotation
  80014. * @param scale
  80015. * @param scene
  80016. */
  80017. private _textureTransformTextureAsync;
  80018. }
  80019. }
  80020. declare module BABYLON.GLTF2.Exporter.Extensions {
  80021. /**
  80022. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  80023. */
  80024. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  80025. /** The name of this extension. */
  80026. readonly name: string;
  80027. /** Defines whether this extension is enabled. */
  80028. enabled: boolean;
  80029. /** Defines whether this extension is required */
  80030. required: boolean;
  80031. /** Reference to the glTF exporter */
  80032. private _exporter;
  80033. private _lights;
  80034. /** @hidden */
  80035. constructor(exporter: _Exporter);
  80036. /** @hidden */
  80037. dispose(): void;
  80038. /** @hidden */
  80039. get wasUsed(): boolean;
  80040. /** @hidden */
  80041. onExporting(): void;
  80042. /**
  80043. * Define this method to modify the default behavior when exporting a node
  80044. * @param context The context when exporting the node
  80045. * @param node glTF node
  80046. * @param babylonNode BabylonJS node
  80047. * @param nodeMap Node mapping of unique id to glTF node index
  80048. * @returns nullable INode promise
  80049. */
  80050. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80051. [key: number]: number;
  80052. }): Promise<Nullable<INode>>;
  80053. }
  80054. }
  80055. declare module BABYLON.GLTF2.Exporter.Extensions {
  80056. /**
  80057. * @hidden
  80058. */
  80059. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  80060. /** Name of this extension */
  80061. readonly name: string;
  80062. /** Defines whether this extension is enabled */
  80063. enabled: boolean;
  80064. /** Defines whether this extension is required */
  80065. required: boolean;
  80066. /** Reference to the glTF exporter */
  80067. private _textureInfos;
  80068. private _exportedTextures;
  80069. private _wasUsed;
  80070. constructor(exporter: _Exporter);
  80071. dispose(): void;
  80072. /** @hidden */
  80073. get wasUsed(): boolean;
  80074. private _getTextureIndex;
  80075. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80076. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80077. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  80078. }
  80079. }
  80080. declare module BABYLON {
  80081. /**
  80082. * Class for generating STL data from a Babylon scene.
  80083. */
  80084. export class STLExport {
  80085. /**
  80086. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  80087. * @param meshes list defines the mesh to serialize
  80088. * @param download triggers the automatic download of the file.
  80089. * @param fileName changes the downloads fileName.
  80090. * @param binary changes the STL to a binary type.
  80091. * @param isLittleEndian toggle for binary type exporter.
  80092. * @returns the STL as UTF8 string
  80093. */
  80094. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  80095. }
  80096. }
  80097. declare module "babylonjs-gltf2interface" {
  80098. export = BABYLON.GLTF2;
  80099. }
  80100. /**
  80101. * Module for glTF 2.0 Interface
  80102. */
  80103. declare module BABYLON.GLTF2 {
  80104. /**
  80105. * The datatype of the components in the attribute
  80106. */
  80107. const enum AccessorComponentType {
  80108. /**
  80109. * Byte
  80110. */
  80111. BYTE = 5120,
  80112. /**
  80113. * Unsigned Byte
  80114. */
  80115. UNSIGNED_BYTE = 5121,
  80116. /**
  80117. * Short
  80118. */
  80119. SHORT = 5122,
  80120. /**
  80121. * Unsigned Short
  80122. */
  80123. UNSIGNED_SHORT = 5123,
  80124. /**
  80125. * Unsigned Int
  80126. */
  80127. UNSIGNED_INT = 5125,
  80128. /**
  80129. * Float
  80130. */
  80131. FLOAT = 5126,
  80132. }
  80133. /**
  80134. * Specifies if the attirbute is a scalar, vector, or matrix
  80135. */
  80136. const enum AccessorType {
  80137. /**
  80138. * Scalar
  80139. */
  80140. SCALAR = "SCALAR",
  80141. /**
  80142. * Vector2
  80143. */
  80144. VEC2 = "VEC2",
  80145. /**
  80146. * Vector3
  80147. */
  80148. VEC3 = "VEC3",
  80149. /**
  80150. * Vector4
  80151. */
  80152. VEC4 = "VEC4",
  80153. /**
  80154. * Matrix2x2
  80155. */
  80156. MAT2 = "MAT2",
  80157. /**
  80158. * Matrix3x3
  80159. */
  80160. MAT3 = "MAT3",
  80161. /**
  80162. * Matrix4x4
  80163. */
  80164. MAT4 = "MAT4",
  80165. }
  80166. /**
  80167. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80168. */
  80169. const enum AnimationChannelTargetPath {
  80170. /**
  80171. * Translation
  80172. */
  80173. TRANSLATION = "translation",
  80174. /**
  80175. * Rotation
  80176. */
  80177. ROTATION = "rotation",
  80178. /**
  80179. * Scale
  80180. */
  80181. SCALE = "scale",
  80182. /**
  80183. * Weights
  80184. */
  80185. WEIGHTS = "weights",
  80186. }
  80187. /**
  80188. * Interpolation algorithm
  80189. */
  80190. const enum AnimationSamplerInterpolation {
  80191. /**
  80192. * The animated values are linearly interpolated between keyframes
  80193. */
  80194. LINEAR = "LINEAR",
  80195. /**
  80196. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  80197. */
  80198. STEP = "STEP",
  80199. /**
  80200. * The animation's interpolation is computed using a cubic spline with specified tangents
  80201. */
  80202. CUBICSPLINE = "CUBICSPLINE",
  80203. }
  80204. /**
  80205. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80206. */
  80207. const enum CameraType {
  80208. /**
  80209. * A perspective camera containing properties to create a perspective projection matrix
  80210. */
  80211. PERSPECTIVE = "perspective",
  80212. /**
  80213. * An orthographic camera containing properties to create an orthographic projection matrix
  80214. */
  80215. ORTHOGRAPHIC = "orthographic",
  80216. }
  80217. /**
  80218. * The mime-type of the image
  80219. */
  80220. const enum ImageMimeType {
  80221. /**
  80222. * JPEG Mime-type
  80223. */
  80224. JPEG = "image/jpeg",
  80225. /**
  80226. * PNG Mime-type
  80227. */
  80228. PNG = "image/png",
  80229. }
  80230. /**
  80231. * The alpha rendering mode of the material
  80232. */
  80233. const enum MaterialAlphaMode {
  80234. /**
  80235. * The alpha value is ignored and the rendered output is fully opaque
  80236. */
  80237. OPAQUE = "OPAQUE",
  80238. /**
  80239. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  80240. */
  80241. MASK = "MASK",
  80242. /**
  80243. * 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)
  80244. */
  80245. BLEND = "BLEND",
  80246. }
  80247. /**
  80248. * The type of the primitives to render
  80249. */
  80250. const enum MeshPrimitiveMode {
  80251. /**
  80252. * Points
  80253. */
  80254. POINTS = 0,
  80255. /**
  80256. * Lines
  80257. */
  80258. LINES = 1,
  80259. /**
  80260. * Line Loop
  80261. */
  80262. LINE_LOOP = 2,
  80263. /**
  80264. * Line Strip
  80265. */
  80266. LINE_STRIP = 3,
  80267. /**
  80268. * Triangles
  80269. */
  80270. TRIANGLES = 4,
  80271. /**
  80272. * Triangle Strip
  80273. */
  80274. TRIANGLE_STRIP = 5,
  80275. /**
  80276. * Triangle Fan
  80277. */
  80278. TRIANGLE_FAN = 6,
  80279. }
  80280. /**
  80281. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80282. */
  80283. const enum TextureMagFilter {
  80284. /**
  80285. * Nearest
  80286. */
  80287. NEAREST = 9728,
  80288. /**
  80289. * Linear
  80290. */
  80291. LINEAR = 9729,
  80292. }
  80293. /**
  80294. * Minification filter. All valid values correspond to WebGL enums
  80295. */
  80296. const enum TextureMinFilter {
  80297. /**
  80298. * Nearest
  80299. */
  80300. NEAREST = 9728,
  80301. /**
  80302. * Linear
  80303. */
  80304. LINEAR = 9729,
  80305. /**
  80306. * Nearest Mip-Map Nearest
  80307. */
  80308. NEAREST_MIPMAP_NEAREST = 9984,
  80309. /**
  80310. * Linear Mipmap Nearest
  80311. */
  80312. LINEAR_MIPMAP_NEAREST = 9985,
  80313. /**
  80314. * Nearest Mipmap Linear
  80315. */
  80316. NEAREST_MIPMAP_LINEAR = 9986,
  80317. /**
  80318. * Linear Mipmap Linear
  80319. */
  80320. LINEAR_MIPMAP_LINEAR = 9987,
  80321. }
  80322. /**
  80323. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80324. */
  80325. const enum TextureWrapMode {
  80326. /**
  80327. * Clamp to Edge
  80328. */
  80329. CLAMP_TO_EDGE = 33071,
  80330. /**
  80331. * Mirrored Repeat
  80332. */
  80333. MIRRORED_REPEAT = 33648,
  80334. /**
  80335. * Repeat
  80336. */
  80337. REPEAT = 10497,
  80338. }
  80339. /**
  80340. * glTF Property
  80341. */
  80342. interface IProperty {
  80343. /**
  80344. * Dictionary object with extension-specific objects
  80345. */
  80346. extensions?: {
  80347. [key: string]: any;
  80348. };
  80349. /**
  80350. * Application-Specific data
  80351. */
  80352. extras?: any;
  80353. }
  80354. /**
  80355. * glTF Child of Root Property
  80356. */
  80357. interface IChildRootProperty extends IProperty {
  80358. /**
  80359. * The user-defined name of this object
  80360. */
  80361. name?: string;
  80362. }
  80363. /**
  80364. * Indices of those attributes that deviate from their initialization value
  80365. */
  80366. interface IAccessorSparseIndices extends IProperty {
  80367. /**
  80368. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80369. */
  80370. bufferView: number;
  80371. /**
  80372. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80373. */
  80374. byteOffset?: number;
  80375. /**
  80376. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  80377. */
  80378. componentType: AccessorComponentType;
  80379. }
  80380. /**
  80381. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  80382. */
  80383. interface IAccessorSparseValues extends IProperty {
  80384. /**
  80385. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80386. */
  80387. bufferView: number;
  80388. /**
  80389. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80390. */
  80391. byteOffset?: number;
  80392. }
  80393. /**
  80394. * Sparse storage of attributes that deviate from their initialization value
  80395. */
  80396. interface IAccessorSparse extends IProperty {
  80397. /**
  80398. * The number of attributes encoded in this sparse accessor
  80399. */
  80400. count: number;
  80401. /**
  80402. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  80403. */
  80404. indices: IAccessorSparseIndices;
  80405. /**
  80406. * 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
  80407. */
  80408. values: IAccessorSparseValues;
  80409. }
  80410. /**
  80411. * 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
  80412. */
  80413. interface IAccessor extends IChildRootProperty {
  80414. /**
  80415. * The index of the bufferview
  80416. */
  80417. bufferView?: number;
  80418. /**
  80419. * The offset relative to the start of the bufferView in bytes
  80420. */
  80421. byteOffset?: number;
  80422. /**
  80423. * The datatype of components in the attribute
  80424. */
  80425. componentType: AccessorComponentType;
  80426. /**
  80427. * Specifies whether integer data values should be normalized
  80428. */
  80429. normalized?: boolean;
  80430. /**
  80431. * The number of attributes referenced by this accessor
  80432. */
  80433. count: number;
  80434. /**
  80435. * Specifies if the attribute is a scalar, vector, or matrix
  80436. */
  80437. type: AccessorType;
  80438. /**
  80439. * Maximum value of each component in this attribute
  80440. */
  80441. max?: number[];
  80442. /**
  80443. * Minimum value of each component in this attribute
  80444. */
  80445. min?: number[];
  80446. /**
  80447. * Sparse storage of attributes that deviate from their initialization value
  80448. */
  80449. sparse?: IAccessorSparse;
  80450. }
  80451. /**
  80452. * Targets an animation's sampler at a node's property
  80453. */
  80454. interface IAnimationChannel extends IProperty {
  80455. /**
  80456. * The index of a sampler in this animation used to compute the value for the target
  80457. */
  80458. sampler: number;
  80459. /**
  80460. * The index of the node and TRS property to target
  80461. */
  80462. target: IAnimationChannelTarget;
  80463. }
  80464. /**
  80465. * The index of the node and TRS property that an animation channel targets
  80466. */
  80467. interface IAnimationChannelTarget extends IProperty {
  80468. /**
  80469. * The index of the node to target
  80470. */
  80471. node: number;
  80472. /**
  80473. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80474. */
  80475. path: AnimationChannelTargetPath;
  80476. }
  80477. /**
  80478. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80479. */
  80480. interface IAnimationSampler extends IProperty {
  80481. /**
  80482. * The index of an accessor containing keyframe input values, e.g., time
  80483. */
  80484. input: number;
  80485. /**
  80486. * Interpolation algorithm
  80487. */
  80488. interpolation?: AnimationSamplerInterpolation;
  80489. /**
  80490. * The index of an accessor, containing keyframe output values
  80491. */
  80492. output: number;
  80493. }
  80494. /**
  80495. * A keyframe animation
  80496. */
  80497. interface IAnimation extends IChildRootProperty {
  80498. /**
  80499. * An array of channels, each of which targets an animation's sampler at a node's property
  80500. */
  80501. channels: IAnimationChannel[];
  80502. /**
  80503. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80504. */
  80505. samplers: IAnimationSampler[];
  80506. }
  80507. /**
  80508. * Metadata about the glTF asset
  80509. */
  80510. interface IAsset extends IChildRootProperty {
  80511. /**
  80512. * A copyright message suitable for display to credit the content creator
  80513. */
  80514. copyright?: string;
  80515. /**
  80516. * Tool that generated this glTF model. Useful for debugging
  80517. */
  80518. generator?: string;
  80519. /**
  80520. * The glTF version that this asset targets
  80521. */
  80522. version: string;
  80523. /**
  80524. * The minimum glTF version that this asset targets
  80525. */
  80526. minVersion?: string;
  80527. }
  80528. /**
  80529. * A buffer points to binary geometry, animation, or skins
  80530. */
  80531. interface IBuffer extends IChildRootProperty {
  80532. /**
  80533. * 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
  80534. */
  80535. uri?: string;
  80536. /**
  80537. * The length of the buffer in bytes
  80538. */
  80539. byteLength: number;
  80540. }
  80541. /**
  80542. * A view into a buffer generally representing a subset of the buffer
  80543. */
  80544. interface IBufferView extends IChildRootProperty {
  80545. /**
  80546. * The index of the buffer
  80547. */
  80548. buffer: number;
  80549. /**
  80550. * The offset into the buffer in bytes
  80551. */
  80552. byteOffset?: number;
  80553. /**
  80554. * The lenth of the bufferView in bytes
  80555. */
  80556. byteLength: number;
  80557. /**
  80558. * The stride, in bytes
  80559. */
  80560. byteStride?: number;
  80561. }
  80562. /**
  80563. * An orthographic camera containing properties to create an orthographic projection matrix
  80564. */
  80565. interface ICameraOrthographic extends IProperty {
  80566. /**
  80567. * The floating-point horizontal magnification of the view. Must not be zero
  80568. */
  80569. xmag: number;
  80570. /**
  80571. * The floating-point vertical magnification of the view. Must not be zero
  80572. */
  80573. ymag: number;
  80574. /**
  80575. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  80576. */
  80577. zfar: number;
  80578. /**
  80579. * The floating-point distance to the near clipping plane
  80580. */
  80581. znear: number;
  80582. }
  80583. /**
  80584. * A perspective camera containing properties to create a perspective projection matrix
  80585. */
  80586. interface ICameraPerspective extends IProperty {
  80587. /**
  80588. * The floating-point aspect ratio of the field of view
  80589. */
  80590. aspectRatio?: number;
  80591. /**
  80592. * The floating-point vertical field of view in radians
  80593. */
  80594. yfov: number;
  80595. /**
  80596. * The floating-point distance to the far clipping plane
  80597. */
  80598. zfar?: number;
  80599. /**
  80600. * The floating-point distance to the near clipping plane
  80601. */
  80602. znear: number;
  80603. }
  80604. /**
  80605. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80606. */
  80607. interface ICamera extends IChildRootProperty {
  80608. /**
  80609. * An orthographic camera containing properties to create an orthographic projection matrix
  80610. */
  80611. orthographic?: ICameraOrthographic;
  80612. /**
  80613. * A perspective camera containing properties to create a perspective projection matrix
  80614. */
  80615. perspective?: ICameraPerspective;
  80616. /**
  80617. * Specifies if the camera uses a perspective or orthographic projection
  80618. */
  80619. type: CameraType;
  80620. }
  80621. /**
  80622. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  80623. */
  80624. interface IImage extends IChildRootProperty {
  80625. /**
  80626. * 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
  80627. */
  80628. uri?: string;
  80629. /**
  80630. * The image's MIME type
  80631. */
  80632. mimeType?: ImageMimeType;
  80633. /**
  80634. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  80635. */
  80636. bufferView?: number;
  80637. }
  80638. /**
  80639. * Material Normal Texture Info
  80640. */
  80641. interface IMaterialNormalTextureInfo extends ITextureInfo {
  80642. /**
  80643. * The scalar multiplier applied to each normal vector of the normal texture
  80644. */
  80645. scale?: number;
  80646. }
  80647. /**
  80648. * Material Occlusion Texture Info
  80649. */
  80650. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  80651. /**
  80652. * A scalar multiplier controlling the amount of occlusion applied
  80653. */
  80654. strength?: number;
  80655. }
  80656. /**
  80657. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  80658. */
  80659. interface IMaterialPbrMetallicRoughness {
  80660. /**
  80661. * The material's base color factor
  80662. */
  80663. baseColorFactor?: number[];
  80664. /**
  80665. * The base color texture
  80666. */
  80667. baseColorTexture?: ITextureInfo;
  80668. /**
  80669. * The metalness of the material
  80670. */
  80671. metallicFactor?: number;
  80672. /**
  80673. * The roughness of the material
  80674. */
  80675. roughnessFactor?: number;
  80676. /**
  80677. * The metallic-roughness texture
  80678. */
  80679. metallicRoughnessTexture?: ITextureInfo;
  80680. }
  80681. /**
  80682. * The material appearance of a primitive
  80683. */
  80684. interface IMaterial extends IChildRootProperty {
  80685. /**
  80686. * 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
  80687. */
  80688. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80689. /**
  80690. * The normal map texture
  80691. */
  80692. normalTexture?: IMaterialNormalTextureInfo;
  80693. /**
  80694. * The occlusion map texture
  80695. */
  80696. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80697. /**
  80698. * The emissive map texture
  80699. */
  80700. emissiveTexture?: ITextureInfo;
  80701. /**
  80702. * 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
  80703. */
  80704. emissiveFactor?: number[];
  80705. /**
  80706. * The alpha rendering mode of the material
  80707. */
  80708. alphaMode?: MaterialAlphaMode;
  80709. /**
  80710. * The alpha cutoff value of the material
  80711. */
  80712. alphaCutoff?: number;
  80713. /**
  80714. * Specifies whether the material is double sided
  80715. */
  80716. doubleSided?: boolean;
  80717. }
  80718. /**
  80719. * Geometry to be rendered with the given material
  80720. */
  80721. interface IMeshPrimitive extends IProperty {
  80722. /**
  80723. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  80724. */
  80725. attributes: {
  80726. [name: string]: number;
  80727. };
  80728. /**
  80729. * The index of the accessor that contains the indices
  80730. */
  80731. indices?: number;
  80732. /**
  80733. * The index of the material to apply to this primitive when rendering
  80734. */
  80735. material?: number;
  80736. /**
  80737. * The type of primitives to render. All valid values correspond to WebGL enums
  80738. */
  80739. mode?: MeshPrimitiveMode;
  80740. /**
  80741. * 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
  80742. */
  80743. targets?: {
  80744. [name: string]: number;
  80745. }[];
  80746. }
  80747. /**
  80748. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  80749. */
  80750. interface IMesh extends IChildRootProperty {
  80751. /**
  80752. * An array of primitives, each defining geometry to be rendered with a material
  80753. */
  80754. primitives: IMeshPrimitive[];
  80755. /**
  80756. * Array of weights to be applied to the Morph Targets
  80757. */
  80758. weights?: number[];
  80759. }
  80760. /**
  80761. * A node in the node hierarchy
  80762. */
  80763. interface INode extends IChildRootProperty {
  80764. /**
  80765. * The index of the camera referenced by this node
  80766. */
  80767. camera?: number;
  80768. /**
  80769. * The indices of this node's children
  80770. */
  80771. children?: number[];
  80772. /**
  80773. * The index of the skin referenced by this node
  80774. */
  80775. skin?: number;
  80776. /**
  80777. * A floating-point 4x4 transformation matrix stored in column-major order
  80778. */
  80779. matrix?: number[];
  80780. /**
  80781. * The index of the mesh in this node
  80782. */
  80783. mesh?: number;
  80784. /**
  80785. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  80786. */
  80787. rotation?: number[];
  80788. /**
  80789. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  80790. */
  80791. scale?: number[];
  80792. /**
  80793. * The node's translation along the x, y, and z axes
  80794. */
  80795. translation?: number[];
  80796. /**
  80797. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  80798. */
  80799. weights?: number[];
  80800. }
  80801. /**
  80802. * Texture sampler properties for filtering and wrapping modes
  80803. */
  80804. interface ISampler extends IChildRootProperty {
  80805. /**
  80806. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80807. */
  80808. magFilter?: TextureMagFilter;
  80809. /**
  80810. * Minification filter. All valid values correspond to WebGL enums
  80811. */
  80812. minFilter?: TextureMinFilter;
  80813. /**
  80814. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80815. */
  80816. wrapS?: TextureWrapMode;
  80817. /**
  80818. * T (V) wrapping mode. All valid values correspond to WebGL enums
  80819. */
  80820. wrapT?: TextureWrapMode;
  80821. }
  80822. /**
  80823. * The root nodes of a scene
  80824. */
  80825. interface IScene extends IChildRootProperty {
  80826. /**
  80827. * The indices of each root node
  80828. */
  80829. nodes: number[];
  80830. }
  80831. /**
  80832. * Joints and matrices defining a skin
  80833. */
  80834. interface ISkin extends IChildRootProperty {
  80835. /**
  80836. * 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
  80837. */
  80838. inverseBindMatrices?: number;
  80839. /**
  80840. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  80841. */
  80842. skeleton?: number;
  80843. /**
  80844. * 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)
  80845. */
  80846. joints: number[];
  80847. }
  80848. /**
  80849. * A texture and its sampler
  80850. */
  80851. interface ITexture extends IChildRootProperty {
  80852. /**
  80853. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  80854. */
  80855. sampler?: number;
  80856. /**
  80857. * The index of the image used by this texture
  80858. */
  80859. source: number;
  80860. }
  80861. /**
  80862. * Reference to a texture
  80863. */
  80864. interface ITextureInfo extends IProperty {
  80865. /**
  80866. * The index of the texture
  80867. */
  80868. index: number;
  80869. /**
  80870. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  80871. */
  80872. texCoord?: number;
  80873. }
  80874. /**
  80875. * The root object for a glTF asset
  80876. */
  80877. interface IGLTF extends IProperty {
  80878. /**
  80879. * An array of accessors. An accessor is a typed view into a bufferView
  80880. */
  80881. accessors?: IAccessor[];
  80882. /**
  80883. * An array of keyframe animations
  80884. */
  80885. animations?: IAnimation[];
  80886. /**
  80887. * Metadata about the glTF asset
  80888. */
  80889. asset: IAsset;
  80890. /**
  80891. * An array of buffers. A buffer points to binary geometry, animation, or skins
  80892. */
  80893. buffers?: IBuffer[];
  80894. /**
  80895. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  80896. */
  80897. bufferViews?: IBufferView[];
  80898. /**
  80899. * An array of cameras
  80900. */
  80901. cameras?: ICamera[];
  80902. /**
  80903. * Names of glTF extensions used somewhere in this asset
  80904. */
  80905. extensionsUsed?: string[];
  80906. /**
  80907. * Names of glTF extensions required to properly load this asset
  80908. */
  80909. extensionsRequired?: string[];
  80910. /**
  80911. * An array of images. An image defines data used to create a texture
  80912. */
  80913. images?: IImage[];
  80914. /**
  80915. * An array of materials. A material defines the appearance of a primitive
  80916. */
  80917. materials?: IMaterial[];
  80918. /**
  80919. * An array of meshes. A mesh is a set of primitives to be rendered
  80920. */
  80921. meshes?: IMesh[];
  80922. /**
  80923. * An array of nodes
  80924. */
  80925. nodes?: INode[];
  80926. /**
  80927. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  80928. */
  80929. samplers?: ISampler[];
  80930. /**
  80931. * The index of the default scene
  80932. */
  80933. scene?: number;
  80934. /**
  80935. * An array of scenes
  80936. */
  80937. scenes?: IScene[];
  80938. /**
  80939. * An array of skins. A skin is defined by joints and matrices
  80940. */
  80941. skins?: ISkin[];
  80942. /**
  80943. * An array of textures
  80944. */
  80945. textures?: ITexture[];
  80946. }
  80947. /**
  80948. * The glTF validation results
  80949. * @ignore
  80950. */
  80951. interface IGLTFValidationResults {
  80952. info: {
  80953. generator: string;
  80954. hasAnimations: boolean;
  80955. hasDefaultScene: boolean;
  80956. hasMaterials: boolean;
  80957. hasMorphTargets: boolean;
  80958. hasSkins: boolean;
  80959. hasTextures: boolean;
  80960. maxAttributesUsed: number;
  80961. primitivesCount: number
  80962. };
  80963. issues: {
  80964. messages: Array<string>;
  80965. numErrors: number;
  80966. numHints: number;
  80967. numInfos: number;
  80968. numWarnings: number;
  80969. truncated: boolean
  80970. };
  80971. mimeType: string;
  80972. uri: string;
  80973. validatedAt: string;
  80974. validatorVersion: string;
  80975. }
  80976. /**
  80977. * The glTF validation options
  80978. */
  80979. interface IGLTFValidationOptions {
  80980. /** Uri to use */
  80981. uri?: string;
  80982. /** Function used to load external resources */
  80983. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  80984. /** Boolean indicating that we need to validate accessor data */
  80985. validateAccessorData?: boolean;
  80986. /** max number of issues allowed */
  80987. maxIssues?: number;
  80988. /** Ignored issues */
  80989. ignoredIssues?: Array<string>;
  80990. /** Value to override severy settings */
  80991. severityOverrides?: Object;
  80992. }
  80993. /**
  80994. * The glTF validator object
  80995. * @ignore
  80996. */
  80997. interface IGLTFValidator {
  80998. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  80999. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81000. }
  81001. }
  81002. declare module BABYLON {
  81003. /** @hidden */
  81004. export var cellPixelShader: {
  81005. name: string;
  81006. shader: string;
  81007. };
  81008. }
  81009. declare module BABYLON {
  81010. /** @hidden */
  81011. export var cellVertexShader: {
  81012. name: string;
  81013. shader: string;
  81014. };
  81015. }
  81016. declare module BABYLON {
  81017. export class CellMaterial extends BABYLON.PushMaterial {
  81018. private _diffuseTexture;
  81019. diffuseTexture: BABYLON.BaseTexture;
  81020. diffuseColor: BABYLON.Color3;
  81021. _computeHighLevel: boolean;
  81022. computeHighLevel: boolean;
  81023. private _disableLighting;
  81024. disableLighting: boolean;
  81025. private _maxSimultaneousLights;
  81026. maxSimultaneousLights: number;
  81027. constructor(name: string, scene: BABYLON.Scene);
  81028. needAlphaBlending(): boolean;
  81029. needAlphaTesting(): boolean;
  81030. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81031. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81032. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81033. getAnimatables(): BABYLON.IAnimatable[];
  81034. getActiveTextures(): BABYLON.BaseTexture[];
  81035. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81036. dispose(forceDisposeEffect?: boolean): void;
  81037. getClassName(): string;
  81038. clone(name: string): CellMaterial;
  81039. serialize(): any;
  81040. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  81041. }
  81042. }
  81043. declare module BABYLON {
  81044. export class CustomShaderStructure {
  81045. FragmentStore: string;
  81046. VertexStore: string;
  81047. constructor();
  81048. }
  81049. export class ShaderSpecialParts {
  81050. constructor();
  81051. Fragment_Begin: string;
  81052. Fragment_Definitions: string;
  81053. Fragment_MainBegin: string;
  81054. Fragment_Custom_Diffuse: string;
  81055. Fragment_Before_Lights: string;
  81056. Fragment_Before_Fog: string;
  81057. Fragment_Custom_Alpha: string;
  81058. Fragment_Before_FragColor: string;
  81059. Vertex_Begin: string;
  81060. Vertex_Definitions: string;
  81061. Vertex_MainBegin: string;
  81062. Vertex_Before_PositionUpdated: string;
  81063. Vertex_Before_NormalUpdated: string;
  81064. Vertex_After_WorldPosComputed: string;
  81065. Vertex_MainEnd: string;
  81066. }
  81067. export class CustomMaterial extends BABYLON.StandardMaterial {
  81068. static ShaderIndexer: number;
  81069. CustomParts: ShaderSpecialParts;
  81070. _isCreatedShader: boolean;
  81071. _createdShaderName: string;
  81072. _customUniform: string[];
  81073. _newUniforms: string[];
  81074. _newUniformInstances: {
  81075. [name: string]: any;
  81076. };
  81077. _newSamplerInstances: {
  81078. [name: string]: BABYLON.Texture;
  81079. };
  81080. _customAttributes: string[];
  81081. FragmentShader: string;
  81082. VertexShader: string;
  81083. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81084. ReviewUniform(name: string, arr: string[]): string[];
  81085. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81086. constructor(name: string, scene: BABYLON.Scene);
  81087. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  81088. AddAttribute(name: string): CustomMaterial;
  81089. Fragment_Begin(shaderPart: string): CustomMaterial;
  81090. Fragment_Definitions(shaderPart: string): CustomMaterial;
  81091. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  81092. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  81093. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  81094. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  81095. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  81096. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  81097. Vertex_Begin(shaderPart: string): CustomMaterial;
  81098. Vertex_Definitions(shaderPart: string): CustomMaterial;
  81099. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  81100. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  81101. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  81102. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  81103. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  81104. }
  81105. }
  81106. declare module BABYLON {
  81107. export class ShaderAlebdoParts {
  81108. constructor();
  81109. Fragment_Begin: string;
  81110. Fragment_Definitions: string;
  81111. Fragment_MainBegin: string;
  81112. Fragment_Custom_Albedo: string;
  81113. Fragment_Before_Lights: string;
  81114. Fragment_Custom_MetallicRoughness: string;
  81115. Fragment_Custom_MicroSurface: string;
  81116. Fragment_Before_Fog: string;
  81117. Fragment_Custom_Alpha: string;
  81118. Fragment_Before_FragColor: string;
  81119. Vertex_Begin: string;
  81120. Vertex_Definitions: string;
  81121. Vertex_MainBegin: string;
  81122. Vertex_Before_PositionUpdated: string;
  81123. Vertex_Before_NormalUpdated: string;
  81124. Vertex_After_WorldPosComputed: string;
  81125. Vertex_MainEnd: string;
  81126. }
  81127. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  81128. static ShaderIndexer: number;
  81129. CustomParts: ShaderAlebdoParts;
  81130. _isCreatedShader: boolean;
  81131. _createdShaderName: string;
  81132. _customUniform: string[];
  81133. _newUniforms: string[];
  81134. _newUniformInstances: {
  81135. [name: string]: any;
  81136. };
  81137. _newSamplerInstances: {
  81138. [name: string]: BABYLON.Texture;
  81139. };
  81140. _customAttributes: string[];
  81141. FragmentShader: string;
  81142. VertexShader: string;
  81143. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81144. ReviewUniform(name: string, arr: string[]): string[];
  81145. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81146. constructor(name: string, scene: BABYLON.Scene);
  81147. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  81148. AddAttribute(name: string): PBRCustomMaterial;
  81149. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  81150. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  81151. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  81152. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  81153. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  81154. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  81155. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  81156. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  81157. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  81158. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  81159. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  81160. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  81161. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  81162. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  81163. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  81164. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  81165. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  81166. }
  81167. }
  81168. declare module BABYLON {
  81169. /** @hidden */
  81170. export var firePixelShader: {
  81171. name: string;
  81172. shader: string;
  81173. };
  81174. }
  81175. declare module BABYLON {
  81176. /** @hidden */
  81177. export var fireVertexShader: {
  81178. name: string;
  81179. shader: string;
  81180. };
  81181. }
  81182. declare module BABYLON {
  81183. export class FireMaterial extends BABYLON.PushMaterial {
  81184. private _diffuseTexture;
  81185. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81186. private _distortionTexture;
  81187. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81188. private _opacityTexture;
  81189. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81190. diffuseColor: BABYLON.Color3;
  81191. speed: number;
  81192. private _scaledDiffuse;
  81193. private _lastTime;
  81194. constructor(name: string, scene: BABYLON.Scene);
  81195. needAlphaBlending(): boolean;
  81196. needAlphaTesting(): boolean;
  81197. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81198. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81199. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81200. getAnimatables(): BABYLON.IAnimatable[];
  81201. getActiveTextures(): BABYLON.BaseTexture[];
  81202. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81203. getClassName(): string;
  81204. dispose(forceDisposeEffect?: boolean): void;
  81205. clone(name: string): FireMaterial;
  81206. serialize(): any;
  81207. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  81208. }
  81209. }
  81210. declare module BABYLON {
  81211. /** @hidden */
  81212. export var furPixelShader: {
  81213. name: string;
  81214. shader: string;
  81215. };
  81216. }
  81217. declare module BABYLON {
  81218. /** @hidden */
  81219. export var furVertexShader: {
  81220. name: string;
  81221. shader: string;
  81222. };
  81223. }
  81224. declare module BABYLON {
  81225. export class FurMaterial extends BABYLON.PushMaterial {
  81226. private _diffuseTexture;
  81227. diffuseTexture: BABYLON.BaseTexture;
  81228. private _heightTexture;
  81229. heightTexture: BABYLON.BaseTexture;
  81230. diffuseColor: BABYLON.Color3;
  81231. furLength: number;
  81232. furAngle: number;
  81233. furColor: BABYLON.Color3;
  81234. furOffset: number;
  81235. furSpacing: number;
  81236. furGravity: BABYLON.Vector3;
  81237. furSpeed: number;
  81238. furDensity: number;
  81239. furOcclusion: number;
  81240. furTexture: BABYLON.DynamicTexture;
  81241. private _disableLighting;
  81242. disableLighting: boolean;
  81243. private _maxSimultaneousLights;
  81244. maxSimultaneousLights: number;
  81245. highLevelFur: boolean;
  81246. _meshes: BABYLON.AbstractMesh[];
  81247. private _furTime;
  81248. constructor(name: string, scene: BABYLON.Scene);
  81249. get furTime(): number;
  81250. set furTime(furTime: number);
  81251. needAlphaBlending(): boolean;
  81252. needAlphaTesting(): boolean;
  81253. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81254. updateFur(): void;
  81255. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81256. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81257. getAnimatables(): BABYLON.IAnimatable[];
  81258. getActiveTextures(): BABYLON.BaseTexture[];
  81259. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81260. dispose(forceDisposeEffect?: boolean): void;
  81261. clone(name: string): FurMaterial;
  81262. serialize(): any;
  81263. getClassName(): string;
  81264. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  81265. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  81266. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  81267. }
  81268. }
  81269. declare module BABYLON {
  81270. /** @hidden */
  81271. export var gradientPixelShader: {
  81272. name: string;
  81273. shader: string;
  81274. };
  81275. }
  81276. declare module BABYLON {
  81277. /** @hidden */
  81278. export var gradientVertexShader: {
  81279. name: string;
  81280. shader: string;
  81281. };
  81282. }
  81283. declare module BABYLON {
  81284. export class GradientMaterial extends BABYLON.PushMaterial {
  81285. private _maxSimultaneousLights;
  81286. maxSimultaneousLights: number;
  81287. topColor: BABYLON.Color3;
  81288. topColorAlpha: number;
  81289. bottomColor: BABYLON.Color3;
  81290. bottomColorAlpha: number;
  81291. offset: number;
  81292. scale: number;
  81293. smoothness: number;
  81294. private _disableLighting;
  81295. disableLighting: boolean;
  81296. constructor(name: string, scene: BABYLON.Scene);
  81297. needAlphaBlending(): boolean;
  81298. needAlphaTesting(): boolean;
  81299. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81300. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81301. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81302. getAnimatables(): BABYLON.IAnimatable[];
  81303. dispose(forceDisposeEffect?: boolean): void;
  81304. clone(name: string): GradientMaterial;
  81305. serialize(): any;
  81306. getClassName(): string;
  81307. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  81308. }
  81309. }
  81310. declare module BABYLON {
  81311. /** @hidden */
  81312. export var gridPixelShader: {
  81313. name: string;
  81314. shader: string;
  81315. };
  81316. }
  81317. declare module BABYLON {
  81318. /** @hidden */
  81319. export var gridVertexShader: {
  81320. name: string;
  81321. shader: string;
  81322. };
  81323. }
  81324. declare module BABYLON {
  81325. /**
  81326. * The grid materials allows you to wrap any shape with a grid.
  81327. * Colors are customizable.
  81328. */
  81329. export class GridMaterial extends BABYLON.PushMaterial {
  81330. /**
  81331. * Main color of the grid (e.g. between lines)
  81332. */
  81333. mainColor: BABYLON.Color3;
  81334. /**
  81335. * Color of the grid lines.
  81336. */
  81337. lineColor: BABYLON.Color3;
  81338. /**
  81339. * The scale of the grid compared to unit.
  81340. */
  81341. gridRatio: number;
  81342. /**
  81343. * Allows setting an offset for the grid lines.
  81344. */
  81345. gridOffset: BABYLON.Vector3;
  81346. /**
  81347. * The frequency of thicker lines.
  81348. */
  81349. majorUnitFrequency: number;
  81350. /**
  81351. * The visibility of minor units in the grid.
  81352. */
  81353. minorUnitVisibility: number;
  81354. /**
  81355. * The grid opacity outside of the lines.
  81356. */
  81357. opacity: number;
  81358. /**
  81359. * Determine RBG output is premultiplied by alpha value.
  81360. */
  81361. preMultiplyAlpha: boolean;
  81362. private _opacityTexture;
  81363. opacityTexture: BABYLON.BaseTexture;
  81364. private _gridControl;
  81365. /**
  81366. * constructor
  81367. * @param name The name given to the material in order to identify it afterwards.
  81368. * @param scene The scene the material is used in.
  81369. */
  81370. constructor(name: string, scene: BABYLON.Scene);
  81371. /**
  81372. * Returns wehter or not the grid requires alpha blending.
  81373. */
  81374. needAlphaBlending(): boolean;
  81375. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81376. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81377. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81378. /**
  81379. * Dispose the material and its associated resources.
  81380. * @param forceDisposeEffect will also dispose the used effect when true
  81381. */
  81382. dispose(forceDisposeEffect?: boolean): void;
  81383. clone(name: string): GridMaterial;
  81384. serialize(): any;
  81385. getClassName(): string;
  81386. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  81387. }
  81388. }
  81389. declare module BABYLON {
  81390. /** @hidden */
  81391. export var lavaPixelShader: {
  81392. name: string;
  81393. shader: string;
  81394. };
  81395. }
  81396. declare module BABYLON {
  81397. /** @hidden */
  81398. export var lavaVertexShader: {
  81399. name: string;
  81400. shader: string;
  81401. };
  81402. }
  81403. declare module BABYLON {
  81404. export class LavaMaterial extends BABYLON.PushMaterial {
  81405. private _diffuseTexture;
  81406. diffuseTexture: BABYLON.BaseTexture;
  81407. noiseTexture: BABYLON.BaseTexture;
  81408. fogColor: BABYLON.Color3;
  81409. speed: number;
  81410. movingSpeed: number;
  81411. lowFrequencySpeed: number;
  81412. fogDensity: number;
  81413. private _lastTime;
  81414. diffuseColor: BABYLON.Color3;
  81415. private _disableLighting;
  81416. disableLighting: boolean;
  81417. private _unlit;
  81418. unlit: boolean;
  81419. private _maxSimultaneousLights;
  81420. maxSimultaneousLights: number;
  81421. private _scaledDiffuse;
  81422. constructor(name: string, scene: BABYLON.Scene);
  81423. needAlphaBlending(): boolean;
  81424. needAlphaTesting(): boolean;
  81425. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81426. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81427. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81428. getAnimatables(): BABYLON.IAnimatable[];
  81429. getActiveTextures(): BABYLON.BaseTexture[];
  81430. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81431. dispose(forceDisposeEffect?: boolean): void;
  81432. clone(name: string): LavaMaterial;
  81433. serialize(): any;
  81434. getClassName(): string;
  81435. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  81436. }
  81437. }
  81438. declare module BABYLON {
  81439. /** @hidden */
  81440. export var mixPixelShader: {
  81441. name: string;
  81442. shader: string;
  81443. };
  81444. }
  81445. declare module BABYLON {
  81446. /** @hidden */
  81447. export var mixVertexShader: {
  81448. name: string;
  81449. shader: string;
  81450. };
  81451. }
  81452. declare module BABYLON {
  81453. export class MixMaterial extends BABYLON.PushMaterial {
  81454. /**
  81455. * Mix textures
  81456. */
  81457. private _mixTexture1;
  81458. mixTexture1: BABYLON.BaseTexture;
  81459. private _mixTexture2;
  81460. mixTexture2: BABYLON.BaseTexture;
  81461. /**
  81462. * Diffuse textures
  81463. */
  81464. private _diffuseTexture1;
  81465. diffuseTexture1: BABYLON.Texture;
  81466. private _diffuseTexture2;
  81467. diffuseTexture2: BABYLON.Texture;
  81468. private _diffuseTexture3;
  81469. diffuseTexture3: BABYLON.Texture;
  81470. private _diffuseTexture4;
  81471. diffuseTexture4: BABYLON.Texture;
  81472. private _diffuseTexture5;
  81473. diffuseTexture5: BABYLON.Texture;
  81474. private _diffuseTexture6;
  81475. diffuseTexture6: BABYLON.Texture;
  81476. private _diffuseTexture7;
  81477. diffuseTexture7: BABYLON.Texture;
  81478. private _diffuseTexture8;
  81479. diffuseTexture8: BABYLON.Texture;
  81480. /**
  81481. * Uniforms
  81482. */
  81483. diffuseColor: BABYLON.Color3;
  81484. specularColor: BABYLON.Color3;
  81485. specularPower: number;
  81486. private _disableLighting;
  81487. disableLighting: boolean;
  81488. private _maxSimultaneousLights;
  81489. maxSimultaneousLights: number;
  81490. constructor(name: string, scene: BABYLON.Scene);
  81491. needAlphaBlending(): boolean;
  81492. needAlphaTesting(): boolean;
  81493. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81494. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81495. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81496. getAnimatables(): BABYLON.IAnimatable[];
  81497. getActiveTextures(): BABYLON.BaseTexture[];
  81498. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81499. dispose(forceDisposeEffect?: boolean): void;
  81500. clone(name: string): MixMaterial;
  81501. serialize(): any;
  81502. getClassName(): string;
  81503. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  81504. }
  81505. }
  81506. declare module BABYLON {
  81507. /** @hidden */
  81508. export var normalPixelShader: {
  81509. name: string;
  81510. shader: string;
  81511. };
  81512. }
  81513. declare module BABYLON {
  81514. /** @hidden */
  81515. export var normalVertexShader: {
  81516. name: string;
  81517. shader: string;
  81518. };
  81519. }
  81520. declare module BABYLON {
  81521. export class NormalMaterial extends BABYLON.PushMaterial {
  81522. private _diffuseTexture;
  81523. diffuseTexture: BABYLON.BaseTexture;
  81524. diffuseColor: BABYLON.Color3;
  81525. private _disableLighting;
  81526. disableLighting: boolean;
  81527. private _maxSimultaneousLights;
  81528. maxSimultaneousLights: number;
  81529. constructor(name: string, scene: BABYLON.Scene);
  81530. needAlphaBlending(): boolean;
  81531. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81532. needAlphaTesting(): boolean;
  81533. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81536. getAnimatables(): BABYLON.IAnimatable[];
  81537. getActiveTextures(): BABYLON.BaseTexture[];
  81538. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81539. dispose(forceDisposeEffect?: boolean): void;
  81540. clone(name: string): NormalMaterial;
  81541. serialize(): any;
  81542. getClassName(): string;
  81543. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  81544. }
  81545. }
  81546. declare module BABYLON {
  81547. /** @hidden */
  81548. export var shadowOnlyPixelShader: {
  81549. name: string;
  81550. shader: string;
  81551. };
  81552. }
  81553. declare module BABYLON {
  81554. /** @hidden */
  81555. export var shadowOnlyVertexShader: {
  81556. name: string;
  81557. shader: string;
  81558. };
  81559. }
  81560. declare module BABYLON {
  81561. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  81562. private _activeLight;
  81563. constructor(name: string, scene: BABYLON.Scene);
  81564. shadowColor: BABYLON.Color3;
  81565. needAlphaBlending(): boolean;
  81566. needAlphaTesting(): boolean;
  81567. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81568. get activeLight(): BABYLON.IShadowLight;
  81569. set activeLight(light: BABYLON.IShadowLight);
  81570. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81571. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81572. clone(name: string): ShadowOnlyMaterial;
  81573. serialize(): any;
  81574. getClassName(): string;
  81575. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  81576. }
  81577. }
  81578. declare module BABYLON {
  81579. /** @hidden */
  81580. export var simplePixelShader: {
  81581. name: string;
  81582. shader: string;
  81583. };
  81584. }
  81585. declare module BABYLON {
  81586. /** @hidden */
  81587. export var simpleVertexShader: {
  81588. name: string;
  81589. shader: string;
  81590. };
  81591. }
  81592. declare module BABYLON {
  81593. export class SimpleMaterial extends BABYLON.PushMaterial {
  81594. private _diffuseTexture;
  81595. diffuseTexture: BABYLON.BaseTexture;
  81596. diffuseColor: BABYLON.Color3;
  81597. private _disableLighting;
  81598. disableLighting: boolean;
  81599. private _maxSimultaneousLights;
  81600. maxSimultaneousLights: number;
  81601. constructor(name: string, scene: BABYLON.Scene);
  81602. needAlphaBlending(): boolean;
  81603. needAlphaTesting(): boolean;
  81604. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81605. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81606. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81607. getAnimatables(): BABYLON.IAnimatable[];
  81608. getActiveTextures(): BABYLON.BaseTexture[];
  81609. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81610. dispose(forceDisposeEffect?: boolean): void;
  81611. clone(name: string): SimpleMaterial;
  81612. serialize(): any;
  81613. getClassName(): string;
  81614. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  81615. }
  81616. }
  81617. declare module BABYLON {
  81618. /** @hidden */
  81619. export var skyPixelShader: {
  81620. name: string;
  81621. shader: string;
  81622. };
  81623. }
  81624. declare module BABYLON {
  81625. /** @hidden */
  81626. export var skyVertexShader: {
  81627. name: string;
  81628. shader: string;
  81629. };
  81630. }
  81631. declare module BABYLON {
  81632. /**
  81633. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  81634. * @see https://doc.babylonjs.com/extensions/sky
  81635. */
  81636. export class SkyMaterial extends BABYLON.PushMaterial {
  81637. /**
  81638. * Defines the overall luminance of sky in interval ]0, 1[.
  81639. */
  81640. luminance: number;
  81641. /**
  81642. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  81643. */
  81644. turbidity: number;
  81645. /**
  81646. * Defines the sky appearance (light intensity).
  81647. */
  81648. rayleigh: number;
  81649. /**
  81650. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  81651. */
  81652. mieCoefficient: number;
  81653. /**
  81654. * Defines the amount of haze particles following the Mie scattering theory.
  81655. */
  81656. mieDirectionalG: number;
  81657. /**
  81658. * Defines the distance of the sun according to the active scene camera.
  81659. */
  81660. distance: number;
  81661. /**
  81662. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  81663. * "inclined".
  81664. */
  81665. inclination: number;
  81666. /**
  81667. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  81668. * an object direction and a reference direction.
  81669. */
  81670. azimuth: number;
  81671. /**
  81672. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  81673. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  81674. */
  81675. sunPosition: BABYLON.Vector3;
  81676. /**
  81677. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  81678. * .sunPosition property.
  81679. */
  81680. useSunPosition: boolean;
  81681. /**
  81682. * Defines an offset vector used to get a horizon offset.
  81683. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  81684. */
  81685. cameraOffset: BABYLON.Vector3;
  81686. private _cameraPosition;
  81687. /**
  81688. * Instantiates a new sky material.
  81689. * This material allows to create dynamic and texture free
  81690. * effects for skyboxes by taking care of the atmosphere state.
  81691. * @see https://doc.babylonjs.com/extensions/sky
  81692. * @param name Define the name of the material in the scene
  81693. * @param scene Define the scene the material belong to
  81694. */
  81695. constructor(name: string, scene: BABYLON.Scene);
  81696. /**
  81697. * Specifies if the material will require alpha blending
  81698. * @returns a boolean specifying if alpha blending is needed
  81699. */
  81700. needAlphaBlending(): boolean;
  81701. /**
  81702. * Specifies if this material should be rendered in alpha test mode
  81703. * @returns false as the sky material doesn't need alpha testing.
  81704. */
  81705. needAlphaTesting(): boolean;
  81706. /**
  81707. * Get the texture used for alpha test purpose.
  81708. * @returns null as the sky material has no texture.
  81709. */
  81710. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81711. /**
  81712. * Get if the submesh is ready to be used and all its information available.
  81713. * Child classes can use it to update shaders
  81714. * @param mesh defines the mesh to check
  81715. * @param subMesh defines which submesh to check
  81716. * @param useInstances specifies that instances should be used
  81717. * @returns a boolean indicating that the submesh is ready or not
  81718. */
  81719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81720. /**
  81721. * Binds the submesh to this material by preparing the effect and shader to draw
  81722. * @param world defines the world transformation matrix
  81723. * @param mesh defines the mesh containing the submesh
  81724. * @param subMesh defines the submesh to bind the material to
  81725. */
  81726. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81727. /**
  81728. * Get the list of animatables in the material.
  81729. * @returns the list of animatables object used in the material
  81730. */
  81731. getAnimatables(): BABYLON.IAnimatable[];
  81732. /**
  81733. * Disposes the material
  81734. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81735. */
  81736. dispose(forceDisposeEffect?: boolean): void;
  81737. /**
  81738. * Makes a duplicate of the material, and gives it a new name
  81739. * @param name defines the new name for the duplicated material
  81740. * @returns the cloned material
  81741. */
  81742. clone(name: string): SkyMaterial;
  81743. /**
  81744. * Serializes this material in a JSON representation
  81745. * @returns the serialized material object
  81746. */
  81747. serialize(): any;
  81748. /**
  81749. * Gets the current class name of the material e.g. "SkyMaterial"
  81750. * Mainly use in serialization.
  81751. * @returns the class name
  81752. */
  81753. getClassName(): string;
  81754. /**
  81755. * Creates a sky material from parsed material data
  81756. * @param source defines the JSON representation of the material
  81757. * @param scene defines the hosting scene
  81758. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  81759. * @returns a new sky material
  81760. */
  81761. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  81762. }
  81763. }
  81764. declare module BABYLON {
  81765. /** @hidden */
  81766. export var terrainPixelShader: {
  81767. name: string;
  81768. shader: string;
  81769. };
  81770. }
  81771. declare module BABYLON {
  81772. /** @hidden */
  81773. export var terrainVertexShader: {
  81774. name: string;
  81775. shader: string;
  81776. };
  81777. }
  81778. declare module BABYLON {
  81779. export class TerrainMaterial extends BABYLON.PushMaterial {
  81780. private _mixTexture;
  81781. mixTexture: BABYLON.BaseTexture;
  81782. private _diffuseTexture1;
  81783. diffuseTexture1: BABYLON.Texture;
  81784. private _diffuseTexture2;
  81785. diffuseTexture2: BABYLON.Texture;
  81786. private _diffuseTexture3;
  81787. diffuseTexture3: BABYLON.Texture;
  81788. private _bumpTexture1;
  81789. bumpTexture1: BABYLON.Texture;
  81790. private _bumpTexture2;
  81791. bumpTexture2: BABYLON.Texture;
  81792. private _bumpTexture3;
  81793. bumpTexture3: BABYLON.Texture;
  81794. diffuseColor: BABYLON.Color3;
  81795. specularColor: BABYLON.Color3;
  81796. specularPower: number;
  81797. private _disableLighting;
  81798. disableLighting: boolean;
  81799. private _maxSimultaneousLights;
  81800. maxSimultaneousLights: number;
  81801. constructor(name: string, scene: BABYLON.Scene);
  81802. needAlphaBlending(): boolean;
  81803. needAlphaTesting(): boolean;
  81804. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81807. getAnimatables(): BABYLON.IAnimatable[];
  81808. getActiveTextures(): BABYLON.BaseTexture[];
  81809. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81810. dispose(forceDisposeEffect?: boolean): void;
  81811. clone(name: string): TerrainMaterial;
  81812. serialize(): any;
  81813. getClassName(): string;
  81814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  81815. }
  81816. }
  81817. declare module BABYLON {
  81818. /** @hidden */
  81819. export var triplanarPixelShader: {
  81820. name: string;
  81821. shader: string;
  81822. };
  81823. }
  81824. declare module BABYLON {
  81825. /** @hidden */
  81826. export var triplanarVertexShader: {
  81827. name: string;
  81828. shader: string;
  81829. };
  81830. }
  81831. declare module BABYLON {
  81832. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  81833. mixTexture: BABYLON.BaseTexture;
  81834. private _diffuseTextureX;
  81835. diffuseTextureX: BABYLON.BaseTexture;
  81836. private _diffuseTextureY;
  81837. diffuseTextureY: BABYLON.BaseTexture;
  81838. private _diffuseTextureZ;
  81839. diffuseTextureZ: BABYLON.BaseTexture;
  81840. private _normalTextureX;
  81841. normalTextureX: BABYLON.BaseTexture;
  81842. private _normalTextureY;
  81843. normalTextureY: BABYLON.BaseTexture;
  81844. private _normalTextureZ;
  81845. normalTextureZ: BABYLON.BaseTexture;
  81846. tileSize: number;
  81847. diffuseColor: BABYLON.Color3;
  81848. specularColor: BABYLON.Color3;
  81849. specularPower: number;
  81850. private _disableLighting;
  81851. disableLighting: boolean;
  81852. private _maxSimultaneousLights;
  81853. maxSimultaneousLights: number;
  81854. constructor(name: string, scene: BABYLON.Scene);
  81855. needAlphaBlending(): boolean;
  81856. needAlphaTesting(): boolean;
  81857. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81858. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81859. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81860. getAnimatables(): BABYLON.IAnimatable[];
  81861. getActiveTextures(): BABYLON.BaseTexture[];
  81862. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81863. dispose(forceDisposeEffect?: boolean): void;
  81864. clone(name: string): TriPlanarMaterial;
  81865. serialize(): any;
  81866. getClassName(): string;
  81867. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  81868. }
  81869. }
  81870. declare module BABYLON {
  81871. /** @hidden */
  81872. export var waterPixelShader: {
  81873. name: string;
  81874. shader: string;
  81875. };
  81876. }
  81877. declare module BABYLON {
  81878. /** @hidden */
  81879. export var waterVertexShader: {
  81880. name: string;
  81881. shader: string;
  81882. };
  81883. }
  81884. declare module BABYLON {
  81885. export class WaterMaterial extends BABYLON.PushMaterial {
  81886. renderTargetSize: BABYLON.Vector2;
  81887. private _bumpTexture;
  81888. bumpTexture: BABYLON.BaseTexture;
  81889. diffuseColor: BABYLON.Color3;
  81890. specularColor: BABYLON.Color3;
  81891. specularPower: number;
  81892. private _disableLighting;
  81893. disableLighting: boolean;
  81894. private _maxSimultaneousLights;
  81895. maxSimultaneousLights: number;
  81896. /**
  81897. * @param {number}: Represents the wind force
  81898. */
  81899. windForce: number;
  81900. /**
  81901. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  81902. */
  81903. windDirection: BABYLON.Vector2;
  81904. /**
  81905. * @param {number}: Wave height, represents the height of the waves
  81906. */
  81907. waveHeight: number;
  81908. /**
  81909. * @param {number}: Bump height, represents the bump height related to the bump map
  81910. */
  81911. bumpHeight: number;
  81912. /**
  81913. * @param {boolean}: Add a smaller moving bump to less steady waves.
  81914. */
  81915. private _bumpSuperimpose;
  81916. bumpSuperimpose: boolean;
  81917. /**
  81918. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  81919. */
  81920. private _fresnelSeparate;
  81921. fresnelSeparate: boolean;
  81922. /**
  81923. * @param {boolean}: bump Waves modify the reflection.
  81924. */
  81925. private _bumpAffectsReflection;
  81926. bumpAffectsReflection: boolean;
  81927. /**
  81928. * @param {number}: The water color blended with the refraction (near)
  81929. */
  81930. waterColor: BABYLON.Color3;
  81931. /**
  81932. * @param {number}: The blend factor related to the water color
  81933. */
  81934. colorBlendFactor: number;
  81935. /**
  81936. * @param {number}: The water color blended with the reflection (far)
  81937. */
  81938. waterColor2: BABYLON.Color3;
  81939. /**
  81940. * @param {number}: The blend factor related to the water color (reflection, far)
  81941. */
  81942. colorBlendFactor2: number;
  81943. /**
  81944. * @param {number}: Represents the maximum length of a wave
  81945. */
  81946. waveLength: number;
  81947. /**
  81948. * @param {number}: Defines the waves speed
  81949. */
  81950. waveSpeed: number;
  81951. /**
  81952. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  81953. * will avoid calculating useless pixels in the pixel shader of the water material.
  81954. */
  81955. disableClipPlane: boolean;
  81956. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  81957. private _mesh;
  81958. private _refractionRTT;
  81959. private _reflectionRTT;
  81960. private _reflectionTransform;
  81961. private _lastTime;
  81962. private _lastDeltaTime;
  81963. private _useLogarithmicDepth;
  81964. private _waitingRenderList;
  81965. private _imageProcessingConfiguration;
  81966. private _imageProcessingObserver;
  81967. /**
  81968. * Gets a boolean indicating that current material needs to register RTT
  81969. */
  81970. get hasRenderTargetTextures(): boolean;
  81971. /**
  81972. * Constructor
  81973. */
  81974. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  81975. get useLogarithmicDepth(): boolean;
  81976. set useLogarithmicDepth(value: boolean);
  81977. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  81978. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  81979. addToRenderList(node: any): void;
  81980. enableRenderTargets(enable: boolean): void;
  81981. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  81982. get renderTargetsEnabled(): boolean;
  81983. needAlphaBlending(): boolean;
  81984. needAlphaTesting(): boolean;
  81985. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81986. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81987. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81988. private _createRenderTargets;
  81989. getAnimatables(): BABYLON.IAnimatable[];
  81990. getActiveTextures(): BABYLON.BaseTexture[];
  81991. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81992. dispose(forceDisposeEffect?: boolean): void;
  81993. clone(name: string): WaterMaterial;
  81994. serialize(): any;
  81995. getClassName(): string;
  81996. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  81997. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  81998. }
  81999. }
  82000. declare module BABYLON {
  82001. /** @hidden */
  82002. export var asciiartPixelShader: {
  82003. name: string;
  82004. shader: string;
  82005. };
  82006. }
  82007. declare module BABYLON {
  82008. /**
  82009. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  82010. *
  82011. * It basically takes care rendering the font front the given font size to a texture.
  82012. * This is used later on in the postprocess.
  82013. */
  82014. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  82015. private _font;
  82016. private _text;
  82017. private _charSize;
  82018. /**
  82019. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82020. */
  82021. get charSize(): number;
  82022. /**
  82023. * Create a new instance of the Ascii Art FontTexture class
  82024. * @param name the name of the texture
  82025. * @param font the font to use, use the W3C CSS notation
  82026. * @param text the caracter set to use in the rendering.
  82027. * @param scene the scene that owns the texture
  82028. */
  82029. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82030. /**
  82031. * Gets the max char width of a font.
  82032. * @param font the font to use, use the W3C CSS notation
  82033. * @return the max char width
  82034. */
  82035. private getFontWidth;
  82036. /**
  82037. * Gets the max char height of a font.
  82038. * @param font the font to use, use the W3C CSS notation
  82039. * @return the max char height
  82040. */
  82041. private getFontHeight;
  82042. /**
  82043. * Clones the current AsciiArtTexture.
  82044. * @return the clone of the texture.
  82045. */
  82046. clone(): AsciiArtFontTexture;
  82047. /**
  82048. * Parses a json object representing the texture and returns an instance of it.
  82049. * @param source the source JSON representation
  82050. * @param scene the scene to create the texture for
  82051. * @return the parsed texture
  82052. */
  82053. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  82054. }
  82055. /**
  82056. * Option available in the Ascii Art Post Process.
  82057. */
  82058. export interface IAsciiArtPostProcessOptions {
  82059. /**
  82060. * The font to use following the w3c font definition.
  82061. */
  82062. font?: string;
  82063. /**
  82064. * The character set to use in the postprocess.
  82065. */
  82066. characterSet?: string;
  82067. /**
  82068. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82069. * This number is defined between 0 and 1;
  82070. */
  82071. mixToTile?: number;
  82072. /**
  82073. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82074. * This number is defined between 0 and 1;
  82075. */
  82076. mixToNormal?: number;
  82077. }
  82078. /**
  82079. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  82080. *
  82081. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82082. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  82083. */
  82084. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  82085. /**
  82086. * The font texture used to render the char in the post process.
  82087. */
  82088. private _asciiArtFontTexture;
  82089. /**
  82090. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82091. * This number is defined between 0 and 1;
  82092. */
  82093. mixToTile: number;
  82094. /**
  82095. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82096. * This number is defined between 0 and 1;
  82097. */
  82098. mixToNormal: number;
  82099. /**
  82100. * Instantiates a new Ascii Art Post Process.
  82101. * @param name the name to give to the postprocess
  82102. * @camera the camera to apply the post process to.
  82103. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  82104. */
  82105. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  82106. }
  82107. }
  82108. declare module BABYLON {
  82109. /** @hidden */
  82110. export var digitalrainPixelShader: {
  82111. name: string;
  82112. shader: string;
  82113. };
  82114. }
  82115. declare module BABYLON {
  82116. /**
  82117. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  82118. *
  82119. * It basically takes care rendering the font front the given font size to a texture.
  82120. * This is used later on in the postprocess.
  82121. */
  82122. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  82123. private _font;
  82124. private _text;
  82125. private _charSize;
  82126. /**
  82127. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82128. */
  82129. get charSize(): number;
  82130. /**
  82131. * Create a new instance of the Digital Rain FontTexture class
  82132. * @param name the name of the texture
  82133. * @param font the font to use, use the W3C CSS notation
  82134. * @param text the caracter set to use in the rendering.
  82135. * @param scene the scene that owns the texture
  82136. */
  82137. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82138. /**
  82139. * Gets the max char width of a font.
  82140. * @param font the font to use, use the W3C CSS notation
  82141. * @return the max char width
  82142. */
  82143. private getFontWidth;
  82144. /**
  82145. * Gets the max char height of a font.
  82146. * @param font the font to use, use the W3C CSS notation
  82147. * @return the max char height
  82148. */
  82149. private getFontHeight;
  82150. /**
  82151. * Clones the current DigitalRainFontTexture.
  82152. * @return the clone of the texture.
  82153. */
  82154. clone(): DigitalRainFontTexture;
  82155. /**
  82156. * Parses a json object representing the texture and returns an instance of it.
  82157. * @param source the source JSON representation
  82158. * @param scene the scene to create the texture for
  82159. * @return the parsed texture
  82160. */
  82161. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  82162. }
  82163. /**
  82164. * Option available in the Digital Rain Post Process.
  82165. */
  82166. export interface IDigitalRainPostProcessOptions {
  82167. /**
  82168. * The font to use following the w3c font definition.
  82169. */
  82170. font?: string;
  82171. /**
  82172. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82173. * This number is defined between 0 and 1;
  82174. */
  82175. mixToTile?: number;
  82176. /**
  82177. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82178. * This number is defined between 0 and 1;
  82179. */
  82180. mixToNormal?: number;
  82181. }
  82182. /**
  82183. * DigitalRainPostProcess helps rendering everithing in digital rain.
  82184. *
  82185. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82186. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  82187. */
  82188. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  82189. /**
  82190. * The font texture used to render the char in the post process.
  82191. */
  82192. private _digitalRainFontTexture;
  82193. /**
  82194. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82195. * This number is defined between 0 and 1;
  82196. */
  82197. mixToTile: number;
  82198. /**
  82199. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82200. * This number is defined between 0 and 1;
  82201. */
  82202. mixToNormal: number;
  82203. /**
  82204. * Instantiates a new Digital Rain Post Process.
  82205. * @param name the name to give to the postprocess
  82206. * @camera the camera to apply the post process to.
  82207. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  82208. */
  82209. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  82210. }
  82211. }
  82212. declare module BABYLON {
  82213. /** @hidden */
  82214. export var brickProceduralTexturePixelShader: {
  82215. name: string;
  82216. shader: string;
  82217. };
  82218. }
  82219. declare module BABYLON {
  82220. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  82221. private _numberOfBricksHeight;
  82222. private _numberOfBricksWidth;
  82223. private _jointColor;
  82224. private _brickColor;
  82225. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82226. updateShaderUniforms(): void;
  82227. get numberOfBricksHeight(): number;
  82228. set numberOfBricksHeight(value: number);
  82229. get numberOfBricksWidth(): number;
  82230. set numberOfBricksWidth(value: number);
  82231. get jointColor(): BABYLON.Color3;
  82232. set jointColor(value: BABYLON.Color3);
  82233. get brickColor(): BABYLON.Color3;
  82234. set brickColor(value: BABYLON.Color3);
  82235. /**
  82236. * Serializes this brick procedural texture
  82237. * @returns a serialized brick procedural texture object
  82238. */
  82239. serialize(): any;
  82240. /**
  82241. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  82242. * @param parsedTexture defines parsed texture data
  82243. * @param scene defines the current scene
  82244. * @param rootUrl defines the root URL containing brick procedural texture information
  82245. * @returns a parsed Brick Procedural BABYLON.Texture
  82246. */
  82247. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  82248. }
  82249. }
  82250. declare module BABYLON {
  82251. /** @hidden */
  82252. export var cloudProceduralTexturePixelShader: {
  82253. name: string;
  82254. shader: string;
  82255. };
  82256. }
  82257. declare module BABYLON {
  82258. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  82259. private _skyColor;
  82260. private _cloudColor;
  82261. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82262. updateShaderUniforms(): void;
  82263. get skyColor(): BABYLON.Color4;
  82264. set skyColor(value: BABYLON.Color4);
  82265. get cloudColor(): BABYLON.Color4;
  82266. set cloudColor(value: BABYLON.Color4);
  82267. /**
  82268. * Serializes this cloud procedural texture
  82269. * @returns a serialized cloud procedural texture object
  82270. */
  82271. serialize(): any;
  82272. /**
  82273. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  82274. * @param parsedTexture defines parsed texture data
  82275. * @param scene defines the current scene
  82276. * @param rootUrl defines the root URL containing cloud procedural texture information
  82277. * @returns a parsed Cloud Procedural BABYLON.Texture
  82278. */
  82279. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  82280. }
  82281. }
  82282. declare module BABYLON {
  82283. /** @hidden */
  82284. export var fireProceduralTexturePixelShader: {
  82285. name: string;
  82286. shader: string;
  82287. };
  82288. }
  82289. declare module BABYLON {
  82290. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  82291. private _time;
  82292. private _speed;
  82293. private _autoGenerateTime;
  82294. private _fireColors;
  82295. private _alphaThreshold;
  82296. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82297. updateShaderUniforms(): void;
  82298. render(useCameraPostProcess?: boolean): void;
  82299. static get PurpleFireColors(): BABYLON.Color3[];
  82300. static get GreenFireColors(): BABYLON.Color3[];
  82301. static get RedFireColors(): BABYLON.Color3[];
  82302. static get BlueFireColors(): BABYLON.Color3[];
  82303. get autoGenerateTime(): boolean;
  82304. set autoGenerateTime(value: boolean);
  82305. get fireColors(): BABYLON.Color3[];
  82306. set fireColors(value: BABYLON.Color3[]);
  82307. get time(): number;
  82308. set time(value: number);
  82309. get speed(): BABYLON.Vector2;
  82310. set speed(value: BABYLON.Vector2);
  82311. get alphaThreshold(): number;
  82312. set alphaThreshold(value: number);
  82313. /**
  82314. * Serializes this fire procedural texture
  82315. * @returns a serialized fire procedural texture object
  82316. */
  82317. serialize(): any;
  82318. /**
  82319. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  82320. * @param parsedTexture defines parsed texture data
  82321. * @param scene defines the current scene
  82322. * @param rootUrl defines the root URL containing fire procedural texture information
  82323. * @returns a parsed Fire Procedural BABYLON.Texture
  82324. */
  82325. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  82326. }
  82327. }
  82328. declare module BABYLON {
  82329. /** @hidden */
  82330. export var grassProceduralTexturePixelShader: {
  82331. name: string;
  82332. shader: string;
  82333. };
  82334. }
  82335. declare module BABYLON {
  82336. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  82337. private _grassColors;
  82338. private _groundColor;
  82339. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82340. updateShaderUniforms(): void;
  82341. get grassColors(): BABYLON.Color3[];
  82342. set grassColors(value: BABYLON.Color3[]);
  82343. get groundColor(): BABYLON.Color3;
  82344. set groundColor(value: BABYLON.Color3);
  82345. /**
  82346. * Serializes this grass procedural texture
  82347. * @returns a serialized grass procedural texture object
  82348. */
  82349. serialize(): any;
  82350. /**
  82351. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  82352. * @param parsedTexture defines parsed texture data
  82353. * @param scene defines the current scene
  82354. * @param rootUrl defines the root URL containing grass procedural texture information
  82355. * @returns a parsed Grass Procedural BABYLON.Texture
  82356. */
  82357. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  82358. }
  82359. }
  82360. declare module BABYLON {
  82361. /** @hidden */
  82362. export var marbleProceduralTexturePixelShader: {
  82363. name: string;
  82364. shader: string;
  82365. };
  82366. }
  82367. declare module BABYLON {
  82368. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  82369. private _numberOfTilesHeight;
  82370. private _numberOfTilesWidth;
  82371. private _amplitude;
  82372. private _jointColor;
  82373. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82374. updateShaderUniforms(): void;
  82375. get numberOfTilesHeight(): number;
  82376. set numberOfTilesHeight(value: number);
  82377. get amplitude(): number;
  82378. set amplitude(value: number);
  82379. get numberOfTilesWidth(): number;
  82380. set numberOfTilesWidth(value: number);
  82381. get jointColor(): BABYLON.Color3;
  82382. set jointColor(value: BABYLON.Color3);
  82383. /**
  82384. * Serializes this marble procedural texture
  82385. * @returns a serialized marble procedural texture object
  82386. */
  82387. serialize(): any;
  82388. /**
  82389. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  82390. * @param parsedTexture defines parsed texture data
  82391. * @param scene defines the current scene
  82392. * @param rootUrl defines the root URL containing marble procedural texture information
  82393. * @returns a parsed Marble Procedural BABYLON.Texture
  82394. */
  82395. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  82396. }
  82397. }
  82398. declare module BABYLON {
  82399. /** @hidden */
  82400. export var normalMapProceduralTexturePixelShader: {
  82401. name: string;
  82402. shader: string;
  82403. };
  82404. }
  82405. declare module BABYLON {
  82406. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  82407. private _baseTexture;
  82408. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82409. updateShaderUniforms(): void;
  82410. render(useCameraPostProcess?: boolean): void;
  82411. resize(size: any, generateMipMaps: any): void;
  82412. get baseTexture(): BABYLON.Texture;
  82413. set baseTexture(texture: BABYLON.Texture);
  82414. /**
  82415. * Serializes this normal map procedural texture
  82416. * @returns a serialized normal map procedural texture object
  82417. */
  82418. serialize(): any;
  82419. /**
  82420. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  82421. * @param parsedTexture defines parsed texture data
  82422. * @param scene defines the current scene
  82423. * @param rootUrl defines the root URL containing normal map procedural texture information
  82424. * @returns a parsed Normal Map Procedural BABYLON.Texture
  82425. */
  82426. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  82427. }
  82428. }
  82429. declare module BABYLON {
  82430. /** @hidden */
  82431. export var perlinNoiseProceduralTexturePixelShader: {
  82432. name: string;
  82433. shader: string;
  82434. };
  82435. }
  82436. declare module BABYLON {
  82437. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  82438. time: number;
  82439. timeScale: number;
  82440. translationSpeed: number;
  82441. private _currentTranslation;
  82442. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82443. updateShaderUniforms(): void;
  82444. render(useCameraPostProcess?: boolean): void;
  82445. resize(size: any, generateMipMaps: any): void;
  82446. /**
  82447. * Serializes this perlin noise procedural texture
  82448. * @returns a serialized perlin noise procedural texture object
  82449. */
  82450. serialize(): any;
  82451. /**
  82452. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  82453. * @param parsedTexture defines parsed texture data
  82454. * @param scene defines the current scene
  82455. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  82456. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  82457. */
  82458. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  82459. }
  82460. }
  82461. declare module BABYLON {
  82462. /** @hidden */
  82463. export var roadProceduralTexturePixelShader: {
  82464. name: string;
  82465. shader: string;
  82466. };
  82467. }
  82468. declare module BABYLON {
  82469. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  82470. private _roadColor;
  82471. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82472. updateShaderUniforms(): void;
  82473. get roadColor(): BABYLON.Color3;
  82474. set roadColor(value: BABYLON.Color3);
  82475. /**
  82476. * Serializes this road procedural texture
  82477. * @returns a serialized road procedural texture object
  82478. */
  82479. serialize(): any;
  82480. /**
  82481. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  82482. * @param parsedTexture defines parsed texture data
  82483. * @param scene defines the current scene
  82484. * @param rootUrl defines the root URL containing road procedural texture information
  82485. * @returns a parsed Road Procedural BABYLON.Texture
  82486. */
  82487. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  82488. }
  82489. }
  82490. declare module BABYLON {
  82491. /** @hidden */
  82492. export var starfieldProceduralTexturePixelShader: {
  82493. name: string;
  82494. shader: string;
  82495. };
  82496. }
  82497. declare module BABYLON {
  82498. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  82499. private _time;
  82500. private _alpha;
  82501. private _beta;
  82502. private _zoom;
  82503. private _formuparam;
  82504. private _stepsize;
  82505. private _tile;
  82506. private _brightness;
  82507. private _darkmatter;
  82508. private _distfading;
  82509. private _saturation;
  82510. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82511. updateShaderUniforms(): void;
  82512. get time(): number;
  82513. set time(value: number);
  82514. get alpha(): number;
  82515. set alpha(value: number);
  82516. get beta(): number;
  82517. set beta(value: number);
  82518. get formuparam(): number;
  82519. set formuparam(value: number);
  82520. get stepsize(): number;
  82521. set stepsize(value: number);
  82522. get zoom(): number;
  82523. set zoom(value: number);
  82524. get tile(): number;
  82525. set tile(value: number);
  82526. get brightness(): number;
  82527. set brightness(value: number);
  82528. get darkmatter(): number;
  82529. set darkmatter(value: number);
  82530. get distfading(): number;
  82531. set distfading(value: number);
  82532. get saturation(): number;
  82533. set saturation(value: number);
  82534. /**
  82535. * Serializes this starfield procedural texture
  82536. * @returns a serialized starfield procedural texture object
  82537. */
  82538. serialize(): any;
  82539. /**
  82540. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  82541. * @param parsedTexture defines parsed texture data
  82542. * @param scene defines the current scene
  82543. * @param rootUrl defines the root URL containing startfield procedural texture information
  82544. * @returns a parsed Starfield Procedural BABYLON.Texture
  82545. */
  82546. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  82547. }
  82548. }
  82549. declare module BABYLON {
  82550. /** @hidden */
  82551. export var woodProceduralTexturePixelShader: {
  82552. name: string;
  82553. shader: string;
  82554. };
  82555. }
  82556. declare module BABYLON {
  82557. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  82558. private _ampScale;
  82559. private _woodColor;
  82560. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82561. updateShaderUniforms(): void;
  82562. get ampScale(): number;
  82563. set ampScale(value: number);
  82564. get woodColor(): BABYLON.Color3;
  82565. set woodColor(value: BABYLON.Color3);
  82566. /**
  82567. * Serializes this wood procedural texture
  82568. * @returns a serialized wood procedural texture object
  82569. */
  82570. serialize(): any;
  82571. /**
  82572. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  82573. * @param parsedTexture defines parsed texture data
  82574. * @param scene defines the current scene
  82575. * @param rootUrl defines the root URL containing wood procedural texture information
  82576. * @returns a parsed Wood Procedural BABYLON.Texture
  82577. */
  82578. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  82579. }
  82580. }